Pārlūkot izejas kodu

vcc: support vcc over ssh

intirain 4 gadi atpakaļ
vecāks
revīzija
8f5f0493e6
3 mainītis faili ar 51 papildinājumiem un 17 dzēšanām
  1. 2 2
      Makefile
  2. 2 2
      include/vcc/version.h
  3. 47 13
      main.c

+ 2 - 2
Makefile

@@ -1,6 +1,6 @@
 VCC_MAJOR 		= 1
-VCC_MINOR 		= 10
-VCC_PATCH 		= 4
+VCC_MINOR 		= 11
+VCC_PATCH 		= 0
 VCC_STR 		= -rc 
 
 VCC_COMPILE_TIME 	= $(shell date)

+ 2 - 2
include/vcc/version.h

@@ -1,2 +1,2 @@
-#define VCC_VERSION "VCC 1.10.4 Sat Apr 16 21:38:00 CST 2022 root"
-#define VCC_SEMVER "vcc 1.10.4-rc "
+#define VCC_VERSION "VCC 1.11.0 Sun Apr 17 13:51:33 CST 2022 root"
+#define VCC_SEMVER "vcc 1.11.0-rc "

+ 47 - 13
main.c

@@ -105,6 +105,38 @@ static int login(int got_usrname) {
 	return 0;
 }
 
+/* vos, the vcc over ssh, allows user to use vcc without install it. 
+ * you can use 'ssh username@example.com' and you will get login just like 
+ * using ssh but you can use vcc over that. 
+ * */
+
+int vos_login(void) {
+	char *passwd, *key, *iv, *name;
+
+	if (!(name = getenv("VOS_USRNAME"))) 
+		return 0;
+
+	strcpy(usrname, name);
+
+	if (!(passwd = getenv("VOS_PASSWD"))) {
+		fprintf(stderr, "Password not specified. \n");
+
+		exit(EXIT_FAILURE);
+	}
+
+	vcc_login(usrname, passwd);
+	do_cmd_lself(NULL);
+
+	/* crypt_init will copy that into a heap buffer */
+
+	if (!(key = getenv("VOS_KEY")) || !(iv = getenv("VOS_IV"))) 
+		return 1;
+	
+	crypt_init(key, iv);
+
+	return 1;
+}
+
 int parse_args(char **argv, int *port, char **ip) {
 	int i = 1;
 	/*
@@ -179,25 +211,28 @@ int main(int argc, char **argv) {
 #endif
 
 	printf(VCC_VERSION "\n");
-
-	got_usrname = parse_args(argv, &port, &ip);
 	init_socket(ip, port);
-
 	printf("Connected to server. \n");
-	login(got_usrname);
 
-	show_algo_info();
+	if (!vos_login()) {
+		/* normally startup */
 
-	memset(key, 0, 64);
-	memset(iv, 0, 64);
+		got_usrname = parse_args(argv, &port, &ip);
+		login(got_usrname);
 
-	fprintf(stderr, "Key: ");
-	read(0, key, 64);
+		show_algo_info();
 
-	fprintf(stderr, "IV: ");
-	read(0, iv, 64);
+		memset(key, 0, 64);
+		memset(iv, 0, 64);
 
-	crypt_init(key, iv);
+		fprintf(stderr, "Key: ");
+		read(0, key, 64);
+
+		fprintf(stderr, "IV: ");
+		read(0, iv, 64);
+
+		crypt_init(key, iv);
+	}
 	
 	fds[0].fd = 0;
 	fds[0].events = POLLIN;
@@ -236,7 +271,6 @@ int main(int argc, char **argv) {
 
 		if (!n) {
 			/* 1 sec timed out */
-
 			get_msgs();
 
 			continue;