Back to index

citadel  8.12
Defines | Functions
user_ops.h File Reference
#include <ctype.h>
#include <syslog.h>

Go to the source code of this file.

Defines

#define RENAMEUSER_OK   0 /* Operation succeeded */
#define RENAMEUSER_LOGGED_IN   1 /* Cannot rename a user who is currently logged in */
#define RENAMEUSER_NOT_FOUND   2 /* The old user name does not exist */
#define RENAMEUSER_ALREADY_EXISTS   3 /* An account with the desired new name already exists */

Functions

int hash (char *str)
int getuser (struct ctdluser *, char *) __attribute__((deprecated))
int lgetuser (struct ctdluser *, char *) __attribute__((deprecated))
void putuser (struct ctdluser *) __attribute__((deprecated))
void lputuser (struct ctdluser *) __attribute__((deprecated))
int is_aide (void)
int is_room_aide (void)
int getuserbynumber (struct ctdluser *usbuf, long int number) __attribute__((deprecated))
void rebuild_usersbynumber (void)
void cmd_user (char *cmdbuf)
void session_startup (void)
void logged_in_response (void)
int purge_user (char *pname)
int create_user (const char *newusername, long len, int become_user)
void do_login (void)
int CtdlInvtKick (char *iuser, int op)
void ForEachUser (void(*CallBack)(struct ctdluser *EachUser, void *out_data), void *in_data)
void ListThisUser (struct ctdluser *usbuf, void *data)
int NewMailCount (void)
int InitialMailCheck (void)
void put_visit (visit *newvisit)
void MailboxName (char *buf, size_t n, const struct ctdluser *who, const char *prefix) __attribute__((deprecated))
int GenerateRelationshipIndex (char *IndexBuf, long RoomID, long RoomGen, long UserID)
int CtdlAssociateSystemUser (char *screenname, char *loginname)
void CtdlSetPassword (char *new_pw)
int CtdlForgetThisRoom (void)
void cmd_newu (char *cmdbuf)
void start_chkpwd_daemon (void)
int rename_user (char *oldname, char *newname)
static INLINE long cutuserkey (char *username)
 

ifndef CTDL_INLINE_USR

/#define CTDL_INLINE_USR static INLINE

endif


static INLINE void makeuserkey (char *key, const char *username, long len)
 CTDL_INLINE_USR.
int internal_create_user (const char *username, long len, struct ctdluser *usbuf, uid_t uid)

Define Documentation

#define RENAMEUSER_ALREADY_EXISTS   3 /* An account with the desired new name already exists */

Definition at line 56 of file user_ops.h.

#define RENAMEUSER_LOGGED_IN   1 /* Cannot rename a user who is currently logged in */

Definition at line 54 of file user_ops.h.

#define RENAMEUSER_NOT_FOUND   2 /* The old user name does not exist */

Definition at line 55 of file user_ops.h.

#define RENAMEUSER_OK   0 /* Operation succeeded */

Definition at line 53 of file user_ops.h.


Function Documentation

void cmd_newu ( char *  cmdbuf)

Definition at line 1280 of file user_ops.c.

