diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-11-25 14:52:47 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-11-25 14:52:47 +0100 |
commit | b2e5fc35ebc127e2a1ac03c7ff0719b1e6b6cd6b (patch) | |
tree | 21c86016df03253513c3bbe80fc7eef71b209d68 | |
parent | 18221506e5aeb9c279b73bc9418b60c75b10399a (diff) | |
download | busybox-w32-b2e5fc35ebc127e2a1ac03c7ff0719b1e6b6cd6b.tar.gz busybox-w32-b2e5fc35ebc127e2a1ac03c7ff0719b1e6b6cd6b.tar.bz2 busybox-w32-b2e5fc35ebc127e2a1ac03c7ff0719b1e6b6cd6b.zip |
ntpd: and real handling for -N, show usage w/o options; trim text
function old new delta
ntp_init 317 348 +31
bb_msg_you_must_be_root - 17 +17
xsocket 66 76 +10
changepath 195 194 -1
bb_msg_perm_denied_are_you_root 35 34 -1
send_tree 355 353 -2
count_lines 74 72 -2
must_be_root 17 - -17
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 2/4 up/down: 58/-23) Total: 35 bytes
text data bss dec hexfilename
832873 441 7548 840862 cd49ebusybox_old
832839 441 7548 840828 cd47cbusybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | include/libbb.h | 1 | ||||
-rw-r--r-- | include/usage.h | 3 | ||||
-rw-r--r-- | libbb/messages.c | 3 | ||||
-rw-r--r-- | libbb/xfuncs_printf.c | 2 | ||||
-rw-r--r-- | miscutils/crontab.c | 4 | ||||
-rw-r--r-- | networking/ntpd.c | 20 | ||||
-rw-r--r-- | networking/tcpudp.c | 2 | ||||
-rw-r--r-- | networking/traceroute.c | 2 | ||||
-rw-r--r-- | util-linux/mount.c | 10 |
9 files changed, 29 insertions, 18 deletions
diff --git a/include/libbb.h b/include/libbb.h index 1194f7eca..1f39c95e1 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1474,6 +1474,7 @@ extern const char bb_msg_write_error[]; | |||
1474 | extern const char bb_msg_unknown[]; | 1474 | extern const char bb_msg_unknown[]; |
1475 | extern const char bb_msg_can_not_create_raw_socket[]; | 1475 | extern const char bb_msg_can_not_create_raw_socket[]; |
1476 | extern const char bb_msg_perm_denied_are_you_root[]; | 1476 | extern const char bb_msg_perm_denied_are_you_root[]; |
1477 | extern const char bb_msg_you_must_be_root[]; | ||
1477 | extern const char bb_msg_requires_arg[]; | 1478 | extern const char bb_msg_requires_arg[]; |
1478 | extern const char bb_msg_invalid_arg[]; | 1479 | extern const char bb_msg_invalid_arg[]; |
1479 | extern const char bb_msg_standard_input[]; | 1480 | extern const char bb_msg_standard_input[]; |
diff --git a/include/usage.h b/include/usage.h index 461f5fca1..760e8545b 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -3219,6 +3219,9 @@ | |||
3219 | "\n -n Do not daemonize" \ | 3219 | "\n -n Do not daemonize" \ |
3220 | "\n -g Set system time even if offset is > 1000 sec" \ | 3220 | "\n -g Set system time even if offset is > 1000 sec" \ |
3221 | "\n -q Quit after clock is set" \ | 3221 | "\n -q Quit after clock is set" \ |
3222 | /* -N exists for mostly compat reasons, thus Not essential to inform */ \ | ||
3223 | /* the user that it exists: user may use nice as well */ \ | ||
3224 | /* "\n -N Run at high priority" */ \ | ||
3222 | "\n -l Run as server on port 123" \ | 3225 | "\n -l Run as server on port 123" \ |
3223 | "\n -p PEER Obtain time from PEER (may be repeated)" \ | 3226 | "\n -p PEER Obtain time from PEER (may be repeated)" \ |
3224 | 3227 | ||
diff --git a/libbb/messages.c b/libbb/messages.c index 90090283c..1d0e58720 100644 --- a/libbb/messages.c +++ b/libbb/messages.c | |||
@@ -28,7 +28,8 @@ const char bb_msg_write_error[] ALIGN1 = "write error"; | |||
28 | const char bb_msg_read_error[] ALIGN1 = "read error"; | 28 | const char bb_msg_read_error[] ALIGN1 = "read error"; |
29 | const char bb_msg_unknown[] ALIGN1 = "(unknown)"; | 29 | const char bb_msg_unknown[] ALIGN1 = "(unknown)"; |
30 | const char bb_msg_can_not_create_raw_socket[] ALIGN1 = "can't create raw socket"; | 30 | const char bb_msg_can_not_create_raw_socket[] ALIGN1 = "can't create raw socket"; |
31 | const char bb_msg_perm_denied_are_you_root[] ALIGN1 = "permission denied. (are you root?)"; | 31 | const char bb_msg_perm_denied_are_you_root[] ALIGN1 = "permission denied (are you root?)"; |
32 | const char bb_msg_you_must_be_root[] ALIGN1 = "you must be root"; | ||
32 | const char bb_msg_requires_arg[] ALIGN1 = "%s requires an argument"; | 33 | const char bb_msg_requires_arg[] ALIGN1 = "%s requires an argument"; |
33 | const char bb_msg_invalid_arg[] ALIGN1 = "invalid argument '%s' to '%s'"; | 34 | const char bb_msg_invalid_arg[] ALIGN1 = "invalid argument '%s' to '%s'"; |
34 | const char bb_msg_standard_input[] ALIGN1 = "standard input"; | 35 | const char bb_msg_standard_input[] ALIGN1 = "standard input"; |
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 644134a0e..d36284131 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -388,7 +388,7 @@ int FAST_FUNC xsocket(int domain, int type, int protocol) | |||
388 | if (domain == AF_PACKET) s = "PACKET"; | 388 | if (domain == AF_PACKET) s = "PACKET"; |
389 | if (domain == AF_NETLINK) s = "NETLINK"; | 389 | if (domain == AF_NETLINK) s = "NETLINK"; |
390 | IF_FEATURE_IPV6(if (domain == AF_INET6) s = "INET6";) | 390 | IF_FEATURE_IPV6(if (domain == AF_INET6) s = "INET6";) |
391 | bb_perror_msg_and_die("socket(AF_%s)", s); | 391 | bb_perror_msg_and_die("socket(AF_%s,%d,%d)", s, type, protocol); |
392 | #else | 392 | #else |
393 | bb_perror_msg_and_die("socket"); | 393 | bb_perror_msg_and_die("socket"); |
394 | #endif | 394 | #endif |
diff --git a/miscutils/crontab.c b/miscutils/crontab.c index 67b10f684..044440435 100644 --- a/miscutils/crontab.c +++ b/miscutils/crontab.c | |||
@@ -118,9 +118,9 @@ int crontab_main(int argc UNUSED_PARAM, char **argv) | |||
118 | argv += optind; | 118 | argv += optind; |
119 | 119 | ||
120 | if (sanitize_env_if_suid()) { /* Clears dangerous stuff, sets PATH */ | 120 | if (sanitize_env_if_suid()) { /* Clears dangerous stuff, sets PATH */ |
121 | /* run by non-root? */ | 121 | /* Run by non-root */ |
122 | if (opt_ler & (OPT_u|OPT_c)) | 122 | if (opt_ler & (OPT_u|OPT_c)) |
123 | bb_error_msg_and_die("only root can use -c or -u"); | 123 | bb_error_msg_and_die(bb_msg_you_must_be_root); |
124 | } | 124 | } |
125 | 125 | ||
126 | if (opt_ler & OPT_u) { | 126 | if (opt_ler & OPT_u) { |
diff --git a/networking/ntpd.c b/networking/ntpd.c index 12e498d48..e2c3506ed 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -7,7 +7,9 @@ | |||
7 | */ | 7 | */ |
8 | #include "libbb.h" | 8 | #include "libbb.h" |
9 | #include <netinet/ip.h> /* For IPTOS_LOWDELAY definition */ | 9 | #include <netinet/ip.h> /* For IPTOS_LOWDELAY definition */ |
10 | 10 | #ifndef IPTOS_LOWDELAY | |
11 | # define IPTOS_LOWDELAY 0x10 | ||
12 | #endif | ||
11 | #ifndef IP_PKTINFO | 13 | #ifndef IP_PKTINFO |
12 | # error "Sorry, your kernel has to support IP_PKTINFO" | 14 | # error "Sorry, your kernel has to support IP_PKTINFO" |
13 | #endif | 15 | #endif |
@@ -161,10 +163,11 @@ enum { | |||
161 | OPT_n = (1 << 0), | 163 | OPT_n = (1 << 0), |
162 | OPT_g = (1 << 1), | 164 | OPT_g = (1 << 1), |
163 | OPT_q = (1 << 2), | 165 | OPT_q = (1 << 2), |
166 | OPT_N = (1 << 3), | ||
164 | /* Insert new options above this line. */ | 167 | /* Insert new options above this line. */ |
165 | /* Non-compat options: */ | 168 | /* Non-compat options: */ |
166 | OPT_p = (1 << 3), | 169 | OPT_p = (1 << 4), |
167 | OPT_l = (1 << 4), | 170 | OPT_l = (1 << 5) * ENABLE_FEATURE_NTPD_SERVER, |
168 | }; | 171 | }; |
169 | 172 | ||
170 | 173 | ||
@@ -877,16 +880,18 @@ static NOINLINE void ntp_init(char **argv) | |||
877 | /* tzset(); - why? it's called automatically when needed, no? */ | 880 | /* tzset(); - why? it's called automatically when needed, no? */ |
878 | 881 | ||
879 | if (getuid()) | 882 | if (getuid()) |
880 | bb_error_msg_and_die("need root privileges"); | 883 | bb_error_msg_and_die(bb_msg_you_must_be_root); |
881 | 884 | ||
882 | peers = NULL; | 885 | peers = NULL; |
883 | opt_complementary = "dd:p::"; /* d: counter, p: list */ | 886 | opt_complementary = "dd:p::"; /* d: counter, p: list */ |
884 | opts = getopt32(argv, | 887 | opts = getopt32(argv, |
885 | "ngq" /* compat */ | 888 | "ngqN" /* compat */ |
886 | "p:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */ | 889 | "p:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */ |
887 | "d" /* compat */ | 890 | "d" /* compat */ |
888 | "46aAbLNx", /* compat, ignored */ | 891 | "46aAbLx", /* compat, ignored */ |
889 | &peers, &G.verbose); | 892 | &peers, &G.verbose); |
893 | if (!(opts & (OPT_p|OPT_l))) | ||
894 | bb_show_usage(); | ||
890 | #if ENABLE_FEATURE_NTPD_SERVER | 895 | #if ENABLE_FEATURE_NTPD_SERVER |
891 | G.listen_fd = -1; | 896 | G.listen_fd = -1; |
892 | if (opts & OPT_l) { | 897 | if (opts & OPT_l) { |
@@ -903,6 +908,9 @@ static NOINLINE void ntp_init(char **argv) | |||
903 | logmode = LOGMODE_NONE; | 908 | logmode = LOGMODE_NONE; |
904 | bb_daemonize(DAEMON_DEVNULL_STDIO); | 909 | bb_daemonize(DAEMON_DEVNULL_STDIO); |
905 | } | 910 | } |
911 | /* I hesitate to set -20 prio. -15 should be high enough for timekeeping */ | ||
912 | if (opts & OPT_N) | ||
913 | setpriority(PRIO_PROCESS, 0, -15); | ||
906 | 914 | ||
907 | /* Set some globals */ | 915 | /* Set some globals */ |
908 | { | 916 | { |
diff --git a/networking/tcpudp.c b/networking/tcpudp.c index 25b3319ec..d0db33b79 100644 --- a/networking/tcpudp.c +++ b/networking/tcpudp.c | |||
@@ -239,7 +239,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv) | |||
239 | client = 0; | 239 | client = 0; |
240 | if ((getuid() == 0) && !(opts & OPT_u)) { | 240 | if ((getuid() == 0) && !(opts & OPT_u)) { |
241 | xfunc_exitcode = 100; | 241 | xfunc_exitcode = 100; |
242 | bb_error_msg_and_die("-U ssluser must be set when running as root"); | 242 | bb_error_msg_and_die(bb_msg_you_must_be_root); |
243 | } | 243 | } |
244 | if (opts & OPT_u) | 244 | if (opts & OPT_u) |
245 | if (!uidgid_get(&sslugid, ssluser, 1)) { | 245 | if (!uidgid_get(&sslugid, ssluser, 1)) { |
diff --git a/networking/traceroute.c b/networking/traceroute.c index e9f3cc6c9..110bdfa76 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -835,7 +835,7 @@ common_traceroute_main(int op, char **argv) | |||
835 | * probe (e.g., on a multi-homed host). | 835 | * probe (e.g., on a multi-homed host). |
836 | */ | 836 | */ |
837 | if (getuid() != 0) | 837 | if (getuid() != 0) |
838 | bb_error_msg_and_die("you must be root to use -s"); | 838 | bb_error_msg_and_die(bb_msg_you_must_be_root); |
839 | } | 839 | } |
840 | if (op & OPT_WAITTIME) | 840 | if (op & OPT_WAITTIME) |
841 | waittime = xatou_range(waittime_str, 1, 24 * 60 * 60); | 841 | waittime = xatou_range(waittime_str, 1, 24 * 60 * 60); |
diff --git a/util-linux/mount.c b/util-linux/mount.c index 271e691e7..d27d65f80 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -1801,8 +1801,6 @@ static int match_opt(const char *fs_opt, const char *O_opt) | |||
1801 | 1801 | ||
1802 | // Parse options, if necessary parse fstab/mtab, and call singlemount for | 1802 | // Parse options, if necessary parse fstab/mtab, and call singlemount for |
1803 | // each directory to be mounted. | 1803 | // each directory to be mounted. |
1804 | static const char must_be_root[] ALIGN1 = "you must be root"; | ||
1805 | |||
1806 | int mount_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 1804 | int mount_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
1807 | int mount_main(int argc UNUSED_PARAM, char **argv) | 1805 | int mount_main(int argc UNUSED_PARAM, char **argv) |
1808 | { | 1806 | { |
@@ -1871,7 +1869,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
1871 | // argument when we get it. | 1869 | // argument when we get it. |
1872 | if (argv[1]) { | 1870 | if (argv[1]) { |
1873 | if (nonroot) | 1871 | if (nonroot) |
1874 | bb_error_msg_and_die(must_be_root); | 1872 | bb_error_msg_and_die(bb_msg_you_must_be_root); |
1875 | mtpair->mnt_fsname = argv[0]; | 1873 | mtpair->mnt_fsname = argv[0]; |
1876 | mtpair->mnt_dir = argv[1]; | 1874 | mtpair->mnt_dir = argv[1]; |
1877 | mtpair->mnt_type = fstype; | 1875 | mtpair->mnt_type = fstype; |
@@ -1888,7 +1886,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
1888 | 1886 | ||
1889 | i = parse_mount_options(cmdopts, NULL); // FIXME: should be "long", not "int" | 1887 | i = parse_mount_options(cmdopts, NULL); // FIXME: should be "long", not "int" |
1890 | if (nonroot && (i & ~MS_SILENT)) // Non-root users cannot specify flags | 1888 | if (nonroot && (i & ~MS_SILENT)) // Non-root users cannot specify flags |
1891 | bb_error_msg_and_die(must_be_root); | 1889 | bb_error_msg_and_die(bb_msg_you_must_be_root); |
1892 | 1890 | ||
1893 | // If we have a shared subtree flag, don't worry about fstab or mtab. | 1891 | // If we have a shared subtree flag, don't worry about fstab or mtab. |
1894 | if (ENABLE_FEATURE_MOUNT_FLAGS | 1892 | if (ENABLE_FEATURE_MOUNT_FLAGS |
@@ -1947,7 +1945,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
1947 | // No, mount -a won't mount anything, | 1945 | // No, mount -a won't mount anything, |
1948 | // even user mounts, for mere humans | 1946 | // even user mounts, for mere humans |
1949 | if (nonroot) | 1947 | if (nonroot) |
1950 | bb_error_msg_and_die(must_be_root); | 1948 | bb_error_msg_and_die(bb_msg_you_must_be_root); |
1951 | 1949 | ||
1952 | // Does type match? (NULL matches always) | 1950 | // Does type match? (NULL matches always) |
1953 | if (!match_fstype(mtcur, fstype)) | 1951 | if (!match_fstype(mtcur, fstype)) |
@@ -2012,7 +2010,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv) | |||
2012 | // fstab must have "users" or "user" | 2010 | // fstab must have "users" or "user" |
2013 | l = parse_mount_options(mtcur->mnt_opts, NULL); | 2011 | l = parse_mount_options(mtcur->mnt_opts, NULL); |
2014 | if (!(l & MOUNT_USERS)) | 2012 | if (!(l & MOUNT_USERS)) |
2015 | bb_error_msg_and_die(must_be_root); | 2013 | bb_error_msg_and_die(bb_msg_you_must_be_root); |
2016 | } | 2014 | } |
2017 | 2015 | ||
2018 | // Mount the last thing we found | 2016 | // Mount the last thing we found |