~ubuntu-branches/debian/squeeze/ntp/squeeze-201010051545

« back to all changes in this revision

Viewing changes to ntpd/cmd_args.c

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2004-10-11 16:10:27 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041011161027-icyjbji8ujym633o
Tags: 1:4.2.0a-10ubuntu2
Use ntp.ubuntulinux.org instead of pool.ntp.org

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
#include "ntp_stdlib.h"
10
10
#include "ntp_cmdargs.h"
11
11
 
 
12
#ifdef SIM
 
13
#include "ntpsim.h"
 
14
#endif /* SIM */
 
15
 
12
16
/*
13
17
 * Definitions of things either imported from or exported to outside
14
18
 */
15
19
extern char const *progname;
16
 
int     listen_to_virtual_ips = 0;
17
 
 
18
 
static const char *ntp_options = "aAbc:dD:f:gk:l:LmnN:p:P:qr:s:t:v:V:x";
 
20
int     listen_to_virtual_ips = 1;
 
21
 
 
22
#ifdef SYS_WINNT
 
23
extern BOOL NoWinService;
 
24
#endif
 
25
 
 
26
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:-:";
19
27
 
20
28
#ifdef HAVE_NETINFO
21
29
extern int      check_netinfo;
72
80
                case 'd':
73
81
                case 'D':
74
82
                    msyslog(LOG_ERR, "ntpd not compiled with -DDEBUG option - no DEBUG support");
75
 
                    fprintf(stderr, "ntpd not compiled with -DDEBUG option - no DEBUG support");
 
83
                    fprintf(stderr, "ntpd not compiled with -DDEBUG option - no DEBUG support\n");
76
84
                    ++errflg;
77
85
                    break;
78
86
#endif
79
87
                case 'L':
80
 
                    listen_to_virtual_ips = 1;
 
88
                    listen_to_virtual_ips = 0;
81
89
                    break;
82
90
                case 'l':
83
91
                        {
84
92
                                FILE *new_file;
85
93
 
86
 
                                new_file = fopen(ntp_optarg, "a");
 
94
                                if(strcmp(ntp_optarg, "stderr") == 0)
 
95
                                        new_file = stderr;
 
96
                                else if(strcmp(ntp_optarg, "stdout") == 0)
 
97
                                        new_file = stdout;
 
98
                                else
 
99
                                        new_file = fopen(ntp_optarg, "a");
87
100
                                if (new_file != NULL) {
88
101
                                        NLOG(NLOG_SYSINFO)
89
102
                                                msyslog(LOG_NOTICE, "logging to file %s", ntp_optarg);
104
117
                case 'n':
105
118
                case 'q':
106
119
                    ++nofork;
 
120
#ifdef SYS_WINNT
 
121
                    NoWinService = TRUE;         
 
122
#endif
107
123
                    break;
108
124
 
109
125
                case 'N':
110
 
                    priority_done = strcmp(ntp_optarg, "high");
 
126
                    priority_done = 0;
111
127
                    break;
112
128
                        
113
129
                case '?':
114
130
                    ++errflg;
115
131
                    break;
116
132
 
 
133
            case '-':
 
134
              if ( ! strcmp(ntp_optarg, "version") ) {
 
135
                printf("%.80s: %.80s\n", progname, Version);
 
136
                exit(0);
 
137
              } else if ( ! strcmp(ntp_optarg, "help") ) {
 
138
                /* usage(); */
 
139
                /* exit(0); */
 
140
                ++errflg;
 
141
              } else if ( ! strcmp(ntp_optarg, "copyright") ) {
 
142
                printf("unknown\n");
 
143
                exit(0);
 
144
              } else {
 
145
                fprintf(stderr, "%.80s: Error unknown argument '--%.80s'\n",
 
146
                        progname,
 
147
                        ntp_optarg);
 
148
                exit(12);
 
149
              }
 
150
              break;
 
151
 
117
152
                default:
118
153
                        break;
119
154
                }
126
161
#if defined(HAVE_SCHED_SETSCHEDULER)
127
162
                (void) fprintf(stderr, "\t\t[ -P fixed_process_priority ]\n");
128
163
#endif
 
164
#ifdef HAVE_DROPROOT
 
165
                (void) fprintf(stderr, "\t\t[ -u user[:group] ] [ -i chrootdir ]\n");
 
166
#endif
129
167
                exit(2);
130
168
        }
131
169
        ntp_optind = 0; /* reset ntp_optind to restart ntp_getopt */
152
190
        )
