diff --git a/src/server/slavefuncs.c b/src/server/slavefuncs.c --- a/src/server/slavefuncs.c +++ b/src/server/slavefuncs.c @@ -23,10 +23,24 @@ */ #include #include - +#include -void ssh_keygen(){ - // Give me some args! +int ssh_keygen(){ + fprintf(stderr, "We're generating your SSH key. Please be patient.\n"); + char *command = "ssh-keygenn"; // append .exe if win32? + char *path_to_command = "/usr/bin/ssh-keygenn"; + int ret; + char *cmd[] = { command, "-b", "-o", (char *)0 }; // TODO: Give me the correct args! + ret = execv(path_to_command, cmd); // This path will be absolute for testing, should be relative to install on production + if(ret == -1){ + fprintf(stderr, "Generating your key failed. Ensure that ssh-keygen is present!\n"); // Use different executor that searches the path? there is one... + return 0; + } + else{ + fprintf(stderr,"We successfully generated your key! Yay!"); + return 1; + } +return 0; } int register_user(char *username, char *email) @@ -36,7 +50,6 @@ int register_user(char *username, char * * All created user accounts should be sandboxed accordingly, requiring a different skel, and the default shell to be rbash. Also, * a custom path defined in the .bash_profile of the skel is needed. */ - char *keyname; // Url to the key char buf[10]; struct execio *testrem; char *execargv[] = @@ -71,7 +84,7 @@ int register_user(char *username, char * } execio_close(testrem); - ssh_keygen(); // Should return relative path to keyfile, or jus the keyname + ssh_keygen(); // generates username.rsa /* TODO: Scan distrenslave.conf for !username and !key and replace them with "keyname" and the "username" */ return 1;