diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-09-16 06:22:25 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-09-16 06:22:25 +0000 |
commit | c38678d14b87f8e2d4f0d610d0aa61c656f17539 (patch) | |
tree | 8a08f41faae7672a634f32234dee4b5308cda39c | |
parent | 166fa4684f33579277f34d887537c2abefc9deb0 (diff) | |
download | busybox-w32-c38678d14b87f8e2d4f0d610d0aa61c656f17539.tar.gz busybox-w32-c38678d14b87f8e2d4f0d610d0aa61c656f17539.tar.bz2 busybox-w32-c38678d14b87f8e2d4f0d610d0aa61c656f17539.zip |
Apply vodz' last_patch52
-rw-r--r-- | applets/applets.c | 2 | ||||
-rw-r--r-- | console-tools/chvt.c | 2 | ||||
-rw-r--r-- | console-tools/deallocvt.c | 2 | ||||
-rw-r--r-- | console-tools/setkeycodes.c | 2 | ||||
-rw-r--r-- | include/applets.h | 4 | ||||
-rw-r--r-- | include/libbb.h | 2 | ||||
-rw-r--r-- | include/usage.h | 2 | ||||
-rw-r--r-- | libbb/get_console.c | 9 | ||||
-rw-r--r-- | loginutils/adduser.c | 16 | ||||
-rw-r--r-- | procps/kill.c | 32 |
10 files changed, 30 insertions, 43 deletions
diff --git a/applets/applets.c b/applets/applets.c index 8171a309d..168501811 100644 --- a/applets/applets.c +++ b/applets/applets.c | |||
@@ -90,7 +90,7 @@ extern void show_usage(void) | |||
90 | } | 90 | } |
91 | } | 91 | } |
92 | format_string = "%s\n\nUsage: %s %s\n\n"; | 92 | format_string = "%s\n\nUsage: %s %s\n\n"; |
93 | if(*usage_string == 0) | 93 | if(*usage_string == '\b') |
94 | format_string = "%s\n\nNo help available.\n\n"; | 94 | format_string = "%s\n\nNo help available.\n\n"; |
95 | fprintf(stderr, format_string, | 95 | fprintf(stderr, format_string, |
96 | full_version, applet_using->name, usage_string); | 96 | full_version, applet_using->name, usage_string); |
diff --git a/console-tools/chvt.c b/console-tools/chvt.c index c76e9c780..8136f1c15 100644 --- a/console-tools/chvt.c +++ b/console-tools/chvt.c | |||
@@ -24,7 +24,7 @@ int chvt_main(int argc, char **argv) | |||
24 | 24 | ||
25 | if ((argc != 2) || (**(argv + 1) == '-')) | 25 | if ((argc != 2) || (**(argv + 1) == '-')) |
26 | show_usage(); | 26 | show_usage(); |
27 | fd = get_console_fd("/dev/console"); | 27 | fd = get_console_fd(); |
28 | num = atoi(argv[1]); | 28 | num = atoi(argv[1]); |
29 | if (ioctl(fd, VT_ACTIVATE, num)) | 29 | if (ioctl(fd, VT_ACTIVATE, num)) |
30 | perror_msg_and_die("VT_ACTIVATE"); | 30 | perror_msg_and_die("VT_ACTIVATE"); |
diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c index 15cd0c9b9..b7dcc9e22 100644 --- a/console-tools/deallocvt.c +++ b/console-tools/deallocvt.c | |||
@@ -21,7 +21,7 @@ int deallocvt_main(int argc, char *argv[]) | |||
21 | if (argc > 2) | 21 | if (argc > 2) |
22 | show_usage(); | 22 | show_usage(); |
23 | 23 | ||
24 | fd = get_console_fd("/dev/console"); | 24 | fd = get_console_fd(); |
25 | 25 | ||
26 | if (argc == 1) { | 26 | if (argc == 1) { |
27 | /* deallocate all unused consoles */ | 27 | /* deallocate all unused consoles */ |
diff --git a/console-tools/setkeycodes.c b/console-tools/setkeycodes.c index c3c7e09aa..85612c8b1 100644 --- a/console-tools/setkeycodes.c +++ b/console-tools/setkeycodes.c | |||
@@ -46,7 +46,7 @@ setkeycodes_main(int argc, char** argv) | |||
46 | show_usage(); | 46 | show_usage(); |
47 | } | 47 | } |
48 | 48 | ||
49 | fd = get_console_fd("/dev/console"); | 49 | fd = get_console_fd(); |
50 | 50 | ||
51 | while (argc > 2) { | 51 | while (argc > 2) { |
52 | a.keycode = atoi(argv[2]); | 52 | a.keycode = atoi(argv[2]); |
diff --git a/include/applets.h b/include/applets.h index f6a840024..d5c257052 100644 --- a/include/applets.h +++ b/include/applets.h | |||
@@ -23,11 +23,11 @@ | |||
23 | #elif defined(MAKE_USAGE) | 23 | #elif defined(MAKE_USAGE) |
24 | #ifdef CONFIG_FEATURE_VERBOSE_USAGE | 24 | #ifdef CONFIG_FEATURE_VERBOSE_USAGE |
25 | #define APPLET(a,b,c,d) a##_trivial_usage "\n\n" a##_full_usage "\0" | 25 | #define APPLET(a,b,c,d) a##_trivial_usage "\n\n" a##_full_usage "\0" |
26 | #define APPLET_NOUSAGE(a,b,c,d) "\0" | 26 | #define APPLET_NOUSAGE(a,b,c,d) "\b\0" |
27 | #define APPLET_ODDNAME(a,b,c,d,e) e##_trivial_usage "\n\n" e##_full_usage "\0" | 27 | #define APPLET_ODDNAME(a,b,c,d,e) e##_trivial_usage "\n\n" e##_full_usage "\0" |
28 | #else | 28 | #else |
29 | #define APPLET(a,b,c,d) a##_trivial_usage "\0" | 29 | #define APPLET(a,b,c,d) a##_trivial_usage "\0" |
30 | #define APPLET_NOUSAGE(a,b,c,d) "\0" | 30 | #define APPLET_NOUSAGE(a,b,c,d) "\b\0" |
31 | #define APPLET_ODDNAME(a,b,c,d,e) e##_trivial_usage "\0" | 31 | #define APPLET_ODDNAME(a,b,c,d,e) e##_trivial_usage "\0" |
32 | #endif | 32 | #endif |
33 | #elif defined(MAKE_LINKS) | 33 | #elif defined(MAKE_LINKS) |
diff --git a/include/libbb.h b/include/libbb.h index 252496e0f..6ab942bd8 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -123,7 +123,7 @@ extern int parse_mode( const char* s, mode_t* theMode); | |||
123 | 123 | ||
124 | extern int get_kernel_revision(void); | 124 | extern int get_kernel_revision(void); |
125 | 125 | ||
126 | extern int get_console_fd(char* tty_name); | 126 | extern int get_console_fd(void); |
127 | extern struct mntent *find_mount_point(const char *name, const char *table); | 127 | extern struct mntent *find_mount_point(const char *name, const char *table); |
128 | extern void write_mtab(char* blockDevice, char* directory, | 128 | extern void write_mtab(char* blockDevice, char* directory, |
129 | char* filesystemType, long flags, char* string_flags); | 129 | char* filesystemType, long flags, char* string_flags); |
diff --git a/include/usage.h b/include/usage.h index ee697150b..968823e54 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -1369,7 +1369,7 @@ | |||
1369 | #define passwd_trivial_usage \ | 1369 | #define passwd_trivial_usage \ |
1370 | "[OPTION] [name]" | 1370 | "[OPTION] [name]" |
1371 | #define passwd_full_usage \ | 1371 | #define passwd_full_usage \ |
1372 | "CChange a user password. If no name is specified,\n" \ | 1372 | "Change a user password. If no name is specified,\n" \ |
1373 | "changes the password for the current user.\n" \ | 1373 | "changes the password for the current user.\n" \ |
1374 | "Options:\n" \ | 1374 | "Options:\n" \ |
1375 | "\t-a\tDefine which algorithm shall be used for the password.\n" \ | 1375 | "\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 04a6bd1a6..794888fa7 100644 --- a/libbb/get_console.c +++ b/libbb/get_console.c | |||
@@ -36,7 +36,7 @@ static const int KDGKBTYPE = 0x4B33; /* get keyboard type */ | |||
36 | static const int KB_84 = 0x01; | 36 | static const int KB_84 = 0x01; |
37 | static const int KB_101 = 0x02; /* this is what we always answer */ | 37 | static const int KB_101 = 0x02; /* this is what we always answer */ |
38 | 38 | ||
39 | int is_a_console(int fd) | 39 | static int is_a_console(int fd) |
40 | { | 40 | { |
41 | char arg; | 41 | char arg; |
42 | 42 | ||
@@ -82,17 +82,14 @@ static int open_a_console(char *fnam) | |||
82 | * if tty_name is non-NULL, try this one instead. | 82 | * if tty_name is non-NULL, try this one instead. |
83 | */ | 83 | */ |
84 | 84 | ||
85 | int get_console_fd(char *tty_name) | 85 | int get_console_fd(void) |
86 | { | 86 | { |
87 | int fd; | 87 | int fd; |
88 | 88 | ||
89 | if (tty_name) { | 89 | if (-1 == (fd = open_a_console("/dev/console"))) |
90 | if (-1 == (fd = open_a_console(tty_name))) | ||
91 | return -1; | 90 | return -1; |
92 | else | 91 | else |
93 | return fd; | 92 | return fd; |
94 | } | ||
95 | |||
96 | fd = open_a_console(CURRENT_TTY); | 93 | fd = open_a_console(CURRENT_TTY); |
97 | if (fd >= 0) | 94 | if (fd >= 0) |
98 | return fd; | 95 | return fd; |
diff --git a/loginutils/adduser.c b/loginutils/adduser.c index 7455f23a6..3485611cc 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c | |||
@@ -110,18 +110,20 @@ static int passwd_study(const char *filename, struct passwd *p) | |||
110 | 110 | ||
111 | static void addgroup_wrapper(const char *login, gid_t gid) | 111 | static void addgroup_wrapper(const char *login, gid_t gid) |
112 | { | 112 | { |
113 | char *cmd = xmalloc(strlen(login)+32); | 113 | char *cmd; |
114 | 114 | ||
115 | sprintf(cmd, "addgroup -g %d %s", gid, login); | 115 | bb_asprintf(&cmd, "addgroup -g %d %s", gid, login); |
116 | system(cmd); | 116 | system(cmd); |
117 | free(cmd); | 117 | free(cmd); |
118 | } | 118 | } |
119 | 119 | ||
120 | static void passwd_wrapper(const char *login) __attribute__ ((noreturn)); | ||
121 | |||
120 | static void passwd_wrapper(const char *login) | 122 | static void passwd_wrapper(const char *login) |
121 | { | 123 | { |
122 | static const char prog[] = "passwd"; | 124 | static const char prog[] = "passwd"; |
123 | execlp(prog, prog, login, NULL); | 125 | execlp(prog, prog, login, NULL); |
124 | error_msg_and_die("Failed to execute 'passwd', you must set the password for '%s' manually", login); | 126 | error_msg_and_die("Failed to execute '%s', you must set the password for '%s' manually", prog, login); |
125 | } | 127 | } |
126 | 128 | ||
127 | /* putpwent(3) remix */ | 129 | /* putpwent(3) remix */ |
@@ -137,7 +139,6 @@ static int adduser(const char *filename, struct passwd *p) | |||
137 | /* make sure everything is kosher and setup uid && gid */ | 139 | /* make sure everything is kosher and setup uid && gid */ |
138 | passwd = wfopen(filename, "a"); | 140 | passwd = wfopen(filename, "a"); |
139 | if (passwd == NULL) { | 141 | if (passwd == NULL) { |
140 | /* return -1; */ | ||
141 | return 1; | 142 | return 1; |
142 | } | 143 | } |
143 | fseek(passwd, 0, SEEK_END); | 144 | fseek(passwd, 0, SEEK_END); |
@@ -153,13 +154,11 @@ static int adduser(const char *filename, struct passwd *p) | |||
153 | error_msg("group name %s already in use", p->pw_name); | 154 | error_msg("group name %s already in use", p->pw_name); |
154 | else | 155 | else |
155 | error_msg("generic error."); | 156 | error_msg("generic error."); |
156 | /* return -1; */ | ||
157 | return 1; | 157 | return 1; |
158 | } | 158 | } |
159 | 159 | ||
160 | /* add to passwd */ | 160 | /* add to passwd */ |
161 | if (putpwent(p, passwd) == -1) { | 161 | if (putpwent(p, passwd) == -1) { |
162 | /* return -1; */ | ||
163 | return 1; | 162 | return 1; |
164 | } | 163 | } |
165 | fclose(passwd); | 164 | fclose(passwd); |
@@ -169,7 +168,6 @@ static int adduser(const char *filename, struct passwd *p) | |||
169 | if (shadow_enabled) { | 168 | if (shadow_enabled) { |
170 | shadow = wfopen(shadow_file, "a"); | 169 | shadow = wfopen(shadow_file, "a"); |
171 | if (shadow == NULL) { | 170 | if (shadow == NULL) { |
172 | /* return -1; */ | ||
173 | return 1; | 171 | return 1; |
174 | } | 172 | } |
175 | fseek(shadow, 0, SEEK_END); | 173 | fseek(shadow, 0, SEEK_END); |
@@ -206,8 +204,6 @@ static int adduser(const char *filename, struct passwd *p) | |||
206 | } | 204 | } |
207 | /* interactively set passwd */ | 205 | /* interactively set passwd */ |
208 | passwd_wrapper(p->pw_name); | 206 | passwd_wrapper(p->pw_name); |
209 | |||
210 | return 0; | ||
211 | } | 207 | } |
212 | 208 | ||
213 | 209 | ||
@@ -293,4 +289,4 @@ int adduser_main(int argc, char **argv) | |||
293 | return adduser(passwd_file, &pw); | 289 | return adduser(passwd_file, &pw); |
294 | } | 290 | } |
295 | 291 | ||
296 | /* $Id: adduser.c,v 1.3 2002/07/16 23:50:05 sandman Exp $ */ | 292 | /* $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 5f2f6618f..2ef87aea6 100644 --- a/procps/kill.c +++ b/procps/kill.c | |||
@@ -40,6 +40,7 @@ extern int kill_main(int argc, char **argv) | |||
40 | { | 40 | { |
41 | int whichApp, sig = SIGTERM, quiet; | 41 | int whichApp, sig = SIGTERM, quiet; |
42 | const char *name; | 42 | const char *name; |
43 | int errors = 0; | ||
43 | 44 | ||
44 | #ifdef CONFIG_KILLALL | 45 | #ifdef CONFIG_KILLALL |
45 | /* Figure out what we are trying to do here */ | 46 | /* Figure out what we are trying to do here */ |
@@ -111,37 +112,33 @@ do_it_now: | |||
111 | perror_msg_and_die( "Bad PID"); | 112 | perror_msg_and_die( "Bad PID"); |
112 | pid = strtol(*argv, NULL, 0); | 113 | pid = strtol(*argv, NULL, 0); |
113 | if (kill(pid, sig) != 0) { | 114 | if (kill(pid, sig) != 0) { |
114 | perror_msg_and_die( "Could not kill pid '%d'", pid); | 115 | perror_msg( "Could not kill pid '%d'", pid); |
116 | errors++; | ||
115 | } | 117 | } |
116 | argv++; | 118 | argv++; |
117 | } | 119 | } |
120 | |||
118 | } | 121 | } |
119 | #ifdef CONFIG_KILLALL | 122 | #ifdef CONFIG_KILLALL |
120 | else { | 123 | else { |
121 | int all_found = TRUE; | ||
122 | pid_t myPid=getpid(); | 124 | pid_t myPid=getpid(); |
123 | /* Looks like they want to do a killall. Do that */ | 125 | /* Looks like they want to do a killall. Do that */ |
124 | while (--argc >= 0) { | 126 | while (--argc >= 0) { |
125 | long* pidList; | 127 | long* pidList; |
126 | 128 | ||
127 | pidList = find_pid_by_name( *argv); | 129 | pidList = find_pid_by_name(*argv); |
128 | if (!pidList || *pidList<=0) { | 130 | if (!pidList || *pidList<=0) { |
129 | all_found = FALSE; | 131 | errors++; |
130 | if (quiet) { | 132 | if (quiet==0) |
131 | exit(EXIT_FAILURE); | 133 | error_msg( "%s: no process killed", *argv); |
132 | } else { | 134 | } else { |
133 | error_msg_and_die( "%s: no process killed", *argv); | 135 | for(; *pidList!=0; pidList++) { |
134 | } | ||
135 | } | ||
136 | |||
137 | for(; pidList && *pidList!=0; pidList++) { | ||
138 | if (*pidList==myPid) | 136 | if (*pidList==myPid) |
139 | continue; | 137 | continue; |
140 | if (kill(*pidList, sig) != 0) { | 138 | if (kill(*pidList, sig) != 0) { |
141 | if (quiet) { | 139 | errors++; |
142 | exit(EXIT_FAILURE); | 140 | if (quiet==0) |
143 | } else { | 141 | perror_msg( "Could not kill pid '%d'", *pidList); |
144 | perror_msg_and_die( "Could not kill pid '%d'", *pidList); | ||
145 | } | 142 | } |
146 | } | 143 | } |
147 | } | 144 | } |
@@ -150,10 +147,7 @@ do_it_now: | |||
150 | * upon exit, so we can save a byte or two */ | 147 | * upon exit, so we can save a byte or two */ |
151 | argv++; | 148 | argv++; |
152 | } | 149 | } |
153 | if (! all_found) | ||
154 | return EXIT_FAILURE; | ||
155 | } | 150 | } |
156 | #endif | 151 | #endif |
157 | 152 | return errors; | |
158 | return EXIT_SUCCESS; | ||
159 | } | 153 | } |