|
@@ -105,6 +105,38 @@ static int login(int got_usrname) {
|
|
|
return 0;
|
|
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 parse_args(char **argv, int *port, char **ip) {
|
|
|
int i = 1;
|
|
int i = 1;
|
|
|
/*
|
|
/*
|
|
@@ -179,25 +211,28 @@ int main(int argc, char **argv) {
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
printf(VCC_VERSION "\n");
|
|
printf(VCC_VERSION "\n");
|
|
|
-
|
|
|
|
|
- got_usrname = parse_args(argv, &port, &ip);
|
|
|
|
|
init_socket(ip, port);
|
|
init_socket(ip, port);
|
|
|
-
|
|
|
|
|
printf("Connected to server. \n");
|
|
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].fd = 0;
|
|
|
fds[0].events = POLLIN;
|
|
fds[0].events = POLLIN;
|
|
@@ -236,7 +271,6 @@ int main(int argc, char **argv) {
|
|
|
|
|
|
|
|
if (!n) {
|
|
if (!n) {
|
|
|
/* 1 sec timed out */
|
|
/* 1 sec timed out */
|
|
|
-
|
|
|
|
|
get_msgs();
|
|
get_msgs();
|
|
|
|
|
|
|
|
continue;
|
|
continue;
|