-/*
- * set password - citadel protocol implementation
- */
-void cmd_setp(char *new_pw)
-{
- int generate_random_password = 0;
-
- if (CtdlAccessCheck(ac_logged_in)) {
- return;
- }
- if ( (CC->user.uid != CTDLUID) && (CC->user.uid != (-1)) ) {
- cprintf("%d Not allowed. Use the 'passwd' command.\n", ERROR + NOT_HERE);
- return;
- }
- if (CC->is_master) {
- cprintf("%d The master prefix password cannot be changed with this command.\n",
- ERROR + NOT_HERE);
- return;
- }
-
- if (!strcasecmp(new_pw, "GENERATE_RANDOM_PASSWORD")) {
- char random_password[17];
- generate_random_password = 1;
- snprintf(random_password, sizeof random_password, "%08lx%08lx", random(), random());
- CtdlSetPassword(random_password);
- cprintf("%d %s\n", CIT_OK, random_password);
- }
- else {
- strproc(new_pw);
- if (IsEmptyStr(new_pw)) {
- cprintf("%d Password unchanged.\n", CIT_OK);
- return;
- }
- CtdlSetPassword(new_pw);
- cprintf("%d Password changed.\n", CIT_OK);
- }
-}
-
-
-/*
- * cmd_creu() - administratively create a new user account (do not log in to it)
- */
-void cmd_creu(char *cmdbuf)
-{
- int a;
- char username[26];
- char password[32];
- struct ctdluser tmp;
-
- if (CtdlAccessCheck(ac_aide)) {
- return;
- }
-
- extract_token(username, cmdbuf, 0, '|', sizeof username);
- extract_token(password, cmdbuf, 1, '|', sizeof password);
- username[25] = 0;
- password[31] = 0;
- strproc(username);
- strproc(password);
-
- if (IsEmptyStr(username)) {
- cprintf("%d You must supply a user name.\n", ERROR + USERNAME_REQUIRED);
- return;
- }
-
- a = create_user(username, 0);
-
- if (a == 0) {
- if (!IsEmptyStr(password)) {
- lgetuser(&tmp, username);
- safestrncpy(tmp.password, password, sizeof(tmp.password));
- lputuser(&tmp);
- }
- cprintf("%d User '%s' created %s.\n", CIT_OK, username,
- (!IsEmptyStr(password)) ? "and password set" :
- "with no password");
- return;
- } else if (a == ERROR + ALREADY_EXISTS) {
- cprintf("%d '%s' already exists.\n", ERROR + ALREADY_EXISTS, username);
- return;
- } else if ( (config.c_auth_mode != AUTHMODE_NATIVE) && (a == ERROR + NO_SUCH_USER) ) {
- cprintf("%d User accounts are not created within Citadel in host authentication mode.\n",
- ERROR + NO_SUCH_USER);
- return;
- } else {
- cprintf("%d An error occurred creating the user account.\n", ERROR + INTERNAL_ERROR);
- }
-}
-
-
-
-/*
- * get user parameters
- */
-void cmd_getu(void)
-{
-
- if (CtdlAccessCheck(ac_logged_in))
- return;
-
- getuser(&CC->user, CC->curr_user);
- cprintf("%d %d|%d|%d|\n",
- CIT_OK,
- CC->user.USscreenwidth,
- CC->user.USscreenheight,
- (CC->user.flags & US_USER_SET)
- );
-}
-
-/*
- * set user parameters
- */
-void cmd_setu(char *new_parms)
-{
- if (CtdlAccessCheck(ac_logged_in))
- return;
-
- if (num_parms(new_parms) < 3) {
- cprintf("%d Usage error.\n", ERROR + ILLEGAL_VALUE);
- return;
- }
- lgetuser(&CC->user, CC->curr_user);
- CC->user.USscreenwidth = extract_int(new_parms, 0);
- CC->user.USscreenheight = extract_int(new_parms, 1);
- CC->user.flags = CC->user.flags & (~US_USER_SET);
- CC->user.flags = CC->user.flags |
- (extract_int(new_parms, 2) & US_USER_SET);
-
- lputuser(&CC->user);
- cprintf("%d Ok\n", CIT_OK);
-}
-
-/*
- * set last read pointer
- */
-void cmd_slrp(char *new_ptr)
-{
- long newlr;
- struct visit vbuf;
- struct visit original_vbuf;
-
- if (CtdlAccessCheck(ac_logged_in)) {
- return;
- }
-
- if (!strncasecmp(new_ptr, "highest", 7)) {
- newlr = CC->room.QRhighest;
- } else {
- newlr = atol(new_ptr);
- }
-
- lgetuser(&CC->user, CC->curr_user);
-
- CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
- memcpy(&original_vbuf, &vbuf, sizeof(struct visit));
- vbuf.v_lastseen = newlr;
- snprintf(vbuf.v_seen, sizeof vbuf.v_seen, "*:%ld", newlr);
-
- /* Only rewrite the record if it changed */
- if ( (vbuf.v_lastseen != original_vbuf.v_lastseen)
- || (strcmp(vbuf.v_seen, original_vbuf.v_seen)) ) {
- CtdlSetRelationship(&vbuf, &CC->user, &CC->room);
- }
-
- lputuser(&CC->user);
- cprintf("%d %ld\n", CIT_OK, newlr);
-}
-
-
-void cmd_seen(char *argbuf) {
- long target_msgnum = 0L;
- int target_setting = 0;
-
- if (CtdlAccessCheck(ac_logged_in)) {
- return;
- }
-
- if (num_parms(argbuf) != 2) {
- cprintf("%d Invalid parameters\n", ERROR + ILLEGAL_VALUE);
- return;
- }
-
- target_msgnum = extract_long(argbuf, 0);
- target_setting = extract_int(argbuf, 1);
-
- CtdlSetSeen(&target_msgnum, 1, target_setting,
- ctdlsetseen_seen, NULL, NULL);
- cprintf("%d OK\n", CIT_OK);
-}
-
-
-void cmd_gtsn(char *argbuf) {
- char buf[SIZ];
-
- if (CtdlAccessCheck(ac_logged_in)) {
- return;
- }
-
- CtdlGetSeen(buf, ctdlsetseen_seen);
- cprintf("%d %s\n", CIT_OK, buf);
-}