summaryrefslogtreecommitdiff
path: root/networking/ntpd.c
diff options
context:
space:
mode:
authorDenys Vlasenko2009-11-25 14:52:47 +0100
committerDenys Vlasenko2009-11-25 14:52:47 +0100
commitb2e5fc35ebc127e2a1ac03c7ff0719b1e6b6cd6b (patch)
tree21c86016df03253513c3bbe80fc7eef71b209d68 /networking/ntpd.c
parent18221506e5aeb9c279b73bc9418b60c75b10399a (diff)
downloadbusybox-b2e5fc35ebc127e2a1ac03c7ff0719b1e6b6cd6b.zip
busybox-b2e5fc35ebc127e2a1ac03c7ff0719b1e6b6cd6b.tar.gz
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>
Diffstat (limited to 'networking/ntpd.c')
-rw-r--r--networking/ntpd.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 12e498d..e2c3506 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -7,7 +7,9 @@
*/
#include "libbb.h"
#include <netinet/ip.h> /* For IPTOS_LOWDELAY definition */
-
+#ifndef IPTOS_LOWDELAY
+# define IPTOS_LOWDELAY 0x10
+#endif
#ifndef IP_PKTINFO
# error "Sorry, your kernel has to support IP_PKTINFO"
#endif
@@ -161,10 +163,11 @@ enum {
OPT_n = (1 << 0),
OPT_g = (1 << 1),
OPT_q = (1 << 2),
+ OPT_N = (1 << 3),
/* Insert new options above this line. */
/* Non-compat options: */
- OPT_p = (1 << 3),
- OPT_l = (1 << 4),
+ OPT_p = (1 << 4),
+ OPT_l = (1 << 5) * ENABLE_FEATURE_NTPD_SERVER,
};
@@ -877,16 +880,18 @@ static NOINLINE void ntp_init(char **argv)
/* tzset(); - why? it's called automatically when needed, no? */
if (getuid())
- bb_error_msg_and_die("need root privileges");
+ bb_error_msg_and_die(bb_msg_you_must_be_root);
peers = NULL;
opt_complementary = "dd:p::"; /* d: counter, p: list */
opts = getopt32(argv,
- "ngq" /* compat */
+ "ngqN" /* compat */
"p:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */
"d" /* compat */
- "46aAbLNx", /* compat, ignored */
+ "46aAbLx", /* compat, ignored */
&peers, &G.verbose);
+ if (!(opts & (OPT_p|OPT_l)))
+ bb_show_usage();
#if ENABLE_FEATURE_NTPD_SERVER
G.listen_fd = -1;
if (opts & OPT_l) {
@@ -903,6 +908,9 @@ static NOINLINE void ntp_init(char **argv)
logmode = LOGMODE_NONE;
bb_daemonize(DAEMON_DEVNULL_STDIO);
}
+ /* I hesitate to set -20 prio. -15 should be high enough for timekeeping */
+ if (opts & OPT_N)
+ setpriority(PRIO_PROCESS, 0, -15);
/* Set some globals */
{