diff options
Diffstat (limited to 'contrib/ntp/ntpd/cmd_args.c')
-rw-r--r-- | contrib/ntp/ntpd/cmd_args.c | 131 |
1 files changed, 118 insertions, 13 deletions
diff --git a/contrib/ntp/ntpd/cmd_args.c b/contrib/ntp/ntpd/cmd_args.c index 9f61b4a..3ed9b66 100644 --- a/contrib/ntp/ntpd/cmd_args.c +++ b/contrib/ntp/ntpd/cmd_args.c @@ -9,13 +9,21 @@ #include "ntp_stdlib.h" #include "ntp_cmdargs.h" +#ifdef SIM +#include "ntpsim.h" +#endif /* SIM */ + /* * Definitions of things either imported from or exported to outside */ extern char const *progname; -int listen_to_virtual_ips = 0; +int listen_to_virtual_ips = 1; + +#ifdef SYS_WINNT +extern BOOL NoWinService; +#endif -static const char *ntp_options = "aAbc:dD:f:gk:l:LmnN:p:P:qr:s:t:v:V:x"; +static const char *ntp_options = "aAbB:c:C:dD:f:gi:k:l:LmnNO:p:P:qr:s:S:t:T:W:u:v:V:xY:Z:-:"; #ifdef HAVE_NETINFO extern int check_netinfo; @@ -72,18 +80,23 @@ getstartup( case 'd': case 'D': msyslog(LOG_ERR, "ntpd not compiled with -DDEBUG option - no DEBUG support"); - fprintf(stderr, "ntpd not compiled with -DDEBUG option - no DEBUG support"); + fprintf(stderr, "ntpd not compiled with -DDEBUG option - no DEBUG support\n"); ++errflg; break; #endif case 'L': - listen_to_virtual_ips = 1; + listen_to_virtual_ips = 0; break; case 'l': { FILE *new_file; - new_file = fopen(ntp_optarg, "a"); + if(strcmp(ntp_optarg, "stderr") == 0) + new_file = stderr; + else if(strcmp(ntp_optarg, "stdout") == 0) + new_file = stdout; + else + new_file = fopen(ntp_optarg, "a"); if (new_file != NULL) { NLOG(NLOG_SYSINFO) msyslog(LOG_NOTICE, "logging to file %s", ntp_optarg); @@ -104,16 +117,38 @@ getstartup( case 'n': case 'q': ++nofork; +#ifdef SYS_WINNT + NoWinService = TRUE; +#endif break; case 'N': - priority_done = strcmp(ntp_optarg, "high"); + priority_done = 0; break; case '?': ++errflg; break; + case '-': + if ( ! strcmp(ntp_optarg, "version") ) { + printf("%.80s: %.80s\n", progname, Version); + exit(0); + } else if ( ! strcmp(ntp_optarg, "help") ) { + /* usage(); */ + /* exit(0); */ + ++errflg; + } else if ( ! strcmp(ntp_optarg, "copyright") ) { + printf("unknown\n"); + exit(0); + } else { + fprintf(stderr, "%.80s: Error unknown argument '--%.80s'\n", + progname, + ntp_optarg); + exit(12); + } + break; + default: break; } @@ -126,6 +161,9 @@ getstartup( #if defined(HAVE_SCHED_SETSCHEDULER) (void) fprintf(stderr, "\t\t[ -P fixed_process_priority ]\n"); #endif +#ifdef HAVE_CLOCKCTL + (void) fprintf(stderr, "\t\t[ -u user[:group] ] [ -i chrootdir ]\n"); +#endif exit(2); } ntp_optind = 0; /* reset ntp_optind to restart ntp_getopt */ @@ -152,6 +190,7 @@ getCmdOpts( ) { extern char *config_file; + struct sockaddr_in inaddrntp; int errflg; int c; @@ -171,15 +210,15 @@ getCmdOpts( while ((c = ntp_getopt(argc, argv, ntp_options)) != EOF) { switch (c) { case 'a': - proto_config(PROTO_AUTHENTICATE, 1, 0.); + proto_config(PROTO_AUTHENTICATE, 1, 0., NULL); break; case 'A': - proto_config(PROTO_AUTHENTICATE, 0, 0.); + proto_config(PROTO_AUTHENTICATE, 0, 0., NULL); break; case 'b': - proto_config(PROTO_BROADCLIENT, 1, 0.); + proto_config(PROTO_BROADCLIENT, 1, 0., NULL); break; case 'c': @@ -214,6 +253,16 @@ getCmdOpts( allow_panic = TRUE; break; + case 'i': +#ifdef HAVE_CLOCKCTL + if (!ntp_optarg) + errflg++; + else + chrootdir = ntp_optarg; + break; +#else + errflg++; +#endif case 'k': getauthkeys(ntp_optarg); break; @@ -223,7 +272,10 @@ getCmdOpts( break; case 'm': - proto_config(PROTO_MULTICAST_ADD, htonl(INADDR_NTP), 0.); + inaddrntp.sin_family = AF_INET; + inaddrntp.sin_port = htons(NTP_PORT); + inaddrntp.sin_addr.s_addr = htonl(INADDR_NTP); + proto_config(PROTO_MULTICAST_ADD, 0, 0., (struct sockaddr_storage*)&inaddrntp); sys_bclient = 1; break; @@ -259,11 +311,24 @@ getCmdOpts( "command line broadcast delay value %s undecodable", ntp_optarg); } else { - proto_config(PROTO_BROADDELAY, 0, tmp); + proto_config(PROTO_BROADDELAY, 0, tmp, NULL); } } while (0); break; + case 'u': +#ifdef HAVE_CLOCKCTL + user = malloc(strlen(ntp_optarg) + 1); + if ((user == NULL) || (ntp_optarg == NULL)) + errflg++; + (void)strncpy(user, ntp_optarg, strlen(ntp_optarg) + 1); + group = rindex(user, ':'); + if (group) + *group++ = '\0'; /* get rid of the ':' */ +#else + errflg++; +#endif + break; case 's': stats_config(STATS_STATSDIR, ntp_optarg); break; @@ -286,13 +351,50 @@ getCmdOpts( case 'v': case 'V': set_sys_var(ntp_optarg, strlen(ntp_optarg)+1, - RW | ((c == 'V') ? DEF : 0)); + (u_short) (RW | ((c == 'V') ? DEF : 0))); break; case 'x': - allow_step = FALSE; + clock_max = 600; break; +#ifdef SIM + case 'B': + sscanf(ntp_optarg, "%lf", &ntp_node.bdly); + break; + + case 'C': + sscanf(ntp_optarg, "%lf", &ntp_node.snse); + break; + + case 'H': + sscanf(ntp_optarg, "%lf", &ntp_node.slew); + break; + + case 'O': + sscanf(ntp_optarg, "%lf", &ntp_node.clk_time); + break; + case 'S': + sscanf(ntp_optarg, "%lf", &ntp_node.sim_time); + break; + + case 'T': + sscanf(ntp_optarg, "%lf", &ntp_node.ferr); + break; + + case 'W': + sscanf(ntp_optarg, "%lf", &ntp_node.fnse); + break; + + case 'Y': + sscanf(ntp_optarg, "%lf", &ntp_node.ndly); + break; + + case 'Z': + sscanf(ntp_optarg, "%lf", &ntp_node.pdly); + break; + +#endif /* SIM */ default: errflg++; break; @@ -307,6 +409,9 @@ getCmdOpts( #if defined(HAVE_SCHED_SETSCHEDULER) (void) fprintf(stderr, "\t\t[ -P fixed_process_priority ]\n"); #endif +#ifdef HAVE_CLOCKCTL + (void) fprintf(stderr, "\t\t[ -u user[:group] ] [ -i chrootdir ]\n"); +#endif exit(2); } return; |