diff options
author | pgf <pgf@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-08-04 18:33:36 +0000 |
---|---|---|
committer | pgf <pgf@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-08-04 18:33:36 +0000 |
commit | 68d6abfa3b67065ed32c71798cceff7aeb6a7714 (patch) | |
tree | 2c05b0d96837fd76d21d58de53e843fbd08788d1 | |
parent | 3c19be904348ec54a596d4eae7c79b0157e0b0bc (diff) | |
download | busybox-w32-68d6abfa3b67065ed32c71798cceff7aeb6a7714.tar.gz busybox-w32-68d6abfa3b67065ed32c71798cceff7aeb6a7714.tar.bz2 busybox-w32-68d6abfa3b67065ed32c71798cceff7aeb6a7714.zip |
applying jim bauer's patch to eliminate modprobe's dependency
on /bin/sh. bug #8.
0000008: modprobe applet is dependent on having a shell
git-svn-id: svn://busybox.net/trunk/busybox@11043 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | AUTHORS | 3 | ||||
-rw-r--r-- | modutils/modprobe.c | 64 |
2 files changed, 54 insertions, 13 deletions
@@ -29,6 +29,9 @@ Jeff Angielski <jeff@theptrgroup.com> | |||
29 | Enrik Berkhan <Enrik.Berkhan@inka.de> | 29 | Enrik Berkhan <Enrik.Berkhan@inka.de> |
30 | setconsole | 30 | setconsole |
31 | 31 | ||
32 | Jim Bauer <jfbauer@nfr.com> | ||
33 | modprobe shell dependency | ||
34 | |||
32 | Edward Betts <edward@debian.org> | 35 | Edward Betts <edward@debian.org> |
33 | expr, hostid, logname, whoami | 36 | expr, hostid, logname, whoami |
34 | 37 | ||
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index b8268b3ab..8d739ef3c 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (c) 2002 by Robert Griebl, griebl@gmx.de | 5 | * Copyright (c) 2002 by Robert Griebl, griebl@gmx.de |
6 | * Copyright (c) 2003 by Andrew Dennison, andrew.dennison@motec.com.au | 6 | * Copyright (c) 2003 by Andrew Dennison, andrew.dennison@motec.com.au |
7 | * Copyright (c) 2005 by Jim Bauer, jfbauer@nfr.com | ||
7 | * | 8 | * |
8 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -22,6 +23,8 @@ | |||
22 | */ | 23 | */ |
23 | 24 | ||
24 | #include <sys/utsname.h> | 25 | #include <sys/utsname.h> |
26 | #include <sys/types.h> | ||
27 | #include <sys/wait.h> | ||
25 | #include <getopt.h> | 28 | #include <getopt.h> |
26 | #include <stdlib.h> | 29 | #include <stdlib.h> |
27 | #include <unistd.h> | 30 | #include <unistd.h> |
@@ -393,30 +396,65 @@ static int already_loaded (const char *name) | |||
393 | 396 | ||
394 | static int mod_process ( struct mod_list_t *list, int do_insert ) | 397 | static int mod_process ( struct mod_list_t *list, int do_insert ) |
395 | { | 398 | { |
396 | char lcmd [4096]; | ||
397 | int rc = 0; | 399 | int rc = 0; |
400 | char *argv[10]; | ||
401 | int argc; | ||
398 | 402 | ||
399 | while ( list ) { | 403 | while ( list ) { |
400 | *lcmd = '\0'; | 404 | argc = 0; |
401 | if ( do_insert ) { | 405 | if ( do_insert ) { |
402 | if (already_loaded (list->m_name) != 1) | 406 | if (already_loaded (list->m_name) != 1) { |
403 | snprintf ( lcmd, sizeof( lcmd ) - 1, "insmod %s %s %s %s %s", | 407 | argv[argc++] = "insmod"; |
404 | do_syslog ? "-s" : "", autoclean ? "-k" : "", | 408 | if (do_syslog) |
405 | quiet ? "-q" : "", list-> m_path, list-> m_options ? | 409 | argv[argc++] = "-s"; |
406 | list-> m_options : "" ); | 410 | if (autoclean) |
411 | argv[argc++] = "-k"; | ||
412 | if (quiet) | ||
413 | argv[argc++] = "-q"; | ||
414 | argv[argc++] = list-> m_path; | ||
415 | if (list-> m_options) | ||
416 | argv[argc++] = list-> m_options; | ||
417 | } | ||
407 | } else { | 418 | } else { |
408 | /* modutils uses short name for removal */ | 419 | /* modutils uses short name for removal */ |
409 | if (already_loaded (list->m_name) != 0) | 420 | if (already_loaded (list->m_name) != 0) { |
410 | snprintf ( lcmd, sizeof( lcmd ) - 1, "rmmod %s %s", | 421 | argv[argc++] = "rmmod"; |
411 | do_syslog ? "-s" : "", list-> m_name ); | 422 | if (do_syslog) |
423 | argv[argc++] = "-s"; | ||
424 | argv[argc++] = list->m_name; | ||
425 | } | ||
412 | } | 426 | } |
427 | argv[argc] = NULL; | ||
413 | 428 | ||
414 | if (*lcmd) { | 429 | if (argc) { |
415 | if (verbose) { | 430 | if (verbose) { |
416 | printf("%s\n", lcmd); | 431 | int i; |
432 | for (i=0; i<argc; i++) | ||
433 | printf("%s ", argv[i]); | ||
434 | printf("\n"); | ||
417 | } | 435 | } |
418 | if (!show_only) { | 436 | if (!show_only) { |
419 | int rc2 = system(lcmd); | 437 | int rc2 = 0; |
438 | int status; | ||
439 | switch (fork()) { | ||
440 | case -1: | ||
441 | rc2 = 1; | ||
442 | break; | ||
443 | case 0: //child | ||
444 | execvp(argv[0], argv); | ||
445 | bb_perror_msg_and_die("exec of %s", argv[0]); | ||
446 | /* NOTREACHED */ | ||
447 | default: | ||
448 | if (wait(&status) == -1) { | ||
449 | rc2 = 1; | ||
450 | break; | ||
451 | } | ||
452 | if (WIFEXITED(status)) | ||
453 | rc2 = WEXITSTATUS(status); | ||
454 | if (WIFSIGNALED(status)) | ||
455 | rc2 = WTERMSIG(status); | ||
456 | break; | ||
457 | } | ||
420 | if (do_insert) { | 458 | if (do_insert) { |
421 | rc = rc2; /* only last module matters */ | 459 | rc = rc2; /* only last module matters */ |
422 | } | 460 | } |