Code shuffling fixes warning with inline function... weirdo.
[citadel.git] / citadel / user_ops.c
index 7eefb54eb8240359e8c70aef6d4b1c007db17f99..2b66fdbe24029a51e77fd6896008977b5ebc31c1 100644 (file)
@@ -778,7 +778,9 @@ void CtdlUserLogout(void)
 {
        CitContext *CCC = MyContext();
 
-       syslog(LOG_DEBUG, "CtdlUserLogout() logging out <%s>\n", CCC->curr_user);
+       syslog(LOG_DEBUG, "CtdlUserLogout() logging out <%s> from session %d",
+               CCC->curr_user, CCC->cs_pid
+       );
 
        /*
         * If there is a download in progress, abort it.
@@ -854,8 +856,23 @@ static int validpw(uid_t uid, const char *pass)
 
        begin_critical_section(S_CHKPWD);
        rv = write(chkpwd_write_pipe[1], &uid, sizeof(uid_t));
+       if (rv == -1) {
+               syslog(LOG_EMERG, "Communicatino with chkpwd broken: %s\n", strerror(errno));
+               end_critical_section(S_CHKPWD);
+               return 0;
+       }
        rv = write(chkpwd_write_pipe[1], pass, 256);
+       if (rv == -1) {
+               syslog(LOG_EMERG, "Communicatino with chkpwd broken: %s\n", strerror(errno));
+               end_critical_section(S_CHKPWD);
+               return 0;
+       }
        rv = read(chkpwd_read_pipe[0], buf, 4);
+       if (rv == -1) {
+               syslog(LOG_EMERG, "Communicatino with chkpwd broken: %s\n", strerror(errno));
+               end_critical_section(S_CHKPWD);
+               return 0;
+       }
        end_critical_section(S_CHKPWD);
 
        if (!strncmp(buf, "PASS", 4)) {
@@ -1258,7 +1275,7 @@ void cmd_newu(char *cmdbuf)
 {
        int a;
        long len;
-       char username[26];
+       char username[SIZ];
 
        if (config.c_auth_mode != AUTHMODE_NATIVE) {
                cprintf("%d This system does not use native mode authentication.\n",
@@ -1333,8 +1350,6 @@ void CtdlSetPassword(char *new_pw)
  */
 void cmd_setp(char *new_pw)
 {
-       int generate_random_password = 0;
-
        if (CtdlAccessCheck(ac_logged_in)) {
                return;
        }
@@ -1350,7 +1365,6 @@ void cmd_setp(char *new_pw)
 
        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);
@@ -1383,17 +1397,16 @@ void cmd_creu(char *cmdbuf)
        }
 
        extract_token(username, cmdbuf, 0, '|', sizeof username);
-       extract_token(password, cmdbuf, 1, '|', sizeof password);
-       ////username[25] = 0;
-       //password[31] = 0;
        strproc(username);
        strproc(password);
-       len = cutuserkey(username);
-
        if (IsEmptyStr(username)) {
                cprintf("%d You must supply a user name.\n", ERROR + USERNAME_REQUIRED);
                return;
        }
+       len = cutuserkey(username);
+
+
+       extract_token(password, cmdbuf, 1, '|', sizeof password);
 
        a = create_user(username, len, 0);