diff options
Diffstat (limited to 'ntpd/cmd_args.c')
-rw-r--r-- | ntpd/cmd_args.c | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/ntpd/cmd_args.c b/ntpd/cmd_args.c index 760bcede58498..7843bc317162e 100644 --- a/ntpd/cmd_args.c +++ b/ntpd/cmd_args.c @@ -87,6 +87,16 @@ getCmdOpts( droproot = 1; chrootdir = OPT_ARG( JAILDIR ); #else + fprintf(stderr, + "command line -i option (jaildir) is not supported by this binary" +# ifndef SYS_WINNT + ",\n" "can not drop root privileges. See configure options\n" + "--enable-clockctl and --enable-linuxcaps.\n"); +# else + ".\n"); +# endif + msyslog(LOG_ERR, + "command line -i option (jaildir) is not supported by this binary."); errflg++; #endif } @@ -118,8 +128,8 @@ getCmdOpts( stats_config(STATS_STATSDIR, OPT_ARG( STATSDIR )); if (HAVE_OPT( TRUSTEDKEY )) { - int ct = STACKCT_OPT( TRUSTEDKEY ); - const char** pp = STACKLST_OPT( TRUSTEDKEY ); + int ct = STACKCT_OPT( TRUSTEDKEY ); + const char** pp = STACKLST_OPT( TRUSTEDKEY ); do { u_long tkey; @@ -141,23 +151,29 @@ getCmdOpts( char *ntp_optarg = OPT_ARG( USER ); droproot = 1; - user = malloc(strlen(ntp_optarg) + 1); - if (user == NULL) { - errflg++; - } else { - (void)strncpy(user, ntp_optarg, strlen(ntp_optarg) + 1); - group = rindex(user, ':'); - if (group) - *group++ = '\0'; /* get rid of the ':' */ - } + user = emalloc(strlen(ntp_optarg) + 1); + (void)strncpy(user, ntp_optarg, strlen(ntp_optarg) + 1); + group = rindex(user, ':'); + if (group) + *group++ = '\0'; /* get rid of the ':' */ #else + fprintf(stderr, + "command line -u/--user option is not supported by this binary" +# ifndef SYS_WINNT + ",\n" "can not drop root privileges. See configure options\n" + "--enable-clockctl and --enable-linuxcaps.\n"); +# else + ".\n"); +# endif + msyslog(LOG_ERR, + "command line -u/--user option is not supported by this binary."); errflg++; #endif } if (HAVE_OPT( VAR )) { - int ct = STACKCT_OPT( VAR ); - const char** pp = STACKLST_OPT( VAR ); + int ct = STACKCT_OPT( VAR ); + const char** pp = STACKLST_OPT( VAR ); do { const char* my_ntp_optarg = *pp++; @@ -168,8 +184,8 @@ getCmdOpts( } if (HAVE_OPT( DVAR )) { - int ct = STACKCT_OPT( DVAR ); - const char** pp = STACKLST_OPT( DVAR ); + int ct = STACKCT_OPT( DVAR ); + const char** pp = STACKLST_OPT( DVAR ); do { const char* my_ntp_optarg = *pp++; @@ -188,9 +204,12 @@ getCmdOpts( if (val >= 0) interface_interval = val; else { - msyslog(LOG_ERR, - "command line interface update interval %ld must be greater or equal to 0", - val); + fprintf(stderr, + "command line interface update interval %ld must not be negative\n", + val); + msyslog(LOG_ERR, + "command line interface update interval %ld must not be negative", + val); errflg++; } } @@ -225,7 +244,8 @@ getCmdOpts( #endif /* SIM */ if (errflg || argc) { - printf("argc is <%d>\n", argc); + if (argc) + fprintf(stderr, "argc after processing is <%d>\n", argc); optionUsage(myOptions, 2); } return; |