153
191
{
154
192
        extern char *config_file;
 
193
        struct sockaddr_in inaddrntp;
155
194
        int errflg;
156
195
        int c;
157
196
 
171
210
        while ((c = ntp_getopt(argc, argv, ntp_options)) != EOF) {
172
211
                switch (c) {
173
212
                    case 'a':
174
 
                        proto_config(PROTO_AUTHENTICATE, 1, 0.);
 
213
                        proto_config(PROTO_AUTHENTICATE, 1, 0., NULL);
175
214
                        break;
176
215
 
177
216
                    case 'A':
178
 
                        proto_config(PROTO_AUTHENTICATE, 0, 0.);
 
217
                        proto_config(PROTO_AUTHENTICATE, 0, 0., NULL);
179
218
                        break;
180
219
 
181
220
                    case 'b':
182
 
                        proto_config(PROTO_BROADCLIENT, 1, 0.);
 
221
                        proto_config(PROTO_BROADCLIENT, 1, 0., NULL);
183
222
                        break;
184
223
 
185
224
                    case 'c':
214
253
                        allow_panic = TRUE;
215
254
                        break;
216
255
 
 
256
                    case 'i':
 
257
#ifdef HAVE_DROPROOT
 
258
                        droproot = 1;
 
259
                        if (!ntp_optarg)
 
260
                                errflg++;
 
261
                        else
 
262
                                chrootdir = ntp_optarg;
 
263
                        break;
 
264
#else
 
265
                        errflg++;
 
266
#endif
217
267
                    case 'k':
218
268
                        getauthkeys(ntp_optarg);
219
269
                        break;
223
273
                        break;
224
274
 
225
275
                    case 'm':
226
 
                        proto_config(PROTO_MULTICAST_ADD, htonl(INADDR_NTP), 0.);
 
276
                        inaddrntp.sin_family = AF_INET;
 
277
                        inaddrntp.sin_port = htons(NTP_PORT);
 
278
                        inaddrntp.sin_addr.s_addr = htonl(INADDR_NTP);
 
279
                        proto_config(PROTO_MULTICAST_ADD, 0, 0., (struct sockaddr_storage*)&inaddrntp);
227
280
                        sys_bclient = 1;
228
281
                        break;
229
282
 
259
312
                                                "command line broadcast delay value %s undecodable",
260
313
                                                ntp_optarg);
261
314
                                } else {
262
 
                                        proto_config(PROTO_BROADDELAY, 0, tmp);
 
315
                                        proto_config(PROTO_BROADDELAY, 0, tmp, NULL);
263
316
                                }
264
317
                        } while (0);
265
318
                        break;
266
319
                        
 
320
                    case 'u':
 
321
#ifdef HAVE_DROPROOT
 
322
                        droproot = 1;
 
323
                        if( ! ntp_optarg ) {
 
324
                                errflg++;
 
325
                        } else {
 
326
                                user = malloc(strlen(ntp_optarg) + 1);
 
327
                                if (user == NULL) {
 
328
                                        errflg++;
 
329
                                } else {
 
330
                                        (void)strncpy(user, ntp_optarg, strlen(ntp_optarg) + 1);
 
331
                                        group = rindex(user, ':');
 
332
                                        if (group)
 
333
                                                *group++ = '\0'; /* get rid of the ':' */
 
334
                                }
 
335
                        }
 
336
#else
 
337
                        errflg++;
 
338
#endif
 
339
                        break;
267
340
                    case 's':
268
341
                        stats_config(STATS_STATSDIR, ntp_optarg);
269
342
                        break;
286
359
                    case 'v':
287
360
                    case 'V':
288
361
                        set_sys_var(ntp_optarg, strlen(ntp_optarg)+1,
289
 
                            RW | ((c == 'V') ? DEF : 0));
 
362
                            (u_short) (RW | ((c == 'V') ? DEF : 0)));
290
363
                        break;
291
364
 
292
365
                    case 'x':
293
 
                        allow_step = FALSE;
 
366
                        clock_max = 600;
294
367
                        break;
295
 
 
 
368
#ifdef SIM
 
369
                case 'B':
 
370
                        sscanf(ntp_optarg, "%lf", &ntp_node.bdly);
 
371
                        break;
 
372
 
 
373
                case 'C':
 
374
                        sscanf(ntp_optarg, "%lf", &ntp_node.snse);
 
375
                        break;
 
376
 
 
377
                case 'H':
 
378
                        sscanf(ntp_optarg, "%lf", &ntp_node.slew);
 
379
                        break;
 
380
 
 
381
                case 'O':
 
382
                        sscanf(ntp_optarg, "%lf", &ntp_node.clk_time);
 
383
                        break;
 
384
 
 
385
                case 'S':
 
386
                        sscanf(ntp_optarg, "%lf", &ntp_node.sim_time);
 
387
                        break;
 
388
 
 
389
                case 'T':
 
390
                        sscanf(ntp_optarg, "%lf", &ntp_node.ferr);
 
391
                        break;
 
392
 
 
393
                case 'W':
 
394
                        sscanf(ntp_optarg, "%lf", &ntp_node.fnse);
 
395
                        break;
 
396
 
 
397
                case 'Y':
 
398
                        sscanf(ntp_optarg, "%lf", &ntp_node.ndly);
 
399
                        break;
 
400
 
 
401
                case 'Z': 
 
402
                        sscanf(ntp_optarg, "%lf", &ntp_node.pdly);
 
403
                        break;
 
404
 
 
405
#endif /* SIM */
296
406
                    default:
297
407
                        errflg++;
298
408
                        break;
307
417
#if defined(HAVE_SCHED_SETSCHEDULER)
308
418
                (void) fprintf(stderr, "\t\t[ -P fixed_process_priority ]\n");
309
419
#endif
 
420
#ifdef HAVE_DROPROOT
 
421
                (void) fprintf(stderr, "\t\t[ -u user[:group] ] [ -i chrootdir ]\n");
 
422
#endif
310
423
                exit(2);
311
424
        }
312
425
        return;