]> git.ozlabs.org Git - ppp.git/blob - pppd/options.c
Add in "." between hostname and domain name
[ppp.git] / pppd / options.c
1 /*
2  * options.c - handles option processing for PPP.
3  *
4  * Copyright (c) 1989 Carnegie Mellon University.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms are permitted
8  * provided that the above copyright notice and this paragraph are
9  * duplicated in all such forms and that any documentation,
10  * advertising materials, and other materials related to such
11  * distribution and use acknowledge that the software was developed
12  * by Carnegie Mellon University.  The name of the
13  * University may not be used to endorse or promote products derived
14  * from this software without specific prior written permission.
15  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18  */
19
20 #ifndef lint
21 static char rcsid[] = "$Id: options.c,v 1.22 1995/06/30 01:52:24 paulus Exp $";
22 #endif
23
24 #include <stdio.h>
25 #include <errno.h>
26 #include <unistd.h>
27 #include <limits.h>
28 #include <stdlib.h>
29 #include <termios.h>
30 #include <syslog.h>
31 #include <string.h>
32 #include <netdb.h>
33 #include <pwd.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <netinet/in.h>
37
38 #include "pppd.h"
39 #include "pathnames.h"
40 #include "patchlevel.h"
41 #include "fsm.h"
42 #include "lcp.h"
43 #include "ipcp.h"
44 #include "upap.h"
45 #include "chap.h"
46 #include "ccp.h"
47
48 #include <net/ppp-comp.h>
49
50 #define FALSE   0
51 #define TRUE    1
52
53 #if defined(ultrix) || defined(NeXT)
54 char *strdup __P((char *));
55 #endif
56
57 #ifndef GIDSET_TYPE
58 #define GIDSET_TYPE     gid_t
59 #endif
60
61 /*
62  * Option variables and default values.
63  */
64 int     debug = 0;              /* Debug flag */
65 int     kdebugflag = 0;         /* Tell kernel to print debug messages */
66 int     default_device = 1;     /* Using /dev/tty or equivalent */
67 char    devnam[MAXPATHLEN] = "/dev/tty";        /* Device name */
68 int     crtscts = 0;            /* Use hardware flow control */
69 int     modem = 1;              /* Use modem control lines */
70 int     inspeed = 0;            /* Input/Output speed requested */
71 u_int32_t netmask = 0;          /* IP netmask to set on interface */
72 int     lockflag = 0;           /* Create lock file to lock the serial dev */
73 int     nodetach = 0;           /* Don't detach from controlling tty */
74 char    *connector = NULL;      /* Script to establish physical link */
75 char    *disconnector = NULL;   /* Script to disestablish physical link */
76 char    user[MAXNAMELEN];       /* Username for PAP */
77 char    passwd[MAXSECRETLEN];   /* Password for PAP */
78 int     auth_required = 0;      /* Peer is required to authenticate */
79 int     defaultroute = 0;       /* assign default route through interface */
80 int     proxyarp = 0;           /* Set up proxy ARP entry for peer */
81 int     persist = 0;            /* Reopen link after it goes down */
82 int     uselogin = 0;           /* Use /etc/passwd for checking PAP */
83 int     lcp_echo_interval = 0;  /* Interval between LCP echo-requests */
84 int     lcp_echo_fails = 0;     /* Tolerance to unanswered echo-requests */
85 char    our_name[MAXNAMELEN];   /* Our name for authentication purposes */
86 char    remote_name[MAXNAMELEN]; /* Peer's name for authentication */
87 int     usehostname = 0;        /* Use hostname for our_name */
88 int     disable_defaultip = 0;  /* Don't use hostname for default IP adrs */
89 char    *ipparam = NULL;        /* Extra parameter for ip up/down scripts */
90 int     cryptpap;               /* Passwords in pap-secrets are encrypted */
91
92 #ifdef _linux_
93 int idle_time_limit = 0;
94 static int setidle __P((char **));
95 #endif
96
97 /*
98  * Prototypes
99  */
100 static int setdebug __P((void));
101 static int setkdebug __P((char **));
102 static int setpassive __P((void));
103 static int setsilent __P((void));
104 static int noopt __P((void));
105 static int setnovj __P((void));
106 static int setnovjccomp __P((void));
107 static int setvjslots __P((char **));
108 static int reqpap __P((void));
109 static int nopap __P((void));
110 static int setupapfile __P((char **));
111 static int nochap __P((void));
112 static int reqchap __P((void));
113 static int setspeed __P((char *));
114 static int noaccomp __P((void));
115 static int noasyncmap __P((void));
116 static int noipaddr __P((void));
117 static int nomagicnumber __P((void));
118 static int setasyncmap __P((char **));
119 static int setescape __P((char **));
120 static int setmru __P((char **));
121 static int setmtu __P((char **));
122 static int nomru __P((void));
123 static int nopcomp __P((void));
124 static int setconnector __P((char **));
125 static int setdisconnector __P((char **));
126 static int setdomain __P((char **));
127 static int setnetmask __P((char **));
128 static int setcrtscts __P((void));
129 static int setnocrtscts __P((void));
130 static int setxonxoff __P((void));
131 static int setnodetach __P((void));
132 static int setmodem __P((void));
133 static int setlocal __P((void));
134 static int setlock __P((void));
135 static int setname __P((char **));
136 static int setuser __P((char **));
137 static int setremote __P((char **));
138 static int setauth __P((void));
139 static int readfile __P((char **));
140 static int setdefaultroute __P((void));
141 static int setproxyarp __P((void));
142 static int setpersist __P((void));
143 static int setdologin __P((void));
144 static int setusehostname __P((void));
145 static int setnoipdflt __P((void));
146 static int setlcptimeout __P((char **));
147 static int setlcpterm __P((char **));
148 static int setlcpconf __P((char **));
149 static int setlcpfails __P((char **));
150 static int setipcptimeout __P((char **));
151 static int setipcpterm __P((char **));
152 static int setipcpconf __P((char **));
153 static int setipcpfails __P((char **));
154 static int setpaptimeout __P((char **));
155 static int setpapreqs __P((char **));
156 static int setpapreqtime __P((char **));
157 static int setchaptimeout __P((char **));
158 static int setchapchal __P((char **));
159 static int setchapintv __P((char **));
160 static int setipcpaccl __P((void));
161 static int setipcpaccr __P((void));
162 static int setlcpechointv __P((char **));
163 static int setlcpechofails __P((char **));
164 static int setbsdcomp __P((char **));
165 static int setnobsdcomp __P((void));
166 static int setipparam __P((char **));
167 static int setpapcrypt __P((void));
168
169 static int number_option __P((char *, u_int32_t *, int));
170 static int readable __P((int fd));
171
172 void usage();
173
174 /*
175  * Valid arguments.
176  */
177 static struct cmd {
178     char *cmd_name;
179     int num_args;
180     int (*cmd_func)();
181 } cmds[] = {
182     {"-all", 0, noopt},         /* Don't request/allow any options */
183     {"-ac", 0, noaccomp},       /* Disable Address/Control compress */
184     {"-am", 0, noasyncmap},     /* Disable asyncmap negotiation */
185     {"-as", 1, setasyncmap},    /* set the desired async map */
186     {"-d", 0, setdebug},        /* Increase debugging level */
187     {"-detach", 0, setnodetach}, /* don't fork */
188     {"-ip", 0, noipaddr},       /* Disable IP address negotiation */
189     {"-mn", 0, nomagicnumber},  /* Disable magic number negotiation */
190     {"-mru", 0, nomru},         /* Disable mru negotiation */
191     {"-p", 0, setpassive},      /* Set passive mode */
192     {"-pc", 0, nopcomp},        /* Disable protocol field compress */
193     {"+ua", 1, setupapfile},    /* Get PAP user and password from file */
194     {"+pap", 0, reqpap},        /* Require PAP auth from peer */
195     {"-pap", 0, nopap},         /* Don't allow UPAP authentication with peer */
196     {"+chap", 0, reqchap},      /* Require CHAP authentication from peer */
197     {"-chap", 0, nochap},       /* Don't allow CHAP authentication with peer */
198     {"-vj", 0, setnovj},        /* disable VJ compression */
199     {"-vjccomp", 0, setnovjccomp}, /* disable VJ connection-ID compression */
200     {"vj-max-slots", 1, setvjslots}, /* Set maximum VJ header slots */
201     {"asyncmap", 1, setasyncmap}, /* set the desired async map */
202     {"escape", 1, setescape},   /* set chars to escape on transmission */
203     {"connect", 1, setconnector}, /* A program to set up a connection */
204     {"disconnect", 1, setdisconnector}, /* program to disconnect serial dev. */
205     {"crtscts", 0, setcrtscts}, /* set h/w flow control */
206     {"-crtscts", 0, setnocrtscts}, /* clear h/w flow control */
207     {"xonxoff", 0, setxonxoff}, /* set s/w flow control */
208     {"debug", 0, setdebug},     /* Increase debugging level */
209     {"kdebug", 1, setkdebug},   /* Enable kernel-level debugging */
210     {"domain", 1, setdomain},   /* Add given domain name to hostname*/
211     {"mru", 1, setmru},         /* Set MRU value for negotiation */
212     {"mtu", 1, setmtu},         /* Set our MTU */
213     {"netmask", 1, setnetmask}, /* set netmask */
214     {"passive", 0, setpassive}, /* Set passive mode */
215     {"silent", 0, setsilent},   /* Set silent mode */
216     {"modem", 0, setmodem},     /* Use modem control lines */
217     {"local", 0, setlocal},     /* Don't use modem control lines */
218     {"lock", 0, setlock},       /* Lock serial device (with lock file) */
219     {"name", 1, setname},       /* Set local name for authentication */
220     {"user", 1, setuser},       /* Set username for PAP auth with peer */
221     {"usehostname", 0, setusehostname}, /* Must use hostname for auth. */
222     {"remotename", 1, setremote}, /* Set remote name for authentication */
223     {"auth", 0, setauth},       /* Require authentication from peer */
224     {"file", 1, readfile},      /* Take options from a file */
225     {"defaultroute", 0, setdefaultroute}, /* Add default route */
226     {"proxyarp", 0, setproxyarp}, /* Add proxy ARP entry */
227     {"persist", 0, setpersist}, /* Keep on reopening connection after close */
228     {"login", 0, setdologin},   /* Use system password database for UPAP */
229     {"noipdefault", 0, setnoipdflt}, /* Don't use name for default IP adrs */
230     {"lcp-echo-failure", 1, setlcpechofails}, /* consecutive echo failures */
231     {"lcp-echo-interval", 1, setlcpechointv}, /* time for lcp echo events */
232     {"lcp-restart", 1, setlcptimeout}, /* Set timeout for LCP */
233     {"lcp-max-terminate", 1, setlcpterm}, /* Set max #xmits for term-reqs */
234     {"lcp-max-configure", 1, setlcpconf}, /* Set max #xmits for conf-reqs */
235     {"lcp-max-failure", 1, setlcpfails}, /* Set max #conf-naks for LCP */
236     {"ipcp-restart", 1, setipcptimeout}, /* Set timeout for IPCP */
237     {"ipcp-max-terminate", 1, setipcpterm}, /* Set max #xmits for term-reqs */
238     {"ipcp-max-configure", 1, setipcpconf}, /* Set max #xmits for conf-reqs */
239     {"ipcp-max-failure", 1, setipcpfails}, /* Set max #conf-naks for IPCP */
240     {"pap-restart", 1, setpaptimeout},  /* Set retransmit timeout for PAP */
241     {"pap-max-authreq", 1, setpapreqs}, /* Set max #xmits for auth-reqs */
242     {"pap-timeout", 1, setpapreqtime},  /* Set time limit for peer PAP auth. */
243     {"chap-restart", 1, setchaptimeout}, /* Set timeout for CHAP */
244     {"chap-max-challenge", 1, setchapchal}, /* Set max #xmits for challenge */
245     {"chap-interval", 1, setchapintv}, /* Set interval for rechallenge */
246     {"ipcp-accept-local", 0, setipcpaccl}, /* Accept peer's address for us */
247     {"ipcp-accept-remote", 0, setipcpaccr}, /* Accept peer's address for it */
248     {"bsdcomp", 1, setbsdcomp},         /* request BSD-Compress */
249     {"-bsdcomp", 0, setnobsdcomp},      /* don't allow BSD-Compress */
250     {"ipparam", 1, setipparam},         /* set ip script parameter */
251     {"papcrypt", 0, setpapcrypt},       /* PAP passwords encrypted */
252 #ifdef _linux_
253     {"idle-disconnect", 1, setidle}, /* seconds for disconnect of idle IP */
254 #endif
255     {NULL, 0, NULL}
256 };
257
258
259 #ifndef IMPLEMENTATION
260 #define IMPLEMENTATION ""
261 #endif
262
263 static char *usage_string = "\
264 pppd version %s patch level %d%s\n\
265 Usage: %s [ arguments ], where arguments are:\n\
266         <device>        Communicate over the named device\n\
267         <speed>         Set the baud rate to <speed>\n\
268         <loc>:<rem>     Set the local and/or remote interface IP\n\
269                         addresses.  Either one may be omitted.\n\
270         asyncmap <n>    Set the desired async map to hex <n>\n\
271         auth            Require authentication from peer\n\
272         connect <p>     Invoke shell command <p> to set up the serial line\n\
273         crtscts         Use hardware RTS/CTS flow control\n\
274         defaultroute    Add default route through interface\n\
275         file <f>        Take options from file <f>\n\
276         modem           Use modem control lines\n\
277         mru <n>         Set MRU value to <n> for negotiation\n\
278         netmask <n>     Set interface netmask to <n>\n\
279 See pppd(8) for more options.\n\
280 ";
281
282
283 /*
284  * parse_args - parse a string of arguments, from the command
285  * line or from a file.
286  */
287 int
288 parse_args(argc, argv)
289     int argc;
290     char **argv;
291 {
292     char *arg, *val;
293     struct cmd *cmdp;
294     int ret;
295
296     while (argc > 0) {
297         arg = *argv++;
298         --argc;
299
300         /*
301          * First see if it's a command.
302          */
303         for (cmdp = cmds; cmdp->cmd_name; cmdp++)
304             if (!strcmp(arg, cmdp->cmd_name))
305                 break;
306
307         if (cmdp->cmd_name != NULL) {
308             if (argc < cmdp->num_args) {
309                 fprintf(stderr, "Too few parameters for command %s\n", arg);
310                 return 0;
311             }
312             if (!(*cmdp->cmd_func)(argv))
313                 return 0;
314             argc -= cmdp->num_args;
315             argv += cmdp->num_args;
316
317         } else {
318             /*
319              * Maybe a tty name, speed or IP address?
320              */
321             if ((ret = setdevname(arg)) == 0
322                 && (ret = setspeed(arg)) == 0
323                 && (ret = setipaddr(arg)) == 0) {
324                 fprintf(stderr, "%s: unrecognized command\n", arg);
325                 usage();
326                 return 0;
327             }
328             if (ret < 0)        /* error */
329                 return 0;
330         }
331     }
332     return 1;
333 }
334
335 /*
336  * usage - print out a message telling how to use the program.
337  */
338 void
339 usage()
340 {
341     fprintf(stderr, usage_string, VERSION, PATCHLEVEL, IMPLEMENTATION,
342             progname);
343 }
344
345 /*
346  * options_from_file - Read a string of options from a file,
347  * and interpret them.
348  */
349 int
350 options_from_file(filename, must_exist, check_prot)
351     char *filename;
352     int must_exist;
353     int check_prot;
354 {
355     FILE *f;
356     int i, newline, ret;
357     struct cmd *cmdp;
358     char *argv[MAXARGS];
359     char args[MAXARGS][MAXWORDLEN];
360     char cmd[MAXWORDLEN];
361
362     if ((f = fopen(filename, "r")) == NULL) {
363         if (!must_exist && errno == ENOENT)
364             return 1;
365         perror(filename);
366         return 0;
367     }
368     if (check_prot && !readable(fileno(f))) {
369         fprintf(stderr, "%s: access denied\n", filename);
370         fclose(f);
371         return 0;
372     }
373
374     while (getword(f, cmd, &newline, filename)) {
375         /*
376          * First see if it's a command.
377          */
378         for (cmdp = cmds; cmdp->cmd_name; cmdp++)
379             if (!strcmp(cmd, cmdp->cmd_name))
380                 break;
381
382         if (cmdp->cmd_name != NULL) {
383             for (i = 0; i < cmdp->num_args; ++i) {
384                 if (!getword(f, args[i], &newline, filename)) {
385                     fprintf(stderr,
386                             "In file %s: too few parameters for command %s\n",
387                             filename, cmd);
388                     fclose(f);
389                     return 0;
390                 }
391                 argv[i] = args[i];
392             }
393             if (!(*cmdp->cmd_func)(argv)) {
394                 fclose(f);
395                 return 0;
396             }
397
398         } else {
399             /*
400              * Maybe a tty name, speed or IP address?
401              */
402             if ((ret = setdevname(cmd)) == 0
403                 && (ret = setspeed(cmd)) == 0
404                 && (ret = setipaddr(cmd)) == 0) {
405                 fprintf(stderr, "In file %s: unrecognized command %s\n",
406                         filename, cmd);
407                 fclose(f);
408                 return 0;
409             }
410             if (ret < 0)        /* error */
411                 return 0;
412         }
413     }
414     return 1;
415 }
416
417 /*
418  * options_from_user - See if the use has a ~/.ppprc file,
419  * and if so, interpret options from it.
420  */
421 int
422 options_from_user()
423 {
424     char *user, *path, *file;
425     int ret;
426     struct passwd *pw;
427
428     pw = getpwuid(getuid());
429     if (pw == NULL || (user = pw->pw_dir) == NULL || user[0] == 0)
430         return 1;
431     file = _PATH_USEROPT;
432     path = malloc(strlen(user) + strlen(file) + 2);
433     if (path == NULL)
434         novm("init file name");
435     strcpy(path, user);
436     strcat(path, "/");
437     strcat(path, file);
438     ret = options_from_file(path, 0, 1);
439     free(path);
440     return ret;
441 }
442
443 /*
444  * options_for_tty - See if an options file exists for the serial
445  * device, and if so, interpret options from it.
446  */
447 int
448 options_for_tty()
449 {
450     char *dev, *path;
451     int ret;
452
453     dev = strrchr(devnam, '/');
454     if (dev == NULL)
455         dev = devnam;
456     else
457         ++dev;
458     if (strcmp(dev, "tty") == 0)
459         return 1;               /* don't look for /etc/ppp/options.tty */
460     path = malloc(strlen(_PATH_TTYOPT) + strlen(dev) + 1);
461     if (path == NULL)
462         novm("tty init file name");
463     strcpy(path, _PATH_TTYOPT);
464     strcat(path, dev);
465     ret = options_from_file(path, 0, 0);
466     free(path);
467     return ret;
468 }
469
470 /*
471  * readable - check if a file is readable by the real user.
472  */
473 static int
474 readable(fd)
475     int fd;
476 {
477     uid_t uid;
478     int ngroups, i;
479     struct stat sbuf;
480     GIDSET_TYPE groups[NGROUPS_MAX];
481
482     uid = getuid();
483     if (uid == 0)
484         return 1;
485     if (fstat(fd, &sbuf) != 0)
486         return 0;
487     if (sbuf.st_uid == uid)
488         return sbuf.st_mode & S_IRUSR;
489     if (sbuf.st_gid == getgid())
490         return sbuf.st_mode & S_IRGRP;
491     ngroups = getgroups(NGROUPS_MAX, groups);
492     for (i = 0; i < ngroups; ++i)
493         if (sbuf.st_gid == groups[i])
494             return sbuf.st_mode & S_IRGRP;
495     return sbuf.st_mode & S_IROTH;
496 }
497
498 /*
499  * Read a word from a file.
500  * Words are delimited by white-space or by quotes (" or ').
501  * Quotes, white-space and \ may be escaped with \.
502  * \<newline> is ignored.
503  */
504
505 int
506 getword(f, word, newlinep, filename)
507     FILE *f;
508     char *word;
509     int *newlinep;
510     char *filename;
511 {
512     int c, len, escape;
513     int quoted, comment;
514     int value, digit, got, n;
515
516 #define isoctal(c) ((c) >= '0' && (c) < '8')
517
518     *newlinep = 0;
519     len = 0;
520     escape = 0;
521     comment = 0;
522
523     /*
524      * First skip white-space and comments.
525      */
526     for (;;) {
527         c = getc(f);
528         if (c == EOF)
529             break;
530
531         /*
532          * A newline means the end of a comment; backslash-newline
533          * is ignored.  Note that we cannot have escape && comment.
534          */
535         if (c == '\n') {
536             if (!escape) {
537                 *newlinep = 1;
538                 comment = 0;
539             } else
540                 escape = 0;
541             continue;
542         }
543
544         /*
545          * Ignore characters other than newline in a comment.
546          */
547         if (comment)
548             continue;
549
550         /*
551          * If this character is escaped, we have a word start.
552          */
553         if (escape)
554             break;
555
556         /*
557          * If this is the escape character, look at the next character.
558          */
559         if (c == '\\') {
560             escape = 1;
561             continue;
562         }
563
564         /*
565          * If this is the start of a comment, ignore the rest of the line.
566          */
567         if (c == '#') {
568             comment = 1;
569             continue;
570         }
571
572         /*
573          * A non-whitespace character is the start of a word.
574          */
575         if (!isspace(c))
576             break;
577     }
578
579     /*
580      * Save the delimiter for quoted strings.
581      */
582     if (!escape && (c == '"' || c == '\'')) {
583         quoted = c;
584         c = getc(f);
585     } else
586         quoted = 0;
587
588     /*
589      * Process characters until the end of the word.
590      */
591     while (c != EOF) {
592         if (escape) {
593             /*
594              * This character is escaped: backslash-newline is ignored,
595              * various other characters indicate particular values
596              * as for C backslash-escapes.
597              */
598             escape = 0;
599             if (c == '\n') {
600                 c = getc(f);
601                 continue;
602             }
603
604             got = 0;
605             switch (c) {
606             case 'a':
607                 value = '\a';
608                 break;
609             case 'b':
610                 value = '\b';
611                 break;
612             case 'f':
613                 value = '\f';
614                 break;
615             case 'n':
616                 value = '\n';
617                 break;
618             case 'r':
619                 value = '\r';
620                 break;
621             case 's':
622                 value = ' ';
623                 break;
624             case 't':
625                 value = '\t';
626                 break;
627
628             default:
629                 if (isoctal(c)) {
630                     /*
631                      * \ddd octal sequence
632                      */
633                     value = 0;
634                     for (n = 0; n < 3 && isoctal(c); ++n) {
635                         value = (value << 3) + (c & 07);
636                         c = getc(f);
637                     }
638                     got = 1;
639                     break;
640                 }
641
642                 if (c == 'x') {
643                     /*
644                      * \x<hex_string> sequence
645                      */
646                     value = 0;
647                     c = getc(f);
648                     for (n = 0; n < 2 && isxdigit(c); ++n) {
649                         digit = toupper(c) - '0';
650                         if (digit > 10)
651                             digit += '0' + 10 - 'A';
652                         value = (value << 4) + digit;
653                         c = getc (f);
654                     }
655                     got = 1;
656                     break;
657                 }
658
659                 /*
660                  * Otherwise the character stands for itself.
661                  */
662                 value = c;
663                 break;
664             }
665
666             /*
667              * Store the resulting character for the escape sequence.
668              */
669             if (len < MAXWORDLEN-1)
670                 word[len] = value;
671             ++len;
672
673             if (!got)
674                 c = getc(f);
675             continue;
676
677         }
678
679         /*
680          * Not escaped: see if we've reached the end of the word.
681          */
682         if (quoted) {
683             if (c == quoted)
684                 break;
685         } else {
686             if (isspace(c) || c == '#') {
687                 ungetc (c, f);
688                 break;
689             }
690         }
691
692         /*
693          * Backslash starts an escape sequence.
694          */
695         if (c == '\\') {
696             escape = 1;
697             c = getc(f);
698             continue;
699         }
700
701         /*
702          * An ordinary character: store it in the word and get another.
703          */
704         if (len < MAXWORDLEN-1)
705             word[len] = c;
706         ++len;
707
708         c = getc(f);
709     }
710
711     /*
712      * End of the word: check for errors.
713      */
714     if (c == EOF) {
715         if (ferror(f)) {
716             if (errno == 0)
717                 errno = EIO;
718             perror(filename);
719             die(1);
720         }
721         /*
722          * If len is zero, then we didn't find a word before the
723          * end of the file.
724          */
725         if (len == 0)
726             return 0;
727     }
728
729     /*
730      * Warn if the word was too long, and append a terminating null.
731      */
732     if (len >= MAXWORDLEN) {
733         fprintf(stderr, "%s: warning: word in file %s too long (%.20s...)\n",
734                 progname, filename, word);
735         len = MAXWORDLEN - 1;
736     }
737     word[len] = 0;
738
739     return 1;
740
741 #undef isoctal
742
743 }
744
745 /*
746  * number_option - parse an unsigned numeric parameter for an option.
747  */
748 static int
749 number_option(str, valp, base)
750     char *str;
751     u_int32_t *valp;
752     int base;
753 {
754     char *ptr;
755
756     *valp = strtoul(str, &ptr, base);
757     if (ptr == str) {
758         fprintf(stderr, "%s: invalid number: %s\n", progname, str);
759         return 0;
760     }
761     return 1;
762 }
763
764
765 /*
766  * int_option - like number_option, but valp is int *,
767  * the base is assumed to be 0, and *valp is not changed
768  * if there is an error.
769  */
770 static int
771 int_option(str, valp)
772     char *str;
773     int *valp;
774 {
775     u_int32_t v;
776
777     if (!number_option(str, &v, 0))
778         return 0;
779     *valp = (int) v;
780     return 1;
781 }
782
783
784 /*
785  * The following procedures execute commands.
786  */
787
788 /*
789  * readfile - take commands from a file.
790  */
791 static int
792 readfile(argv)
793     char **argv;
794 {
795     return options_from_file(*argv, 1, 1);
796 }
797
798 /*
799  * setdebug - Set debug (command line argument).
800  */
801 static int
802 setdebug()
803 {
804     debug++;
805     return (1);
806 }
807
808 /*
809  * setkdebug - Set kernel debugging level.
810  */
811 static int
812 setkdebug(argv)
813     char **argv;
814 {
815     return int_option(*argv, &kdebugflag);
816 }
817
818 /*
819  * noopt - Disable all options.
820  */
821 static int
822 noopt()
823 {
824     BZERO((char *) &lcp_wantoptions[0], sizeof (struct lcp_options));
825     BZERO((char *) &lcp_allowoptions[0], sizeof (struct lcp_options));
826     BZERO((char *) &ipcp_wantoptions[0], sizeof (struct ipcp_options));
827     BZERO((char *) &ipcp_allowoptions[0], sizeof (struct ipcp_options));
828     return (1);
829 }
830
831 /*
832  * noaccomp - Disable Address/Control field compression negotiation.
833  */
834 static int
835 noaccomp()
836 {
837     lcp_wantoptions[0].neg_accompression = 0;
838     lcp_allowoptions[0].neg_accompression = 0;
839     return (1);
840 }
841
842
843 /*
844  * noasyncmap - Disable async map negotiation.
845  */
846 static int
847 noasyncmap()
848 {
849     lcp_wantoptions[0].neg_asyncmap = 0;
850     lcp_allowoptions[0].neg_asyncmap = 0;
851     return (1);
852 }
853
854
855 /*
856  * noipaddr - Disable IP address negotiation.
857  */
858 static int
859 noipaddr()
860 {
861     ipcp_wantoptions[0].neg_addr = 0;
862     ipcp_allowoptions[0].neg_addr = 0;
863     return (1);
864 }
865
866
867 /*
868  * nomagicnumber - Disable magic number negotiation.
869  */
870 static int
871 nomagicnumber()
872 {
873     lcp_wantoptions[0].neg_magicnumber = 0;
874     lcp_allowoptions[0].neg_magicnumber = 0;
875     return (1);
876 }
877
878
879 /*
880  * nomru - Disable mru negotiation.
881  */
882 static int
883 nomru()
884 {
885     lcp_wantoptions[0].neg_mru = 0;
886     lcp_allowoptions[0].neg_mru = 0;
887     return (1);
888 }
889
890
891 /*
892  * setmru - Set MRU for negotiation.
893  */
894 static int
895 setmru(argv)
896     char **argv;
897 {
898     u_int32_t mru;
899
900     if (!number_option(*argv, &mru, 0))
901         return 0;
902     lcp_wantoptions[0].mru = mru;
903     lcp_wantoptions[0].neg_mru = 1;
904     return (1);
905 }
906
907
908 /*
909  * setmru - Set the largest MTU we'll use.
910  */
911 static int
912 setmtu(argv)
913     char **argv;
914 {
915     u_int32_t mtu;
916
917     if (!number_option(*argv, &mtu, 0))
918         return 0;
919     if (mtu < MINMRU || mtu > MAXMRU) {
920         fprintf(stderr, "mtu option value of %ld is too %s\n", mtu,
921                 (mtu < MINMRU? "small": "large"));
922         return 0;
923     }
924     lcp_allowoptions[0].mru = mtu;
925     return (1);
926 }
927
928
929 /*
930  * nopcomp - Disable Protocol field compression negotiation.
931  */
932 static int
933 nopcomp()
934 {
935     lcp_wantoptions[0].neg_pcompression = 0;
936     lcp_allowoptions[0].neg_pcompression = 0;
937     return (1);
938 }
939
940
941 /*
942  * setpassive - Set passive mode (don't give up if we time out sending
943  * LCP configure-requests).
944  */
945 static int
946 setpassive()
947 {
948     lcp_wantoptions[0].passive = 1;
949     return (1);
950 }
951
952
953 /*
954  * setsilent - Set silent mode (don't start sending LCP configure-requests
955  * until we get one from the peer).
956  */
957 static int
958 setsilent()
959 {
960     lcp_wantoptions[0].silent = 1;
961     return 1;
962 }
963
964
965 /*
966  * nopap - Disable PAP authentication with peer.
967  */
968 static int
969 nopap()
970 {
971     lcp_allowoptions[0].neg_upap = 0;
972     return (1);
973 }
974
975
976 /*
977  * reqpap - Require PAP authentication from peer.
978  */
979 static int
980 reqpap()
981 {
982     lcp_wantoptions[0].neg_upap = 1;
983     auth_required = 1;
984     return 1;
985 }
986
987
988 /*
989  * setupapfile - specifies UPAP info for authenticating with peer.
990  */
991 static int
992 setupapfile(argv)
993     char **argv;
994 {
995     FILE * ufile;
996     int l;
997
998     lcp_allowoptions[0].neg_upap = 1;
999
1000     /* open user info file */
1001     if ((ufile = fopen(*argv, "r")) == NULL) {
1002         fprintf(stderr, "unable to open user login data file %s\n", *argv);
1003         return 0;
1004     }
1005     if (!readable(fileno(ufile))) {
1006         fprintf(stderr, "%s: access denied\n", *argv);
1007         return 0;
1008     }
1009     check_access(ufile, *argv);
1010
1011     /* get username */
1012     if (fgets(user, MAXNAMELEN - 1, ufile) == NULL
1013         || fgets(passwd, MAXSECRETLEN - 1, ufile) == NULL){
1014         fprintf(stderr, "Unable to read user login data file %s.\n", *argv);
1015         return 0;
1016     }
1017     fclose(ufile);
1018
1019     /* get rid of newlines */
1020     l = strlen(user);
1021     if (l > 0 && user[l-1] == '\n')
1022         user[l-1] = 0;
1023     l = strlen(passwd);
1024     if (l > 0 && passwd[l-1] == '\n')
1025         passwd[l-1] = 0;
1026
1027     return (1);
1028 }
1029
1030
1031 /*
1032  * nochap - Disable CHAP authentication with peer.
1033  */
1034 static int
1035 nochap()
1036 {
1037     lcp_allowoptions[0].neg_chap = 0;
1038     return (1);
1039 }
1040
1041
1042 /*
1043  * reqchap - Require CHAP authentication from peer.
1044  */
1045 static int
1046 reqchap()
1047 {
1048     lcp_wantoptions[0].neg_chap = 1;
1049     auth_required = 1;
1050     return (1);
1051 }
1052
1053
1054 /*
1055  * setnovj - disable vj compression
1056  */
1057 static int
1058 setnovj()
1059 {
1060     ipcp_wantoptions[0].neg_vj = 0;
1061     ipcp_allowoptions[0].neg_vj = 0;
1062     return (1);
1063 }
1064
1065
1066 /*
1067  * setnovjccomp - disable VJ connection-ID compression
1068  */
1069 static int
1070 setnovjccomp()
1071 {
1072     ipcp_wantoptions[0].cflag = 0;
1073     ipcp_allowoptions[0].cflag = 0;
1074     return 1;
1075 }
1076
1077
1078 /*
1079  * setvjslots - set maximum number of connection slots for VJ compression
1080  */
1081 static int
1082 setvjslots(argv)
1083     char **argv;
1084 {
1085     int value;
1086
1087     if (!int_option(*argv, &value))
1088         return 0;
1089     if (value < 2 || value > 16) {
1090         fprintf(stderr, "pppd: vj-max-slots value must be between 2 and 16\n");
1091         return 0;
1092     }
1093     ipcp_wantoptions [0].maxslotindex =
1094         ipcp_allowoptions[0].maxslotindex = value - 1;
1095     return 1;
1096 }
1097
1098
1099 /*
1100  * setconnector - Set a program to connect to a serial line
1101  */
1102 static int
1103 setconnector(argv)
1104     char **argv;
1105 {
1106     connector = strdup(*argv);
1107     if (connector == NULL)
1108         novm("connector string");
1109   
1110     return (1);
1111 }
1112
1113 /*
1114  * setdisconnector - Set a program to disconnect from the serial line
1115  */
1116 static int
1117 setdisconnector(argv)
1118     char **argv;
1119 {
1120     disconnector = strdup(*argv);
1121     if (disconnector == NULL)
1122         novm("disconnector string");
1123   
1124     return (1);
1125 }
1126
1127
1128 /*
1129  * setdomain - Set domain name to append to hostname 
1130  */
1131 static int
1132 setdomain(argv)
1133     char **argv;
1134 {
1135     gethostname(hostname, MAXNAMELEN);
1136     if (*argv != 0) {
1137         strncat(hostname, ".", MAXNAMELEN - strlen(hostname));
1138         strncat(hostname, *argv, MAXNAMELEN - strlen(hostname));
1139     }
1140     hostname[MAXNAMELEN-1] = 0;
1141     return (1);
1142 }
1143
1144
1145 /*
1146  * setasyncmap - add bits to asyncmap (what we request peer to escape).
1147  */
1148 static int
1149 setasyncmap(argv)
1150     char **argv;
1151 {
1152     u_int32_t asyncmap;
1153
1154     if (!number_option(*argv, &asyncmap, 16))
1155         return 0;
1156     lcp_wantoptions[0].asyncmap |= asyncmap;
1157     lcp_wantoptions[0].neg_asyncmap = 1;
1158     return(1);
1159 }
1160
1161
1162 /*
1163  * setescape - add chars to the set we escape on transmission.
1164  */
1165 static int
1166 setescape(argv)
1167     char **argv;
1168 {
1169     int n, ret;
1170     char *p, *endp;
1171
1172     p = *argv;
1173     ret = 1;
1174     while (*p) {
1175         n = strtol(p, &endp, 16);
1176         if (p == endp) {
1177             fprintf(stderr, "%s: invalid hex number: %s\n", progname, p);
1178             return 0;
1179         }
1180         p = endp;
1181         if (n < 0 || 0x20 <= n && n <= 0x3F || n == 0x5E || n > 0xFF) {
1182             fprintf(stderr, "%s: can't escape character 0x%x\n", progname, n);
1183             ret = 0;
1184         } else
1185             xmit_accm[0][n >> 5] |= 1 << (n & 0x1F);
1186         while (*p == ',' || *p == ' ')
1187             ++p;
1188     }
1189     return ret;
1190 }
1191
1192
1193 /*
1194  * setspeed - Set the speed.
1195  */
1196 static int
1197 setspeed(arg)
1198     char *arg;
1199 {
1200     char *ptr;
1201     int spd;
1202
1203     spd = strtol(arg, &ptr, 0);
1204     if (ptr == arg || *ptr != 0 || spd == 0)
1205         return 0;
1206     inspeed = spd;
1207     return 1;
1208 }
1209
1210
1211 /*
1212  * setdevname - Set the device name.
1213  */
1214 int
1215 setdevname(cp)
1216     char *cp;
1217 {
1218     struct stat statbuf;
1219     char *tty, *ttyname();
1220     char dev[MAXPATHLEN];
1221   
1222     if (strncmp("/dev/", cp, 5) != 0) {
1223         strcpy(dev, "/dev/");
1224         strncat(dev, cp, MAXPATHLEN - 5);
1225         dev[MAXPATHLEN-1] = 0;
1226         cp = dev;
1227     }
1228
1229     /*
1230      * Check if there is a device by this name.
1231      */
1232     if (stat(cp, &statbuf) < 0) {
1233         if (errno == ENOENT)
1234             return 0;
1235         syslog(LOG_ERR, cp);
1236         return -1;
1237     }
1238   
1239     (void) strncpy(devnam, cp, MAXPATHLEN);
1240     devnam[MAXPATHLEN-1] = 0;
1241     default_device = FALSE;
1242   
1243     return 1;
1244 }
1245
1246
1247 /*
1248  * setipaddr - Set the IP address
1249  */
1250 int
1251 setipaddr(arg)
1252     char *arg;
1253 {
1254     struct hostent *hp;
1255     char *colon;
1256     u_int32_t local, remote;
1257     ipcp_options *wo = &ipcp_wantoptions[0];
1258   
1259     /*
1260      * IP address pair separated by ":".
1261      */
1262     if ((colon = strchr(arg, ':')) == NULL)
1263         return 0;
1264   
1265     /*
1266      * If colon first character, then no local addr.
1267      */
1268     if (colon != arg) {
1269         *colon = '\0';
1270         if ((local = inet_addr(arg)) == -1) {
1271             if ((hp = gethostbyname(arg)) == NULL) {
1272                 fprintf(stderr, "unknown host: %s\n", arg);
1273                 return -1;
1274             } else {
1275                 local = *(u_int32_t *)hp->h_addr;
1276                 if (our_name[0] == 0) {
1277                     strncpy(our_name, arg, MAXNAMELEN);
1278                     our_name[MAXNAMELEN-1] = 0;
1279                 }
1280             }
1281         }
1282         if (bad_ip_adrs(local)) {
1283             fprintf(stderr, "bad local IP address %s\n", ip_ntoa(local));
1284             return -1;
1285         }
1286         if (local != 0)
1287             wo->ouraddr = local;
1288         *colon = ':';
1289     }
1290   
1291     /*
1292      * If colon last character, then no remote addr.
1293      */
1294     if (*++colon != '\0') {
1295         if ((remote = inet_addr(colon)) == -1) {
1296             if ((hp = gethostbyname(colon)) == NULL) {
1297                 fprintf(stderr, "unknown host: %s\n", colon);
1298                 return -1;
1299             } else {
1300                 remote = *(u_int32_t *)hp->h_addr;
1301                 if (remote_name[0] == 0) {
1302                     strncpy(remote_name, colon, MAXNAMELEN);
1303                     remote_name[MAXNAMELEN-1] = 0;
1304                 }
1305             }
1306         }
1307         if (bad_ip_adrs(remote)) {
1308             fprintf(stderr, "bad remote IP address %s\n", ip_ntoa(remote));
1309             return -1;
1310         }
1311         if (remote != 0)
1312             wo->hisaddr = remote;
1313     }
1314
1315     return 1;
1316 }
1317
1318
1319 /*
1320  * setnoipdflt - disable setipdefault()
1321  */
1322 static int
1323 setnoipdflt()
1324 {
1325     disable_defaultip = 1;
1326     return 1;
1327 }
1328
1329
1330 /*
1331  * setipcpaccl - accept peer's idea of our address
1332  */
1333 static int
1334 setipcpaccl()
1335 {
1336     ipcp_wantoptions[0].accept_local = 1;
1337     return 1;
1338 }
1339
1340
1341 /*
1342  * setipcpaccr - accept peer's idea of its address
1343  */
1344 static int
1345 setipcpaccr()
1346 {
1347     ipcp_wantoptions[0].accept_remote = 1;
1348     return 1;
1349 }
1350
1351
1352 /*
1353  * setipdefault - default our local IP address based on our hostname.
1354  */
1355 void
1356 setipdefault()
1357 {
1358     struct hostent *hp;
1359     u_int32_t local;
1360     ipcp_options *wo = &ipcp_wantoptions[0];
1361
1362     /*
1363      * If local IP address already given, don't bother.
1364      */
1365     if (wo->ouraddr != 0 || disable_defaultip)
1366         return;
1367
1368     /*
1369      * Look up our hostname (possibly with domain name appended)
1370      * and take the first IP address as our local IP address.
1371      * If there isn't an IP address for our hostname, too bad.
1372      */
1373     wo->accept_local = 1;       /* don't insist on this default value */
1374     if ((hp = gethostbyname(hostname)) == NULL)
1375         return;
1376     local = *(u_int32_t *)hp->h_addr;
1377     if (local != 0 && !bad_ip_adrs(local))
1378         wo->ouraddr = local;
1379 }
1380
1381
1382 /*
1383  * setnetmask - set the netmask to be used on the interface.
1384  */
1385 static int
1386 setnetmask(argv)
1387     char **argv;
1388 {
1389     u_int32_t mask;
1390
1391     if ((mask = inet_addr(*argv)) == -1 || (netmask & ~mask) != 0) {
1392         fprintf(stderr, "Invalid netmask %s\n", *argv);
1393         return 0;
1394     }
1395
1396     netmask = mask;
1397     return (1);
1398 }
1399
1400 static int
1401 setcrtscts()
1402 {
1403     crtscts = 1;
1404     return (1);
1405 }
1406
1407 static int
1408 setnocrtscts()
1409 {
1410     crtscts = -1;
1411     return (1);
1412 }
1413
1414 static int
1415 setxonxoff()
1416 {
1417     lcp_wantoptions[0].asyncmap |= 0x000A0000;  /* escape ^S and ^Q */
1418     lcp_wantoptions[0].neg_asyncmap = 1;
1419
1420     crtscts = 2;
1421     return (1);
1422 }
1423
1424 static int
1425 setnodetach()
1426 {
1427     nodetach = 1;
1428     return (1);
1429 }
1430
1431 static int
1432 setmodem()
1433 {
1434     modem = 1;
1435     return 1;
1436 }
1437
1438 static int
1439 setlocal()
1440 {
1441     modem = 0;
1442     return 1;
1443 }
1444
1445 static int
1446 setlock()
1447 {
1448     lockflag = 1;
1449     return 1;
1450 }
1451
1452 static int
1453 setusehostname()
1454 {
1455     usehostname = 1;
1456     return 1;
1457 }
1458
1459 static int
1460 setname(argv)
1461     char **argv;
1462 {
1463     if (our_name[0] == 0) {
1464         strncpy(our_name, argv[0], MAXNAMELEN);
1465         our_name[MAXNAMELEN-1] = 0;
1466     }
1467     return 1;
1468 }
1469
1470 static int
1471 setuser(argv)
1472     char **argv;
1473 {
1474     strncpy(user, argv[0], MAXNAMELEN);
1475     user[MAXNAMELEN-1] = 0;
1476     return 1;
1477 }
1478
1479 static int
1480 setremote(argv)
1481     char **argv;
1482 {
1483     strncpy(remote_name, argv[0], MAXNAMELEN);
1484     remote_name[MAXNAMELEN-1] = 0;
1485     return 1;
1486 }
1487
1488 static int
1489 setauth()
1490 {
1491     auth_required = 1;
1492     return 1;
1493 }
1494
1495 static int
1496 setdefaultroute()
1497 {
1498     ipcp_wantoptions[0].default_route = 1;
1499     return 1;
1500 }
1501
1502 static int
1503 setproxyarp()
1504 {
1505     ipcp_wantoptions[0].proxy_arp = 1;
1506     return 1;
1507 }
1508
1509 static int
1510 setpersist()
1511 {
1512     persist = 1;
1513     return 1;
1514 }
1515
1516 static int
1517 setdologin()
1518 {
1519     uselogin = 1;
1520     return 1;
1521 }
1522
1523 /*
1524  * Functions to set the echo interval for modem-less monitors
1525  */
1526
1527 static int
1528 setlcpechointv(argv)
1529     char **argv;
1530 {
1531     return int_option(*argv, &lcp_echo_interval);
1532 }
1533
1534 static int
1535 setlcpechofails(argv)
1536     char **argv;
1537 {
1538     return int_option(*argv, &lcp_echo_fails);
1539 }
1540
1541 /*
1542  * Functions to set timeouts, max transmits, etc.
1543  */
1544 static int
1545 setlcptimeout(argv)
1546     char **argv;
1547 {
1548     return int_option(*argv, &lcp_fsm[0].timeouttime);
1549 }
1550
1551 static int
1552 setlcpterm(argv)
1553     char **argv;
1554 {
1555     return int_option(*argv, &lcp_fsm[0].maxtermtransmits);
1556 }
1557
1558 static int
1559 setlcpconf(argv)
1560     char **argv;
1561 {
1562     return int_option(*argv, &lcp_fsm[0].maxconfreqtransmits);
1563 }
1564
1565 static int
1566 setlcpfails(argv)
1567     char **argv;
1568 {
1569     return int_option(*argv, &lcp_fsm[0].maxnakloops);
1570 }
1571
1572 static int
1573 setipcptimeout(argv)
1574     char **argv;
1575 {
1576     return int_option(*argv, &ipcp_fsm[0].timeouttime);
1577 }
1578
1579 static int
1580 setipcpterm(argv)
1581     char **argv;
1582 {
1583     return int_option(*argv, &ipcp_fsm[0].maxtermtransmits);
1584 }
1585
1586 static int
1587 setipcpconf(argv)
1588     char **argv;
1589 {
1590     return int_option(*argv, &ipcp_fsm[0].maxconfreqtransmits);
1591 }
1592
1593 static int
1594 setipcpfails(argv)
1595     char **argv;
1596 {
1597     return int_option(*argv, &lcp_fsm[0].maxnakloops);
1598 }
1599
1600 static int
1601 setpaptimeout(argv)
1602     char **argv;
1603 {
1604     return int_option(*argv, &upap[0].us_timeouttime);
1605 }
1606
1607 static int
1608 setpapreqtime(argv)
1609     char **argv;
1610 {
1611     return int_option(*argv, &upap[0].us_reqtimeout);
1612 }
1613
1614 static int
1615 setpapreqs(argv)
1616     char **argv;
1617 {
1618     return int_option(*argv, &upap[0].us_maxtransmits);
1619 }
1620
1621 static int
1622 setchaptimeout(argv)
1623     char **argv;
1624 {
1625     return int_option(*argv, &chap[0].timeouttime);
1626 }
1627
1628 static int
1629 setchapchal(argv)
1630     char **argv;
1631 {
1632     return int_option(*argv, &chap[0].max_transmits);
1633 }
1634
1635 static int
1636 setchapintv(argv)
1637     char **argv;
1638 {
1639     return int_option(*argv, &chap[0].chal_interval);
1640 }
1641
1642 static int
1643 setbsdcomp(argv)
1644     char **argv;
1645 {
1646     int rbits, abits;
1647     char *str, *endp;
1648
1649     str = *argv;
1650     abits = rbits = strtol(str, &endp, 0);
1651     if (endp != str && *endp == ',') {
1652         str = endp + 1;
1653         abits = strtol(str, &endp, 0);
1654     }
1655     if (*endp != 0 || endp == str) {
1656         fprintf(stderr, "%s: invalid argument format for bsdcomp option\n",
1657                 progname);
1658         return 0;
1659     }
1660     if (rbits != 0 && (rbits < BSD_MIN_BITS || rbits > BSD_MAX_BITS)
1661         || abits != 0 && (abits < BSD_MIN_BITS || abits > BSD_MAX_BITS)) {
1662         fprintf(stderr, "%s: bsdcomp option values must be 0 or %d .. %d\n",
1663                 progname, BSD_MIN_BITS, BSD_MAX_BITS);
1664         return 0;
1665     }
1666     if (rbits > 0) {
1667         ccp_wantoptions[0].bsd_compress = 1;
1668         ccp_wantoptions[0].bsd_bits = rbits;
1669     } else
1670         ccp_wantoptions[0].bsd_compress = 0;
1671     if (abits > 0) {
1672         ccp_allowoptions[0].bsd_compress = 1;
1673         ccp_allowoptions[0].bsd_bits = abits;
1674     } else
1675         ccp_allowoptions[0].bsd_compress = 0;
1676     return 1;
1677 }
1678
1679 static int
1680 setnobsdcomp()
1681 {
1682     ccp_wantoptions[0].bsd_compress = 0;
1683     ccp_allowoptions[0].bsd_compress = 0;
1684     return 1;
1685 }
1686
1687 static int
1688 setipparam(argv)
1689     char **argv;
1690 {
1691     ipparam = strdup(*argv);
1692     if (ipparam == NULL)
1693         novm("ipparam string");
1694
1695     return 1;
1696 }
1697
1698 static int
1699 setpapcrypt()
1700 {
1701     cryptpap = 1;
1702     return 1;
1703 }
1704
1705 #ifdef _linux_
1706 static int setidle (argv)
1707     char **argv;
1708 {
1709     return int_option(*argv, &idle_time_limit);
1710 }
1711 #endif