diff options
-rw-r--r-- | miscutils/makedevs.c | 44 | ||||
-rw-r--r-- | miscutils/watchdog.c | 34 | ||||
-rw-r--r-- | networking/ifupdown.c | 26 | ||||
-rw-r--r-- | networking/telnet.c | 36 | ||||
-rw-r--r-- | util-linux/rdate.c | 63 |
5 files changed, 43 insertions, 160 deletions
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c index e988400eb..7bfe54fc1 100644 --- a/miscutils/makedevs.c +++ b/miscutils/makedevs.c | |||
@@ -4,7 +4,6 @@ | |||
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #include <string.h> | 5 | #include <string.h> |
6 | #include <fcntl.h> | 6 | #include <fcntl.h> |
7 | #include <getopt.h> | ||
8 | #include <time.h> | 7 | #include <time.h> |
9 | #include <ctype.h> | 8 | #include <ctype.h> |
10 | #include <unistd.h> | 9 | #include <unistd.h> |
@@ -76,40 +75,20 @@ int makedevs_main(int argc, char **argv) | |||
76 | 75 | ||
77 | #elif defined CONFIG_FEATURE_MAKEDEVS_TABLE | 76 | #elif defined CONFIG_FEATURE_MAKEDEVS_TABLE |
78 | 77 | ||
79 | /* | 78 | /* Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ |
80 | * This program is free software; you can redistribute it and/or modify | ||
81 | * it under the terms of the GNU General Public License version 2 as | ||
82 | * published by the Free Software Foundation. | ||
83 | * | ||
84 | * This program is distributed in the hope that it will be useful, | ||
85 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
86 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
87 | * GNU Library General Public License for more details. | ||
88 | * | ||
89 | * You should have received a copy of the GNU General Public License | ||
90 | * along with this program; if not, write to the Free Software | ||
91 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
92 | * | ||
93 | */ | ||
94 | 79 | ||
95 | extern int makedevs_main(int argc, char **argv) | 80 | extern int makedevs_main(int argc, char **argv) |
96 | { | 81 | { |
97 | int opt; | ||
98 | FILE *table = stdin; | 82 | FILE *table = stdin; |
99 | char *rootdir = NULL; | 83 | char *rootdir = NULL; |
100 | char *line = NULL; | 84 | char *line = NULL; |
101 | int linenum = 0; | 85 | int linenum = 0; |
102 | int ret = EXIT_SUCCESS; | 86 | int ret = EXIT_SUCCESS; |
103 | 87 | ||
104 | while ((opt = getopt(argc, argv, "d:")) != -1) { | 88 | unsigned long flags; |
105 | switch(opt) { | 89 | flags = bb_getopt_ulflags(argc, argv, "d:", &line); |
106 | case 'd': | 90 | if (line) |
107 | table = bb_xfopen((line=optarg), "r"); | 91 | table = bb_xfopen(line, "r"); |
108 | break; | ||
109 | default: | ||
110 | bb_show_usage(); | ||
111 | } | ||
112 | } | ||
113 | 92 | ||
114 | if (optind >= argc || (rootdir=argv[optind])==NULL) { | 93 | if (optind >= argc || (rootdir=argv[optind])==NULL) { |
115 | bb_error_msg_and_die("root directory not specified"); | 94 | bb_error_msg_and_die("root directory not specified"); |
@@ -159,16 +138,9 @@ extern int makedevs_main(int argc, char **argv) | |||
159 | if (name[0] == '#') { | 138 | if (name[0] == '#') { |
160 | continue; | 139 | continue; |
161 | } | 140 | } |
162 | if (group) { | 141 | |
163 | gid = get_ug_id(group, bb_xgetgrnam); | 142 | gid = group ? get_ug_id(group, bb_xgetgrnam) : getgid(); |
164 | } else { | 143 | uid = user ? get_ug_id(user, bb_xgetpwnam) : getuid(); |
165 | gid = getgid(); | ||
166 | } | ||
167 | if (user) { | ||
168 | uid = get_ug_id(user, bb_xgetpwnam); | ||
169 | } else { | ||
170 | uid = getuid(); | ||
171 | } | ||
172 | full_name = concat_path_file(rootdir, name); | 144 | full_name = concat_path_file(rootdir, name); |
173 | 145 | ||
174 | if (type == 'd') { | 146 | if (type == 'd') { |
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c index 276fadebd..4b00e50c6 100644 --- a/miscutils/watchdog.c +++ b/miscutils/watchdog.c | |||
@@ -4,20 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org> | 5 | * Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | */ | 8 | */ |
22 | 9 | ||
23 | #include <stdio.h> | 10 | #include <stdio.h> |
@@ -40,19 +27,14 @@ static void watchdog_shutdown(int unused) | |||
40 | exit(0); | 27 | exit(0); |
41 | } | 28 | } |
42 | 29 | ||
43 | extern int watchdog_main(int argc, char **argv) | 30 | int watchdog_main(int argc, char **argv) |
44 | { | 31 | { |
45 | int opt; | 32 | |
46 | 33 | char *t_arg; | |
47 | while ((opt = getopt(argc, argv, "t:")) > 0) { | 34 | unsigned long flags; |
48 | switch (opt) { | 35 | flags = bb_getopt_ulflags(argc, argv, "t:", &t_arg); |
49 | case 't': | 36 | if (flags & 1) |
50 | timer_duration = bb_xgetlarg(optarg, 10, 0, INT_MAX); | 37 | timer_duration = bb_xgetlarg(t_arg, 10, 0, INT_MAX); |
51 | break; | ||
52 | default: | ||
53 | bb_show_usage(); | ||
54 | } | ||
55 | } | ||
56 | 38 | ||
57 | /* We're only interested in the watchdog device .. */ | 39 | /* We're only interested in the watchdog device .. */ |
58 | if (optind < argc - 1 || argc == 1) | 40 | if (optind < argc - 1 || argc == 1) |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index d23c9f70a..757827858 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -12,19 +12,7 @@ | |||
12 | * Lines in the interfaces file cannot wrap. | 12 | * Lines in the interfaces file cannot wrap. |
13 | * To adhere to the FHS, the default state file is /var/run/ifstate. | 13 | * To adhere to the FHS, the default state file is /var/run/ifstate. |
14 | * | 14 | * |
15 | * This program is free software; you can redistribute it and/or modify | 15 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
16 | * it under the terms of the GNU General Public License as published by | ||
17 | * the Free Software Foundation; either version 2 of the License, or | ||
18 | * (at your option) any later version. | ||
19 | * | ||
20 | * This program is distributed in the hope that it will be useful, | ||
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
23 | * GNU General Public License for more details. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License | ||
26 | * along with this program; if not, write to the Free Software | ||
27 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
28 | */ | 16 | */ |
29 | 17 | ||
30 | /* TODO: standardise execute() return codes to return 0 for success and 1 for failure */ | 18 | /* TODO: standardise execute() return codes to return 0 for success and 1 for failure */ |
@@ -819,7 +807,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |||
819 | } | 807 | } |
820 | 808 | ||
821 | /* Add the interface to the list */ | 809 | /* Add the interface to the list */ |
822 | defn->autointerfaces = llist_add_to_end(defn->autointerfaces, strdup(firstword)); | 810 | defn->autointerfaces = llist_add_to_end(defn->autointerfaces, bb_xstrdup(firstword)); |
823 | debug_noise("\nauto %s\n", firstword); | 811 | debug_noise("\nauto %s\n", firstword); |
824 | } | 812 | } |
825 | currently_processing = NONE; | 813 | currently_processing = NONE; |
@@ -1254,7 +1242,7 @@ extern int ifupdown_main(int argc, char **argv) | |||
1254 | const llist_t *list = state_list; | 1242 | const llist_t *list = state_list; |
1255 | while (list) { | 1243 | while (list) { |
1256 | new_item = xmalloc(sizeof(llist_t)); | 1244 | new_item = xmalloc(sizeof(llist_t)); |
1257 | new_item->data = strdup(list->data); | 1245 | new_item->data = bb_xstrdup(list->data); |
1258 | new_item->link = NULL; | 1246 | new_item->link = NULL; |
1259 | list = target_list; | 1247 | list = target_list; |
1260 | if (list == NULL) | 1248 | if (list == NULL) |
@@ -1273,7 +1261,7 @@ extern int ifupdown_main(int argc, char **argv) | |||
1273 | /* iface_down */ | 1261 | /* iface_down */ |
1274 | const llist_t *list = state_list; | 1262 | const llist_t *list = state_list; |
1275 | while (list) { | 1263 | while (list) { |
1276 | target_list = llist_add_to_end(target_list, strdup(list->data)); | 1264 | target_list = llist_add_to_end(target_list, bb_xstrdup(list->data)); |
1277 | list = list->link; | 1265 | list = list->link; |
1278 | } | 1266 | } |
1279 | target_list = defn->autointerfaces; | 1267 | target_list = defn->autointerfaces; |
@@ -1294,15 +1282,15 @@ extern int ifupdown_main(int argc, char **argv) | |||
1294 | int okay = 0; | 1282 | int okay = 0; |
1295 | int cmds_ret; | 1283 | int cmds_ret; |
1296 | 1284 | ||
1297 | iface = strdup(target_list->data); | 1285 | iface = bb_xstrdup(target_list->data); |
1298 | target_list = target_list->link; | 1286 | target_list = target_list->link; |
1299 | 1287 | ||
1300 | pch = strchr(iface, '='); | 1288 | pch = strchr(iface, '='); |
1301 | if (pch) { | 1289 | if (pch) { |
1302 | *pch = '\0'; | 1290 | *pch = '\0'; |
1303 | liface = strdup(pch + 1); | 1291 | liface = bb_xstrdup(pch + 1); |
1304 | } else { | 1292 | } else { |
1305 | liface = strdup(iface); | 1293 | liface = bb_xstrdup(iface); |
1306 | } | 1294 | } |
1307 | 1295 | ||
1308 | if (!force) { | 1296 | if (!force) { |
diff --git a/networking/telnet.c b/networking/telnet.c index 24160057b..d9f0e94bc 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
@@ -8,19 +8,7 @@ | |||
8 | * Created: Thu Apr 7 13:29:41 1994 too | 8 | * Created: Thu Apr 7 13:29:41 1994 too |
9 | * Last modified: Fri Jun 9 14:34:24 2000 too | 9 | * Last modified: Fri Jun 9 14:34:24 2000 too |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or modify | 11 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19 | * General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | * | 12 | * |
25 | * HISTORY | 13 | * HISTORY |
26 | * Revision 3.1 1994/04/17 11:31:54 too | 14 | * Revision 3.1 1994/04/17 11:31:54 too |
@@ -636,10 +624,6 @@ extern int telnet_main(int argc, char** argv) | |||
636 | int maxfd; | 624 | int maxfd; |
637 | #endif | 625 | #endif |
638 | 626 | ||
639 | #ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN | ||
640 | int opt; | ||
641 | #endif | ||
642 | |||
643 | #ifdef CONFIG_FEATURE_AUTOWIDTH | 627 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
644 | get_terminal_width_height(0, &win_width, &win_height); | 628 | get_terminal_width_height(0, &win_width, &win_height); |
645 | #endif | 629 | #endif |
@@ -661,20 +645,10 @@ extern int telnet_main(int argc, char** argv) | |||
661 | bb_show_usage(); | 645 | bb_show_usage(); |
662 | 646 | ||
663 | #ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN | 647 | #ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN |
664 | autologin = NULL; | 648 | unsigned long flags = bb_getopt_ulflags(argc, argv, "al:", &autologin); |
665 | while ((opt = getopt(argc, argv, "al:")) != EOF) { | 649 | if (flags & 1) |
666 | switch (opt) { | 650 | autologin = getenv("USER"); |
667 | case 'l': | 651 | |
668 | autologin = optarg; | ||
669 | break; | ||
670 | case 'a': | ||
671 | autologin = getenv("USER"); | ||
672 | break; | ||
673 | case '?': | ||
674 | bb_show_usage(); | ||
675 | break; | ||
676 | } | ||
677 | } | ||
678 | if (optind < argc) { | 652 | if (optind < argc) { |
679 | bb_lookup_host(&s_in, argv[optind++]); | 653 | bb_lookup_host(&s_in, argv[optind++]); |
680 | s_in.sin_port = bb_lookup_port((optind < argc) ? argv[optind++] : | 654 | s_in.sin_port = bb_lookup_port((optind < argc) ? argv[optind++] : |
diff --git a/util-linux/rdate.c b/util-linux/rdate.c index a73e8eebf..e2824607e 100644 --- a/util-linux/rdate.c +++ b/util-linux/rdate.c | |||
@@ -5,20 +5,7 @@ | |||
5 | * | 5 | * |
6 | * by Sterling Huxley <sterling@europa.com> | 6 | * by Sterling Huxley <sterling@europa.com> |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * Licensed under GPL v2 or later, see file License for details. |
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 | */ | 9 | */ |
23 | 10 | ||
24 | #include <sys/time.h> | 11 | #include <sys/time.h> |
@@ -27,7 +14,6 @@ | |||
27 | #include <netinet/in.h> | 14 | #include <netinet/in.h> |
28 | #include <netdb.h> | 15 | #include <netdb.h> |
29 | #include <stdio.h> | 16 | #include <stdio.h> |
30 | #include <getopt.h> | ||
31 | #include <string.h> | 17 | #include <string.h> |
32 | #include <time.h> | 18 | #include <time.h> |
33 | #include <stdlib.h> | 19 | #include <stdlib.h> |
@@ -46,14 +32,14 @@ static void socket_timeout(int sig) | |||
46 | 32 | ||
47 | static time_t askremotedate(const char *host) | 33 | static time_t askremotedate(const char *host) |
48 | { | 34 | { |
49 | unsigned long int nett, localt; | 35 | unsigned long nett; |
50 | struct sockaddr_in s_in; | 36 | struct sockaddr_in s_in; |
51 | int fd; | 37 | int fd; |
52 | 38 | ||
53 | bb_lookup_host(&s_in, host); | 39 | bb_lookup_host(&s_in, host); |
54 | s_in.sin_port = bb_lookup_port("time", "tcp", 37); | 40 | s_in.sin_port = bb_lookup_port("time", "tcp", 37); |
55 | 41 | ||
56 | /* Add a timeout for dead or non accessable servers */ | 42 | /* Add a timeout for dead or inaccessible servers */ |
57 | alarm(10); | 43 | alarm(10); |
58 | signal(SIGALRM, socket_timeout); | 44 | signal(SIGALRM, socket_timeout); |
59 | 45 | ||
@@ -61,7 +47,6 @@ static time_t askremotedate(const char *host) | |||
61 | 47 | ||
62 | if (safe_read(fd, (void *)&nett, 4) != 4) /* read time from server */ | 48 | if (safe_read(fd, (void *)&nett, 4) != 4) /* read time from server */ |
63 | bb_error_msg_and_die("%s did not send the complete time", host); | 49 | bb_error_msg_and_die("%s did not send the complete time", host); |
64 | |||
65 | close(fd); | 50 | close(fd); |
66 | 51 | ||
67 | /* convert from network byte order to local byte order. | 52 | /* convert from network byte order to local byte order. |
@@ -70,40 +55,22 @@ static time_t askremotedate(const char *host) | |||
70 | * the RFC 868 time 2,208,988,800 corresponds to 00:00 1 Jan 1970 GMT | 55 | * the RFC 868 time 2,208,988,800 corresponds to 00:00 1 Jan 1970 GMT |
71 | * Subtract the RFC 868 time to get Linux epoch | 56 | * Subtract the RFC 868 time to get Linux epoch |
72 | */ | 57 | */ |
73 | localt= ntohl(nett) - RFC_868_BIAS; | 58 | |
74 | 59 | return(ntohl(nett) - RFC_868_BIAS); | |
75 | return(localt); | ||
76 | } | 60 | } |
77 | 61 | ||
78 | int rdate_main(int argc, char **argv) | 62 | int rdate_main(int argc, char **argv) |
79 | { | 63 | { |
80 | time_t remote_time; | 64 | time_t remote_time; |
81 | int opt; | 65 | |
82 | int setdate = 1; | 66 | unsigned long flags = bb_getopt_ulflags(argc, argv, "sp"); |
83 | int printdate = 1; | 67 | |
84 | 68 | if (!flags || argc == optind) | |
85 | /* Interpret command line args */ | ||
86 | while ((opt = getopt(argc, argv, "sp")) > 0) { | ||
87 | switch (opt) { | ||
88 | case 's': | ||
89 | printdate = 0; | ||
90 | setdate = 1; | ||
91 | break; | ||
92 | case 'p': | ||
93 | printdate = 1; | ||
94 | setdate = 0; | ||
95 | break; | ||
96 | default: | ||
97 | bb_show_usage(); | ||
98 | } | ||
99 | } | ||
100 | |||
101 | if (optind == argc) | ||
102 | bb_show_usage(); | 69 | bb_show_usage(); |
103 | 70 | ||
104 | remote_time = askremotedate(argv[optind]); | 71 | remote_time = askremotedate(argv[optind]); |
105 | 72 | ||
106 | if (setdate) { | 73 | if (flags & 1) { |
107 | time_t current_time; | 74 | time_t current_time; |
108 | 75 | ||
109 | time(¤t_time); | 76 | time(¤t_time); |
@@ -112,10 +79,10 @@ int rdate_main(int argc, char **argv) | |||
112 | else | 79 | else |
113 | if (stime(&remote_time) < 0) | 80 | if (stime(&remote_time) < 0) |
114 | bb_perror_msg_and_die("Could not set time of day"); | 81 | bb_perror_msg_and_die("Could not set time of day"); |
115 | } | 82 | |
116 | 83 | /* No need to check for the -p flag as it's the only option left */ | |
117 | if (printdate) | 84 | |
118 | printf("%s", ctime(&remote_time)); | 85 | } else printf("%s", ctime(&remote_time)); |
119 | 86 | ||
120 | return EXIT_SUCCESS; | 87 | return EXIT_SUCCESS; |
121 | } | 88 | } |