X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/52a236230220232fd632b5aa88eb9bb31dba346e..06259405cd587d29eec78914f8df2dc88f8a9b33:/sbr/credentials.c diff --git a/sbr/credentials.c b/sbr/credentials.c index 9d4e41c2..9b5dd537 100644 --- a/sbr/credentials.c +++ b/sbr/credentials.c @@ -17,11 +17,12 @@ init_credentials_file () { char *hdir = getenv ("HOME"); credentials_file = concat (hdir ? hdir : ".", "/.netrc", NULL); - } else if (! strncasecmp (cred_style, "file:", 5)) { + } else if (! strncasecmp (cred_style, "file:", 5) || + ! strncasecmp (cred_style, "file-nopermcheck:", 17)) { struct stat st; - char *filename = cred_style + 5; + char *filename = strchr(cred_style, ':') + 1; - while (*filename && isspace ((int) *filename)) ++filename; + while (*filename && isspace ((unsigned char) *filename)) ++filename; if (*filename == '/') { credentials_file = filename; @@ -36,6 +37,9 @@ init_credentials_file () { } } } + + if (! strncasecmp (cred_style, "file-nopermcheck:", 17)) + credentials_no_perm_check = 1; } } } @@ -48,16 +52,15 @@ nmh_get_credentials (char *host, char *user, int sasl, nmh_creds_t creds) { 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 (); - } + creds->user = user == NULL ? getusername () : user; if (sasl) { + + /* 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 (); - } else { - ruserpass (host, &creds->user, &creds->password); } - } else if (! strncasecmp (cred_style, "file:", 5)) { + } else if (! strncasecmp (cred_style, "file:", 5) || + ! strncasecmp (cred_style, "file-nopermcheck:", 17)) { /* * Determine user using the first of: * 1) -user switch @@ -67,8 +70,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; - 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; }