]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
mlmmj-unsub should also setuid, and fix a bug in mlmmj-sub so -U is actually recogniz...
authormmj <none@none>
Wed, 13 Oct 2004 11:06:39 +0000 (21:06 +1000)
committermmj <none@none>
Wed, 13 Oct 2004 11:06:39 +0000 (21:06 +1000)
ChangeLog
src/mlmmj-sub.c
src/mlmmj-unsub.c

index 00ad7bbb742a65d323e6da1aeffce8271d9dad87..7faf02ec935389ac88399df1c9c959218ab0ff52 100644 (file)
--- 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
index 4f01c65c7d0aa769834848bd9e4670cf0521e4ec..4ef01ee502a57daec1f6aeb4cfc8a6c6456a1d6b 100644 (file)
@@ -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;
index 0b336b0d4722033a2aa74dec989b86f04d33343f..45ad1f7349814e123f2dd3cbbcf33563d986ce4b 100644 (file)
@@ -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/");