diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-05-01 19:10:52 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-05-01 19:10:52 +0000 |
commit | 94f5e0ba7ca7af260f4bf2d8c77b8e6f6f528b18 (patch) | |
tree | 7f40ce6f49ca9ce727653928d1b9f655afb5cb66 | |
parent | 28c49b6c9c98dc592759063d10c49b209e849cae (diff) | |
download | busybox-w32-94f5e0ba7ca7af260f4bf2d8c77b8e6f6f528b18.tar.gz busybox-w32-94f5e0ba7ca7af260f4bf2d8c77b8e6f6f528b18.tar.bz2 busybox-w32-94f5e0ba7ca7af260f4bf2d8c77b8e6f6f528b18.zip |
Some accrued fixes/updates.
* cp/mv now accepts (and ignores) the -f flag, since it always
does force anyway
* tail can now accept -<num> commands (e.g. -10) for better
compatibility with the standard tail command
* added a simple id implementation; doesn't support supp. groups yet
-rw-r--r-- | Changelog | 7 | ||||
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | applets/busybox.c | 3 | ||||
-rw-r--r-- | busybox.c | 3 | ||||
-rw-r--r-- | busybox.def.h | 1 | ||||
-rw-r--r-- | console-tools/loadkmap.c | 1 | ||||
-rw-r--r-- | coreutils/id.c | 92 | ||||
-rw-r--r-- | coreutils/tail.c | 6 | ||||
-rw-r--r-- | cp_mv.c | 4 | ||||
-rw-r--r-- | id.c | 92 | ||||
-rw-r--r-- | internal.h | 15 | ||||
-rw-r--r-- | loadkmap.c | 1 | ||||
-rw-r--r-- | networking/telnet.c | 21 | ||||
-rw-r--r-- | tail.c | 6 | ||||
-rw-r--r-- | telnet.c | 21 | ||||
-rw-r--r-- | utility.c | 57 |
16 files changed, 286 insertions, 46 deletions
@@ -2,6 +2,7 @@ | |||
2 | * added the -v option (inverted search) to grep, | 2 | * added the -v option (inverted search) to grep, |
3 | updated docs/busybox.pod accordingly. -beppu | 3 | updated docs/busybox.pod accordingly. -beppu |
4 | * Added mktemp, contributed by Daniel Jacobowitz <dan@debian.org> | 4 | * Added mktemp, contributed by Daniel Jacobowitz <dan@debian.org> |
5 | * Added setkeycodes, for those that have wierd keyboard buttons. | ||
5 | * Fix for ping warnings from Sascha Ziemann <szi@aibon.ping.de> | 6 | * Fix for ping warnings from Sascha Ziemann <szi@aibon.ping.de> |
6 | * Fixed update segfault | 7 | * Fixed update segfault |
7 | * Fixed mknod -- minor number was always 0 | 8 | * Fixed mknod -- minor number was always 0 |
@@ -9,6 +10,12 @@ | |||
9 | that wanted "tar cf foo.tar foo" (i.e. no "-" before options) | 10 | that wanted "tar cf foo.tar foo" (i.e. no "-" before options) |
10 | I broke creation of tarballs. I reverted the change (so tar needs | 11 | I broke creation of tarballs. I reverted the change (so tar needs |
11 | the "-" for all options). | 12 | the "-" for all options). |
13 | * Several contributions from Randolph Chung <tausq@debian.org>. | ||
14 | * cp/mv now accepts (and ignores) the -f flag, since it always | ||
15 | does force anyway | ||
16 | * tail can now accept -<num> commands (e.g. -10) for better | ||
17 | compatibility with the standard tail command | ||
18 | * added a simple id implementation; doesn't support supp. groups yet | ||
12 | * More doc updates | 19 | * More doc updates |
13 | 20 | ||
14 | -Erik | 21 | -Erik |
@@ -4,7 +4,7 @@ or that doing so is even a good idea. It just means that I _might_ get | |||
4 | around to it some time. If you have any good ideas, please let me know. | 4 | around to it some time. If you have any good ideas, please let me know. |
5 | 5 | ||
6 | * login/sulogin/passwd/getty/etc are part of tinylogin, and so are not | 6 | * login/sulogin/passwd/getty/etc are part of tinylogin, and so are not |
7 | needed or wanted in busybox (or else I'd have to link in libcrypt). | 7 | needed or wanted in busybox (or else I'd have to link to libcrypt). |
8 | 8 | ||
9 | * Networking apps are probably going to be split out some time soon into a | 9 | * Networking apps are probably going to be split out some time soon into a |
10 | separate package (named perhaps tiny-netkit?). This currently includes | 10 | separate package (named perhaps tiny-netkit?). This currently includes |
diff --git a/applets/busybox.c b/applets/busybox.c index ca767584a..d8a38ada3 100644 --- a/applets/busybox.c +++ b/applets/busybox.c | |||
@@ -134,6 +134,9 @@ static const struct Applet applets[] = { | |||
134 | #ifdef BB_HOSTNAME | 134 | #ifdef BB_HOSTNAME |
135 | {"hostname", hostname_main, _BB_DIR_BIN}, | 135 | {"hostname", hostname_main, _BB_DIR_BIN}, |
136 | #endif | 136 | #endif |
137 | #ifdef BB_ID | ||
138 | {"id", id_main, _BB_DIR_USR_BIN}, | ||
139 | #endif | ||
137 | #ifdef BB_INIT | 140 | #ifdef BB_INIT |
138 | {"init", init_main, _BB_DIR_SBIN}, | 141 | {"init", init_main, _BB_DIR_SBIN}, |
139 | #endif | 142 | #endif |
@@ -134,6 +134,9 @@ static const struct Applet applets[] = { | |||
134 | #ifdef BB_HOSTNAME | 134 | #ifdef BB_HOSTNAME |
135 | {"hostname", hostname_main, _BB_DIR_BIN}, | 135 | {"hostname", hostname_main, _BB_DIR_BIN}, |
136 | #endif | 136 | #endif |
137 | #ifdef BB_ID | ||
138 | {"id", id_main, _BB_DIR_USR_BIN}, | ||
139 | #endif | ||
137 | #ifdef BB_INIT | 140 | #ifdef BB_INIT |
138 | {"init", init_main, _BB_DIR_SBIN}, | 141 | {"init", init_main, _BB_DIR_SBIN}, |
139 | #endif | 142 | #endif |
diff --git a/busybox.def.h b/busybox.def.h index c10c1a318..86b8059cb 100644 --- a/busybox.def.h +++ b/busybox.def.h | |||
@@ -36,6 +36,7 @@ | |||
36 | #define BB_HEAD | 36 | #define BB_HEAD |
37 | #define BB_HOSTID | 37 | #define BB_HOSTID |
38 | #define BB_HOSTNAME | 38 | #define BB_HOSTNAME |
39 | #define BB_ID | ||
39 | #define BB_INIT | 40 | #define BB_INIT |
40 | // Don't bother turning BB_INSMOD on. It doesn't work yet. | 41 | // Don't bother turning BB_INSMOD on. It doesn't work yet. |
41 | //#define BB_INSMOD | 42 | //#define BB_INSMOD |
diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c index 75e52e148..2ac4273db 100644 --- a/console-tools/loadkmap.c +++ b/console-tools/loadkmap.c | |||
@@ -51,6 +51,7 @@ int loadkmap_main(int argc, char **argv) | |||
51 | } | 51 | } |
52 | 52 | ||
53 | read(0, buff, 7); | 53 | read(0, buff, 7); |
54 | printf("buff='%s'\n", buff); | ||
54 | if (0 != strncmp(buff, magic, 7)) { | 55 | if (0 != strncmp(buff, magic, 7)) { |
55 | fprintf(stderr, "This is not a valid binary keymap.\n"); | 56 | fprintf(stderr, "This is not a valid binary keymap.\n"); |
56 | exit(FALSE); | 57 | exit(FALSE); |
diff --git a/coreutils/id.c b/coreutils/id.c new file mode 100644 index 000000000..8ded0e521 --- /dev/null +++ b/coreutils/id.c | |||
@@ -0,0 +1,92 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Mini id implementation for busybox | ||
4 | * | ||
5 | * | ||
6 | * Copyright (C) 2000 by Randolph Chung <tausq@debian.org> | ||
7 | * | ||
8 | * 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 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include "internal.h" | ||
25 | #include <stdio.h> | ||
26 | #include <unistd.h> | ||
27 | #include <pwd.h> | ||
28 | #include <grp.h> | ||
29 | #include <sys/types.h> | ||
30 | |||
31 | static const char id_usage[] = | ||
32 | "id [OPTIONS]... [USERNAME]\n\n" | ||
33 | "Print information for USERNAME or the current user\n\n" | ||
34 | "\t-g\tprints only the group ID\n" | ||
35 | "\t-u\tprints only the user ID\n" | ||
36 | "\t-r\tprints the real user ID instead of the effective ID (with -ug)\n\n"; | ||
37 | |||
38 | extern int id_main(int argc, char **argv) | ||
39 | { | ||
40 | int no_user = 0, no_group = 0, print_real = 0; | ||
41 | char *cp, *user, *group; | ||
42 | gid_t gid; | ||
43 | |||
44 | cp = user = group = NULL; | ||
45 | |||
46 | argc--; argv++; | ||
47 | |||
48 | while (argc > 0) { | ||
49 | cp = *argv; | ||
50 | if (*cp == '-') { | ||
51 | switch (*++cp) { | ||
52 | case 'u': no_group = 1; break; | ||
53 | case 'g': no_user = 1; break; | ||
54 | case 'r': print_real = 1; break; | ||
55 | default: usage(id_usage); | ||
56 | } | ||
57 | } else { | ||
58 | user = cp; | ||
59 | } | ||
60 | argc--; argv++; | ||
61 | } | ||
62 | |||
63 | if (no_user && no_group) usage(id_usage); | ||
64 | |||
65 | if (user == NULL) { | ||
66 | user = xmalloc(9); | ||
67 | group = xmalloc(9); | ||
68 | if (print_real) { | ||
69 | my_getpwuid(user, getuid()); | ||
70 | my_getgrgid(group, getgid()); | ||
71 | } else { | ||
72 | my_getpwuid(user, geteuid()); | ||
73 | my_getgrgid(group, getegid()); | ||
74 | } | ||
75 | } else { | ||
76 | group = xmalloc(9); | ||
77 | gid = my_getpwnamegid(user); | ||
78 | my_getgrgid(group, gid); | ||
79 | } | ||
80 | |||
81 | if (no_group) printf("%u\n", my_getpwnam(user)); | ||
82 | else if (no_user) printf("%u\n", my_getgrnam(group)); | ||
83 | else | ||
84 | printf("uid=%u(%s) gid=%u(%s)\n", | ||
85 | my_getpwnam(user), user, my_getgrnam(group), group); | ||
86 | |||
87 | |||
88 | exit(0); | ||
89 | } | ||
90 | |||
91 | |||
92 | /* END CODE */ | ||
diff --git a/coreutils/tail.c b/coreutils/tail.c index 315eee188..321c5c4b2 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c | |||
@@ -368,8 +368,10 @@ extern int tail_main(int argc, char **argv) | |||
368 | case 'h': | 368 | case 'h': |
369 | usage(tail_usage); | 369 | usage(tail_usage); |
370 | default: | 370 | default: |
371 | fprintf(stderr, "tail: invalid option -- %c\n", opt); | 371 | if ((n_units = atoi(&argv[i][1])) < 1) { |
372 | usage(tail_usage); | 372 | fprintf(stderr, "tail: invalid option -- %c\n", opt); |
373 | usage(tail_usage); | ||
374 | } | ||
373 | } | 375 | } |
374 | } else { | 376 | } else { |
375 | break; | 377 | break; |
@@ -56,6 +56,7 @@ static const char *cp_mv_usage[] = /* .rodata */ | |||
56 | "\t-a\tSame as -dpR\n" | 56 | "\t-a\tSame as -dpR\n" |
57 | "\t-d\tPreserves links\n" | 57 | "\t-d\tPreserves links\n" |
58 | "\t-p\tPreserves file attributes if possible\n" | 58 | "\t-p\tPreserves file attributes if possible\n" |
59 | "\t-f\tforce (implied; ignored) - always set\n" | ||
59 | "\t-R\tCopies directories recursively\n" | 60 | "\t-R\tCopies directories recursively\n" |
60 | #endif | 61 | #endif |
61 | , | 62 | , |
@@ -218,6 +219,9 @@ extern int cp_mv_main(int argc, char **argv) | |||
218 | case 'R': | 219 | case 'R': |
219 | recursiveFlag = TRUE; | 220 | recursiveFlag = TRUE; |
220 | break; | 221 | break; |
222 | case 'f': | ||
223 | /* for compatibility; busybox cp/mv always does force */ | ||
224 | break; | ||
221 | default: | 225 | default: |
222 | usage(cp_mv_usage[is_cp]); | 226 | usage(cp_mv_usage[is_cp]); |
223 | } | 227 | } |
@@ -0,0 +1,92 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Mini id implementation for busybox | ||
4 | * | ||
5 | * | ||
6 | * Copyright (C) 2000 by Randolph Chung <tausq@debian.org> | ||
7 | * | ||
8 | * 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 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include "internal.h" | ||
25 | #include <stdio.h> | ||
26 | #include <unistd.h> | ||
27 | #include <pwd.h> | ||
28 | #include <grp.h> | ||
29 | #include <sys/types.h> | ||
30 | |||
31 | static const char id_usage[] = | ||
32 | "id [OPTIONS]... [USERNAME]\n\n" | ||
33 | "Print information for USERNAME or the current user\n\n" | ||
34 | "\t-g\tprints only the group ID\n" | ||
35 | "\t-u\tprints only the user ID\n" | ||
36 | "\t-r\tprints the real user ID instead of the effective ID (with -ug)\n\n"; | ||
37 | |||
38 | extern int id_main(int argc, char **argv) | ||
39 | { | ||
40 | int no_user = 0, no_group = 0, print_real = 0; | ||
41 | char *cp, *user, *group; | ||
42 | gid_t gid; | ||
43 | |||
44 | cp = user = group = NULL; | ||
45 | |||
46 | argc--; argv++; | ||
47 | |||
48 | while (argc > 0) { | ||
49 | cp = *argv; | ||
50 | if (*cp == '-') { | ||
51 | switch (*++cp) { | ||
52 | case 'u': no_group = 1; break; | ||
53 | case 'g': no_user = 1; break; | ||
54 | case 'r': print_real = 1; break; | ||
55 | default: usage(id_usage); | ||
56 | } | ||
57 | } else { | ||
58 | user = cp; | ||
59 | } | ||
60 | argc--; argv++; | ||
61 | } | ||
62 | |||
63 | if (no_user && no_group) usage(id_usage); | ||
64 | |||
65 | if (user == NULL) { | ||
66 | user = xmalloc(9); | ||
67 | group = xmalloc(9); | ||
68 | if (print_real) { | ||
69 | my_getpwuid(user, getuid()); | ||
70 | my_getgrgid(group, getgid()); | ||
71 | } else { | ||
72 | my_getpwuid(user, geteuid()); | ||
73 | my_getgrgid(group, getegid()); | ||
74 | } | ||
75 | } else { | ||
76 | group = xmalloc(9); | ||
77 | gid = my_getpwnamegid(user); | ||
78 | my_getgrgid(group, gid); | ||
79 | } | ||
80 | |||
81 | if (no_group) printf("%u\n", my_getpwnam(user)); | ||
82 | else if (no_user) printf("%u\n", my_getgrnam(group)); | ||
83 | else | ||
84 | printf("uid=%u(%s) gid=%u(%s)\n", | ||
85 | my_getpwnam(user), user, my_getgrnam(group), group); | ||
86 | |||
87 | |||
88 | exit(0); | ||
89 | } | ||
90 | |||
91 | |||
92 | /* END CODE */ | ||
diff --git a/internal.h b/internal.h index a81651bec..859bee1c3 100644 --- a/internal.h +++ b/internal.h | |||
@@ -129,6 +129,7 @@ extern int halt_main(int argc, char** argv); | |||
129 | extern int head_main(int argc, char** argv); | 129 | extern int head_main(int argc, char** argv); |
130 | extern int hostid_main(int argc, char** argv); | 130 | extern int hostid_main(int argc, char** argv); |
131 | extern int hostname_main(int argc, char** argv); | 131 | extern int hostname_main(int argc, char** argv); |
132 | extern int id_main(int argc, char** argv); | ||
132 | extern int init_main(int argc, char** argv); | 133 | extern int init_main(int argc, char** argv); |
133 | extern int insmod_main(int argc, char** argv); | 134 | extern int insmod_main(int argc, char** argv); |
134 | extern int kill_main(int argc, char** argv); | 135 | extern int kill_main(int argc, char** argv); |
@@ -233,10 +234,7 @@ extern int createPath (const char *name, int mode); | |||
233 | extern int parse_mode( const char* s, mode_t* theMode); | 234 | extern int parse_mode( const char* s, mode_t* theMode); |
234 | 235 | ||
235 | extern int get_kernel_revision(void); | 236 | extern int get_kernel_revision(void); |
236 | extern uid_t my_getpwnam(char *name); | 237 | |
237 | extern gid_t my_getgrnam(char *name); | ||
238 | extern void my_getpwuid(char* name, uid_t uid); | ||
239 | extern void my_getgrgid(char* group, gid_t gid); | ||
240 | extern int get_console_fd(char* tty_name); | 238 | extern int get_console_fd(char* tty_name); |
241 | extern struct mntent *findMountPoint(const char *name, const char *table); | 239 | extern struct mntent *findMountPoint(const char *name, const char *table); |
242 | extern void write_mtab(char* blockDevice, char* directory, | 240 | extern void write_mtab(char* blockDevice, char* directory, |
@@ -253,6 +251,15 @@ extern void *xmalloc (size_t size); | |||
253 | extern int find_real_root_device_name(char* name); | 251 | extern int find_real_root_device_name(char* name); |
254 | extern char *cstring_lineFromFile(FILE *f); | 252 | extern char *cstring_lineFromFile(FILE *f); |
255 | 253 | ||
254 | /* These parse entries in /etc/passwd and /etc/group. This is desirable | ||
255 | * for BusyBox since we want to avoid using the glibc NSS stuff, which | ||
256 | * increases target size and is often not needed embedded systems. */ | ||
257 | extern uid_t my_getpwnam(char *name); | ||
258 | extern gid_t my_getgrnam(char *name); | ||
259 | extern void my_getpwuid(char *name, uid_t uid); | ||
260 | extern void my_getgrgid(char *group, gid_t gid); | ||
261 | extern gid_t my_getpwnamegid(char *name); | ||
262 | |||
256 | 263 | ||
257 | #if defined BB_INIT || defined BB_SYSLOGD | 264 | #if defined BB_INIT || defined BB_SYSLOGD |
258 | extern int device_open(char *device, int mode); | 265 | extern int device_open(char *device, int mode); |
diff --git a/loadkmap.c b/loadkmap.c index 75e52e148..2ac4273db 100644 --- a/loadkmap.c +++ b/loadkmap.c | |||
@@ -51,6 +51,7 @@ int loadkmap_main(int argc, char **argv) | |||
51 | } | 51 | } |
52 | 52 | ||
53 | read(0, buff, 7); | 53 | read(0, buff, 7); |
54 | printf("buff='%s'\n", buff); | ||
54 | if (0 != strncmp(buff, magic, 7)) { | 55 | if (0 != strncmp(buff, magic, 7)) { |
55 | fprintf(stderr, "This is not a valid binary keymap.\n"); | 56 | fprintf(stderr, "This is not a valid binary keymap.\n"); |
56 | exit(FALSE); | 57 | exit(FALSE); |
diff --git a/networking/telnet.c b/networking/telnet.c index 076728fb0..8c58521eb 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
@@ -1,6 +1,5 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | 1 | /* |
3 | * $Id: telnet.c,v 1.1 2000/02/22 17:17:45 erik Exp $ | 2 | * $Id: telnet.c,v 1.2 2000/05/01 19:10:52 erik Exp $ |
4 | * Mini telnet implementation for busybox | 3 | * Mini telnet implementation for busybox |
5 | * | 4 | * |
6 | * Copyright (C) 2000 by Randolph Chung <tausq@debian.org> | 5 | * Copyright (C) 2000 by Randolph Chung <tausq@debian.org> |
@@ -102,15 +101,15 @@ static inline void telnet_senddont(int s, int c) { SENDCOMMAND(DONT, c); } | |||
102 | static void telnet_setoptions(int s) | 101 | static void telnet_setoptions(int s) |
103 | { | 102 | { |
104 | /* | 103 | /* |
105 | telnet_senddo(s, TELOPT_SGA); TFLAG_SET(TELOPT_SGA, DO); | ||
106 | telnet_sendwill(s, TELOPT_NAWS); TFLAG_SET(TELOPT_NAWS, WILL); | 104 | telnet_sendwill(s, TELOPT_NAWS); TFLAG_SET(TELOPT_NAWS, WILL); |
107 | telnet_sendwill(s, TELOPT_TSPEED); TFLAG_SET(TELOPT_TSPEED, WILL); | 105 | telnet_sendwill(s, TELOPT_TSPEED); TFLAG_SET(TELOPT_TSPEED, WILL); |
108 | telnet_sendwill(s, TELOPT_LFLOW); TFLAG_SET(TELOPT_LFLOW, WILL); | ||
109 | telnet_sendwill(s, TELOPT_LINEMODE); TFLAG_SET(TELOPT_LINEMODE, WILL); | ||
110 | telnet_sendwill(s, TELOPT_NEW_ENVIRON); TFLAG_SET(TELOPT_NEW_ENVIRON, WILL); | 106 | telnet_sendwill(s, TELOPT_NEW_ENVIRON); TFLAG_SET(TELOPT_NEW_ENVIRON, WILL); |
111 | telnet_senddo(s, TELOPT_STATUS); TFLAG_SET(TELOPT_STATUS, DO); | 107 | telnet_senddo(s, TELOPT_STATUS); TFLAG_SET(TELOPT_STATUS, DO); |
112 | telnet_sendwill(s, TELOPT_TTYPE); TFLAG_SET(TELOPT_TTYPE, WILL); | 108 | telnet_sendwill(s, TELOPT_TTYPE); TFLAG_SET(TELOPT_TTYPE, WILL); |
113 | */ | 109 | */ |
110 | telnet_senddo(s, TELOPT_SGA); TFLAG_SET(TELOPT_SGA, DO); | ||
111 | telnet_sendwill(s, TELOPT_LFLOW); TFLAG_SET(TELOPT_LFLOW, WILL); | ||
112 | telnet_sendwill(s, TELOPT_LINEMODE); TFLAG_SET(TELOPT_LINEMODE, WILL); | ||
114 | telnet_senddo(s, TELOPT_BINARY); TFLAG_SET(TELOPT_BINARY, DO); | 113 | telnet_senddo(s, TELOPT_BINARY); TFLAG_SET(TELOPT_BINARY, DO); |
115 | telnet_sendwill(s, TELOPT_BINARY); TFLAG_SET(TELOPT_BINARY, WILL); | 114 | telnet_sendwill(s, TELOPT_BINARY); TFLAG_SET(TELOPT_BINARY, WILL); |
116 | } | 115 | } |
@@ -457,16 +456,16 @@ int main(int argc, char **argv) | |||
457 | int telnet_main(int argc, char **argv) | 456 | int telnet_main(int argc, char **argv) |
458 | #endif | 457 | #endif |
459 | { | 458 | { |
460 | int port = TELNETPORT; | 459 | int port = TELNETPORT; |
461 | 460 | ||
462 | argc--; argv++; | 461 | argc--; argv++; |
463 | if (argc < 1) usage(telnet_usage); | 462 | if (argc < 1) usage(telnet_usage); |
464 | if (argc > 1) port = atoi(argv[1]); | 463 | if (argc > 1) port = atoi(argv[1]); |
465 | telnet_init(); | 464 | telnet_init(); |
466 | atexit(telnet_shutdown); | 465 | atexit(telnet_shutdown); |
467 | 466 | ||
468 | telnet_start(argv[0], port); | 467 | telnet_start(argv[0], port); |
469 | return 0; | 468 | return 0; |
470 | } | 469 | } |
471 | 470 | ||
472 | /* | 471 | /* |
@@ -368,8 +368,10 @@ extern int tail_main(int argc, char **argv) | |||
368 | case 'h': | 368 | case 'h': |
369 | usage(tail_usage); | 369 | usage(tail_usage); |
370 | default: | 370 | default: |
371 | fprintf(stderr, "tail: invalid option -- %c\n", opt); | 371 | if ((n_units = atoi(&argv[i][1])) < 1) { |
372 | usage(tail_usage); | 372 | fprintf(stderr, "tail: invalid option -- %c\n", opt); |
373 | usage(tail_usage); | ||
374 | } | ||
373 | } | 375 | } |
374 | } else { | 376 | } else { |
375 | break; | 377 | break; |
@@ -1,6 +1,5 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | 1 | /* |
3 | * $Id: telnet.c,v 1.1 2000/02/22 17:17:45 erik Exp $ | 2 | * $Id: telnet.c,v 1.2 2000/05/01 19:10:52 erik Exp $ |
4 | * Mini telnet implementation for busybox | 3 | * Mini telnet implementation for busybox |
5 | * | 4 | * |
6 | * Copyright (C) 2000 by Randolph Chung <tausq@debian.org> | 5 | * Copyright (C) 2000 by Randolph Chung <tausq@debian.org> |
@@ -102,15 +101,15 @@ static inline void telnet_senddont(int s, int c) { SENDCOMMAND(DONT, c); } | |||
102 | static void telnet_setoptions(int s) | 101 | static void telnet_setoptions(int s) |
103 | { | 102 | { |
104 | /* | 103 | /* |
105 | telnet_senddo(s, TELOPT_SGA); TFLAG_SET(TELOPT_SGA, DO); | ||
106 | telnet_sendwill(s, TELOPT_NAWS); TFLAG_SET(TELOPT_NAWS, WILL); | 104 | telnet_sendwill(s, TELOPT_NAWS); TFLAG_SET(TELOPT_NAWS, WILL); |
107 | telnet_sendwill(s, TELOPT_TSPEED); TFLAG_SET(TELOPT_TSPEED, WILL); | 105 | telnet_sendwill(s, TELOPT_TSPEED); TFLAG_SET(TELOPT_TSPEED, WILL); |
108 | telnet_sendwill(s, TELOPT_LFLOW); TFLAG_SET(TELOPT_LFLOW, WILL); | ||
109 | telnet_sendwill(s, TELOPT_LINEMODE); TFLAG_SET(TELOPT_LINEMODE, WILL); | ||
110 | telnet_sendwill(s, TELOPT_NEW_ENVIRON); TFLAG_SET(TELOPT_NEW_ENVIRON, WILL); | 106 | telnet_sendwill(s, TELOPT_NEW_ENVIRON); TFLAG_SET(TELOPT_NEW_ENVIRON, WILL); |
111 | telnet_senddo(s, TELOPT_STATUS); TFLAG_SET(TELOPT_STATUS, DO); | 107 | telnet_senddo(s, TELOPT_STATUS); TFLAG_SET(TELOPT_STATUS, DO); |
112 | telnet_sendwill(s, TELOPT_TTYPE); TFLAG_SET(TELOPT_TTYPE, WILL); | 108 | telnet_sendwill(s, TELOPT_TTYPE); TFLAG_SET(TELOPT_TTYPE, WILL); |
113 | */ | 109 | */ |
110 | telnet_senddo(s, TELOPT_SGA); TFLAG_SET(TELOPT_SGA, DO); | ||
111 | telnet_sendwill(s, TELOPT_LFLOW); TFLAG_SET(TELOPT_LFLOW, WILL); | ||
112 | telnet_sendwill(s, TELOPT_LINEMODE); TFLAG_SET(TELOPT_LINEMODE, WILL); | ||
114 | telnet_senddo(s, TELOPT_BINARY); TFLAG_SET(TELOPT_BINARY, DO); | 113 | telnet_senddo(s, TELOPT_BINARY); TFLAG_SET(TELOPT_BINARY, DO); |
115 | telnet_sendwill(s, TELOPT_BINARY); TFLAG_SET(TELOPT_BINARY, WILL); | 114 | telnet_sendwill(s, TELOPT_BINARY); TFLAG_SET(TELOPT_BINARY, WILL); |
116 | } | 115 | } |
@@ -457,16 +456,16 @@ int main(int argc, char **argv) | |||
457 | int telnet_main(int argc, char **argv) | 456 | int telnet_main(int argc, char **argv) |
458 | #endif | 457 | #endif |
459 | { | 458 | { |
460 | int port = TELNETPORT; | 459 | int port = TELNETPORT; |
461 | 460 | ||
462 | argc--; argv++; | 461 | argc--; argv++; |
463 | if (argc < 1) usage(telnet_usage); | 462 | if (argc < 1) usage(telnet_usage); |
464 | if (argc > 1) port = atoi(argv[1]); | 463 | if (argc > 1) port = atoi(argv[1]); |
465 | telnet_init(); | 464 | telnet_init(); |
466 | atexit(telnet_shutdown); | 465 | atexit(telnet_shutdown); |
467 | 466 | ||
468 | telnet_start(argv[0], port); | 467 | telnet_start(argv[0], port); |
469 | return 0; | 468 | return 0; |
470 | } | 469 | } |
471 | 470 | ||
472 | /* | 471 | /* |
@@ -783,18 +783,27 @@ extern int parse_mode(const char *s, mode_t * theMode) | |||
783 | 783 | ||
784 | 784 | ||
785 | 785 | ||
786 | #if defined BB_CHMOD_CHOWN_CHGRP || defined BB_PS || defined BB_LS || defined BB_TAR || defined BB_ID | ||
786 | 787 | ||
787 | 788 | /* This parses entries in /etc/passwd and /etc/group. This is desirable | |
788 | #if defined BB_CHMOD_CHOWN_CHGRP || defined BB_PS || defined BB_LS || defined BB_TAR | 789 | * for BusyBox, since we want to avoid using the glibc NSS stuff, which |
789 | 790 | * increases target size and is often not needed or wanted for embedded | |
790 | /* Use this to avoid needing the glibc NSS stuff | 791 | * systems. |
791 | * This uses storage buf to hold things. | 792 | * |
792 | * */ | 793 | * /etc/passwd entries look like this: |
793 | uid_t my_getid(const char *filename, char *name, uid_t id) | 794 | * root:x:0:0:root:/root:/bin/bash |
795 | * and /etc/group entries look like this: | ||
796 | * root:x:0: | ||
797 | * | ||
798 | * This uses buf as storage to hold things. | ||
799 | * | ||
800 | */ | ||
801 | uid_t my_getid(const char *filename, char *name, uid_t id, gid_t *gid) | ||
794 | { | 802 | { |
795 | FILE *file; | 803 | FILE *file; |
796 | char *rname, *start, *end, buf[128]; | 804 | char *rname, *start, *end, buf[128]; |
797 | uid_t rid; | 805 | id_t rid; |
806 | gid_t rgid = 0; | ||
798 | 807 | ||
799 | file = fopen(filename, "r"); | 808 | file = fopen(filename, "r"); |
800 | if (file == NULL) { | 809 | if (file == NULL) { |
@@ -806,6 +815,7 @@ uid_t my_getid(const char *filename, char *name, uid_t id) | |||
806 | if (buf[0] == '#') | 815 | if (buf[0] == '#') |
807 | continue; | 816 | continue; |
808 | 817 | ||
818 | /* username/group name */ | ||
809 | start = buf; | 819 | start = buf; |
810 | end = strchr(start, ':'); | 820 | end = strchr(start, ':'); |
811 | if (end == NULL) | 821 | if (end == NULL) |
@@ -813,24 +823,32 @@ uid_t my_getid(const char *filename, char *name, uid_t id) | |||
813 | *end = '\0'; | 823 | *end = '\0'; |
814 | rname = start; | 824 | rname = start; |
815 | 825 | ||
826 | /* password */ | ||
816 | start = end + 1; | 827 | start = end + 1; |
817 | end = strchr(start, ':'); | 828 | end = strchr(start, ':'); |
818 | if (end == NULL) | 829 | if (end == NULL) |
819 | continue; | 830 | continue; |
820 | 831 | ||
832 | /* uid in passwd, gid in group */ | ||
821 | start = end + 1; | 833 | start = end + 1; |
822 | rid = (uid_t) strtol(start, &end, 10); | 834 | rid = (uid_t) strtol(start, &end, 10); |
823 | if (end == start) | 835 | if (end == start) |
824 | continue; | 836 | continue; |
825 | 837 | ||
838 | /* gid in passwd */ | ||
839 | start = end + 1; | ||
840 | rgid = (gid_t) strtol(start, &end, 10); | ||
841 | |||
826 | if (name) { | 842 | if (name) { |
827 | if (0 == strcmp(rname, name)) { | 843 | if (0 == strcmp(rname, name)) { |
844 | if (gid) *gid = rgid; | ||
828 | fclose(file); | 845 | fclose(file); |
829 | return (rid); | 846 | return (rid); |
830 | } | 847 | } |
831 | } | 848 | } |
832 | if (id != -1 && id == rid) { | 849 | if (id != -1 && id == rid) { |
833 | strncpy(name, rname, 8); | 850 | strncpy(name, rname, 8); |
851 | if (gid) *gid = rgid; | ||
834 | fclose(file); | 852 | fclose(file); |
835 | return (TRUE); | 853 | return (TRUE); |
836 | } | 854 | } |
@@ -839,30 +857,39 @@ uid_t my_getid(const char *filename, char *name, uid_t id) | |||
839 | return (-1); | 857 | return (-1); |
840 | } | 858 | } |
841 | 859 | ||
860 | /* returns a uid given a username */ | ||
842 | uid_t my_getpwnam(char *name) | 861 | uid_t my_getpwnam(char *name) |
843 | { | 862 | { |
844 | return my_getid("/etc/passwd", name, -1); | 863 | return my_getid("/etc/passwd", name, -1, NULL); |
845 | } | 864 | } |
846 | 865 | ||
866 | /* returns a gid given a group name */ | ||
847 | gid_t my_getgrnam(char *name) | 867 | gid_t my_getgrnam(char *name) |
848 | { | 868 | { |
849 | return my_getid("/etc/group", name, -1); | 869 | return my_getid("/etc/group", name, -1, NULL); |
850 | } | 870 | } |
851 | 871 | ||
872 | /* gets a username given a uid */ | ||
852 | void my_getpwuid(char *name, uid_t uid) | 873 | void my_getpwuid(char *name, uid_t uid) |
853 | { | 874 | { |
854 | my_getid("/etc/passwd", name, uid); | 875 | my_getid("/etc/passwd", name, uid, NULL); |
855 | } | 876 | } |
856 | 877 | ||
878 | /* gets a groupname given a gid */ | ||
857 | void my_getgrgid(char *group, gid_t gid) | 879 | void my_getgrgid(char *group, gid_t gid) |
858 | { | 880 | { |
859 | my_getid("/etc/group", group, gid); | 881 | my_getid("/etc/group", group, gid, NULL); |
860 | } | 882 | } |
861 | 883 | ||
884 | /* gets a gid given a user name */ | ||
885 | gid_t my_getpwnamegid(char *name) | ||
886 | { | ||
887 | gid_t gid; | ||
888 | my_getid("/etc/passwd", name, -1, &gid); | ||
889 | return gid; | ||
890 | } | ||
862 | 891 | ||
863 | #endif /* BB_CHMOD_CHOWN_CHGRP || BB_PS || BB_LS || BB_TAR */ | 892 | #endif /* BB_CHMOD_CHOWN_CHGRP || BB_PS || BB_LS || BB_TAR || BB_ID */ |
864 | |||
865 | |||
866 | 893 | ||
867 | 894 | ||
868 | #if (defined BB_CHVT) || (defined BB_DEALLOCVT) | 895 | #if (defined BB_CHVT) || (defined BB_DEALLOCVT) |