Apply vodz' last_patch52
diff --git a/applets/applets.c b/applets/applets.c
index 8171a30..1685018 100644
--- a/applets/applets.c
+++ b/applets/applets.c
@@ -90,7 +90,7 @@
}
}
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";
fprintf(stderr, format_string,
full_version, applet_using->name, usage_string);
diff --git a/console-tools/chvt.c b/console-tools/chvt.c
index c76e9c7..8136f1c 100644
--- a/console-tools/chvt.c
+++ b/console-tools/chvt.c
@@ -24,7 +24,7 @@
if ((argc != 2) || (**(argv + 1) == '-'))
show_usage();
- fd = get_console_fd("/dev/console");
+ fd = get_console_fd();
num = atoi(argv[1]);
if (ioctl(fd, VT_ACTIVATE, num))
perror_msg_and_die("VT_ACTIVATE");
diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c
index 15cd0c9..b7dcc9e 100644
--- a/console-tools/deallocvt.c
+++ b/console-tools/deallocvt.c
@@ -21,7 +21,7 @@
if (argc > 2)
show_usage();
- fd = get_console_fd("/dev/console");
+ fd = get_console_fd();
if (argc == 1) {
/* deallocate all unused consoles */
diff --git a/console-tools/setkeycodes.c b/console-tools/setkeycodes.c
index c3c7e09..85612c8 100644
--- a/console-tools/setkeycodes.c
+++ b/console-tools/setkeycodes.c
@@ -46,7 +46,7 @@
show_usage();
}
- fd = get_console_fd("/dev/console");
+ fd = get_console_fd();
while (argc > 2) {
a.keycode = atoi(argv[2]);
diff --git a/include/applets.h b/include/applets.h
index f6a8400..d5c2570 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -23,11 +23,11 @@
#elif defined(MAKE_USAGE)
#ifdef CONFIG_FEATURE_VERBOSE_USAGE
#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"
#else
#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"
#endif
#elif defined(MAKE_LINKS)
diff --git a/include/libbb.h b/include/libbb.h
index 252496e..6ab942b 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -123,7 +123,7 @@
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 void write_mtab(char* blockDevice, char* directory,
char* filesystemType, long flags, char* string_flags);
diff --git a/include/usage.h b/include/usage.h
index ee69715..968823e 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -1369,7 +1369,7 @@
#define passwd_trivial_usage \
"[OPTION] [name]"
#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" \
"Options:\n" \
"\t-a\tDefine which algorithm shall be used for the password.\n" \
diff --git a/libbb/get_console.c b/libbb/get_console.c
index 04a6bd1..794888f 100644
--- a/libbb/get_console.c
+++ b/libbb/get_console.c
@@ -36,7 +36,7 @@
static const int KB_84 = 0x01;
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;
@@ -82,17 +82,14 @@
* if tty_name is non-NULL, try this one instead.
*/
-int get_console_fd(char *tty_name)
+int get_console_fd(void)
{
int fd;
- if (tty_name) {
- if (-1 == (fd = open_a_console(tty_name)))
+ if (-1 == (fd = open_a_console("/dev/console")))
return -1;
else
return fd;
- }
-
fd = open_a_console(CURRENT_TTY);
if (fd >= 0)
return fd;
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index 7455f23..3485611 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -110,18 +110,20 @@
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);
free(cmd);
}
+static void passwd_wrapper(const char *login) __attribute__ ((noreturn));
+
static void passwd_wrapper(const char *login)
{
static const char prog[] = "passwd";
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 */
@@ -137,7 +139,6 @@
/* make sure everything is kosher and setup uid && gid */
passwd = wfopen(filename, "a");
if (passwd == NULL) {
- /* return -1; */
return 1;
}
fseek(passwd, 0, SEEK_END);
@@ -153,13 +154,11 @@
error_msg("group name %s already in use", p->pw_name);
else
error_msg("generic error.");
- /* return -1; */
return 1;
}
/* add to passwd */
if (putpwent(p, passwd) == -1) {
- /* return -1; */
return 1;
}
fclose(passwd);
@@ -169,7 +168,6 @@
if (shadow_enabled) {
shadow = wfopen(shadow_file, "a");
if (shadow == NULL) {
- /* return -1; */
return 1;
}
fseek(shadow, 0, SEEK_END);
@@ -206,8 +204,6 @@
}
/* interactively set passwd */
passwd_wrapper(p->pw_name);
-
- return 0;
}
@@ -293,4 +289,4 @@
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 $ */
diff --git a/procps/kill.c b/procps/kill.c
index 5f2f661..2ef87ae 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -40,6 +40,7 @@
{
int whichApp, sig = SIGTERM, quiet;
const char *name;
+ int errors = 0;
#ifdef CONFIG_KILLALL
/* Figure out what we are trying to do here */
@@ -111,37 +112,33 @@
perror_msg_and_die( "Bad PID");
pid = strtol(*argv, NULL, 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++;
}
+
}
#ifdef CONFIG_KILLALL
else {
- int all_found = TRUE;
pid_t myPid=getpid();
/* Looks like they want to do a killall. Do that */
while (--argc >= 0) {
long* pidList;
- pidList = find_pid_by_name( *argv);
+ pidList = find_pid_by_name(*argv);
if (!pidList || *pidList<=0) {
- all_found = FALSE;
- if (quiet) {
- exit(EXIT_FAILURE);
+ errors++;
+ if (quiet==0)
+ error_msg( "%s: no process killed", *argv);
} else {
- error_msg_and_die( "%s: no process killed", *argv);
- }
- }
-
- for(; pidList && *pidList!=0; pidList++) {
+ for(; *pidList!=0; pidList++) {
if (*pidList==myPid)
continue;
if (kill(*pidList, sig) != 0) {
- if (quiet) {
- exit(EXIT_FAILURE);
- } else {
- perror_msg_and_die( "Could not kill pid '%d'", *pidList);
+ errors++;
+ if (quiet==0)
+ perror_msg( "Could not kill pid '%d'", *pidList);
}
}
}
@@ -150,10 +147,7 @@
* upon exit, so we can save a byte or two */
argv++;
}
- if (! all_found)
- return EXIT_FAILURE;
}
#endif
-
- return EXIT_SUCCESS;
+ return errors;
}