From: mmj Date: Wed, 13 Oct 2004 11:06:39 +0000 (+1000) Subject: mlmmj-unsub should also setuid, and fix a bug in mlmmj-sub so -U is actually recogniz... X-Git-Tag: RELEASE_1_1_0~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71ea2b41229a548cff9f799c4cc212d35c544f92;p=thirdparty%2Fmlmmj.git mlmmj-unsub should also setuid, and fix a bug in mlmmj-sub so -U is actually recognized as an option --- diff --git a/ChangeLog b/ChangeLog index 00ad7bbb..7faf02ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + o mlmmj-unsub should also change user id to the listdir owner o Add support for not archiving the list by touching listdir/control/noarchive o Add 'nomail' version of lists. Subscribers to the nomail version are subscribed, but does not get any mail diff --git a/src/mlmmj-sub.c b/src/mlmmj-sub.c index 4f01c65c..4ef01ee5 100644 --- a/src/mlmmj-sub.c +++ b/src/mlmmj-sub.c @@ -408,7 +408,7 @@ int main(int argc, char **argv) mlmmjsend = concatstr(2, bindir, "/mlmmj-send"); myfree(bindir); - while ((opt = getopt(argc, argv, "hcCdnVL:a:")) != -1) { + while ((opt = getopt(argc, argv, "hcCdnVUL:a:")) != -1) { switch(opt) { case 'a': address = optarg; diff --git a/src/mlmmj-unsub.c b/src/mlmmj-unsub.c index 0b336b0d..45ad1f73 100644 --- a/src/mlmmj-unsub.c +++ b/src/mlmmj-unsub.c @@ -416,6 +416,7 @@ static void print_help(const char *prg) " -h: This help\n" " -L: Full path to list directory\n" " -n: Subscribe to no mail version of list\n" + " -U: Don't switch to the user id of the listdir owner\n" " -V: Print version\n" "When no options are specified, unsubscription silently " "happens\n", prg); @@ -426,6 +427,7 @@ int main(int argc, char **argv) { int subread, subwrite, rlock, wlock, opt, unsubres, status, nomail = 0; int confirmunsub = 0, unsubconfirm = 0, notifysub = 0, digest = 0; + int changeuid = 1; char *listaddr, *listdir = NULL, *address = NULL, *subreadname = NULL; char *subwritename, *mlmmjsend, *bindir, *subdir; char *subddirname; @@ -443,7 +445,7 @@ int main(int argc, char **argv) mlmmjsend = concatstr(2, bindir, "/mlmmj-send"); myfree(bindir); - while ((opt = getopt(argc, argv, "hcCdnVL:a:")) != -1) { + while ((opt = getopt(argc, argv, "hcCdnVUL:a:")) != -1) { switch(opt) { case 'L': listdir = optarg; @@ -466,6 +468,9 @@ int main(int argc, char **argv) case 'h': print_help(argv[0]); break; + case 'U': + changeuid = 0; + break; case 'V': print_version(argv[0]); exit(0); @@ -497,6 +502,19 @@ int main(int argc, char **argv) /* get the list address */ listaddr = getlistaddr(listdir); + if(changeuid) { + uid = getuid(); + if(!uid && stat(listdir, &st) == 0) { + printf("Changing to uid %d, owner of %s.\n", + (int)st.st_uid, listdir); + if(setuid(st.st_uid) < 0) { + perror("setuid"); + fprintf(stderr, "Continuing as uid %d\n", + (int)uid); + } + } + } + switch(typesub) { case SUB_NORMAL: subdir = mystrdup("/subscribers.d/");