summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b9e0388)
-authservice service, because OAUTH2 is a SASL mechanism.
16 files changed:
test/mhshow/test-subpart test/mhshow/test-msg-buffer-boundaries \
test/mhstore/test-mhstore test/mkstemp/test-mkstemp \
test/new/test-basic test/pick/test-pick test/pick/test-stderr \
test/mhshow/test-subpart test/mhshow/test-msg-buffer-boundaries \
test/mhstore/test-mhstore test/mkstemp/test-mkstemp \
test/new/test-basic test/pick/test-pick test/pick/test-stderr \
- test/oauth/test-mhlogin test/oauth/test-send \
+ test/oauth/test-mhlogin test/oauth/test-mhparam test/oauth/test-send \
test/oauth/test-inc test/oauth/test-share \
test/post/test-post-aliases test/post/test-post-basic \
test/post/test-post-multiple test/post/test-post-bcc \
test/oauth/test-inc test/oauth/test-share \
test/post/test-post-aliases test/post/test-post-basic \
test/post/test-post-multiple test/post/test-post-bcc \
-.TH INC %manext1% "November 25, 2014" "%nmhversion%"
+.TH INC %manext1% "March 23, 2016" "%nmhversion%"
.RB [ \-sasl " | " \-nosasl ]
.RB [ \-saslmech
.IR mechanism ]
.RB [ \-sasl " | " \-nosasl ]
.RB [ \-saslmech
.IR mechanism ]
.IR service ]
.RB [ \-snoop ]
.RB [ \-version ]
.IR service ]
.RB [ \-snoop ]
.RB [ \-version ]
.BR \-snoop ,
which will allow you to watch the POP transaction take place
between you and the POP server. If
.BR \-snoop ,
which will allow you to watch the POP transaction take place
between you and the POP server. If
is used, the HTTP transaction is also shown.
.PP
If
is used, the HTTP transaction is also shown.
.PP
If
If
.B nmh
has been compiled with OAuth support, the
If
.B nmh
has been compiled with OAuth support, the
switch will enable OAuth authentication. The
.B \-user
switch must be used, and the
.I user-name
switch will enable OAuth authentication. The
.B \-user
switch must be used, and the
.I user-name
-must be an email address the user has for that service. Before using this,
-the user must authorize nmh by running
+must be an email address the user has for the service, which must
+be specified with the
+.B \-authservice
+.I service
+switch. Before using this, the user must authorize nmh by running
-and grant authorization to that account. Only
-.B -oauth
-.I gmail
-is supported. See the
+and grant authorization to that account. See the
.B mhlogin
man page for more details.
.PP
.B mhlogin
man page for more details.
.PP
-.TH SEND %manext1% "November 25, 2014" "%nmhversion%"
+.TH SEND %manext1% "March 23, 2016" "%nmhversion%"
.SH NAME
mhlogin \- login to external (OAuth) services
.SH SYNOPSIS
.HP 5
.na
.B mhlogin
.SH NAME
mhlogin \- login to external (OAuth) services
.SH SYNOPSIS
.HP 5
.na
.B mhlogin
-.RB \-oauth
-.IR service
+.RB [ \-saslmech
+.IR mechanism ]
+.RB [ \-authservice
+.IR service ]
.RB [ \-snoop ]
.RB [ \-version ]
.RB [ \-help ]
.RB [ \-snoop ]
.RB [ \-version ]
.RB [ \-help ]
.B Mhlogin
currently only supports OAuth for Gmail. Run
.B mhlogin
.B Mhlogin
currently only supports OAuth for Gmail. Run
.B mhlogin
+.B \-saslmech xoauth2
+.B \-authservice
.I gmail
and load the printed URL in your browser. Login to a Gmail account, grant
authorization, and copy and paste the code into the
.I gmail
and load the printed URL in your browser. Login to a Gmail account, grant
authorization, and copy and paste the code into the
prompt. Be sure to use the same account with the
.B -user
switch to
prompt. Be sure to use the same account with the
.B -user
switch to
All parameters configuring the service may be overridden by profile components,
and even though only Gmail is supported out of the box, the user can define
new services entirely in the profile. Profile components are prefixed by
All parameters configuring the service may be overridden by profile components,
and even though only Gmail is supported out of the box, the user can define
new services entirely in the profile. Profile components are prefixed by
-.I
-oauth-
-.I
-service-
-for example
+.IR oauth-service- ,
+for example,
.I oauth-gmail-credential-file
which specifies where
.B mhlogin
.I oauth-gmail-credential-file
which specifies where
.B mhlogin
-.TH MSGCHK %manext1% "November 25, 2014" "%nmhversion%"
+.TH MSGCHK %manext1% "March 23, 2016" "%nmhversion%"
.RB [ \-sasl ]
.RB [ \-saslmech
.IR mechanism ]
.RB [ \-sasl ]
.RB [ \-saslmech
.IR mechanism ]
.IR service ]
.RB [ \-snoop ]
.RI [ users
.IR service ]
.RB [ \-snoop ]
.RI [ users
which will
allow you to watch the POP transaction take place between you and the
POP server. If
which will
allow you to watch the POP transaction take place between you and the
POP server. If
is used, the HTTP transaction is also shown.
.PP
If
is used, the HTTP transaction is also shown.
.PP
If
If
.B nmh
has been compiled with OAuth support, the
If
.B nmh
has been compiled with OAuth support, the
switch will enable OAuth authentication. The
.B \-user
switch must be used, and the
.I user-name
switch will enable OAuth authentication. The
.B \-user
switch must be used, and the
.I user-name
-must be an email address the user has for that service. Before using this,
-the user must authorize nmh by running
+must be an email address the user has for the service, which must
+be specified with the
+.B \-authservice
+.I service
+switch. Before using this, the user must authorize nmh by running
-and grant authorization to that account. Only
-.B -oauth
-.I gmail
-is supported. See the
+and grant authorization to that account. See the
.B mhlogin
man page for more details.
.PP
.B mhlogin
man page for more details.
.PP
-.TH SEND %manext1% "November 25, 2014" "%nmhversion%"
+.TH SEND %manext1% "March 23, 2016" "%nmhversion%"
.SH NAME
send \- send a message
.SH SYNOPSIS
.SH NAME
send \- send a message
.SH SYNOPSIS
.RB [ \-msgid " | " \-nomsgid ]
.RB [ \-messageid
.IR localname " | " random ]
.RB [ \-msgid " | " \-nomsgid ]
.RB [ \-messageid
.IR localname " | " random ]
-.RB [ \-oauth
-.IR service ]
.RB [ \-push " | " \-nopush ]
.RB [ \-split
.IR seconds ]
.RB [ \-push " | " \-nopush ]
.RB [ \-split
.IR seconds ]
.IR ssf ]
.RB [ \-saslmech
.IR mechanism ]
.IR ssf ]
.RB [ \-saslmech
.IR mechanism ]
+.RB [ \-authservice
+.IR service ]
.RB [ \-snoop ]
.RB [ \-user
.IR username ]
.RB [ \-snoop ]
.RB [ \-user
.IR username ]
switch can be used to view the SMTP transaction. (Beware that the
SMTP transaction may contain authentication information either in
plaintext or easily decoded base64.) If
switch can be used to view the SMTP transaction. (Beware that the
SMTP transaction may contain authentication information either in
plaintext or easily decoded base64.) If
is used, the HTTP transaction is also shown.
.PP
If
is used, the HTTP transaction is also shown.
.PP
If
If
.B nmh
has been compiled with OAuth support, the
If
.B nmh
has been compiled with OAuth support, the
switch will enable OAuth authentication. The
.B \-user
switch must be used, and the
.I user-name
switch will enable OAuth authentication. The
.B \-user
switch must be used, and the
.I user-name
-must be an email address the user has for that service. Before using this,
-the user must authorize nmh by running
+must be an email address the user has for the service, which must
+be specified with the
+.B \-authservice
+.I service
+switch. Before using this, the user must authorize nmh by running
-and grant authorization to that account. Only
-.B -oauth
-.I gmail
-is supported. See the
+and grant authorization to that account. See the
.B mhlogin
man page for more details.
.PP
.B mhlogin
man page for more details.
.PP
fp = lkfopendata(fn, "r+", &failed_to_lock);
if (fp == NULL) {
if (errno == ENOENT) {
fp = lkfopendata(fn, "r+", &failed_to_lock);
if (fp == NULL) {
if (errno == ENOENT) {
- adios(NULL, "no credentials -- run mhlogin -oauth %s", svc);
+ adios(NULL, "no credentials -- run mhlogin -saslmech xoauth2 -authservice %s", svc);
}
adios(fn, "failed to open");
}
}
adios(fn, "failed to open");
}
if (!mh_oauth_access_token_valid(time(NULL), cred)) {
if (!mh_oauth_refresh(cred)) {
if (mh_oauth_get_err_code(ctx) == MH_OAUTH_NO_REFRESH) {
if (!mh_oauth_access_token_valid(time(NULL), cred)) {
if (!mh_oauth_refresh(cred)) {
if (mh_oauth_get_err_code(ctx) == MH_OAUTH_NO_REFRESH) {
- adios(NULL, "no valid credentials -- run mhlogin -oauth %s",
- svc);
+ adios(NULL, "no valid credentials -- run mhlogin -saslmech xoauth2 -authservice %s", svc);
}
if (mh_oauth_get_err_code(ctx) == MH_OAUTH_BAD_GRANT) {
}
if (mh_oauth_get_err_code(ctx) == MH_OAUTH_BAD_GRANT) {
- adios(NULL, "credentials rejected -- run mhlogin -oath %s",
- svc);
+ adios(NULL, "credentials rejected -- run mhlogin -saslmech xoauth2 -authservice %s", svc);
}
advise(NULL, "error refreshing OAuth2 token");
adios(NULL, mh_oauth_get_err_string(ctx));
}
advise(NULL, "error refreshing OAuth2 token");
adios(NULL, mh_oauth_get_err_string(ctx));
static boolean
update_svc(struct service_info *svc, const char *svc_name, mh_oauth_ctx *ctx)
{
static boolean
update_svc(struct service_info *svc, const char *svc_name, mh_oauth_ctx *ctx)
{
update_svc_field(&svc->name, #name, svc_name); \
if (svc->name == NULL) { \
set_err_details(ctx, MH_OAUTH_BAD_PROFILE, #name " is missing"); \
update_svc_field(&svc->name, #name, svc_name); \
if (svc->name == NULL) { \
set_err_details(ctx, MH_OAUTH_BAD_PROFILE, #name " is missing"); \
- run_test "inc -host 127.0.0.1 -port ${pop_port} -oauth test -user nobody@example.com -width 80" "$@"
+ run_test "inc -host 127.0.0.1 -port ${pop_port} -saslmech xoauth2 -authservice test -user nobody@example.com -width 80" "$@"
}
test_send_no_servers() {
}
test_send_no_servers() {
- run_test "send -draft -server 127.0.0.1 -port ${smtp_port} -oauth test -user nobody@example.com" "$@"
+ run_test "send -draft -server 127.0.0.1 -port ${smtp_port} -saslmech xoauth2 -authservice test -user nobody@example.com" "$@"
}
test_send_only_fakesmtp() {
}
test_send_only_fakesmtp() {
test_mhlogin() {
start_fakehttp
test_mhlogin() {
start_fakehttp
- run_test 'eval echo code | mhlogin -oauth test' \
+ run_test 'eval echo code | mhlogin -saslmech xoauth2 -authservice test' \
"Load the following URL in your browser and authorize nmh to access test:
http://127.0.0.1:${http_port}/oauth/auth?response_type=code&client_id=test-id&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=test-scope
"Load the following URL in your browser and authorize nmh to access test:
http://127.0.0.1:${http_port}/oauth/auth?response_type=code&client_id=test-id&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=test-scope
-run_test "send -draft -server 127.0.0.1 -port ${smtp_port} -oauth test -user nobody@example.com"
+run_test "send -draft -server 127.0.0.1 -port ${smtp_port} -saslmech xoauth2 -authservice test -user nobody@example.com"
# TEST
echo 'expired access token, refresh works, smtp server accepts message'
# TEST
echo 'expired access token, refresh works, smtp server accepts message'
# TEST
echo 'no service definition'
# TEST
echo 'no service definition'
-run_test "send -draft -server 127.0.0.1 -port ${smtp_port} -oauth bogus -user nobody@example.com" 'send: incomplete OAuth2 service definition: scope is missing'
+run_test "send -draft -server 127.0.0.1 -port ${smtp_port} -saslmech xoauth2 -authservice bogus -user nobody@example.com" 'send: incomplete OAuth2 service definition: scope is missing'
# TEST
echo 'no creds file -- should tell user to mhlogin'
rm -f "${MHTMPDIR}/oauth-test"
# TEST
echo 'no creds file -- should tell user to mhlogin'
rm -f "${MHTMPDIR}/oauth-test"
-test_send_no_servers 'send: no credentials -- run mhlogin -oauth test'
+test_send_no_servers 'send: no credentials -- run mhlogin -saslmech xoauth2 -authservice test'
# TEST
echo 'empty creds file -- should tell user to mhlogin'
fake_creds < /dev/null
# TEST
echo 'empty creds file -- should tell user to mhlogin'
fake_creds < /dev/null
-test_send_no_servers 'send: no valid credentials -- run mhlogin -oauth test'
+test_send_no_servers 'send: no valid credentials -- run mhlogin -saslmech xoauth2 -authservice test'
# TEST
echo 'garbage creds file'
# TEST
echo 'garbage creds file'
-test_send_no_servers 'send: no valid credentials -- run mhlogin -oauth test'
+test_send_no_servers 'send: no valid credentials -- run mhlogin -saslmech xoauth2 -authservice test'
# TEST
echo 'access token has no expiration, no refresh token -- tell user to mhlogin'
# TEST
echo 'access token has no expiration, no refresh token -- tell user to mhlogin'
-test_send_no_servers 'send: no valid credentials -- run mhlogin -oauth test'
+test_send_no_servers 'send: no valid credentials -- run mhlogin -saslmech xoauth2 -authservice test'
# TEST
echo 'refresh finds no http server'
# TEST
echo 'refresh finds no http server'
EOF
run_prog send -draft -server 127.0.0.1 -port ${smtp_port} \
EOF
run_prog send -draft -server 127.0.0.1 -port ${smtp_port} \
- -oauth test -user nobody@example.com > "${testname}.send-output" 2>&1 || true
+ -saslmech xoauth2 -authservice test -user nobody@example.com > "${testname}.send-output" 2>&1 || true
# Clear out an error message we get from libcurl on some systems (seen at least
# 3 different versions of this error message, on FreeBSD 10.1, Ubuntu 12.04, and
# Ubuntu 14.04).
# Clear out an error message we get from libcurl on some systems (seen at least
# 3 different versions of this error message, on FreeBSD 10.1, Ubuntu 12.04, and
# Ubuntu 14.04).
-test_send_only_fakehttp 'send: credentials rejected -- run mhlogin -oath test'
+test_send_only_fakehttp 'send: credentials rejected -- run mhlogin -saslmech xoauth2 -authservice test'
# TEST
echo 'refresh gets response too big'
# TEST
echo 'refresh gets response too big'
-run_test 'eval echo code | mhlogin -oauth test' \
+run_test 'eval echo code | mhlogin -saslmech xoauth2 -authservice test' \
"Load the following URL in your browser and authorize nmh to access test:
http://127.0.0.1:${http_port}/oauth/auth?response_type=code&client_id=test-id&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=test-scope
"Load the following URL in your browser and authorize nmh to access test:
http://127.0.0.1:${http_port}/oauth/auth?response_type=code&client_id=test-id&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=test-scope
Enter the authorization code: "
start_pop_xoauth
Enter the authorization code: "
start_pop_xoauth
-run_test "msgchk -host 127.0.0.1 -port ${pop_port} -oauth test -user nobody@example.com" 'nobody@example.com has 1 message (178 bytes) on 127.0.0.1'
+run_test "msgchk -host 127.0.0.1 -port ${pop_port} -saslmech xoauth2 -authservice test -user nobody@example.com" 'nobody@example.com has 1 message (178 bytes) on 127.0.0.1'
start_pop_xoauth
test_inc_success
start_pop_xoauth
test_inc_success
test_inc_success
start_pop_xoauth
test_inc_success
start_pop_xoauth
-run_test "msgchk -host 127.0.0.1 -port ${pop_port} -oauth test -user nobody@example.com" 'nobody@example.com has 1 message (178 bytes) on 127.0.0.1'
+run_test "msgchk -host 127.0.0.1 -port ${pop_port} -saslmech oauth2 -authservice test -user nobody@example.com" 'nobody@example.com has 1 message (178 bytes) on 127.0.0.1'
setup_draft
test_send_only_fakesmtp
setup_draft
test_send_only_fakesmtp
start_fakehttp
start_pop_xoauth
start_fakehttp
start_pop_xoauth
-run_test "msgchk -host 127.0.0.1 -port ${pop_port} -oauth test -user nobody@example.com" 'nobody@example.com has 1 message (178 bytes) on 127.0.0.1'
+run_test "msgchk -host 127.0.0.1 -port ${pop_port} -saslmech xoauth2 -authservice test -user nobody@example.com" 'nobody@example.com has 1 message (178 bytes) on 127.0.0.1'
start_pop_xoauth
test_inc_success
start_pop_xoauth
test_inc_success
test_send
start_pop_xoauth
test_send
start_pop_xoauth
-run_test "msgchk -host 127.0.0.1 -port ${pop_port} -oauth test -user nobody@example.com" 'nobody@example.com has 1 message (178 bytes) on 127.0.0.1'
+run_test "msgchk -host 127.0.0.1 -port ${pop_port} -saslmech xoauth2 -authservice test -user nobody@example.com" 'nobody@example.com has 1 message (178 bytes) on 127.0.0.1'
start_pop_xoauth
test_inc_success
start_pop_xoauth
test_inc_success
X("form formatfile", 0, FORMSW) \
X("format string", 5, FMTSW) \
X("host hostname", 0, HOSTSW) \
X("form formatfile", 0, FORMSW) \
X("format string", 5, FMTSW) \
X("host hostname", 0, HOSTSW) \
- X("oauth service", 0, OAUTHSW) \
X("user username", 0, USERSW) \
X("pack file", 0, PACKSW) \
X("nopack", 0, NPACKSW) \
X("user username", 0, USERSW) \
X("pack file", 0, PACKSW) \
X("nopack", 0, NPACKSW) \
X("sasl", SASLminc(-4), SASLSW) \
X("nosasl", SASLminc(-6), NOSASLSW) \
X("saslmech", SASLminc(-8), SASLMECHSW) \
X("sasl", SASLminc(-4), SASLSW) \
X("nosasl", SASLminc(-6), NOSASLSW) \
X("saslmech", SASLminc(-8), SASLMECHSW) \
+ X("authservice", SASLminc(-11), AUTHSERVICESW) \
X("proxy command", 0, PROXYSW) \
#define X(sw, minchars, id) id,
X("proxy command", 0, PROXYSW) \
#define X(sw, minchars, id) id,
char *cp, *maildir = NULL, *folder = NULL;
char *format = NULL, *form = NULL;
char *host = NULL, *port = NULL, *user = NULL, *proxy = NULL;
char *cp, *maildir = NULL, *folder = NULL;
char *format = NULL, *form = NULL;
char *host = NULL, *port = NULL, *user = NULL, *proxy = NULL;
- char *audfile = NULL, *from = NULL, *saslmech = NULL;
+ char *audfile = NULL, *from = NULL, *saslmech = NULL, *auth_svc = NULL;
char buf[BUFSIZ], **argp, *nfs, **arguments;
struct msgs *mp = NULL;
struct stat st, s1;
FILE *aud = NULL;
char b[PATH_MAX + 1];
char *maildir_copy = NULL; /* copy of mail directory because the static gets overwritten */
char buf[BUFSIZ], **argp, *nfs, **arguments;
struct msgs *mp = NULL;
struct stat st, s1;
FILE *aud = NULL;
char b[PATH_MAX + 1];
char *maildir_copy = NULL; /* copy of mail directory because the static gets overwritten */
- const char *oauth_svc = NULL;
int nmsgs, nbytes;
char *MAILHOST_env_variable;
int nmsgs, nbytes;
char *MAILHOST_env_variable;
adios (NULL, "missing argument to %s", argp[-2]);
continue;
adios (NULL, "missing argument to %s", argp[-2]);
continue;
- case OAUTHSW:
-#ifdef OAUTH_SUPPORT
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- oauth_svc = cp;
-#else
- adios (NULL, "not built with OAuth support");
-#endif
- continue;
-
case USERSW:
if (!(user = *argp++) || *user == '-')
adios (NULL, "missing argument to %s", argp[-2]);
case USERSW:
if (!(user = *argp++) || *user == '-')
adios (NULL, "missing argument to %s", argp[-2]);
if (!(saslmech = *argp++) || *saslmech == '-')
adios (NULL, "missing argument to %s", argp[-2]);
continue;
if (!(saslmech = *argp++) || *saslmech == '-')
adios (NULL, "missing argument to %s", argp[-2]);
continue;
+
+ case AUTHSERVICESW:
+#ifdef OAUTH_SUPPORT
+ if (!(auth_svc = *argp++) || *auth_svc == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+#else
+ adios (NULL, "not built with OAuth support");
+#endif
+ continue;
+
case PROXYSW:
if (!(proxy = *argp++) || *proxy == '-')
adios (NULL, "missing argument to %s", argp[-2]);
case PROXYSW:
if (!(proxy = *argp++) || *proxy == '-')
adios (NULL, "missing argument to %s", argp[-2]);
if (inc_type == INC_POP) {
struct nmh_creds creds = { 0, 0, 0 };
if (inc_type == INC_POP) {
struct nmh_creds creds = { 0, 0, 0 };
- if (oauth_svc == NULL) {
+ if (auth_svc == NULL) {
+ if (saslmech && ! strcasecmp(saslmech, "xoauth2")) {
+ adios (NULL, "must specify -authservice with -saslmech xoauth2");
+ }
nmh_get_credentials (host, user, sasl, &creds);
} else {
if (user == NULL) {
nmh_get_credentials (host, user, sasl, &creds);
} else {
if (user == NULL) {
- adios (NULL, "must specify -user with -oauth");
+ adios (NULL, "must specify -user with -saslmech xoauth2");
* initialize POP connection
*/
if (pop_init (host, port, creds.user, creds.password, proxy, snoop,
* initialize POP connection
*/
if (pop_init (host, port, creds.user, creds.password, proxy, snoop,
- sasl, saslmech, oauth_svc) == NOTOK)
+ sasl, saslmech, auth_svc) == NOTOK)
adios (NULL, "%s", response);
/* Check if there are any messages */
adios (NULL, "%s", response);
/* Check if there are any messages */
#include <h/oauth.h>
#define MHLOGIN_SWITCHES \
#include <h/oauth.h>
#define MHLOGIN_SWITCHES \
- X("oauth", 1, OAUTHSW) \
+ X("saslmech", 1, SASLMECHSW) \
+ X("authservice", -11, AUTHSERVICESW) \
X("snoop", 1, SNOOPSW) \
X("help", 1, HELPSW) \
X("version", 1, VERSIONSW) \
X("snoop", 1, SNOOPSW) \
X("help", 1, HELPSW) \
X("version", 1, VERSIONSW) \
const char *url;
if (svc == NULL) {
const char *url;
if (svc == NULL) {
- adios(NULL, "only support -oauth gmail");
+ adios(NULL, "missing -authservice switch");
}
if (!mh_oauth_new(&ctx, svc)) {
}
if (!mh_oauth_new(&ctx, svc)) {
main(int argc, char **argv)
{
char *cp, **argp, **arguments;
main(int argc, char **argv)
{
char *cp, **argp, **arguments;
+ char *saslmech = NULL, *svc = NULL;
int snoop = 0;
if (nmh_init(argv[0], 1)) { return 1; }
int snoop = 0;
if (nmh_init(argv[0], 1)) { return 1; }
adios (NULL, "-%s unknown", cp);
case HELPSW:
adios (NULL, "-%s unknown", cp);
case HELPSW:
- snprintf(help, sizeof(help), "%s -oauth gmail [switches]",
+ snprintf(help, sizeof(help), "%s [switches]",
invo_name);
print_help (help, switches, 1);
done (0);
invo_name);
print_help (help, switches, 1);
done (0);
print_version(invo_name);
done (0);
print_version(invo_name);
done (0);
- case OAUTHSW:
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- svc = cp;
+ case SASLMECHSW:
+ if (!(saslmech = *argp++) || *saslmech == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ continue;
+
+ case AUTHSERVICESW:
+ if (!(svc = *argp++) || *svc == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
X("snoop", -5, SNOOPSW) \
X("sasl", SASLminc(-4), SASLSW) \
X("saslmech", SASLminc(-5), SASLMECHSW) \
X("snoop", -5, SNOOPSW) \
X("sasl", SASLminc(-4), SASLSW) \
X("saslmech", SASLminc(-5), SASLMECHSW) \
- X("oauth service", 0, OAUTHSW) \
+ X("authservice", SASLminc(-11), AUTHSERVICESW) \
X("proxy command", 0, PROXYSW) \
#define X(sw, minchars, id) id,
X("proxy command", 0, PROXYSW) \
#define X(sw, minchars, id) id,
int status = 0, sasl = 0;
int snoop = 0, vecp = 0;
char *cp, *host = NULL, *port = NULL, *user = NULL, *proxy = NULL;
int status = 0, sasl = 0;
int snoop = 0, vecp = 0;
char *cp, *host = NULL, *port = NULL, *user = NULL, *proxy = NULL;
- char buf[BUFSIZ], *saslmech = NULL;
+ char buf[BUFSIZ], *saslmech = NULL, *auth_svc = NULL;
char **argp, **arguments, *vec[MAXVEC];
struct passwd *pw;
char **argp, **arguments, *vec[MAXVEC];
struct passwd *pw;
- const char *oauth_svc = NULL;
if (nmh_init(argv[0], 1)) { return 1; }
if (nmh_init(argv[0], 1)) { return 1; }
adios (NULL, "missing argument to %s", argp[-2]);
continue;
adios (NULL, "missing argument to %s", argp[-2]);
continue;
- case OAUTHSW:
-#ifdef OAUTH_SUPPORT
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- oauth_svc = cp;
-#else
- adios (NULL, "not built with OAuth support");
-#endif
- continue;
-
case USERSW:
if (!(cp = *argp++) || *cp == '-')
adios (NULL, "missing argument to %s", argp[-2]);
case USERSW:
if (!(cp = *argp++) || *cp == '-')
adios (NULL, "missing argument to %s", argp[-2]);
adios (NULL, "missing argument to %s", argp[-2]);
continue;
adios (NULL, "missing argument to %s", argp[-2]);
continue;
+ case AUTHSERVICESW:
+#ifdef OAUTH_SUPPORT
+ if (!(auth_svc = *argp++) || *auth_svc == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+#else
+ adios (NULL, "not built with OAuth support");
+#endif
+ continue;
+
case PROXYSW:
if (!(proxy = *argp++) || *proxy == '-')
adios (NULL, "missing argument to %s", argp[-2]);
case PROXYSW:
if (!(proxy = *argp++) || *proxy == '-')
adios (NULL, "missing argument to %s", argp[-2]);
if (host) {
if (vecp == 0) {
status = remotemail (host, port, user, proxy, notifysw, 1,
if (host) {
if (vecp == 0) {
status = remotemail (host, port, user, proxy, notifysw, 1,
- snoop, sasl, saslmech, oauth_svc);
+ snoop, sasl, saslmech, auth_svc);
} else {
for (vecp = 0; vec[vecp]; vecp++)
status += remotemail (host, port, vec[vecp], proxy, notifysw, 0,
} else {
for (vecp = 0; vec[vecp]; vecp++)
status += remotemail (host, port, vec[vecp], proxy, notifysw, 0,
- snoop, sasl, saslmech, oauth_svc);
+ snoop, sasl, saslmech, auth_svc);
}
} else {
if (user == NULL) user = getusername ();
}
} else {
if (user == NULL) user = getusername ();
static int
remotemail (char *host, char *port, char *user, char *proxy, int notifysw,
int personal, int snoop, int sasl, char *saslmech,
static int
remotemail (char *host, char *port, char *user, char *proxy, int notifysw,
int personal, int snoop, int sasl, char *saslmech,
{
int nmsgs, nbytes, status;
struct nmh_creds creds = { 0, 0, 0 };
{
int nmsgs, nbytes, status;
struct nmh_creds creds = { 0, 0, 0 };
- if (oauth_svc == NULL) {
+ if (auth_svc == NULL) {
+ if (saslmech && ! strcasecmp(saslmech, "xoauth2")) {
+ adios (NULL, "must specify -authservice with -saslmech xoauth2");
+ }
nmh_get_credentials (host, user, sasl, &creds);
} else {
if (user == NULL) {
nmh_get_credentials (host, user, sasl, &creds);
} else {
if (user == NULL) {
- adios (NULL, "must specify -user with -oauth");
+ adios (NULL, "must specify -user with -saslmech xoauth2");
}
creds.user = user;
}
/* open the POP connection */
if (pop_init (host, port, creds.user, creds.password, proxy, snoop, sasl,
}
creds.user = user;
}
/* open the POP connection */
if (pop_init (host, port, creds.user, creds.password, proxy, snoop, sasl,
- saslmech, oauth_svc) == NOTOK
+ saslmech, auth_svc) == NOTOK
|| pop_stat (&nmsgs, &nbytes) == NOTOK /* check for messages */
|| pop_quit () == NOTOK) { /* quit POP connection */
advise (NULL, "%s", response);
|| pop_stat (&nmsgs, &nbytes) == NOTOK /* check for messages */
|| pop_quit () == NOTOK) { /* quit POP connection */
advise (NULL, "%s", response);
X("nosasl", SASLminc(-6), NOSASLSW) \
X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
X("saslmech", SASLminc(-5), SASLMECHSW) \
X("nosasl", SASLminc(-6), NOSASLSW) \
X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
X("saslmech", SASLminc(-5), SASLMECHSW) \
- X("oauth", -5, OAUTHSW) \
+ X("authservice", SASLminc(-11), AUTHSERVICESW) \
X("user", SASLminc(-4), USERSW) \
X("port server submission port name/number", 4, PORTSW) \
X("tls", TLSminc(-3), TLSSW) \
X("user", SASLminc(-4), USERSW) \
X("port server submission port name/number", 4, PORTSW) \
X("tls", TLSminc(-3), TLSSW) \
adios (NULL, "missing argument to %s", argp[-2]);
continue;
adios (NULL, "missing argument to %s", argp[-2]);
continue;
- case OAUTHSW:
- if (!(cp = *argp++) || *cp == '-')
+ case AUTHSERVICESW:
+#ifdef OAUTH_SUPPORT
+ if (!(xoauth_client_res = *argp++) || *xoauth_client_res == '-')
adios (NULL, "missing argument to %s", argp[-2]);
adios (NULL, "missing argument to %s", argp[-2]);
- xoauth_client_res = cp;
+#else
+ adios (NULL, "not built with OAuth support");
+#endif
X("nosasl", SASLminc(-6), NOSASLSW) \
X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
X("saslmech mechanism", SASLminc(-5), SASLMECHSW) \
X("nosasl", SASLminc(-6), NOSASLSW) \
X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
X("saslmech mechanism", SASLminc(-5), SASLMECHSW) \
- X("oauth service", 0, OAUTHSW) \
+ X("authservice", SASLminc(-11), AUTHSERVICESW) \
X("user username", SASLminc(-4), USERSW) \
X("attach", -6, ATTACHSW) \
X("noattach", -8, NOATTACHSW) \
X("user username", SASLminc(-4), USERSW) \
X("attach", -6, ATTACHSW) \
X("noattach", -8, NOATTACHSW) \
char *cp, *dfolder = NULL, *maildir = NULL;
char buf[BUFSIZ], **ap, **argp, **arguments, *program;
char *msgs[MAXARGS], **vec;
char *cp, *dfolder = NULL, *maildir = NULL;
char buf[BUFSIZ], **ap, **argp, **arguments, *program;
char *msgs[MAXARGS], **vec;
- const char *user = NULL, *oauth_svc = NULL;
+ const char *user = NULL, *saslmech = NULL;
struct msgs *mp;
struct stat st;
int snoop = 0;
struct msgs *mp;
struct stat st;
int snoop = 0;
if (nmh_init(argv[0], 1)) { return 1; }
if (nmh_init(argv[0], 1)) { return 1; }
vec[vecp++] = --cp;
continue;
vec[vecp++] = --cp;
continue;
- case OAUTHSW:
-#ifdef OAUTH_SUPPORT
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- oauth_svc = cp;
-#else
- NMH_UNUSED (user);
- NMH_UNUSED (oauth_svc);
- adios (NULL, "not built with OAuth support");
-#endif
- continue;
-
case USERSW:
vec[vecp++] = --cp;
if (!(cp = *argp++) || *cp == '-')
case USERSW:
vec[vecp++] = --cp;
if (!(cp = *argp++) || *cp == '-')
+ case SASLMECHSW:
+ if (!(saslmech = *argp++) || *saslmech == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ continue;
+
+ case AUTHSERVICESW:
+#ifdef OAUTH_SUPPORT
+ if (!(auth_svc = *argp++) || *auth_svc == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+#else
+ adios (NULL, "not built with OAuth support");
+#endif
+ continue;
+
case ALIASW:
case FILTSW:
case WIDTHSW:
case CLIESW:
case SERVSW:
case ALIASW:
case FILTSW:
case WIDTHSW:
case CLIESW:
case SERVSW:
case SASLMXSSFSW:
case PORTSW:
case MTSSM:
case SASLMXSSFSW:
case PORTSW:
case MTSSM:
- if (oauth_svc != NULL) {
+ if (auth_svc == NULL) {
+ if (saslmech && ! strcasecmp(saslmech, "xoauth2")) {
+ adios (NULL, "must specify -authservice with -saslmech xoauth2");
+ }
+ } else {
- adios (NULL, "must specify -user with -oauth");
+ adios (NULL, "must specify -user with -saslmech xoauth2");
- vec[vecp++] = "-oauth";
- vec[vecp++] = mh_oauth_do_xoauth (user, oauth_svc,
- snoop ? stderr : NULL);
+ vec[vecp++] = "-authservice";
+ if (saslmech && ! strcasecmp(saslmech, "xoauth2")) {
+ vec[vecp++] = mh_oauth_do_xoauth (user, auth_svc, snoop ? stderr : NULL);
+ } else {
+ vec[vecp++] = auth_svc;
+ }
+#else
+ NMH_UNUSED(auth_svc);
+ NMH_UNUSED(user);
+ NMH_UNUSED(saslmech);
#endif /* OAUTH_SUPPORT */
if (altmsg == NULL || stat (altmsg, &st) == NOTOK) {
#endif /* OAUTH_SUPPORT */
if (altmsg == NULL || stat (altmsg, &st) == NOTOK) {
X("nosasl", SASLminc(-6), NOSASLSW) \
X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
X("saslmech", SASLminc(-5), SASLMECHSW) \
X("nosasl", SASLminc(-6), NOSASLSW) \
X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
X("saslmech", SASLminc(-5), SASLMECHSW) \
- X("oauth service", 5, OAUTHSW) \
+ X("authservice", SASLminc(-11), AUTHSERVICESW) \
X("user username", SASLminc(-4), USERSW) \
X("attach fieldname", 6, SNDATTACHSW) \
X("noattach", 0, SNDNOATTACHSW) \
X("user username", SASLminc(-4), USERSW) \
X("attach fieldname", 6, SNDATTACHSW) \
X("noattach", 0, SNDNOATTACHSW) \
int vecp, n = 1;
char *cp, buf[BUFSIZ], **argp, *program;
char **arguments, *savearg[MAXARGS], **vec;
int vecp, n = 1;
char *cp, buf[BUFSIZ], **argp, *program;
char **arguments, *savearg[MAXARGS], **vec;
- const char *user = NULL, *oauth_svc = NULL;
+ const char *user = NULL, *saslmech = NULL;
+ char *auth_svc = NULL;
int snoop = 0;
struct stat st;
int snoop = 0;
struct stat st;
vec[vecp++] = --cp;
continue;
vec[vecp++] = --cp;
continue;
+ case AUTHSERVICESW:
+#ifdef OAUTH_SUPPORT
+ if (!(auth_svc = *argp++) || *auth_svc == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+#else
+ NMH_UNUSED (user);
+ NMH_UNUSED (auth_svc);
+ adios (NULL, "not built with OAuth support");
+#endif
+ continue;
+
+ case SASLMECHSW:
+ saslmech = *argp;
+ /* fall thru */
case ALIASW:
case FILTSW:
case WIDTHSW:
case CLIESW:
case SERVSW:
case SASLMXSSFSW:
case ALIASW:
case FILTSW:
case WIDTHSW:
case CLIESW:
case SERVSW:
case SASLMXSSFSW:
case USERSW:
case PORTSW:
case MTSSM:
case USERSW:
case PORTSW:
case MTSSM:
- case OAUTHSW:
-#ifdef OAUTH_SUPPORT
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- oauth_svc = cp;
-#else
- NMH_UNUSED (user);
- NMH_UNUSED (oauth_svc);
- adios (NULL, "not built with OAuth support");
-#endif
- continue;
-
case SDRFSW:
case SDRMSW:
if (!(cp = *argp++) || *cp == '-') {
case SDRFSW:
case SDRMSW:
if (!(cp = *argp++) || *cp == '-') {
- if (oauth_svc != NULL) {
+ if (auth_svc == NULL) {
+ if (saslmech && ! strcasecmp(saslmech, "xoauth2")) {
+ adios (NULL, "must specify -authservice with -saslmech xoauth2");
+ }
+ } else {
- adios (NULL, "must specify -user with -oauth");
+ adios (NULL, "must specify -user with -saslmech xoauth2");
- vec[vecp++] = "-oauth";
- vec[vecp++] = mh_oauth_do_xoauth (user, oauth_svc,
- snoop ? stderr : NULL);
+ vec[vecp++] = "-authservice";
+ if (saslmech && ! strcasecmp(saslmech, "xoauth2")) {
+ vec[vecp++] = mh_oauth_do_xoauth (user, auth_svc, snoop ? stderr : NULL);
+ } else {
+ vec[vecp++] = auth_svc;
+ }
+#else
+ NMH_UNUSED(saslmech);
#endif /* OAUTH_SUPPORT */
if (altmsg == NULL || stat (altmsg, &st) == NOTOK) {
#endif /* OAUTH_SUPPORT */
if (altmsg == NULL || stat (altmsg, &st) == NOTOK) {