ash: exec: Stricter pathopt parsing
[oweals/busybox.git] / mailutils / popmaildir.c
index 69eca61649c81c589e2fcefee15c684e5bef0fb6..6927e3a58e374a7df376c1ad1fbaff7537e6b66a 100644 (file)
@@ -9,6 +9,24 @@
  *
  * Licensed under GPLv2, see file LICENSE in this source tree.
  */
+//config:config POPMAILDIR
+//config:      bool "popmaildir (10 kb)"
+//config:      default y
+//config:      help
+//config:      Simple yet powerful POP3 mail popper. Delivers content
+//config:      of remote mailboxes to local Maildir.
+//config:
+//config:config FEATURE_POPMAILDIR_DELIVERY
+//config:      bool "Allow message filters and custom delivery program"
+//config:      default y
+//config:      depends on POPMAILDIR
+//config:      help
+//config:      Allow to use a custom program to filter the content
+//config:      of the message before actual delivery (-F "prog [args...]").
+//config:      Allow to use a custom program for message actual delivery
+//config:      (-M "prog [args...]").
+
+//applet:IF_POPMAILDIR(APPLET(popmaildir, BB_DIR_USR_SBIN, BB_SUID_DROP))
 
 //kbuild:lib-$(CONFIG_POPMAILDIR) += popmaildir.o mail.o
 
@@ -27,8 +45,8 @@
 //usage:     "\n       -k              Keep retrieved messages on the server"
 //usage:     "\n       -t SEC          Network timeout"
 //usage:       IF_FEATURE_POPMAILDIR_DELIVERY(
-//usage:     "\n       -F \"PROG ARGS\"        Filter program (may be repeated)"
-//usage:     "\n       -M \"PROG ARGS\"        Delivery program"
+//usage:     "\n       -F 'PROG ARGS'  Filter program (may be repeated)"
+//usage:     "\n       -M 'PROG ARGS'  Delivery program"
 //usage:       )
 //usage:     "\n"
 //usage:     "\nFetch from plain POP3 server:"
@@ -107,9 +125,9 @@ int popmaildir_main(int argc UNUSED_PARAM, char **argv)
        INIT_G();
 
        // parse options
-       opt_complementary = "-1:dd";
-       opts = getopt32(argv,
-               "bdmVcasTkt:+" "R:+Z:L:+H:+" IF_FEATURE_POPMAILDIR_DELIVERY("M:F:"),
+       opts = getopt32(argv, "^"
+               "bdmVcasTkt:+" "R:+Z:L:+H:+" IF_FEATURE_POPMAILDIR_DELIVERY("M:F:")
+               "\0" "-1:dd",
                &timeout, NULL, NULL, NULL, &opt_nlines
                IF_FEATURE_POPMAILDIR_DELIVERY(, &delivery, &delivery) // we treat -M and -F the same
        );
@@ -204,7 +222,7 @@ int popmaildir_main(int argc UNUSED_PARAM, char **argv)
                        fp = popen(delivery, "w");
                        unsetenv("FILENAME");
                        if (!fp) {
-                               bb_perror_msg("delivery helper");
+                               bb_simple_perror_msg("delivery helper");
                                break;
                        }
                } else
@@ -247,7 +265,7 @@ int popmaildir_main(int argc UNUSED_PARAM, char **argv)
 
                // atomically move message to ./new/
                target = xstrdup(filename);
-               strncpy(target, "new", 3);
+               memcpy(target, "new", 3);
                // ... or just stop receiving on failure
                if (rename_or_warn(filename, target))
                        break;