{
       int a;
       long len;
       char username[SIZ];

       if (config.c_auth_mode != AUTHMODE_NATIVE) {
              cprintf("%d This system does not use native mode authentication.\n",
                     ERROR + NOT_HERE);
              return;
       }

       if (config.c_disable_newu) {
              cprintf("%d Self-service user account creation "
                     "is disabled on this system.\n", ERROR + NOT_HERE);
              return;
       }

       if (CC->logged_in) {
              cprintf("%d Already logged in.\n", ERROR + ALREADY_LOGGED_IN);
              return;
       }
       if (CC->nologin) {
              cprintf("%d %s: Too many users are already online (maximum is %d)\n",
                     ERROR + MAX_SESSIONS_EXCEEDED,
                     config.c_nodename, config.c_maxsessions);
       }
       extract_token(username, cmdbuf, 0, '|', sizeof username);
       strproc(username);
       len = cutuserkey(username);

       if (IsEmptyStr(username)) {
              cprintf("%d You must supply a user name.\n", ERROR + USERNAME_REQUIRED);
              return;
       }

       if ((!strcasecmp(username, "bbs")) ||
           (!strcasecmp(username, "new")) ||
           (!strcasecmp(username, "."))) {
              cprintf("%d '%s' is an invalid login name.\n", ERROR + ILLEGAL_VALUE, username);
              return;
       }

       a = create_user(username, len, 1);

       if (a == 0) {
              logged_in_response();
       } else if (a == ERROR + ALREADY_EXISTS) {
              cprintf("%d '%s' already exists.\n",
                     ERROR + ALREADY_EXISTS, username);
              return;
       } else if (a == ERROR + INTERNAL_ERROR) {
              cprintf("%d Internal error - user record disappeared?\n",
                     ERROR + INTERNAL_ERROR);
              return;
       } else {
              cprintf("%d unknown error\n", ERROR + INTERNAL_ERROR);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cmd_user ( char *  cmdbuf)

Definition at line 673 of file user_ops.c.

{
       char username[256];
       int a;

       CON_syslog(LOG_DEBUG, "cmd_user(%s)\n", cmdbuf);
       extract_token(username, cmdbuf, 0, '|', sizeof username);
       CON_syslog(LOG_DEBUG, "username: %s\n", username);
       striplt(username);
       CON_syslog(LOG_DEBUG, "username: %s\n", username);

       a = CtdlLoginExistingUser(NULL, username);
       switch (a) {
       case login_already_logged_in:
              cprintf("%d Already logged in.\n", ERROR + ALREADY_LOGGED_IN);
              return;
       case login_too_many_users:
              cprintf("%d %s: "
                     "Too many users are already online "
                     "(maximum is %d)\n",
                     ERROR + MAX_SESSIONS_EXCEEDED,
                     config.c_nodename, config.c_maxsessions);
              return;
       case login_ok:
              cprintf("%d Password required for %s\n",
                     MORE_DATA, CC->curr_user);
              return;
       case login_not_found:
              cprintf("%d %s not found.\n", ERROR + NO_SUCH_USER, username);
              return;
       default:
              cprintf("%d Internal error\n", ERROR + INTERNAL_ERROR);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int create_user ( const char *  newusername,
long  len,
int  become_user 
)

Definition at line 1174 of file user_ops.c.

{
       struct ctdluser usbuf;
       struct ctdlroom qrbuf;
       char username[256];
       char mailboxname[ROOMNAMELEN];
       char buf[SIZ];
       int retval;
       uid_t uid = (-1);
       

       safestrncpy(username, newusername, sizeof username);
       strproc(username);

       
       if (config.c_auth_mode == AUTHMODE_HOST) {

              /* host auth mode */

              struct passwd pd;
              struct passwd *tempPwdPtr;
              char pwdbuffer[SIZ];
       
#ifdef HAVE_GETPWNAM_R
#ifdef SOLARIS_GETPWUID
              tempPwdPtr = getpwnam_r(username, &pd, pwdbuffer, sizeof(pwdbuffer));
#else // SOLARIS_GETPWUID
              getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer, &tempPwdPtr);
#endif // SOLARIS_GETPWUID
#else // HAVE_GETPWNAM_R
              tempPwdPtr = NULL;
#endif // HAVE_GETPWNAM_R
              if (tempPwdPtr != NULL) {
                     extract_token(username, pd.pw_gecos, 0, ',', sizeof username);
                     uid = pd.pw_uid;
                     if (IsEmptyStr (username))
                     {
                            safestrncpy(username, pd.pw_name, sizeof username);
                            len = cutuserkey(username);
                     }
              }
              else {
                     return (ERROR + NO_SUCH_USER);
              }
       }

#ifdef HAVE_LDAP
       if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
              if (CtdlTryUserLDAP(username, NULL, 0, username, sizeof username, &uid) != 0) {
                     return(ERROR + NO_SUCH_USER);
              }
       }
#endif /* HAVE_LDAP */
       
       if ((retval = internal_create_user(username, len, &usbuf, uid)) != 0)
              return retval;
       
       /*
        * Give the user a private mailbox and a configuration room.
        * Make the latter an invisible system room.
        */
       CtdlMailboxName(mailboxname, sizeof mailboxname, &usbuf, MAILROOM);
       CtdlCreateRoom(mailboxname, 5, "", 0, 1, 1, VIEW_MAILBOX);

       CtdlMailboxName(mailboxname, sizeof mailboxname, &usbuf, USERCONFIGROOM);
       CtdlCreateRoom(mailboxname, 5, "", 0, 1, 1, VIEW_BBS);
       if (CtdlGetRoomLock(&qrbuf, mailboxname) == 0) {
              qrbuf.QRflags2 |= QR2_SYSTEM;
              CtdlPutRoomLock(&qrbuf);
       }

       /* Perform any create functions registered by server extensions */
       PerformUserHooks(&usbuf, EVT_NEWUSER);

       /* Everything below this line can be bypassed if administratively
        * creating a user, instead of doing self-service account creation
        */

       if (become_user) {
              /* Now become the user we just created */
              memcpy(&CC->user, &usbuf, sizeof(struct ctdluser));
              safestrncpy(CC->curr_user, username, sizeof CC->curr_user);
              do_login();
       
              /* Check to make sure we're still who we think we are */
              if (CtdlGetUser(&CC->user, CC->curr_user)) {
                     return (ERROR + INTERNAL_ERROR);
              }
       }
       
       snprintf(buf, SIZ, 
              "New user account <%s> has been created, from host %s [%s].\n",
              username,
              CC->cs_host,
              CC->cs_addr
       );
       CtdlAideMessage(buf, "User Creation Notice");
       CON_syslog(LOG_NOTICE, "New user <%s> created\n", username);
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlAssociateSystemUser ( char *  screenname,
char *  loginname 
)
int CtdlForgetThisRoom ( void  )

Definition at line 1638 of file user_ops.c.

                             {
       visit vbuf;

       /* On some systems, Aides are not allowed to forget rooms */
       if (is_aide() && (config.c_aide_zap == 0)
          && ((CC->room.QRflags & QR_MAILBOX) == 0)  ) {
              return(1);
       }

       CtdlGetUserLock(&CC->user, CC->curr_user);
       CtdlGetRelationship(&vbuf, &CC->user, &CC->room);

       vbuf.v_flags = vbuf.v_flags | V_FORGET;
       vbuf.v_flags = vbuf.v_flags & ~V_ACCESS;

       CtdlSetRelationship(&vbuf, &CC->user, &CC->room);
       CtdlPutUserLock(&CC->user);

       /* Return to the Lobby, so we don't end up in an undefined room */
       CtdlUserGoto(config.c_baseroom, 0, 0, NULL, NULL);
       return(0);

}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlInvtKick ( char *  iuser,
int  op 
)

Definition at line 1559 of file user_ops.c.

                                      {
       struct ctdluser USscratch;
       visit vbuf;
       char bbb[SIZ];

       if (CtdlGetUser(&USscratch, iuser) != 0) {
              return(1);
       }

       CtdlGetRelationship(&vbuf, &USscratch, &CC->room);
       if (op == 1) {
              vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
              vbuf.v_flags = vbuf.v_flags | V_ACCESS;
       }
       if (op == 0) {
              vbuf.v_flags = vbuf.v_flags & ~V_ACCESS;
              vbuf.v_flags = vbuf.v_flags | V_FORGET | V_LOCKOUT;
       }
       CtdlSetRelationship(&vbuf, &USscratch, &CC->room);

       /* post a message in Aide> saying what we just did */
       snprintf(bbb, sizeof bbb, "%s has been %s \"%s\" by %s.\n",
              iuser,
              ((op == 1) ? "invited to" : "kicked out of"),
              CC->room.QRname,
              (CC->logged_in ? CC->user.fullname : "an administrator")
       );
       CtdlAideMessage(bbb,"User Admin Message");

       return(0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CtdlSetPassword ( char *  new_pw)

Definition at line 1344 of file user_ops.c.

{
       CtdlGetUserLock(&CC->user, CC->curr_user);
       safestrncpy(CC->user.password, new_pw, sizeof(CC->user.password));
       CtdlPutUserLock(&CC->user);
       CON_syslog(LOG_INFO, "Password changed for user <%s>\n", CC->curr_user);
       PerformSessionHooks(EVT_SETPASS);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static INLINE long cutuserkey ( char *  username) [static]

ifndef CTDL_INLINE_USR

/#define CTDL_INLINE_USR static INLINE

endif

CTDL_INLINE_USR

Definition at line 65 of file user_ops.h.

                                              { 
       long len;
       len = strlen(username);
       if (len >= USERNAME_SIZE)
       {
              syslog(LOG_INFO, "Username too long: %s", username);
              cit_backtrace ();
              len = USERNAME_SIZE - 1; 
              username[len]='\0';
       }
       return len;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void do_login ( void  )

Definition at line 713 of file user_ops.c.

{
       struct CitContext *CCC = CC;

       CCC->logged_in = 1;
       CON_syslog(LOG_NOTICE, "<%s> logged in\n", CCC->curr_user);

       CtdlGetUserLock(&CCC->user, CCC->curr_user);
       ++(CCC->user.timescalled);
       CCC->previous_login = CCC->user.lastcall;
       time(&CCC->user.lastcall);

       /* If this user's name is the name of the system administrator
        * (as specified in setup), automatically assign access level 6.
        */
       if (!strcasecmp(CCC->user.fullname, config.c_sysadm)) {
              CCC->user.axlevel = AxAideU;
       }

       /* If we're authenticating off the host system, automatically give
        * root the highest level of access.
        */
       if (config.c_auth_mode == AUTHMODE_HOST) {
              if (CCC->user.uid == 0) {
                     CCC->user.axlevel = AxAideU;
              }
       }

       CtdlPutUserLock(&CCC->user);

       /*
        * Populate CCC->cs_inet_email with a default address.  This will be
        * overwritten with the user's directory address, if one exists, when
        * the vCard module's login hook runs.
        */
       snprintf(CCC->cs_inet_email, sizeof CCC->cs_inet_email, "%s@%s",
              CCC->user.fullname, config.c_fqdn);
       convert_spaces_to_underscores(CCC->cs_inet_email);

       /* Create any personal rooms required by the system.
        * (Technically, MAILROOM should be there already, but just in case...)
        */
       CtdlCreateRoom(MAILROOM, 4, "", 0, 1, 0, VIEW_MAILBOX);
       CtdlCreateRoom(SENTITEMS, 4, "", 0, 1, 0, VIEW_MAILBOX);
       CtdlCreateRoom(USERTRASHROOM, 4, "", 0, 1, 0, VIEW_MAILBOX);
       CtdlCreateRoom(USERDRAFTROOM, 4, "", 0, 1, 0, VIEW_MAILBOX);

       /* Run any startup routines registered by loadable modules */
       PerformSessionHooks(EVT_LOGIN);

       /* Enter the lobby */
       CtdlUserGoto(config.c_baseroom, 0, 0, NULL, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ForEachUser ( void(*)(struct ctdluser *EachUser, void *out_data)  CallBack,
void *  in_data 
)

Definition at line 1774 of file user_ops.c.

{
       struct ctdluser usbuf;
       struct cdbdata *cdbus;

       cdb_rewind(CDB_USERS);

       while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
              memset(&usbuf, 0, sizeof(struct ctdluser));
              memcpy(&usbuf, cdbus->ptr,
                     ((cdbus->len > sizeof(struct ctdluser)) ?
                     sizeof(struct ctdluser) : cdbus->len));
              cdb_free(cdbus);
              (*CallBack) (&usbuf, in_data);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int GenerateRelationshipIndex ( char *  IndexBuf,
long  RoomID,
long  RoomGen,
long  UserID 
)

Definition at line 258 of file user_ops.c.

{

       struct {
              long iRoomID;
              long iRoomGen;
              long iUserID;
       } TheIndex;

       TheIndex.iRoomID = RoomID;
       TheIndex.iRoomGen = RoomGen;
       TheIndex.iUserID = UserID;

       memcpy(IndexBuf, &TheIndex, sizeof(TheIndex));
       return (sizeof(TheIndex));
}

Here is the caller graph for this function:

int getuser ( struct ctdluser ,
char *   
)
int getuserbynumber ( struct ctdluser usbuf,
long int  number 
)
int hash ( char *  str)
int InitialMailCheck ( void  )

Definition at line 1995 of file user_ops.c.

{
       int num_newmsgs = 0;
       int a;
       char mailboxname[ROOMNAMELEN];
       struct ctdlroom mailbox;
       visit vbuf;
       struct cdbdata *cdbfr;
       long *msglist = NULL;
       int num_msgs = 0;

       CtdlMailboxName(mailboxname, sizeof mailboxname, &CC->user, MAILROOM);
       if (CtdlGetRoom(&mailbox, mailboxname) != 0)
              return (0);
       CtdlGetRelationship(&vbuf, &CC->user, &mailbox);

       cdbfr = cdb_fetch(CDB_MSGLISTS, &mailbox.QRnumber, sizeof(long));

       if (cdbfr != NULL) {
              msglist = malloc(cdbfr->len);
              memcpy(msglist, cdbfr->ptr, cdbfr->len);
              num_msgs = cdbfr->len / sizeof(long);
              cdb_free(cdbfr);
       }
       if (num_msgs > 0)
              for (a = 0; a < num_msgs; ++a) {
                     if (msglist[a] > 0L) {
                            if (msglist[a] > vbuf.v_lastseen) {
                                   ++num_newmsgs;
                            }
                     }
              }
       if (msglist != NULL)
              free(msglist);

       return (num_newmsgs);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int internal_create_user ( const char *  username,
long  len,
struct ctdluser usbuf,
uid_t  uid 
)

Definition at line 1135 of file user_ops.c.

{
       if (!CtdlGetUserLen(usbuf, username, len)) {
              return (ERROR + ALREADY_EXISTS);
       }

       /* Go ahead and initialize a new user record */
       memset(usbuf, 0, sizeof(struct ctdluser));
       safestrncpy(usbuf->fullname, username, sizeof usbuf->fullname);
       strcpy(usbuf->password, "");
       usbuf->uid = uid;

       /* These are the default flags on new accounts */
       usbuf->flags = US_LASTOLD | US_DISAPPEAR | US_PAGINATOR | US_FLOORS;

       usbuf->timescalled = 0;
       usbuf->posted = 0;
       usbuf->axlevel = config.c_initax;
       usbuf->lastcall = time(NULL);

       /* fetch a new user number */
       usbuf->usernum = get_new_user_number();

       /* add user to the database */
       CtdlPutUser(usbuf);
       cdb_store(CDB_USERSBYNUMBER, &usbuf->usernum, sizeof(long), usbuf->fullname, strlen(usbuf->fullname)+1);

       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int is_aide ( void  )

Definition at line 380 of file user_ops.c.

{
       if (CC->user.axlevel >= AxAideU)
              return (1);
       else
              return (0);
}
int is_room_aide ( void  )

Definition at line 392 of file user_ops.c.

{

       if (!CC->logged_in) {
              return (0);
       }

       if ((CC->user.axlevel >= AxAideU)
           || (CC->room.QRroomaide == CC->user.usernum)) {
              return (1);
       } else {
              return (0);
       }
}
int lgetuser ( struct ctdluser ,
char *   
)

Definition at line 142 of file user_ops.c.

{
       return CtdlGetUserLock(usbuf, name);
}

Here is the call graph for this function:

void ListThisUser ( struct ctdluser usbuf,
void *  data 
)

Definition at line 1796 of file user_ops.c.

{
       char *searchstring;

       searchstring = (char *)data;
       if (bmstrcasestr(usbuf->fullname, searchstring) == NULL) {
              return;
       }

       if (usbuf->axlevel > AxDeleted) {
              if ((CC->user.axlevel >= AxAideU)
                  || ((usbuf->flags & US_UNLISTED) == 0)
                  || ((CC->internal_pgm))) {
                     cprintf("%s|%d|%ld|%ld|%ld|%ld||\n",
                            usbuf->fullname,
                            usbuf->axlevel,
                            usbuf->usernum,
                            (long)usbuf->lastcall,
                            usbuf->timescalled,
                            usbuf->posted);
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void logged_in_response ( void  )

Definition at line 768 of file user_ops.c.

{
       cprintf("%d %s|%d|%ld|%ld|%u|%ld|%ld\n",
              CIT_OK, CC->user.fullname, CC->user.axlevel,
              CC->user.timescalled, CC->user.posted,
              CC->user.flags, CC->user.usernum,
              CC->previous_login);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void lputuser ( struct ctdluser )

Definition at line 189 of file user_ops.c.

{
       CtdlPutUserLock(usbuf);
}

Here is the call graph for this function:

void MailboxName ( char *  buf,
size_t  n,
const struct ctdluser who,
const char *  prefix 
)

Definition at line 371 of file user_ops.c.

{
       snprintf(buf, n, "%010ld.%s", who->usernum, prefix);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static INLINE void makeuserkey ( char *  key,
const char *  username,
long  len 
) [static]

CTDL_INLINE_USR.

Definition at line 83 of file user_ops.h.

                                                                          {
       int i;

       if (len >= USERNAME_SIZE)
       {
              syslog(LOG_INFO, "Username too long: %s", username);
              cit_backtrace ();
              len = USERNAME_SIZE - 1; 
       }
       for (i=0; i<=len; ++i) {
              key[i] = tolower(username[i]);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int NewMailCount ( void  )

Definition at line 1981 of file user_ops.c.

{
       int num_newmsgs = 0;

       num_newmsgs = CC->newmail;
       CC->newmail = 0;

       return (num_newmsgs);
}

Here is the caller graph for this function:

int purge_user ( char *  pname)
void put_visit ( visit newvisit)

Definition at line 283 of file user_ops.c.

{
       char IndexBuf[32];
       int IndexLen = 0;

       memset (IndexBuf, 0, sizeof (IndexBuf));
       /* Generate an index */
       IndexLen = GenerateRelationshipIndex(IndexBuf,
                                        newvisit->v_roomnum,
                                        newvisit->v_roomgen,
                                        newvisit->v_usernum);

       /* Store the record */
       cdb_store(CDB_VISIT, IndexBuf, IndexLen,
                newvisit, sizeof(visit)
       );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void putuser ( struct ctdluser )

Definition at line 170 of file user_ops.c.

{
       CtdlPutUser(usbuf);
}

Here is the call graph for this function:

void rebuild_usersbynumber ( void  )

Definition at line 488 of file user_ops.c.

                                 {
       cdb_trunc(CDB_USERSBYNUMBER);                    /* delete the old indices */
       ForEachUser(rebuild_ubn_for_user, NULL);  /* enumerate the users */
       rebuild_ubn_for_user(NULL, NULL);         /* and index them */
}

Here is the call graph for this function:

Here is the caller graph for this function:

int rename_user ( char *  oldname,
char *  newname 
)

Definition at line 201 of file user_ops.c.

                                              {
       int retcode = RENAMEUSER_OK;
       struct ctdluser usbuf;

       char oldnamekey[USERNAME_SIZE];
       char newnamekey[USERNAME_SIZE];

       /* Create the database keys... */
       makeuserkey(oldnamekey, oldname, cutuserkey(oldname));
       makeuserkey(newnamekey, newname, cutuserkey(newname));

       /* Lock up and get going */
       begin_critical_section(S_USERS);

       /* We cannot rename a user who is currently logged in */
       if (CtdlIsUserLoggedIn(oldname)) {
              end_critical_section(S_USERS);
              return RENAMEUSER_LOGGED_IN;
       }

       if (CtdlGetUser(&usbuf, newname) == 0) {
              retcode = RENAMEUSER_ALREADY_EXISTS;
       }
       else {

              if (CtdlGetUser(&usbuf, oldname) != 0) {
                     retcode = RENAMEUSER_NOT_FOUND;
              }

              else {        /* Sanity checks succeeded.  Now rename the user. */
                     if (usbuf.usernum == 0)
                     {
                            CONM_syslog(LOG_DEBUG, "Can not rename user \"Citadel\".\n");
                            retcode = RENAMEUSER_NOT_FOUND;
                     } else {
                            CON_syslog(LOG_DEBUG, "Renaming <%s> to <%s>\n", oldname, newname);
                            cdb_delete(CDB_USERS, oldnamekey, strlen(oldnamekey));
                            safestrncpy(usbuf.fullname, newname, sizeof usbuf.fullname);
                            CtdlPutUser(&usbuf);
                            cdb_store(CDB_USERSBYNUMBER, &usbuf.usernum, sizeof(long),
                                   usbuf.fullname, strlen(usbuf.fullname)+1 );

                            retcode = RENAMEUSER_OK;
                     }
              }
       
       }

       end_critical_section(S_USERS);
       return(retcode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void session_startup ( void  )
void start_chkpwd_daemon ( void  )

Definition at line 885 of file user_ops.c.

                               {
       pid_t chkpwd_pid;
       struct stat filestats;
       int i;

       CONM_syslog(LOG_DEBUG, "Starting chkpwd daemon for host authentication mode\n");

       if ((stat(file_chkpwd, &filestats)==-1) ||
           (filestats.st_size==0)){
              printf("didn't find chkpwd daemon in %s: %s\n", file_chkpwd, strerror(errno));
              abort();
       }
       if (pipe(chkpwd_write_pipe) != 0) {
              CON_syslog(LOG_EMERG, "Unable to create pipe for chkpwd daemon: %s\n", strerror(errno));
              abort();
       }
       if (pipe(chkpwd_read_pipe) != 0) {
              CON_syslog(LOG_EMERG, "Unable to create pipe for chkpwd daemon: %s\n", strerror(errno));
              abort();
       }

       chkpwd_pid = fork();
       if (chkpwd_pid < 0) {
              CON_syslog(LOG_EMERG, "Unable to fork chkpwd daemon: %s\n", strerror(errno));
              abort();
       }
       if (chkpwd_pid == 0) {
              CONM_syslog(LOG_DEBUG, "Now calling dup2() write\n");
              dup2(chkpwd_write_pipe[0], 0);
              CONM_syslog(LOG_DEBUG, "Now calling dup2() write\n");
              dup2(chkpwd_read_pipe[1], 1);
              CONM_syslog(LOG_DEBUG, "Now closing stuff\n");
              for (i=2; i<256; ++i) close(i);
              CON_syslog(LOG_DEBUG, "Now calling execl(%s)\n", file_chkpwd);
              execl(file_chkpwd, file_chkpwd, NULL);
              CON_syslog(LOG_EMERG, "Unable to exec chkpwd daemon: %s\n", strerror(errno));
              abort();
              exit(errno);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function: