1/* 2 * cmd_args.c = command-line argument processing 3 */ 4#ifdef HAVE_CONFIG_H 5# include <config.h> 6#endif 7 8#include "ntpd.h" --- 73 unchanged lines hidden (view full) --- 82 if (HAVE_OPT( PANICGATE )) 83 allow_panic = TRUE; 84 85 if (HAVE_OPT( JAILDIR )) { 86#ifdef HAVE_DROPROOT 87 droproot = 1; 88 chrootdir = OPT_ARG( JAILDIR ); 89#else |
90 fprintf(stderr, 91 "command line -i option (jaildir) is not supported by this binary" 92# ifndef SYS_WINNT 93 ",\n" "can not drop root privileges. See configure options\n" 94 "--enable-clockctl and --enable-linuxcaps.\n"); 95# else 96 ".\n"); 97# endif 98 msyslog(LOG_ERR, 99 "command line -i option (jaildir) is not supported by this binary."); |
100 errflg++; 101#endif 102 } 103 104 if (HAVE_OPT( KEYFILE )) 105 getauthkeys(OPT_ARG( KEYFILE )); 106 107 if (HAVE_OPT( PIDFILE )) --- 15 unchanged lines hidden (view full) --- 123 proto_config(PROTO_BROADDELAY, 0, tmp, NULL); 124 } 125 } while (0); 126 127 if (HAVE_OPT( STATSDIR )) 128 stats_config(STATS_STATSDIR, OPT_ARG( STATSDIR )); 129 130 if (HAVE_OPT( TRUSTEDKEY )) { |
131 int ct = STACKCT_OPT( TRUSTEDKEY ); 132 const char** pp = STACKLST_OPT( TRUSTEDKEY ); |
133 134 do { 135 u_long tkey; 136 const char* p = *pp++; 137 138 tkey = (int)atol(p); 139 if (tkey == 0 || tkey > NTP_MAXKEY) { 140 msyslog(LOG_ERR, --- 5 unchanged lines hidden (view full) --- 146 } while (--ct > 0); 147 } 148 149 if (HAVE_OPT( USER )) { 150#ifdef HAVE_DROPROOT 151 char *ntp_optarg = OPT_ARG( USER ); 152 153 droproot = 1; |
154 user = emalloc(strlen(ntp_optarg) + 1); 155 (void)strncpy(user, ntp_optarg, strlen(ntp_optarg) + 1); 156 group = rindex(user, ':'); 157 if (group) 158 *group++ = '\0'; /* get rid of the ':' */ |
159#else |
160 fprintf(stderr, 161 "command line -u/--user option is not supported by this binary" 162# ifndef SYS_WINNT 163 ",\n" "can not drop root privileges. See configure options\n" 164 "--enable-clockctl and --enable-linuxcaps.\n"); 165# else 166 ".\n"); 167# endif 168 msyslog(LOG_ERR, 169 "command line -u/--user option is not supported by this binary."); |
170 errflg++; 171#endif 172 } 173 174 if (HAVE_OPT( VAR )) { |
175 int ct = STACKCT_OPT( VAR ); 176 const char** pp = STACKLST_OPT( VAR ); |
177 178 do { 179 const char* my_ntp_optarg = *pp++; 180 181 set_sys_var(my_ntp_optarg, strlen(my_ntp_optarg)+1, 182 (u_short) (RW)); 183 } while (--ct > 0); 184 } 185 186 if (HAVE_OPT( DVAR )) { |
187 int ct = STACKCT_OPT( DVAR ); 188 const char** pp = STACKLST_OPT( DVAR ); |
189 190 do { 191 const char* my_ntp_optarg = *pp++; 192 193 set_sys_var(my_ntp_optarg, strlen(my_ntp_optarg)+1, 194 (u_short) (RW | DEF)); 195 } while (--ct > 0); 196 } 197 198 if (HAVE_OPT( SLEW )) 199 clock_max = 600; 200 201 if (HAVE_OPT( UPDATEINTERVAL )) { 202 long val = OPT_VALUE_UPDATEINTERVAL; 203 204 if (val >= 0) 205 interface_interval = val; 206 else { |
207 fprintf(stderr, 208 "command line interface update interval %ld must not be negative\n", 209 val); 210 msyslog(LOG_ERR, 211 "command line interface update interval %ld must not be negative", 212 val); |
213 errflg++; 214 } 215 } 216#ifdef SIM 217 if (HAVE_OPT( SIMBROADCASTDELAY )) 218 sscanf(OPT_ARG( SIMBROADCASTDELAY ), "%lf", &ntp_node.bdly); 219 220 if (HAVE_OPT( PHASENOISE )) --- 18 unchanged lines hidden (view full) --- 239 sscanf(OPT_ARG( NDELAY ), "%lf", &ntp_node.ndly); 240 241 if (HAVE_OPT( PDELAY )) 242 sscanf(OPT_ARG( PDELAY ), "%lf", &ntp_node.pdly); 243 244#endif /* SIM */ 245 246 if (errflg || argc) { |
247 if (argc) 248 fprintf(stderr, "argc after processing is <%d>\n", argc); |
249 optionUsage(myOptions, 2); 250 } 251 return; 252} |