mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 00:55:11 +00:00
sendmail: another update from the maintainer
function old new delta sendgetmail_main 1894 1937 +43 crond_main 1416 1423 +7 packed_usage 24540 24470 -70 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 50/-70) Total: -20 bytes
This commit is contained in:
parent
78ff8197cc
commit
6ea75e2f5d
@ -1088,18 +1088,16 @@
|
|||||||
"\n -S SECTORS" \
|
"\n -S SECTORS" \
|
||||||
|
|
||||||
#define fetchmail_trivial_usage \
|
#define fetchmail_trivial_usage \
|
||||||
"[-w timeout] [-H server[:port]] [-U user] -P password [-X] [-t] [-z] maildir [prog]"
|
"[-w timeout] [-H [user:pass@]server[:port]] [-S] [-t] [-z] maildir [prog]"
|
||||||
#define fetchmail_full_usage "\n\n" \
|
#define fetchmail_full_usage "\n\n" \
|
||||||
"Fetch content of remote mailbox to local Maildir.\n" \
|
"Fetch content of remote mailbox to local maildir\n" \
|
||||||
"\nOptions:" \
|
"\nOptions:" \
|
||||||
"\n -w timeout Set timeout on network operations" \
|
"\n -w timeout Network timeout" \
|
||||||
"\n -H server[:port] Set server" \
|
"\n -H [user:pass@]server[:port] Server" \
|
||||||
"\n -U username Authenticate with specified username/password" \
|
"\n -S Use openssl connection helper for secure servers" \
|
||||||
"\n -P password" \
|
|
||||||
"\n -X Use openssl connection helper for secured servers" \
|
|
||||||
"\n -t Get only headers" \
|
"\n -t Get only headers" \
|
||||||
"\n -z Delete messages on server" \
|
"\n -z Delete messages on server" \
|
||||||
"\n prog Run prog <message_file> on message delivery" \
|
"\n prog Run 'prog <message_file>' on message delivery" \
|
||||||
|
|
||||||
#define findfs_trivial_usage \
|
#define findfs_trivial_usage \
|
||||||
"LABEL=label or UUID=uuid"
|
"LABEL=label or UUID=uuid"
|
||||||
@ -3123,7 +3121,7 @@
|
|||||||
" 742 andersen andersen S [bash]\n" \
|
" 742 andersen andersen S [bash]\n" \
|
||||||
" 743 andersen andersen S -bash\n" \
|
" 743 andersen andersen S -bash\n" \
|
||||||
" 745 root root S [getty]\n" \
|
" 745 root root S [getty]\n" \
|
||||||
" 2990 andersen andersen R ps\n"
|
" 2990 andersen andersen R ps\n" \
|
||||||
|
|
||||||
#define pscan_trivial_usage \
|
#define pscan_trivial_usage \
|
||||||
"[-cb] [-p MIN_PORT] [-P MAX_PORT] [-t TIMEOUT] [-T MIN_RTT] HOST"
|
"[-cb] [-p MIN_PORT] [-P MAX_PORT] [-t TIMEOUT] [-T MIN_RTT] HOST"
|
||||||
@ -3426,33 +3424,31 @@
|
|||||||
#define selinuxenabled_full_usage ""
|
#define selinuxenabled_full_usage ""
|
||||||
|
|
||||||
#define sendmail_trivial_usage \
|
#define sendmail_trivial_usage \
|
||||||
"[-w timeout] [-H server[:port]] [-U user] [-P password] [-X]\n" \
|
"[-w timeout] [-H [user:pass@]server[:port]] [-S]\n" \
|
||||||
"[-c charset] [-n] [-i] [-s subject] [-a attach]... [-t] [-f sender] [rcpt]..."
|
"[-c charset] [-N type] [-i] [-s subject] [-a attach]... [-t] [-f sender] [rcpt]..."
|
||||||
#define sendmail_full_usage "\n\n" \
|
#define sendmail_full_usage "\n\n" \
|
||||||
"Send an email.\n" \
|
"Send an email\n" \
|
||||||
"\nOptions:" \
|
"\nOptions:" \
|
||||||
"\n -w timeout Set timeout on network operations" \
|
"\n -w timeout Network timeout" \
|
||||||
"\n -H server[:port] Set server" \
|
"\n -H [user:pass@]server[:port] Server" \
|
||||||
"\n -U username Authenticate with specified username/password" \
|
"\n -S Use openssl connection helper for secure servers" \
|
||||||
"\n -P password" \
|
"\n -c charset Assume charset for body and subject (utf-8)" \
|
||||||
"\n -X Use openssl connection helper for secured servers" \
|
"\n -N type Request delivery notification. Type is ignored" \
|
||||||
"\n -c charset Assumed charset for body and subject [utf-8]" \
|
|
||||||
"\n -n Request delivery notification to sender" \
|
|
||||||
"\n -i Ignore single dots in mail body. Implied" \
|
"\n -i Ignore single dots in mail body. Implied" \
|
||||||
"\n -s subject Subject" \
|
"\n -s subject Subject" \
|
||||||
"\n -a file File to attach. May be multiple" \
|
"\n -a file File to attach. May be multiple" \
|
||||||
"\n -t Read recipients and subject from body" \
|
"\n -t Read recipients and subject from body" \
|
||||||
"\n -f Set sender address" \
|
"\n -f sender Sender" \
|
||||||
|
|
||||||
#define seq_trivial_usage \
|
#define seq_trivial_usage \
|
||||||
"[first [increment]] last"
|
"[first [increment]] last"
|
||||||
#define seq_full_usage "\n\n" \
|
#define seq_full_usage "\n\n" \
|
||||||
"Print numbers from FIRST to LAST, in steps of INCREMENT.\n" \
|
"Print numbers from FIRST to LAST, in steps of INCREMENT.\n" \
|
||||||
"FIRST, INCREMENT default to 1" \
|
"FIRST, INCREMENT default to 1\n" \
|
||||||
"\n\nArguments:\n" \
|
"\nArguments:" \
|
||||||
" LAST\n" \
|
"\n LAST" \
|
||||||
" FIRST LAST\n" \
|
"\n FIRST LAST" \
|
||||||
" FIRST INCREMENT LAST"
|
"\n FIRST INCREMENT LAST" \
|
||||||
|
|
||||||
#define sestatus_trivial_usage \
|
#define sestatus_trivial_usage \
|
||||||
"[-vb]"
|
"[-vb]"
|
||||||
@ -3764,7 +3760,7 @@
|
|||||||
" %S Fundamental block size (for block counts)\n" \
|
" %S Fundamental block size (for block counts)\n" \
|
||||||
" %t Type in hex\n" \
|
" %t Type in hex\n" \
|
||||||
" %T Type in human readable form" \
|
" %T Type in human readable form" \
|
||||||
)
|
) \
|
||||||
|
|
||||||
#define strings_trivial_usage \
|
#define strings_trivial_usage \
|
||||||
"[-afo] [-n length] [file...]"
|
"[-afo] [-n length] [file...]"
|
||||||
@ -3930,10 +3926,10 @@
|
|||||||
"\n -q Never output headers giving file names" \
|
"\n -q Never output headers giving file names" \
|
||||||
"\n -s SEC Wait SEC seconds between reads with -f" \
|
"\n -s SEC Wait SEC seconds between reads with -f" \
|
||||||
"\n -v Always output headers giving file names" \
|
"\n -v Always output headers giving file names" \
|
||||||
"\n\n" \
|
"\n" \
|
||||||
"If the first character of N (bytes or lines) is a '+', output begins with\n" \
|
"\nIf the first character of N (bytes or lines) is a '+', output begins with" \
|
||||||
"the Nth item from the start of each file, otherwise, print the last N items\n" \
|
"\nthe Nth item from the start of each file, otherwise, print the last N items" \
|
||||||
"in the file. N bytes may be suffixed by k (x1024), b (x512), or m (1024^2)." ) \
|
"\nin the file. N bytes may be suffixed by k (x1024), b (x512), or m (1024^2)." ) \
|
||||||
|
|
||||||
#define tail_example_usage \
|
#define tail_example_usage \
|
||||||
"$ tail -n 1 /etc/resolv.conf\n" \
|
"$ tail -n 1 /etc/resolv.conf\n" \
|
||||||
|
@ -33,12 +33,8 @@
|
|||||||
#define SENDMAIL "sendmail"
|
#define SENDMAIL "sendmail"
|
||||||
#endif
|
#endif
|
||||||
#ifndef SENDMAIL_ARGS
|
#ifndef SENDMAIL_ARGS
|
||||||
# if ENABLE_SENDMAIL
|
|
||||||
# define SENDMAIL_ARGS "localhost", line->cl_MailTo
|
|
||||||
# else
|
|
||||||
#define SENDMAIL_ARGS "-ti", "oem"
|
#define SENDMAIL_ARGS "-ti", "oem"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#ifndef CRONUPDATE
|
#ifndef CRONUPDATE
|
||||||
#define CRONUPDATE "cron.update"
|
#define CRONUPDATE "cron.update"
|
||||||
#endif
|
#endif
|
||||||
|
@ -262,32 +262,49 @@ static void pop3_message(const char *filename)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static char *parse_url(char *url, char **user, char **pass)
|
||||||
|
{
|
||||||
|
// parse [user[:pass]@]host
|
||||||
|
// return host
|
||||||
|
char *s = strchr(url, '@');
|
||||||
|
*user = *pass = NULL;
|
||||||
|
if (s) {
|
||||||
|
*s++ = '\0';
|
||||||
|
*user = url;
|
||||||
|
url = s;
|
||||||
|
s = strchr(*user, ':');
|
||||||
|
if (s) {
|
||||||
|
*s++ = '\0';
|
||||||
|
*pass = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
int sendgetmail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int sendgetmail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int sendgetmail_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
int sendgetmail_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||||
{
|
{
|
||||||
llist_t *opt_recipients = NULL;
|
llist_t *opt_recipients = NULL;
|
||||||
llist_t *opt_attachments = NULL;
|
llist_t *opt_attachments = NULL;
|
||||||
char *opt_from;
|
char *opt_from;
|
||||||
const char *opt_user;
|
char *opt_user;
|
||||||
const char *opt_pass;
|
char *opt_pass;
|
||||||
enum {
|
enum {
|
||||||
OPT_w = 1 << 0, // network timeout
|
OPT_w = 1 << 0, // network timeout
|
||||||
OPT_H = 1 << 1, // server[:port]
|
OPT_H = 1 << 1, // [user:password@]server[:port]
|
||||||
OPT_U = 1 << 2, // user
|
OPT_S = 1 << 2, // connect using openssl s_client helper
|
||||||
OPT_P = 1 << 3, // password
|
|
||||||
OPT_X = 1 << 4, // connect using openssl s_client helper
|
|
||||||
|
|
||||||
OPTS_t = 1 << 5, // sendmail: read addresses from body
|
OPTS_t = 1 << 3, // sendmail: read addresses from body
|
||||||
OPTF_t = 1 << 5, // fetchmail: use "TOP" not "RETR"
|
OPTF_t = 1 << 3, // fetchmail: use "TOP" not "RETR"
|
||||||
|
|
||||||
OPTS_s = 1 << 6, // sendmail: subject
|
OPTS_s = 1 << 4, // sendmail: subject
|
||||||
OPTF_z = 1 << 6, // fetchmail: delete from server
|
OPTF_z = 1 << 4, // fetchmail: delete from server
|
||||||
|
|
||||||
OPTS_c = 1 << 7, // sendmail: assumed charset
|
OPTS_c = 1 << 5, // sendmail: assumed charset
|
||||||
OPTS_a = 1 << 8, // sendmail: attachment(s)
|
OPTS_a = 1 << 6, // sendmail: attachment(s)
|
||||||
OPTS_i = 1 << 9, // sendmail: ignore lone dots in message body (implied)
|
OPTS_i = 1 << 7, // sendmail: ignore lone dots in message body (implied)
|
||||||
|
|
||||||
OPTS_n = 1 << 10, // sendmail: request notification
|
OPTS_N = 1 << 8, // sendmail: request notification
|
||||||
};
|
};
|
||||||
const char *options;
|
const char *options;
|
||||||
int opts;
|
int opts;
|
||||||
@ -303,18 +320,18 @@ int sendgetmail_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
// save initial stdin (body or attachements can be piped!)
|
// save initial stdin (body or attachements can be piped!)
|
||||||
xdup2(STDIN_FILENO, INITIAL_STDIN_FILENO);
|
xdup2(STDIN_FILENO, INITIAL_STDIN_FILENO);
|
||||||
opt_complementary = "w+:a::";
|
opt_complementary = "w+:a::";
|
||||||
options = "w:H:U:P:Xt" "s:c:a:inf:";
|
options = "w:H:St" "s:c:a:iN:f:";
|
||||||
// body is pseudo attachment read from stdin
|
// body is pseudo attachment read from stdin
|
||||||
llist_add_to_end(&opt_attachments, (char *)"-");
|
llist_add_to_end(&opt_attachments, (char *)"-");
|
||||||
} else {
|
} else {
|
||||||
// FETCHMAIL
|
// FETCHMAIL
|
||||||
opt_after_connect = NULL;
|
opt_after_connect = NULL;
|
||||||
opt_complementary = "-1:w+:P";
|
opt_complementary = "-1:w+";
|
||||||
options = "w:H:U:P:Xt" "z";
|
options = "w:H:St" "z";
|
||||||
}
|
}
|
||||||
opts = getopt32(argv, options,
|
opts = getopt32(argv, options,
|
||||||
&timeout, &opt_connect, &opt_user, &opt_pass,
|
&timeout /* -w */, &opt_connect /* -H */,
|
||||||
&opt_subject, &opt_charset, &opt_attachments, &opt_from
|
&opt_subject, &opt_charset, &opt_attachments, NULL, &opt_from
|
||||||
);
|
);
|
||||||
//argc -= optind;
|
//argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
@ -326,8 +343,14 @@ int sendgetmail_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
if (!opt_connect)
|
if (!opt_connect)
|
||||||
opt_connect = "127.0.0.1";
|
opt_connect = "127.0.0.1";
|
||||||
}
|
}
|
||||||
|
// fetch username and password, if any
|
||||||
|
// NB: parse_url modifies opt_connect[] ONLY if '@' is there.
|
||||||
|
// Thus "127.0.0.1" won't be modified, an is ok that it is RO.
|
||||||
|
opt_connect = parse_url((char*)opt_connect, &opt_user, &opt_pass);
|
||||||
|
// bb_error_msg("H[%s] U[%s] P[%s]", opt_connect, opt_user, opt_pass);
|
||||||
|
|
||||||
// SSL ordered? ->
|
// SSL ordered? ->
|
||||||
if (opts & OPT_X) {
|
if (opts & OPT_S) {
|
||||||
// ... use openssl helper
|
// ... use openssl helper
|
||||||
launch_helper(xargs);
|
launch_helper(xargs);
|
||||||
// no SSL ordered? ->
|
// no SSL ordered? ->
|
||||||
@ -340,10 +363,8 @@ int sendgetmail_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
xdup2(STDIN_FILENO, STDOUT_FILENO);
|
xdup2(STDIN_FILENO, STDOUT_FILENO);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_FETCHMAIL
|
|
||||||
// are we sendmail?
|
// are we sendmail?
|
||||||
if (opt_after_connect)
|
if (!ENABLE_FETCHMAIL || opt_after_connect)
|
||||||
#endif
|
|
||||||
/***************************************************
|
/***************************************************
|
||||||
* SENDMAIL
|
* SENDMAIL
|
||||||
***************************************************/
|
***************************************************/
|
||||||
@ -364,7 +385,7 @@ int sendgetmail_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we didn't use SSL helper? ->
|
// we didn't use SSL helper? ->
|
||||||
if (!(opts & OPT_X)) {
|
if (!(opts & OPT_S)) {
|
||||||
// ... wait for initial server OK
|
// ... wait for initial server OK
|
||||||
smtp_check(NULL, 220);
|
smtp_check(NULL, 220);
|
||||||
}
|
}
|
||||||
@ -402,14 +423,13 @@ int sendgetmail_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
// set sender
|
// set sender
|
||||||
// NOTE: if password has not been specified
|
// NOTE: if password has not been specified
|
||||||
// then no authentication is possible
|
// then no authentication is possible
|
||||||
code = (opts & OPT_P) ? -1 : 250;
|
code = (opt_pass) ? -1 : 250;
|
||||||
// first try softly without authentication
|
// first try softly without authentication
|
||||||
while (250 != smtp_checkp("MAIL FROM:<%s>", opt_from, code)) {
|
while (250 != smtp_checkp("MAIL FROM:<%s>", opt_from, code)) {
|
||||||
// MAIL FROM failed -> authentication needed
|
// MAIL FROM failed -> authentication needed
|
||||||
// have we got username?
|
// have we got username?
|
||||||
if (!(opts & OPT_U)) {
|
if (!opt_user) {
|
||||||
// no! fetch it from "from" option
|
// no! fetch it from "from" option
|
||||||
//opts |= OPT_U;
|
|
||||||
opt_user = xstrdup(opt_from);
|
opt_user = xstrdup(opt_from);
|
||||||
*strchrnul(opt_user, '@') = '\0';
|
*strchrnul(opt_user, '@') = '\0';
|
||||||
}
|
}
|
||||||
@ -450,7 +470,7 @@ int sendgetmail_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// put notification
|
// put notification
|
||||||
if (opts & OPTS_n)
|
if (opts & OPTS_N)
|
||||||
printf("Disposition-Notification-To: %s\r\n", opt_from);
|
printf("Disposition-Notification-To: %s\r\n", opt_from);
|
||||||
|
|
||||||
// make a random string -- it will delimit message parts
|
// make a random string -- it will delimit message parts
|
||||||
@ -515,7 +535,6 @@ int sendgetmail_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
* FETCHMAIL
|
* FETCHMAIL
|
||||||
***************************************************/
|
***************************************************/
|
||||||
else {
|
else {
|
||||||
|
|
||||||
char *buf;
|
char *buf;
|
||||||
unsigned nmsg;
|
unsigned nmsg;
|
||||||
char *hostname;
|
char *hostname;
|
||||||
@ -533,11 +552,14 @@ int sendgetmail_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
*fargs = *argv;
|
*fargs = *argv;
|
||||||
|
|
||||||
// authenticate
|
// authenticate
|
||||||
if (!(opts & OPT_U)) {
|
if (!opt_user) {
|
||||||
//opts |= OPT_U;
|
|
||||||
// N.B. IMHO getenv("USER") can be way easily spoofed!
|
// N.B. IMHO getenv("USER") can be way easily spoofed!
|
||||||
opt_user = bb_getpwuid(NULL, -1, getuid());
|
opt_user = bb_getpwuid(NULL, -1, getuid());
|
||||||
}
|
}
|
||||||
|
// password is mandatory
|
||||||
|
if (!opt_pass) {
|
||||||
|
bb_error_msg_and_die("no password");
|
||||||
|
}
|
||||||
|
|
||||||
// get server greeting
|
// get server greeting
|
||||||
pop3_checkr(NULL, NULL, &buf);
|
pop3_checkr(NULL, NULL, &buf);
|
||||||
|
Loading…
Reference in New Issue
Block a user