]> git.ozlabs.org Git - ppp.git/blob - pppd/options.c
save and restore window size settings
[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.23 1995/07/04 12:33:01 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         if (**argv != '.')
1138             strncat(hostname, ".", MAXNAMELEN - strlen(hostname));
1139         strncat(hostname, *argv, MAXNAMELEN - strlen(hostname));
1140     }
1141     hostname[MAXNAMELEN-1] = 0;
1142     return (1);
1143 }
1144
1145
1146 /*
1147  * setasyncmap - add bits to asyncmap (what we request peer to escape).
1148  */
1149 static int
1150 setasyncmap(argv)
1151     char **argv;
1152 {
1153     u_int32_t asyncmap;
1154
1155     if (!number_option(*argv, &asyncmap, 16))
1156         return 0;
1157     lcp_wantoptions[0].asyncmap |= asyncmap;
1158     lcp_wantoptions[0].neg_asyncmap = 1;
1159     return(1);
1160 }
1161
1162
1163 /*
1164  * setescape - add chars to the set we escape on transmission.
1165  */
1166 static int
1167 setescape(argv)
1168     char **argv;
1169 {
1170     int n, ret;
1171     char *p, *endp;
1172
1173     p = *argv;
1174     ret = 1;
1175     while (*p) {
1176         n = strtol(p, &endp, 16);
1177         if (p == endp) {
1178             fprintf(stderr, "%s: invalid hex number: %s\n", progname, p);
1179             return 0;
1180         }
1181         p = endp;
1182         if (n < 0 || 0x20 <= n && n <= 0x3F || n == 0x5E || n > 0xFF) {
1183             fprintf(stderr, "%s: can't escape character 0x%x\n", progname, n);
1184             ret = 0;
1185         } else
1186             xmit_accm[0][n >> 5] |= 1 << (n & 0x1F);
1187         while (*p == ',' || *p == ' ')
1188             ++p;
1189     }
1190     return ret;
1191 }
1192
1193
1194 /*
1195  * setspeed - Set the speed.
1196  */
1197 static int
1198 setspeed(arg)
1199     char *arg;
1200 {
1201     char *ptr;
1202     int spd;
1203
1204     spd = strtol(arg, &ptr, 0);
1205     if (ptr == arg || *ptr != 0 || spd == 0)
1206         return 0;
1207     inspeed = spd;
1208     return 1;
1209 }
1210
1211
1212 /*
1213  * setdevname - Set the device name.
1214  */
1215 int
1216 setdevname(cp)
1217     char *cp;
1218 {
1219     struct stat statbuf;
1220     char *tty, *ttyname();
1221     char dev[MAXPATHLEN];
1222   
1223     if (strncmp("/dev/", cp, 5) != 0) {
1224         strcpy(dev, "/dev/");
1225         strncat(dev, cp, MAXPATHLEN - 5);
1226         dev[MAXPATHLEN-1] = 0;
1227         cp = dev;
1228     }
1229
1230     /*
1231      * Check if there is a device by this name.
1232      */
1233     if (stat(cp, &statbuf) < 0) {
1234         if (errno == ENOENT)
1235             return 0;
1236         syslog(LOG_ERR, cp);
1237         return -1;
1238     }
1239   
1240     (void) strncpy(devnam, cp, MAXPATHLEN);
1241     devnam[MAXPATHLEN-1] = 0;
1242     default_device = FALSE;
1243   
1244     return 1;
1245 }
1246
1247
1248 /*
1249  * setipaddr - Set the IP address
1250  */
1251 int
1252 setipaddr(arg)
1253     char *arg;
1254 {
1255     struct hostent *hp;
1256     char *colon;
1257     u_int32_t local, remote;
1258     ipcp_options *wo = &ipcp_wantoptions[0];
1259   
1260     /*
1261      * IP address pair separated by ":".
1262      */
1263     if ((colon = strchr(arg, ':')) == NULL)
1264         return 0;
1265   
1266     /*
1267      * If colon first character, then no local addr.
1268      */
1269     if (colon != arg) {
1270         *colon = '\0';
1271         if ((local = inet_addr(arg)) == -1) {
1272             if ((hp = gethostbyname(arg)) == NULL) {
1273                 fprintf(stderr, "unknown host: %s\n", arg);
1274                 return -1;
1275             } else {
1276                 local = *(u_int32_t *)hp->h_addr;
1277                 if (our_name[0] == 0) {
1278                     strncpy(our_name, arg, MAXNAMELEN);
1279                     our_name[MAXNAMELEN-1] = 0;
1280                 }
1281             }
1282         }
1283         if (bad_ip_adrs(local)) {
1284             fprintf(stderr, "bad local IP address %s\n", ip_ntoa(local));
1285             return -1;
1286         }
1287         if (local != 0)
1288             wo->ouraddr = local;
1289         *colon = ':';
1290     }
1291   
1292     /*
1293      * If colon last character, then no remote addr.
1294      */
1295     if (*++colon != '\0') {
1296         if ((remote = inet_addr(colon)) == -1) {
1297             if ((hp = gethostbyname(colon)) == NULL) {
1298                 fprintf(stderr, "unknown host: %s\n", colon);
1299                 return -1;
1300             } else {
1301                 remote = *(u_int32_t *)hp->h_addr;
1302                 if (remote_name[0] == 0) {
1303                     strncpy(remote_name, colon, MAXNAMELEN);
1304                     remote_name[MAXNAMELEN-1] = 0;
1305                 }
1306             }
1307         }
1308         if (bad_ip_adrs(remote)) {
1309             fprintf(stderr, "bad remote IP address %s\n", ip_ntoa(remote));
1310             return -1;
1311         }
1312         if (remote != 0)
1313             wo->hisaddr = remote;
1314     }
1315
1316     return 1;
1317 }
1318
1319
1320 /*
1321  * setnoipdflt - disable setipdefault()
1322  */
1323 static int
1324 setnoipdflt()
1325 {
1326     disable_defaultip = 1;
1327     return 1;
1328 }
1329
1330
1331 /*
1332  * setipcpaccl - accept peer's idea of our address
1333  */
1334 static int
1335 setipcpaccl()
1336 {
1337     ipcp_wantoptions[0].accept_local = 1;
1338     return 1;
1339 }
1340
1341
1342 /*
1343  * setipcpaccr - accept peer's idea of its address
1344  */
1345 static int
1346 setipcpaccr()
1347 {
1348     ipcp_wantoptions[0].accept_remote = 1;
1349     return 1;
1350 }
1351
1352
1353 /*
1354  * setipdefault - default our local IP address based on our hostname.
1355  */
1356 void
1357 setipdefault()
1358 {
1359     struct hostent *hp;
1360     u_int32_t local;
1361     ipcp_options *wo = &ipcp_wantoptions[0];
1362
1363     /*
1364      * If local IP address already given, don't bother.
1365      */
1366     if (wo->ouraddr != 0 || disable_defaultip)
1367         return;
1368
1369     /*
1370      * Look up our hostname (possibly with domain name appended)
1371      * and take the first IP address as our local IP address.
1372      * If there isn't an IP address for our hostname, too bad.
1373      */
1374     wo->accept_local = 1;       /* don't insist on this default value */
1375     if ((hp = gethostbyname(hostname)) == NULL)
1376         return;
1377     local = *(u_int32_t *)hp->h_addr;
1378     if (local != 0 && !bad_ip_adrs(local))
1379         wo->ouraddr = local;
1380 }
1381
1382
1383 /*
1384  * setnetmask - set the netmask to be used on the interface.
1385  */
1386 static int
1387 setnetmask(argv)
1388     char **argv;
1389 {
1390     u_int32_t mask;
1391
1392     if ((mask = inet_addr(*argv)) == -1 || (netmask & ~mask) != 0) {
1393         fprintf(stderr, "Invalid netmask %s\n", *argv);
1394         return 0;
1395     }
1396
1397     netmask = mask;
1398     return (1);
1399 }
1400
1401 static int
1402 setcrtscts()
1403 {
1404     crtscts = 1;
1405     return (1);
1406 }
1407
1408 static int
1409 setnocrtscts()
1410 {
1411     crtscts = -1;
1412     return (1);
1413 }
1414
1415 static int
1416 setxonxoff()
1417 {
1418     lcp_wantoptions[0].asyncmap |= 0x000A0000;  /* escape ^S and ^Q */
1419     lcp_wantoptions[0].neg_asyncmap = 1;
1420
1421     crtscts = 2;
1422     return (1);
1423 }
1424
1425 static int
1426 setnodetach()
1427 {
1428     nodetach = 1;
1429     return (1);
1430 }
1431
1432 static int
1433 setmodem()
1434 {
1435     modem = 1;
1436     return 1;
1437 }
1438
1439 static int
1440 setlocal()
1441 {
1442     modem = 0;
1443     return 1;
1444 }
1445
1446 static int
1447 setlock()
1448 {
1449     lockflag = 1;
1450     return 1;
1451 }
1452
1453 static int
1454 setusehostname()
1455 {
1456     usehostname = 1;
1457     return 1;
1458 }
1459
1460 static int
1461 setname(argv)
1462     char **argv;
1463 {
1464     if (our_name[0] == 0) {
1465         strncpy(our_name, argv[0], MAXNAMELEN);
1466         our_name[MAXNAMELEN-1] = 0;
1467     }
1468     return 1;
1469 }
1470
1471 static int
1472 setuser(argv)
1473     char **argv;
1474 {
1475     strncpy(user, argv[0], MAXNAMELEN);
1476     user[MAXNAMELEN-1] = 0;
1477     return 1;
1478 }
1479
1480 static int
1481 setremote(argv)
1482     char **argv;
1483 {
1484     strncpy(remote_name, argv[0], MAXNAMELEN);
1485     remote_name[MAXNAMELEN-1] = 0;
1486     return 1;
1487 }
1488
1489 static int
1490 setauth()
1491 {
1492     auth_required = 1;
1493     return 1;
1494 }
1495
1496 static int
1497 setdefaultroute()
1498 {
1499     ipcp_wantoptions[0].default_route = 1;
1500     return 1;
1501 }
1502
1503 static int
1504 setproxyarp()
1505 {
1506     ipcp_wantoptions[0].proxy_arp = 1;
1507     return 1;
1508 }
1509
1510 static int
1511 setpersist()
1512 {
1513     persist = 1;
1514     return 1;
1515 }
1516
1517 static int
1518 setdologin()
1519 {
1520     uselogin = 1;
1521     return 1;
1522 }
1523
1524 /*
1525  * Functions to set the echo interval for modem-less monitors
1526  */
1527
1528 static int
1529 setlcpechointv(argv)
1530     char **argv;
1531 {
1532     return int_option(*argv, &lcp_echo_interval);
1533 }
1534
1535 static int
1536 setlcpechofails(argv)
1537     char **argv;
1538 {
1539     return int_option(*argv, &lcp_echo_fails);
1540 }
1541
1542 /*
1543  * Functions to set timeouts, max transmits, etc.
1544  */
1545 static int
1546 setlcptimeout(argv)
1547     char **argv;
1548 {
1549     return int_option(*argv, &lcp_fsm[0].timeouttime);
1550 }
1551
1552 static int
1553 setlcpterm(argv)
1554     char **argv;
1555 {
1556     return int_option(*argv, &lcp_fsm[0].maxtermtransmits);
1557 }
1558
1559 static int
1560 setlcpconf(argv)
1561     char **argv;
1562 {
1563     return int_option(*argv, &lcp_fsm[0].maxconfreqtransmits);
1564 }
1565
1566 static int
1567 setlcpfails(argv)
1568     char **argv;
1569 {
1570     return int_option(*argv, &lcp_fsm[0].maxnakloops);
1571 }
1572
1573 static int
1574 setipcptimeout(argv)
1575     char **argv;
1576 {
1577     return int_option(*argv, &ipcp_fsm[0].timeouttime);
1578 }
1579
1580 static int
1581 setipcpterm(argv)
1582     char **argv;
1583 {
1584     return int_option(*argv, &ipcp_fsm[0].maxtermtransmits);
1585 }
1586
1587 static int
1588 setipcpconf(argv)
1589     char **argv;
1590 {
1591     return int_option(*argv, &ipcp_fsm[0].maxconfreqtransmits);
1592 }
1593
1594 static int
1595 setipcpfails(argv)
1596     char **argv;
1597 {
1598     return int_option(*argv, &lcp_fsm[0].maxnakloops);
1599 }
1600
1601 static int
1602 setpaptimeout(argv)
1603     char **argv;
1604 {
1605     return int_option(*argv, &upap[0].us_timeouttime);
1606 }
1607
1608 static int
1609 setpapreqtime(argv)
1610     char **argv;
1611 {
1612     return int_option(*argv, &upap[0].us_reqtimeout);
1613 }
1614
1615 static int
1616 setpapreqs(argv)
1617     char **argv;
1618 {
1619     return int_option(*argv, &upap[0].us_maxtransmits);
1620 }
1621
1622 static int
1623 setchaptimeout(argv)
1624     char **argv;
1625 {
1626     return int_option(*argv, &chap[0].timeouttime);
1627 }
1628
1629 static int
1630 setchapchal(argv)
1631     char **argv;
1632 {
1633     return int_option(*argv, &chap[0].max_transmits);
1634 }
1635
1636 static int
1637 setchapintv(argv)
1638     char **argv;
1639 {
1640     return int_option(*argv, &chap[0].chal_interval);
1641 }
1642
1643 static int
1644 setbsdcomp(argv)
1645     char **argv;
1646 {
1647     int rbits, abits;
1648     char *str, *endp;
1649
1650     str = *argv;
1651     abits = rbits = strtol(str, &endp, 0);
1652     if (endp != str && *endp == ',') {
1653         str = endp + 1;
1654         abits = strtol(str, &endp, 0);
1655     }
1656     if (*endp != 0 || endp == str) {
1657         fprintf(stderr, "%s: invalid argument format for bsdcomp option\n",
1658                 progname);
1659         return 0;
1660     }
1661     if (rbits != 0 && (rbits < BSD_MIN_BITS || rbits > BSD_MAX_BITS)
1662         || abits != 0 && (abits < BSD_MIN_BITS || abits > BSD_MAX_BITS)) {
1663         fprintf(stderr, "%s: bsdcomp option values must be 0 or %d .. %d\n",
1664                 progname, BSD_MIN_BITS, BSD_MAX_BITS);
1665         return 0;
1666     }
1667     if (rbits > 0) {
1668         ccp_wantoptions[0].bsd_compress = 1;
1669         ccp_wantoptions[0].bsd_bits = rbits;
1670     } else
1671         ccp_wantoptions[0].bsd_compress = 0;
1672     if (abits > 0) {
1673         ccp_allowoptions[0].bsd_compress = 1;
1674         ccp_allowoptions[0].bsd_bits = abits;
1675     } else
1676         ccp_allowoptions[0].bsd_compress = 0;
1677     return 1;
1678 }
1679
1680 static int
1681 setnobsdcomp()
1682 {
1683     ccp_wantoptions[0].bsd_compress = 0;
1684     ccp_allowoptions[0].bsd_compress = 0;
1685     return 1;
1686 }
1687
1688 static int
1689 setipparam(argv)
1690     char **argv;
1691 {
1692     ipparam = strdup(*argv);
1693     if (ipparam == NULL)
1694         novm("ipparam string");
1695
1696     return 1;
1697 }
1698
1699 static int
1700 setpapcrypt()
1701 {
1702     cryptpap = 1;
1703     return 1;
1704 }
1705
1706 #ifdef _linux_
1707 static int setidle (argv)
1708     char **argv;
1709 {
1710     return int_option(*argv, &idle_time_limit);
1711 }
1712 #endif