diff options
author | D. Can Celasun | 2023-10-21 11:18:11 +0100 |
---|---|---|
committer | D. Can Celasun | 2023-10-21 11:18:11 +0100 |
commit | db702d2da0dd0ba438f8b7fd83db91177875e51b (patch) | |
tree | 96ba7714e210ae2699d8fc3993880e4f0f69703d /xoauth2.patch | |
parent | fee40289ade71028d6816b5dc80a3b418b110e04 (diff) | |
download | aur-ssmtp.tar.gz |
[ssmtp] Add xoauth2 patch
Diffstat (limited to 'xoauth2.patch')
-rw-r--r-- | xoauth2.patch | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/xoauth2.patch b/xoauth2.patch new file mode 100644 index 000000000000..bfc0782b2fdf --- /dev/null +++ b/xoauth2.patch @@ -0,0 +1,43 @@ +Adds XOAUTH2 functionality for safer authentication. +Still needs a separate script/service to obtain and refresh OAUTH2 +access token for most mail providers. + +Patch by Moriyoshi Koizumi <mozo@mozo.jp> +Modified by Kangjing Huang <huangkangjing@gmail.com> + + +diff --color -u ssmtp-2.64.orig/ssmtp.c ssmtp-2.64/ssmtp.c +--- ssmtp-2.64.orig/ssmtp.c 2023-10-21 00:39:18.895976193 -0400 ++++ ssmtp-2.64/ssmtp.c 2023-10-21 00:40:59.993918590 -0400 +@@ -1604,6 +1604,7 @@ + } + else { + #endif ++ if(auth_method && strcasecmp(auth_method, "login") == 0) { + memset(buf, 0, bufsize); + to64frombits(buf, auth_user, strlen(auth_user)); + if (use_oldauth) { +@@ -1628,6 +1629,22 @@ + memset(buf, 0, bufsize); + + to64frombits(buf, auth_pass, strlen(auth_pass)); ++ } else if(auth_method && strcasecmp(auth_method, "xoauth2") == 0) { ++ int authbuflen; ++ char *authbuf = malloc(5 + strlen(auth_user) + 1 + 5 + 6 + 1 + strlen(auth_pass) + 2 + 1); ++ if(!authbuf) { ++ die("Out of memory"); ++ } ++ outbytes += smtp_write(sock, "AUTH XOAUTH2"); ++ alarm((unsigned) MEDWAIT); ++ if(smtp_read(sock, buf) != 3) { ++ die("Server didn't accept AUTH XOAUTH2"); ++ } ++ memset(buf, 0, bufsize); ++ authbuflen = sprintf(authbuf, "user=%s\1auth=Bearer %s\1\1", auth_user, auth_pass); ++ to64frombits(buf, (unsigned char*)authbuf, authbuflen); ++ free(authbuf); ++ } + #ifdef MD5AUTH + } + #endif + |