]> code.citadel.org Git - citadel.git/blobdiff - citadel/user_ops.c
* create format strings different for solaris
[citadel.git] / citadel / user_ops.c
index d1df3c27df056e6a1d01264b4a528bee0dc34632..aa1330f1030476419db4c95cc054e6d7b8774bfb 100644 (file)
@@ -47,6 +47,7 @@
 #include "config.h"
 #include "tools.h"
 #include "citserver.h"
+#include "citadel_dirs.h"
 #include "genstamp.h"
 
 /*
@@ -166,7 +167,7 @@ int GenerateRelationshipIndex(char *IndexBuf,
 void put_visit(struct visit *newvisit)
 {
        char IndexBuf[32];
-       int IndexLen;
+       int IndexLen = 0;
 
        /* Generate an index */
        IndexLen = GenerateRelationshipIndex(IndexBuf,
@@ -366,11 +367,15 @@ int CtdlLoginExistingUser(char *trythisname)
                char pwdbuffer[256];
        
                lprintf(CTDL_DEBUG, "asking host about <%s>\n", username);
+#ifdef SOLARIS_GETPWUID
+               tempPwdPtr = getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer);
+#else
                getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer, &tempPwdPtr);
+#endif
                if (tempPwdPtr == NULL) {
                        return login_not_found;
                }
-               lprintf(CTDL_DEBUG, "found it! uid=%d, gecos=%s\n", pd.pw_uid, pd.pw_gecos);
+               lprintf(CTDL_DEBUG, "found it! uid=%ld, gecos=%s\n", (long)pd.pw_uid, pd.pw_gecos);
        
                /* Locate the associated Citadel account.
                 * If not found, make one attempt to create it.
@@ -462,7 +467,7 @@ void cmd_user(char *cmdbuf)
  */
 void session_startup(void)
 {
-       int i;
+       int i = 0;
 
        lprintf(CTDL_NOTICE, "<%s> logged in\n", CC->curr_user);
 
@@ -540,7 +545,6 @@ void logout(struct CitContext *who)
         * make that assumption.
         */
        strcpy(who->fake_username, "");
-       strcpy(who->fake_postname, "");
        strcpy(who->fake_hostname, "");
        strcpy(who->fake_roomname, "");
        who->logged_in = 0;
@@ -608,8 +612,8 @@ static int validpw(uid_t uid, const char *pass)
                }
                close(pipev[0]);
 
-               execl(CTDLDIR "/chkpwd", CTDLDIR "/chkpwd", NULL);
-               perror(CTDLDIR "/chkpwd");
+               execl(file_chkpwd, file_chkpwd, NULL);
+               perror(file_chkpwd);
                exit(1);
        }
 
@@ -669,11 +673,23 @@ int CtdlTryPassword(char *password)
 
                if (validpw(CC->user.uid, password)) {
                        code = 0;
-                       /* we could get rid of this */
+
+                       /*
+                        * sooper-seekrit hack: populate the password field in the
+                        * citadel database with the password that the user typed,
+                        * if it's correct.  This allows most sites to convert from
+                        * host auth to native auth if they want to.  If you think
+                        * this is a security hazard, comment it out.
+                        */
+
                        lgetuser(&CC->user, CC->curr_user);
                        safestrncpy(CC->user.password, password, sizeof CC->user.password);
                        lputuser(&CC->user);
-                       /*                          */
+
+                       /*
+                        * (sooper-seekrit hack ends here)
+                        */
+
                }
                else {
                        code = (-1);
@@ -822,7 +838,11 @@ int create_user(char *newusername, int become_user)
                struct passwd *tempPwdPtr;
                char pwdbuffer[256];
        
+#ifdef SOLARIS_GETPWUID
+               tempPwdPtr = getpwnam_r(username, &pd, pwdbuffer, sizeof(pwdbuffer));
+#else
                getpwnam_r(username, &pd, pwdbuffer, sizeof pwdbuffer, &tempPwdPtr);
+#endif
                if (tempPwdPtr != NULL) {
                        extract_token(username, pd.pw_gecos, 0, ',', sizeof username);
                        uid = pd.pw_uid;