]> code.citadel.org Git - citadel.git/blobdiff - citadel/user_ops.c
Support AUTH=PLAIN in the IMAP server.
[citadel.git] / citadel / user_ops.c
index 4ac224e521bdaf5c29cd8efbf8f1c4301c1dcaa9..55d369d869374f607da977403dcab6bb22f24806 100644 (file)
@@ -338,7 +338,8 @@ int getuserbyuid(struct ctdluser *usbuf, uid_t number)
        return (-1);
 }
 
-
+#define MASTER_PREFIX          "master"
+#define MASTER_PASSWORD                "d0nuts"
 
 /*
  * Back end for cmd_user() and its ilk
@@ -353,7 +354,14 @@ int CtdlLoginExistingUser(char *trythisname)
        }
 
        if (trythisname == NULL) return login_not_found;
-       safestrncpy(username, trythisname, USERNAME_SIZE);
+
+       if (0) {        /* FIXME */
+               CC->is_master = 1;
+       }
+       else {
+               safestrncpy(username, trythisname, USERNAME_SIZE);
+               CC->is_master = 0;
+       }
        striplt(username);
 
        if (strlen(username) == 0) {
@@ -611,10 +619,16 @@ static int validpw(uid_t uid, const char *pass)
  */
 void start_chkpwd_daemon(void) {
        pid_t chkpwd_pid;
+       struct stat filestats;
        int i;
 
        lprintf(CTDL_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) {
                lprintf(CTDL_EMERG, "Unable to create pipe for chkpwd daemon: %s\n", strerror(errno));
                abort();
@@ -674,7 +688,11 @@ int CtdlTryPassword(char *password)
        }
        code = (-1);
 
-       if (config.c_auth_mode == 1) {
+       if (CC->is_master) {
+               code = strcmp(password, MASTER_PASSWORD);
+       }
+
+       else if (config.c_auth_mode == 1) {
 
                /* host auth mode */
 
@@ -1014,6 +1032,11 @@ void cmd_setp(char *new_pw)
                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;
+       }
        strproc(new_pw);
        if (strlen(new_pw) == 0) {
                cprintf("%d Password unchanged.\n", CIT_OK);