]> diplodocus.org Git - nmh/blobdiff - uip/popsbr.c
Escape literal leading full stop in man/new.man.
[nmh] / uip / popsbr.c
index fa9b99d1e542dcddc208350b7d184feb4d538758..ebb9b18f538f71a793366707867f71df8b009c9c 100644 (file)
@@ -15,7 +15,6 @@
 #include <h/signals.h>
 
 #define        TRM     "."
 #include <h/signals.h>
 
 #define        TRM     "."
-#define        TRMLEN  (sizeof TRM - 1)
 
 static int poprint = 0;
 
 
 static int poprint = 0;
 
@@ -145,6 +144,8 @@ pop_init (char *host, char *port, char *user, char *proxy, int snoop,
     if (user)
        netsec_set_userid(nsc, user);
 
     if (user)
        netsec_set_userid(nsc, user);
 
+    netsec_set_hostname(nsc, host);
+
     if (oauth_svc != NULL) {
        if (netsec_set_oauth_service(nsc, oauth_svc) != OK) {
            snprintf(response, sizeof(response), "OAuth2 not supported");
     if (oauth_svc != NULL) {
        if (netsec_set_oauth_service(nsc, oauth_svc) != OK) {
            snprintf(response, sizeof(response), "OAuth2 not supported");
@@ -212,8 +213,8 @@ pop_init (char *host, char *port, char *user, char *proxy, int snoop,
     netsec_set_fd(nsc, fd1, fd2);
     netsec_set_snoop(nsc, snoop);
 
     netsec_set_fd(nsc, fd1, fd2);
     netsec_set_snoop(nsc, snoop);
 
-    if (tls) {
-       if (netsec_set_tls(nsc, 1, &errstr) != OK) {
+    if (tls & P_INITTLS) {
+       if (netsec_set_tls(nsc, 1, tls & P_NOVERIFY, &errstr) != OK) {
            snprintf(response, sizeof(response), "%s", errstr);
            free(errstr);
            return NOTOK;
            snprintf(response, sizeof(response), "%s", errstr);
            free(errstr);
            return NOTOK;
@@ -227,8 +228,8 @@ pop_init (char *host, char *port, char *user, char *proxy, int snoop,
     }
 
     if (sasl) {
     }
 
     if (sasl) {
-       if (netsec_set_sasl_params(nsc, host, "pop", mech,
-                                  pop_sasl_callback, &errstr) != OK) {
+       if (netsec_set_sasl_params(nsc, "pop", mech, pop_sasl_callback,
+                                  &errstr) != OK) {
            snprintf(response, sizeof(response), "%s", errstr);
            free(errstr);
            return NOTOK;
            snprintf(response, sizeof(response), "%s", errstr);
            free(errstr);
            return NOTOK;
@@ -240,6 +241,8 @@ pop_init (char *host, char *port, char *user, char *proxy, int snoop,
            if (poprint)
                fprintf (stderr, "<--- %s\n", response);
            if (*response == '+') {
            if (poprint)
                fprintf (stderr, "<--- %s\n", response);
            if (*response == '+') {
+                nmh_creds_t creds;
+
                if (sasl) {
                    char server_mechs[256];
                    if (check_mech(server_mechs, sizeof(server_mechs)) != OK)
                if (sasl) {
                    char server_mechs[256];
                    if (check_mech(server_mechs, sizeof(server_mechs)) != OK)
@@ -253,7 +256,6 @@ pop_init (char *host, char *port, char *user, char *proxy, int snoop,
                    }
                    return OK;
                }
                    }
                    return OK;
                }
-                nmh_creds_t creds;
 
                 if (!(creds = nmh_get_credentials(host, user)))
                     return NOTOK;
 
                 if (!(creds = nmh_get_credentials(host, user)))
                     return NOTOK;
@@ -270,7 +272,7 @@ pop_init (char *host, char *port, char *user, char *proxy, int snoop,
            strncpy (buffer, response, sizeof(buffer));
            command ("QUIT");
            strncpy (response, buffer, sizeof(response));
            strncpy (buffer, response, sizeof(buffer));
            command ("QUIT");
            strncpy (response, buffer, sizeof(response));
-                               /* and fall */
+           /* FALLTHRU */
 
        case NOTOK: 
        case DONE: 
 
        case NOTOK: 
        case DONE: 
@@ -433,7 +435,7 @@ pop_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata,
        if (line == NULL)
            return NOTOK;
 
        if (line == NULL)
            return NOTOK;
 
-       if (strncmp(line, "+OK", 3) != 0) {
+       if (!has_prefix(line, "+OK")) {
            netsec_err(errstr, "Authentication failed: %s", line);
            return NOTOK;
        }
            netsec_err(errstr, "Authentication failed: %s", line);
            return NOTOK;
        }
@@ -685,14 +687,14 @@ vcommand (const char *fmt, va_list ap)
 int
 multiline (void)
 {
 int
 multiline (void)
 {
-    char buffer[BUFSIZ + TRMLEN];
+    char buffer[BUFSIZ + LEN(TRM)];
 
     if (pop_getline (buffer, sizeof buffer, nsc) != OK)
        return NOTOK;
 
     if (pop_getline (buffer, sizeof buffer, nsc) != OK)
        return NOTOK;
-    if (strncmp (buffer, TRM, TRMLEN) == 0) {
-       if (buffer[TRMLEN] == 0)
+    if (has_prefix(buffer, TRM)) {
+       if (buffer[LEN(TRM)] == 0)
            return DONE;
            return DONE;
-        strncpy (response, buffer + TRMLEN, sizeof(response));
+        strncpy (response, buffer + LEN(TRM), sizeof(response));
     }
     else
        strncpy (response, buffer, sizeof(response));
     }
     else
        strncpy (response, buffer, sizeof(response));