From: Art Cancro Date: Sun, 3 Mar 2002 06:18:45 +0000 (+0000) Subject: * Implemented the CREU server command to administratively create user accounts X-Git-Tag: v7.86~6526 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=55a4740344eaae4dc1e52ffc7059576eb862cd34;p=citadel.git * Implemented the CREU server command to administratively create user accounts * Added the ability to create new user accounts to <.A>ide seredit --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 1f0e457e4..fe3a6ec4f 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 590.122 2002/03/03 06:18:45 ajc + * Implemented the CREU server command to administratively create user accounts + * Added the ability to create new user accounts to <.A>ide seredit + Revision 590.121 2002/03/03 06:05:16 ajc * Split up some of the code in order to prepare for user accounts to be administratively created without logging in to them. @@ -3372,3 +3376,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/citserver.c b/citadel/citserver.c index b28bb0eef..6244d1423 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -933,6 +933,10 @@ void do_command_loop(void) { cmd_newu(&cmdbuf[5]); } + else if (!strncasecmp(cmdbuf,"CREU",4)) { + cmd_creu(&cmdbuf[5]); + } + else if (!strncasecmp(cmdbuf,"SETP",4)) { cmd_setp(&cmdbuf[5]); } diff --git a/citadel/routines.c b/citadel/routines.c index cfe19729f..007be566c 100644 --- a/citadel/routines.c +++ b/citadel/routines.c @@ -121,13 +121,22 @@ void edituser(void) int userpurge; newprompt("User name: ",who,25); - sprintf(buf,"AGUP %s",who); +AGUP: sprintf(buf,"AGUP %s",who); serv_puts(buf); serv_gets(buf); if (buf[0]!='2') { scr_printf("%s\n",&buf[4]); - return; + scr_printf("Do you want to create this user? "); + if (yesno()) { + sprintf(buf, "CREU %s", who); + serv_puts(buf); + serv_gets(buf); + if (buf[0] == '2') goto AGUP; + scr_printf("%s\n",&buf[4]); + return; } + return; + } extract(who, &buf[4], 0); extract(pass, &buf[4], 1); flags = extract_int(&buf[4], 2); diff --git a/citadel/techdoc/session.txt b/citadel/techdoc/session.txt index 6d4274365..3860b60b2 100644 --- a/citadel/techdoc/session.txt +++ b/citadel/techdoc/session.txt @@ -182,7 +182,7 @@ following parameters are returned: NEWU (create NEW User account) - This command creates a new user account and logs it in. The argument to + This command creates a new user account AND LOGS IT IN. The argument to this command will be the name of the account. No case conversion is done on the name. Note that the new account is installed with a default configuration, and no password, so the client should immediately prompt the @@ -191,6 +191,9 @@ command completes. This command returns OK if the account was created and logged in, or ERROR if another user already exists with this name. If OK, it will also return the same parameters that PASS returns. + Please note that the NEWU command should only be used for self-service user account +creation. For administratively creating user accounts, please use the CREU command. + SETP (SET new Password) @@ -200,6 +203,20 @@ returns OK, unless the client is not logged in, in which case it will return ERROR. + CREU (CREate new User account) + + This command creates a new user account AND DOES NOT LOG IT IN. The argument to +this command will be the name of the account. No case conversion is done +on the name. Note that the new account is installed with a default +configuration, and no password. This command returns OK if the account was created, +or ERROR if another user already exists with this name. + + Please note that CREU is intended to be used for activities in which a system +administrator is creating user accounts. For self-service user account creation, +use the NEWU command. + + + LKRN (List Known Rooms with New messages) List known rooms with new messages. If the client is not logged in, ERROR diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 3d22cf86a..7954cfc76 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -757,7 +757,7 @@ int create_user(char *newusername, int become_user) /* - * cmd_newu() - create a new user account + * cmd_newu() - create a new user account and log in as that user */ void cmd_newu(char *cmdbuf) { @@ -836,6 +836,45 @@ void cmd_setp(char *new_pw) PerformSessionHooks(EVT_SETPASS); } + +/* + * cmd_creu() - administratively create a new user account (do not log in to it) + */ +void cmd_creu(char *cmdbuf) +{ + int a; + char username[SIZ]; + + if (CtdlAccessCheck(ac_aide)) { + return; + } + + extract(username, cmdbuf, 0); + username[25] = 0; + strproc(username); + + if (strlen(username) == 0) { + cprintf("%d You must supply a user name.\n", ERROR); + return; + } + + a = create_user(username, 0); + + if (a == 0) { + cprintf("%d ok\n", OK); + return; + } else if (a == ERROR + ALREADY_EXISTS) { + cprintf("%d '%s' already exists.\n", + ERROR + ALREADY_EXISTS, username); + return; + } else { + cprintf("%d An error occured creating the user account.\n", ERROR); + } + rec_log(CL_NEWUSER, username); +} + + + /* * get user parameters */ diff --git a/citadel/user_ops.h b/citadel/user_ops.h index e60ef2a7c..e8e1338b7 100644 --- a/citadel/user_ops.h +++ b/citadel/user_ops.h @@ -15,6 +15,7 @@ int purge_user (char *pname); int create_user (char *newusername, int become_user); void do_login(void); void cmd_newu (char *cmdbuf); +void cmd_creu (char *cmdbuf); void cmd_setp (char *new_pw); void cmd_getu (void); void cmd_setu (char *new_parms);