# HG changeset patch # User ethanzonca # Date 2009-08-01 14:39:06 # Node ID addf1a3579d828435c4cae8f6f55168545c68e93 # Parent 7225f5e7ec4400afc48d9a6fe72cfc39acb05365 Moved ssh_keygen() and conf_replace() before the useradd code to avoid duplicate user creation, etc. diff --git a/src/server/slavefuncs.c b/src/server/slavefuncs.c --- a/src/server/slavefuncs.c +++ b/src/server/slavefuncs.c @@ -109,7 +109,20 @@ return 0; /** Registers the user on the DistRen server */ int register_user(char *username, char *email) { - /* @TODO: Check for problems (e.g. existing rsa key) BEFORE useradding! */ + +/* Note: this code moved here from after the useradd code, so useradd doesn't happen if there is an existing key, etc */ + /* puts the person's username in the conf */ + if(conf_replace(username) == 0){ + fprintf(stderr, "Failed!\n"); + return 0; + } + + /* generates keys for login, @TODO: pub key must somehow be sent to the server. */ + if(ssh_keygen() == 0){ + fprintf(stderr, "Failed!\n"); + return 0; + } + /* * 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 .bashrc of the skel is needed. @@ -150,18 +163,6 @@ int register_user(char *username, char * /* @TODO: Parse the output buffer or something to check when user creation fails due to duplicate users. This is pretty important. */ - // puts the person's username in the conf - if(conf_replace(username) == 0){ - fprintf(stderr, "Failed!\n"); - return 0; - } - - // generates keys for login, @TODO: pub key must somehow be sent to the server. - if(ssh_keygen() == 0){ - fprintf(stderr, "Failed!\n"); - return 0; - } - return 1; // 1 is success }