-authservice service, because OAUTH2 is a SASL mechanism.
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 \
-.TH INC %manext1% "November 25, 2014" "%nmhversion%"
+.TH INC %manext1% "March 23, 2016" "%nmhversion%"
.\"
.\" %nmhwarning%
.\"
.RB [ \-sasl " | " \-nosasl ]
.RB [ \-saslmech
.IR mechanism ]
-.RB [ \-oauth
+.RB [ \-authservice
.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
-.B \-oauth
+.B \-saslmech xoauth2
is used, the HTTP transaction is also shown.
.PP
If
If
.B nmh
has been compiled with OAuth support, the
-.B \-oauth
+.B \-saslmech xoauth2
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
.B mhlogin
-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
.\"
.\" %nmhwarning%
.\"
-.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
-.RB \-oauth
-.IR service
+.RB [ \-saslmech
+.IR mechanism ]
+.RB [ \-authservice
+.IR service ]
.RB [ \-snoop ]
.RB [ \-version ]
.RB [ \-help ]
.B Mhlogin
currently only supports OAuth for Gmail. Run
.B mhlogin
-.B -oauth
+.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
prompt. Be sure to use the same account with the
.B -user
switch to
-.B send
+.BR send .
.PP
The
.B \-snoop
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
-.TH MSGCHK %manext1% "November 25, 2014" "%nmhversion%"
+.TH MSGCHK %manext1% "March 23, 2016" "%nmhversion%"
.\"
.\" %nmhwarning%
.\"
.RB [ \-sasl ]
.RB [ \-saslmech
.IR mechanism ]
-.RB [ \-oauth
+.RB [ \-authservice
.IR service ]
.RB [ \-snoop ]
.RI [ users
which will
allow you to watch the POP transaction take place between you and the
POP server. If
-.B \-oauth
+.B \-saslmech xoauth2
is used, the HTTP transaction is also shown.
.PP
If
If
.B nmh
has been compiled with OAuth support, the
-.B \-oauth
+.B \-saslmech xoauth2
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
.B mhlogin
-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
.\"
.\" %nmhwarning%
.\"
-.TH SEND %manext1% "November 25, 2014" "%nmhversion%"
+.TH SEND %manext1% "March 23, 2016" "%nmhversion%"
.SH NAME
send \- send a message
.SH SYNOPSIS
.RB [ \-msgid " | " \-nomsgid ]
.RB [ \-messageid
.IR localname " | " random ]
-.RB [ \-oauth
-.IR service ]
.RB [ \-push " | " \-nopush ]
.RB [ \-split
.IR seconds ]
.IR ssf ]
.RB [ \-saslmech
.IR mechanism ]
+.RB [ \-authservice
+.IR service ]
.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
-.B \-oauth
+.B \-saslmech xoauth2
is used, the HTTP transaction is also shown.
.PP
If
If
.B nmh
has been compiled with OAuth support, the
-.B \-oauth
+.B \-saslmech xoauth2
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
.B mhlogin
-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
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");
}
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) {
- 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));
static boolean
update_svc(struct service_info *svc, const char *svc_name, mh_oauth_ctx *ctx)
{
-#define update(name) \
+#define update(name) \
update_svc_field(&svc->name, #name, svc_name); \
if (svc->name == NULL) { \
set_err_details(ctx, MH_OAUTH_BAD_PROFILE, #name " is missing"); \
}
test_inc() {
- 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_inc_success() {
}
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_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
EOF
start_fakesmtp
-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 '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_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_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'
expire: 1414303986
EOF
-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'
access: test-access
EOF
-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'
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).
}
EOF
-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'
EOF
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
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
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
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
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
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("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,
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 */
- const char *oauth_svc = NULL;
int nmsgs, nbytes;
char *MAILHOST_env_variable;
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]);
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]);
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) {
- adios (NULL, "must specify -user with -oauth");
+ adios (NULL, "must specify -user with -saslmech xoauth2");
}
creds.user = user;
}
* 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 */
#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) \
const char *url;
if (svc == NULL) {
- adios(NULL, "only support -oauth gmail");
+ adios(NULL, "missing -authservice switch");
}
if (!mh_oauth_new(&ctx, svc)) {
main(int argc, char **argv)
{
char *cp, **argp, **arguments;
- char *svc = NULL;
+ char *saslmech = NULL, *svc = NULL;
int snoop = 0;
if (nmh_init(argv[0], 1)) { return 1; }
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);
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]);
continue;
case SNOOPSW:
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,
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;
- const char *oauth_svc = NULL;
if (nmh_init(argv[0], 1)) { return 1; }
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]);
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]);
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,
- snoop, sasl, saslmech, oauth_svc);
+ snoop, sasl, saslmech, auth_svc);
}
} 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,
- const char *oauth_svc)
+ const char *auth_svc)
{
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) {
- 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,
- 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);
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) \
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]);
- xoauth_client_res = cp;
+#else
+ adios (NULL, "not built with OAuth support");
+#endif
continue;
case USERSW:
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) \
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;
+ char *auth_svc = NULL;
if (nmh_init(argv[0], 1)) { return 1; }
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 == '-')
user = cp;
continue;
+ 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 SASLMECHSW:
case SASLMXSSFSW:
case PORTSW:
case MTSSM:
}
#ifdef OAUTH_SUPPORT
- if (oauth_svc != NULL) {
+ if (auth_svc == NULL) {
+ if (saslmech && ! strcasecmp(saslmech, "xoauth2")) {
+ adios (NULL, "must specify -authservice with -saslmech xoauth2");
+ }
+ } else {
if (user == NULL) {
- 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) {
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) \
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;
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 SASLMECHSW:
case USERSW:
case PORTSW:
case MTSSM:
user = 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 SDRFSW:
case SDRMSW:
if (!(cp = *argp++) || *cp == '-') {
}
#ifdef OAUTH_SUPPORT
- if (oauth_svc != NULL) {
+ if (auth_svc == NULL) {
+ if (saslmech && ! strcasecmp(saslmech, "xoauth2")) {
+ adios (NULL, "must specify -authservice with -saslmech xoauth2");
+ }
+ } else {
if (user == NULL) {
- 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) {