aboutsummaryrefslogtreecommitdiff
path: root/networking/ntpd.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-11-25 14:52:47 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-11-25 14:52:47 +0100
commitb2e5fc35ebc127e2a1ac03c7ff0719b1e6b6cd6b (patch)
tree21c86016df03253513c3bbe80fc7eef71b209d68 /networking/ntpd.c
parent18221506e5aeb9c279b73bc9418b60c75b10399a (diff)
downloadbusybox-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>
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 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 {