tftp: do not risk invoking Sorcerer's Apprentice syndrome
[oweals/busybox.git] / modutils / modprobe-small.c
index 96a0a08ed1fa3893723f5c94b36a7cfc39c5a20c..3fd7bf5adaec76df5b1f1a9b57a1c4045e8a067e 100644 (file)
@@ -600,18 +600,22 @@ static void process_module(char *name, const char *cmdline_options)
        free(deps);
 
        /* modprobe -> load it */
-       if (!is_rmmod && (options && !strstr(options, "blacklist"))) {
-               errno = 0;
-               if (load_module(info->pathname, options) != 0) {
-                       if (EEXIST != errno) {
-                               bb_error_msg("'%s': %s",
+       if (!is_rmmod) {
+               if (!options || strstr(options, "blacklist") == NULL) {
+                       errno = 0;
+                       if (load_module(info->pathname, options) != 0) {
+                               if (EEXIST != errno) {
+                                       bb_error_msg("'%s': %s",
                                                info->pathname,
                                                moderror(errno));
-                       } else {
-                               dbg1_error_msg("'%s': %s",
+                               } else {
+                                       dbg1_error_msg("'%s': %s",
                                                info->pathname,
                                                moderror(errno));
+                               }
                        }
+               } else {
+                       dbg1_error_msg("'%s': blacklisted", info->pathname);
                }
        }
  ret:
@@ -675,7 +679,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
 {
        struct utsname uts;
        char applet0 = applet_name[0];
-       USE_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(char *options;)
+       IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(char *options;)
 
        /* are we lsmod? -> just dump /proc/modules */
        if ('l' == applet0) {
@@ -769,10 +773,10 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
                len = MAXINT(ssize_t);
                map = xmalloc_xopen_read_close(*argv, &len);
                if (init_module(map, len,
-                       USE_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(options ? options : "")
-                       SKIP_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE("")
+                       IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(options ? options : "")
+                       IF_NOT_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE("")
                                ) != 0)
-                       bb_error_msg_and_die("cannot insert '%s': %s",
+                       bb_error_msg_and_die("can't insert '%s': %s",
                                        *argv, moderror(errno));
                return 0;
        }
@@ -787,7 +791,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
        } while (*argv);
 
        if (ENABLE_FEATURE_CLEAN_UP) {
-               USE_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(free(options);)
+               IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(free(options);)
        }
        return EXIT_SUCCESS;
 }