]> diplodocus.org Git - nmh/blobdiff - sbr/credentials.c
mhlist: don't truncate anything when -verbose
[nmh] / sbr / credentials.c
index 9d4e41c29ab87108432b6062addccb5a73234237..ae53a742b9b6ecc0f6bda3a63f2a791d585ce2a3 100644 (file)
@@ -21,7 +21,7 @@ init_credentials_file () {
             struct stat st;
             char *filename = cred_style + 5;
 
             struct stat st;
             char *filename = cred_style + 5;
 
-            while (*filename  &&  isspace ((int) *filename)) ++filename;
+            while (*filename && isspace ((unsigned char) *filename)) ++filename;
 
             if (*filename == '/') {
                 credentials_file = filename;
 
             if (*filename == '/') {
                 credentials_file = filename;
@@ -48,14 +48,12 @@ nmh_get_credentials (char *host, char *user, int sasl, nmh_creds_t creds) {
     creds->host = host;
 
     if (cred_style == NULL  ||  ! strcmp (cred_style, "legacy")) {
     creds->host = host;
 
     if (cred_style == NULL  ||  ! strcmp (cred_style, "legacy")) {
-        /* This is what inc.c and msgchk.c used to contain. */
-        if (user == NULL) {
-            creds->user = getusername ();
-        }
         if (sasl) {
         if (sasl) {
+            creds->user = user == NULL  ?  getusername ()  :  user;
+
+            /* This is what inc.c and msgchk.c used to contain. */
+            /* Only inc.c and msgchk.c do this.  smtp.c doesn't. */
             creds->password = getusername ();
             creds->password = getusername ();
-        } else {
-            ruserpass (host, &creds->user, &creds->password);
         }
     } else if (! strncasecmp (cred_style, "file:", 5)) {
         /*
         }
     } else if (! strncasecmp (cred_style, "file:", 5)) {
         /*
@@ -67,8 +65,11 @@ nmh_get_credentials (char *host, char *user, int sasl, nmh_creds_t creds) {
          *    credentials file didn't have a "default" token)
          */
         creds->user = user;
          *    credentials file didn't have a "default" token)
          */
         creds->user = user;
-        ruserpass (host, &creds->user, &creds->password);
+    } else {
+        admonish (NULL, "unknown credentials style %s", cred_style);
+        return NOTOK;
     }
 
     }
 
+    ruserpass (host, &creds->user, &creds->password);
     return OK;
 }
     return OK;
 }