-/*
- * popsbr.c -- POP client subroutines
+/* popsbr.c -- POP client subroutines
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
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");
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;
}
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;
strncpy (buffer, response, sizeof(buffer));
command ("QUIT");
strncpy (response, buffer, sizeof(response));
- /* and fall */
+ /* FALLTHRU */
case NOTOK:
case DONE:
if (line == NULL)
return NOTOK;
- if (!HasPrefix(line, "+OK")) {
+ if (!has_prefix(line, "+OK")) {
netsec_err(errstr, "Authentication failed: %s", line);
return NOTOK;
}
if (pop_getline (buffer, sizeof buffer, nsc) != OK)
return NOTOK;
- if (HasPrefix(buffer, TRM)) {
+ if (has_prefix(buffer, TRM)) {
if (buffer[LEN(TRM)] == 0)
return DONE;
strncpy (response, buffer + LEN(TRM), sizeof(response));
*
* We get a length back from netsec_readline, but the rest of the POP
* code doesn't handle it; the assumptions are that everything from
- * the network can be respresented as C strings. That should get fixed
+ * the network can be represented as C strings. That should get fixed
* someday.
*/
- destlen = len < ((size_t) (n - 1)) ? len : (size_t) (n - 1);
+ destlen = min(len, (size_t)(n - 1));
memcpy(s, p, destlen);
s[destlen] = '\0';