Change the become_user parameter of create_user() to an enum, to make calling code...
authorArt Cancro <ajc@citadel.org>
Mon, 30 Oct 2017 21:02:01 +0000 (17:02 -0400)
committerArt Cancro <ajc@citadel.org>
Mon, 30 Oct 2017 21:02:01 +0000 (17:02 -0400)
citadel/modules/ctdlproto/serv_user.c
citadel/modules/openid/serv_openid_rp.c
citadel/user_ops.c
citadel/user_ops.h

index 7b7725a6edcffdd9ce8c55893fcad64343ba8cf0..a3238a522c9663e36cc5f074ae1ba8edf8058f3f 100644 (file)
@@ -132,7 +132,7 @@ void cmd_newu(char *cmdbuf)
                return;
        }
 
-       a = create_user(username, 1);
+       a = create_user(username, CREATE_USER_BECOME_USER);
 
        if (a == 0) {
                logged_in_response();
@@ -210,7 +210,7 @@ void cmd_creu(char *cmdbuf)
 
        extract_token(password, cmdbuf, 1, '|', sizeof password);
 
-       a = create_user(username, 0);
+       a = create_user(username, CREATE_USER_DO_NOT_BECOME_USER);
 
        if (a == 0) {
                if (!IsEmptyStr(password)) {
index 69479190e132ebb8233e631d56aee08b1b042f59..5b3a9ac4f15395668b2090f5469e688e9542aa53 100644 (file)
@@ -402,7 +402,7 @@ int openid_create_user_via_ax(StrBuf *claimed_id, HashList *sreg_keys)
        }
 
        /* The desired account name is available.  Create the account and log it in! */
-       if (create_user(nickname, 1)) return(6);
+       if (create_user(nickname, CREATE_USER_BECOME_USER)) return(6);
 
        /* Generate a random password.
         * The user doesn't care what the password is since he is using OpenID.
index 00b02728362cc48a6aaa60bbe554285320fc14df..af407b0d7a1ec686e2638b3a0995514846e83de1 100644 (file)
@@ -553,7 +553,7 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname)
                found_user = getuserbyuid(&CC->user, pd.pw_uid);
                syslog(LOG_DEBUG, "user_ops: found it: uid=%ld, gecos=%s here: %d", (long)pd.pw_uid, pd.pw_gecos, found_user);
                if (found_user != 0) {
-                       create_user(username, 0);
+                       create_user(username, CREATE_USER_DO_NOT_BECOME_USER);
                        found_user = getuserbyuid(&CC->user, pd.pw_uid);
                }
 
@@ -575,7 +575,7 @@ int CtdlLoginExistingUser(char *authname, const char *trythisname)
 
                found_user = getuserbyuid(&CC->user, ldap_uid);
                if (found_user != 0) {
-                       create_user(username, 0);
+                       create_user(username, CREATE_USER_DO_NOT_BECOME_USER);
                        found_user = getuserbyuid(&CC->user, ldap_uid);
                }
 
@@ -1036,8 +1036,8 @@ int internal_create_user(char *username, struct ctdluser *usbuf, uid_t uid)
  * create_user()  -  back end processing to create a new user
  *
  * Set 'newusername' to the desired account name.
- * Set 'become_user' to nonzero if this is self-service account creation and we want
- * to actually log in as the user we just created, otherwise set it to 0.
+ * Set 'become_user' to CREATE_USER_BECOME_USER if this is self-service account creation and we want
+ * to actually log in as the user we just created, otherwise set it to CREATE_USER_DO_NOT_BECOME_USER
  */
 int create_user(const char *newusername, int become_user)
 {
@@ -1114,7 +1114,7 @@ int create_user(const char *newusername, int become_user)
         * creating a user, instead of doing self-service account creation
         */
 
-       if (become_user) {
+       if (become_user == CREATE_USER_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);
index e53fab445b2eeab289d89e0728b476d269c610b7..8dace4ad6b6a351f76605e75b89d29efab2f1b9c 100644 (file)
@@ -12,7 +12,13 @@ void rebuild_usersbynumber(void);
 void session_startup (void);
 void logged_in_response(void);
 int purge_user (char *pname);
+
 int create_user (const char *newusername, int become_user);
+enum {
+       CREATE_USER_DO_NOT_BECOME_USER,
+       CREATE_USER_BECOME_USER
+};
+
 void do_login(void);
 int CtdlInvtKick(char *iuser, int op);
 void ForEachUser(void (*CallBack)(struct ctdluser *EachUser, void *out_data),