mirror of
https://github.com/sheumann/hush.git
synced 2025-01-26 14:33:00 +00:00
applying jim bauer's patch to eliminate modprobe's dependency
on /bin/sh. bug #8. 0000008: modprobe applet is dependent on having a shell
This commit is contained in:
parent
157e8071be
commit
8eeb655661
3
AUTHORS
3
AUTHORS
@ -29,6 +29,9 @@ Jeff Angielski <jeff@theptrgroup.com>
|
|||||||
Enrik Berkhan <Enrik.Berkhan@inka.de>
|
Enrik Berkhan <Enrik.Berkhan@inka.de>
|
||||||
setconsole
|
setconsole
|
||||||
|
|
||||||
|
Jim Bauer <jfbauer@nfr.com>
|
||||||
|
modprobe shell dependency
|
||||||
|
|
||||||
Edward Betts <edward@debian.org>
|
Edward Betts <edward@debian.org>
|
||||||
expr, hostid, logname, whoami
|
expr, hostid, logname, whoami
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2002 by Robert Griebl, griebl@gmx.de
|
* Copyright (c) 2002 by Robert Griebl, griebl@gmx.de
|
||||||
* Copyright (c) 2003 by Andrew Dennison, andrew.dennison@motec.com.au
|
* Copyright (c) 2003 by Andrew Dennison, andrew.dennison@motec.com.au
|
||||||
|
* Copyright (c) 2005 by Jim Bauer, jfbauer@nfr.com
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -22,6 +23,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -393,30 +396,65 @@ static int already_loaded (const char *name)
|
|||||||
|
|
||||||
static int mod_process ( struct mod_list_t *list, int do_insert )
|
static int mod_process ( struct mod_list_t *list, int do_insert )
|
||||||
{
|
{
|
||||||
char lcmd [4096];
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
char *argv[10];
|
||||||
|
int argc;
|
||||||
|
|
||||||
while ( list ) {
|
while ( list ) {
|
||||||
*lcmd = '\0';
|
argc = 0;
|
||||||
if ( do_insert ) {
|
if ( do_insert ) {
|
||||||
if (already_loaded (list->m_name) != 1)
|
if (already_loaded (list->m_name) != 1) {
|
||||||
snprintf ( lcmd, sizeof( lcmd ) - 1, "insmod %s %s %s %s %s",
|
argv[argc++] = "insmod";
|
||||||
do_syslog ? "-s" : "", autoclean ? "-k" : "",
|
if (do_syslog)
|
||||||
quiet ? "-q" : "", list-> m_path, list-> m_options ?
|
argv[argc++] = "-s";
|
||||||
list-> m_options : "" );
|
if (autoclean)
|
||||||
|
argv[argc++] = "-k";
|
||||||
|
if (quiet)
|
||||||
|
argv[argc++] = "-q";
|
||||||
|
argv[argc++] = list-> m_path;
|
||||||
|
if (list-> m_options)
|
||||||
|
argv[argc++] = list-> m_options;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* modutils uses short name for removal */
|
/* modutils uses short name for removal */
|
||||||
if (already_loaded (list->m_name) != 0)
|
if (already_loaded (list->m_name) != 0) {
|
||||||
snprintf ( lcmd, sizeof( lcmd ) - 1, "rmmod %s %s",
|
argv[argc++] = "rmmod";
|
||||||
do_syslog ? "-s" : "", list-> m_name );
|
if (do_syslog)
|
||||||
|
argv[argc++] = "-s";
|
||||||
|
argv[argc++] = list->m_name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
argv[argc] = NULL;
|
||||||
|
|
||||||
if (*lcmd) {
|
if (argc) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
printf("%s\n", lcmd);
|
int i;
|
||||||
|
for (i=0; i<argc; i++)
|
||||||
|
printf("%s ", argv[i]);
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
if (!show_only) {
|
if (!show_only) {
|
||||||
int rc2 = system(lcmd);
|
int rc2 = 0;
|
||||||
|
int status;
|
||||||
|
switch (fork()) {
|
||||||
|
case -1:
|
||||||
|
rc2 = 1;
|
||||||
|
break;
|
||||||
|
case 0: //child
|
||||||
|
execvp(argv[0], argv);
|
||||||
|
bb_perror_msg_and_die("exec of %s", argv[0]);
|
||||||
|
/* NOTREACHED */
|
||||||
|
default:
|
||||||
|
if (wait(&status) == -1) {
|
||||||
|
rc2 = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (WIFEXITED(status))
|
||||||
|
rc2 = WEXITSTATUS(status);
|
||||||
|
if (WIFSIGNALED(status))
|
||||||
|
rc2 = WTERMSIG(status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (do_insert) {
|
if (do_insert) {
|
||||||
rc = rc2; /* only last module matters */
|
rc = rc2; /* only last module matters */
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user