X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/a1067dea91a4cb3fc71b0b33271d2c7c9c8a2d7a..2194825961eefdab538204e3bb682825a5427e14:/uip/inc.c diff --git a/uip/inc.c b/uip/inc.c index f169fc7d..b76f1cd9 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -29,7 +29,6 @@ #include #include #include - #include #include #include @@ -37,8 +36,6 @@ #include #include #include -#include -#include #ifndef CYRUS_SASL # define SASLminc(a) (a) @@ -190,7 +187,6 @@ main (int argc, char **argv) char *maildir_copy = NULL; /* copy of mail directory because the static gets overwritten */ int nmsgs, nbytes; - char *pass = NULL; char *MAILHOST_env_variable; done=inc_done; @@ -201,13 +197,7 @@ main (int argc, char **argv) SAVEGROUPPRIVS(); TRYDROPGROUPPRIVS(); -#ifdef LOCALE - setlocale(LC_ALL, ""); -#endif - invo_name = r1bindex (argv[0], '/'); - - /* read user profile/context */ - context_read(); + if (nmh_init(argv[0], 1)) { return 1; } mts_init (invo_name); arguments = getarguments (invo_name, argc, argv, 1); @@ -391,18 +381,14 @@ main (int argc, char **argv) * a POP server? */ if (inc_type == INC_POP) { - if (user == NULL) - user = getusername (); - if (sasl) - pass = getusername (); - else - ruserpass (host, &user, &pass); + struct nmh_creds creds = { 0, 0, 0 }; /* * initialize POP connection */ - if (pop_init (host, port, user, pass, proxy, snoop, sasl, - saslmech) == NOTOK) + nmh_get_credentials (host, user, sasl, &creds); + if (pop_init (host, port, creds.user, creds.password, proxy, snoop, + sasl, saslmech) == NOTOK) adios (NULL, "%s", response); /* Check if there are any messages */ @@ -555,10 +541,15 @@ go_to_it: else if (i == NOTOK) chmod (audfile, m_gmprot ()); - fprintf (aud, from ? "<> %s -ms %s\n" - : host ? "<> %s -host %s -user %s\n" - : "<> %s\n", - dtimenow (0), from ? from : host, user); + if (from) + fprintf (aud, "<> %s -ms %s\n", dtimenow(0), from); + else { + if (host) + fprintf (aud, "<> %s -host %s -user %s\n", dtimenow(0), + host, user); + else + fprintf (aud, "<> %s\n", dtimenow (0)); + } } /* Get new format string */ @@ -665,7 +656,7 @@ go_to_it: } else { if (ferror(pf) || fclose (pf)) { int e = errno; - unlink (cp); + (void) m_unlink (cp); pop_quit (); errno = e; adios (cp, "write error on"); @@ -760,7 +751,7 @@ go_to_it: break; if (ferror(sf) || fflush(pf) || ferror(pf)) { int e = errno; - fclose(pf); fclose(sf); unlink(cp); + fclose(pf); fclose(sf); (void) m_unlink(cp); errno = e; adios(cp, "copy error %s -> %s", sp, cp); } @@ -807,14 +798,14 @@ go_to_it: } if (ferror(pf) || fclose (pf)) { int e = errno; - unlink (cp); + (void) m_unlink (cp); errno = e; adios (cp, "write error on"); } pf = NULL; free (cp); - if (trnflag && unlink (sp) == NOTOK) + if (trnflag && m_unlink (sp) == NOTOK) adios (sp, "couldn't unlink"); free (sp); /* Free Maildir[i]->filename */ } @@ -856,7 +847,7 @@ go_to_it: close (newfd); else admonish (newmail, "error zero'ing"); - unlink(map_name(newmail)); + (void) m_unlink(map_name(newmail)); } } else { if (noisy)