mirror of
https://github.com/sheumann/hush.git
synced 2025-01-27 06:34:03 +00:00
Apply vodz' last_patch52
This commit is contained in:
parent
166fa4684f
commit
c38678d14b
@ -90,7 +90,7 @@ extern void show_usage(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
format_string = "%s\n\nUsage: %s %s\n\n";
|
format_string = "%s\n\nUsage: %s %s\n\n";
|
||||||
if(*usage_string == 0)
|
if(*usage_string == '\b')
|
||||||
format_string = "%s\n\nNo help available.\n\n";
|
format_string = "%s\n\nNo help available.\n\n";
|
||||||
fprintf(stderr, format_string,
|
fprintf(stderr, format_string,
|
||||||
full_version, applet_using->name, usage_string);
|
full_version, applet_using->name, usage_string);
|
||||||
|
@ -24,7 +24,7 @@ int chvt_main(int argc, char **argv)
|
|||||||
|
|
||||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||||
show_usage();
|
show_usage();
|
||||||
fd = get_console_fd("/dev/console");
|
fd = get_console_fd();
|
||||||
num = atoi(argv[1]);
|
num = atoi(argv[1]);
|
||||||
if (ioctl(fd, VT_ACTIVATE, num))
|
if (ioctl(fd, VT_ACTIVATE, num))
|
||||||
perror_msg_and_die("VT_ACTIVATE");
|
perror_msg_and_die("VT_ACTIVATE");
|
||||||
|
@ -21,7 +21,7 @@ int deallocvt_main(int argc, char *argv[])
|
|||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
show_usage();
|
show_usage();
|
||||||
|
|
||||||
fd = get_console_fd("/dev/console");
|
fd = get_console_fd();
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
/* deallocate all unused consoles */
|
/* deallocate all unused consoles */
|
||||||
|
@ -46,7 +46,7 @@ setkeycodes_main(int argc, char** argv)
|
|||||||
show_usage();
|
show_usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = get_console_fd("/dev/console");
|
fd = get_console_fd();
|
||||||
|
|
||||||
while (argc > 2) {
|
while (argc > 2) {
|
||||||
a.keycode = atoi(argv[2]);
|
a.keycode = atoi(argv[2]);
|
||||||
|
@ -23,11 +23,11 @@
|
|||||||
#elif defined(MAKE_USAGE)
|
#elif defined(MAKE_USAGE)
|
||||||
#ifdef CONFIG_FEATURE_VERBOSE_USAGE
|
#ifdef CONFIG_FEATURE_VERBOSE_USAGE
|
||||||
#define APPLET(a,b,c,d) a##_trivial_usage "\n\n" a##_full_usage "\0"
|
#define APPLET(a,b,c,d) a##_trivial_usage "\n\n" a##_full_usage "\0"
|
||||||
#define APPLET_NOUSAGE(a,b,c,d) "\0"
|
#define APPLET_NOUSAGE(a,b,c,d) "\b\0"
|
||||||
#define APPLET_ODDNAME(a,b,c,d,e) e##_trivial_usage "\n\n" e##_full_usage "\0"
|
#define APPLET_ODDNAME(a,b,c,d,e) e##_trivial_usage "\n\n" e##_full_usage "\0"
|
||||||
#else
|
#else
|
||||||
#define APPLET(a,b,c,d) a##_trivial_usage "\0"
|
#define APPLET(a,b,c,d) a##_trivial_usage "\0"
|
||||||
#define APPLET_NOUSAGE(a,b,c,d) "\0"
|
#define APPLET_NOUSAGE(a,b,c,d) "\b\0"
|
||||||
#define APPLET_ODDNAME(a,b,c,d,e) e##_trivial_usage "\0"
|
#define APPLET_ODDNAME(a,b,c,d,e) e##_trivial_usage "\0"
|
||||||
#endif
|
#endif
|
||||||
#elif defined(MAKE_LINKS)
|
#elif defined(MAKE_LINKS)
|
||||||
|
@ -123,7 +123,7 @@ extern int parse_mode( const char* s, mode_t* theMode);
|
|||||||
|
|
||||||
extern int get_kernel_revision(void);
|
extern int get_kernel_revision(void);
|
||||||
|
|
||||||
extern int get_console_fd(char* tty_name);
|
extern int get_console_fd(void);
|
||||||
extern struct mntent *find_mount_point(const char *name, const char *table);
|
extern struct mntent *find_mount_point(const char *name, const char *table);
|
||||||
extern void write_mtab(char* blockDevice, char* directory,
|
extern void write_mtab(char* blockDevice, char* directory,
|
||||||
char* filesystemType, long flags, char* string_flags);
|
char* filesystemType, long flags, char* string_flags);
|
||||||
|
@ -1369,7 +1369,7 @@
|
|||||||
#define passwd_trivial_usage \
|
#define passwd_trivial_usage \
|
||||||
"[OPTION] [name]"
|
"[OPTION] [name]"
|
||||||
#define passwd_full_usage \
|
#define passwd_full_usage \
|
||||||
"CChange a user password. If no name is specified,\n" \
|
"Change a user password. If no name is specified,\n" \
|
||||||
"changes the password for the current user.\n" \
|
"changes the password for the current user.\n" \
|
||||||
"Options:\n" \
|
"Options:\n" \
|
||||||
"\t-a\tDefine which algorithm shall be used for the password.\n" \
|
"\t-a\tDefine which algorithm shall be used for the password.\n" \
|
||||||
|
@ -36,7 +36,7 @@ static const int KDGKBTYPE = 0x4B33; /* get keyboard type */
|
|||||||
static const int KB_84 = 0x01;
|
static const int KB_84 = 0x01;
|
||||||
static const int KB_101 = 0x02; /* this is what we always answer */
|
static const int KB_101 = 0x02; /* this is what we always answer */
|
||||||
|
|
||||||
int is_a_console(int fd)
|
static int is_a_console(int fd)
|
||||||
{
|
{
|
||||||
char arg;
|
char arg;
|
||||||
|
|
||||||
@ -82,17 +82,14 @@ static int open_a_console(char *fnam)
|
|||||||
* if tty_name is non-NULL, try this one instead.
|
* if tty_name is non-NULL, try this one instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int get_console_fd(char *tty_name)
|
int get_console_fd(void)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (tty_name) {
|
if (-1 == (fd = open_a_console("/dev/console")))
|
||||||
if (-1 == (fd = open_a_console(tty_name)))
|
|
||||||
return -1;
|
return -1;
|
||||||
else
|
else
|
||||||
return fd;
|
return fd;
|
||||||
}
|
|
||||||
|
|
||||||
fd = open_a_console(CURRENT_TTY);
|
fd = open_a_console(CURRENT_TTY);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
return fd;
|
return fd;
|
||||||
|
@ -110,18 +110,20 @@ static int passwd_study(const char *filename, struct passwd *p)
|
|||||||
|
|
||||||
static void addgroup_wrapper(const char *login, gid_t gid)
|
static void addgroup_wrapper(const char *login, gid_t gid)
|
||||||
{
|
{
|
||||||
char *cmd = xmalloc(strlen(login)+32);
|
char *cmd;
|
||||||
|
|
||||||
sprintf(cmd, "addgroup -g %d %s", gid, login);
|
bb_asprintf(&cmd, "addgroup -g %d %s", gid, login);
|
||||||
system(cmd);
|
system(cmd);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void passwd_wrapper(const char *login) __attribute__ ((noreturn));
|
||||||
|
|
||||||
static void passwd_wrapper(const char *login)
|
static void passwd_wrapper(const char *login)
|
||||||
{
|
{
|
||||||
static const char prog[] = "passwd";
|
static const char prog[] = "passwd";
|
||||||
execlp(prog, prog, login, NULL);
|
execlp(prog, prog, login, NULL);
|
||||||
error_msg_and_die("Failed to execute 'passwd', you must set the password for '%s' manually", login);
|
error_msg_and_die("Failed to execute '%s', you must set the password for '%s' manually", prog, login);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* putpwent(3) remix */
|
/* putpwent(3) remix */
|
||||||
@ -137,7 +139,6 @@ static int adduser(const char *filename, struct passwd *p)
|
|||||||
/* make sure everything is kosher and setup uid && gid */
|
/* make sure everything is kosher and setup uid && gid */
|
||||||
passwd = wfopen(filename, "a");
|
passwd = wfopen(filename, "a");
|
||||||
if (passwd == NULL) {
|
if (passwd == NULL) {
|
||||||
/* return -1; */
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
fseek(passwd, 0, SEEK_END);
|
fseek(passwd, 0, SEEK_END);
|
||||||
@ -153,13 +154,11 @@ static int adduser(const char *filename, struct passwd *p)
|
|||||||
error_msg("group name %s already in use", p->pw_name);
|
error_msg("group name %s already in use", p->pw_name);
|
||||||
else
|
else
|
||||||
error_msg("generic error.");
|
error_msg("generic error.");
|
||||||
/* return -1; */
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add to passwd */
|
/* add to passwd */
|
||||||
if (putpwent(p, passwd) == -1) {
|
if (putpwent(p, passwd) == -1) {
|
||||||
/* return -1; */
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
fclose(passwd);
|
fclose(passwd);
|
||||||
@ -169,7 +168,6 @@ static int adduser(const char *filename, struct passwd *p)
|
|||||||
if (shadow_enabled) {
|
if (shadow_enabled) {
|
||||||
shadow = wfopen(shadow_file, "a");
|
shadow = wfopen(shadow_file, "a");
|
||||||
if (shadow == NULL) {
|
if (shadow == NULL) {
|
||||||
/* return -1; */
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
fseek(shadow, 0, SEEK_END);
|
fseek(shadow, 0, SEEK_END);
|
||||||
@ -206,8 +204,6 @@ static int adduser(const char *filename, struct passwd *p)
|
|||||||
}
|
}
|
||||||
/* interactively set passwd */
|
/* interactively set passwd */
|
||||||
passwd_wrapper(p->pw_name);
|
passwd_wrapper(p->pw_name);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -293,4 +289,4 @@ int adduser_main(int argc, char **argv)
|
|||||||
return adduser(passwd_file, &pw);
|
return adduser(passwd_file, &pw);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* $Id: adduser.c,v 1.3 2002/07/16 23:50:05 sandman Exp $ */
|
/* $Id: adduser.c,v 1.4 2002/09/16 06:22:24 andersen Exp $ */
|
||||||
|
@ -40,6 +40,7 @@ extern int kill_main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int whichApp, sig = SIGTERM, quiet;
|
int whichApp, sig = SIGTERM, quiet;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
int errors = 0;
|
||||||
|
|
||||||
#ifdef CONFIG_KILLALL
|
#ifdef CONFIG_KILLALL
|
||||||
/* Figure out what we are trying to do here */
|
/* Figure out what we are trying to do here */
|
||||||
@ -111,37 +112,33 @@ do_it_now:
|
|||||||
perror_msg_and_die( "Bad PID");
|
perror_msg_and_die( "Bad PID");
|
||||||
pid = strtol(*argv, NULL, 0);
|
pid = strtol(*argv, NULL, 0);
|
||||||
if (kill(pid, sig) != 0) {
|
if (kill(pid, sig) != 0) {
|
||||||
perror_msg_and_die( "Could not kill pid '%d'", pid);
|
perror_msg( "Could not kill pid '%d'", pid);
|
||||||
|
errors++;
|
||||||
}
|
}
|
||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_KILLALL
|
#ifdef CONFIG_KILLALL
|
||||||
else {
|
else {
|
||||||
int all_found = TRUE;
|
|
||||||
pid_t myPid=getpid();
|
pid_t myPid=getpid();
|
||||||
/* Looks like they want to do a killall. Do that */
|
/* Looks like they want to do a killall. Do that */
|
||||||
while (--argc >= 0) {
|
while (--argc >= 0) {
|
||||||
long* pidList;
|
long* pidList;
|
||||||
|
|
||||||
pidList = find_pid_by_name( *argv);
|
pidList = find_pid_by_name(*argv);
|
||||||
if (!pidList || *pidList<=0) {
|
if (!pidList || *pidList<=0) {
|
||||||
all_found = FALSE;
|
errors++;
|
||||||
if (quiet) {
|
if (quiet==0)
|
||||||
exit(EXIT_FAILURE);
|
error_msg( "%s: no process killed", *argv);
|
||||||
} else {
|
} else {
|
||||||
error_msg_and_die( "%s: no process killed", *argv);
|
for(; *pidList!=0; pidList++) {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(; pidList && *pidList!=0; pidList++) {
|
|
||||||
if (*pidList==myPid)
|
if (*pidList==myPid)
|
||||||
continue;
|
continue;
|
||||||
if (kill(*pidList, sig) != 0) {
|
if (kill(*pidList, sig) != 0) {
|
||||||
if (quiet) {
|
errors++;
|
||||||
exit(EXIT_FAILURE);
|
if (quiet==0)
|
||||||
} else {
|
perror_msg( "Could not kill pid '%d'", *pidList);
|
||||||
perror_msg_and_die( "Could not kill pid '%d'", *pidList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,10 +147,7 @@ do_it_now:
|
|||||||
* upon exit, so we can save a byte or two */
|
* upon exit, so we can save a byte or two */
|
||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
if (! all_found)
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
return errors;
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user