summaryrefslogtreecommitdiff
path: root/usr.sbin/pppd/options.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pppd/options.c')
-rw-r--r--usr.sbin/pppd/options.c322
1 files changed, 104 insertions, 218 deletions
diff --git a/usr.sbin/pppd/options.c b/usr.sbin/pppd/options.c
index a66719484c4..b76e8025361 100644
--- a/usr.sbin/pppd/options.c
+++ b/usr.sbin/pppd/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.30 2022/12/28 21:30:18 jmc Exp $ */
+/* $OpenBSD: options.c,v 1.31 2024/08/09 05:16:13 deraadt Exp $ */
/*
* options.c - handles option processing for PPP.
@@ -112,7 +112,7 @@ int maxconnect = 0; /* Maximum connect time */
char user[MAXNAMELEN]; /* Username for PAP */
char passwd[MAXSECRETLEN]; /* Password for PAP */
int auth_required = 0; /* Peer is required to authenticate */
-int persist = 0; /* Reopen link after it goes down */
+volatile sig_atomic_t persist = 0; /* Reopen link after it goes down */
int uselogin = 0; /* Use /etc/passwd for checking PAP */
int lcp_echo_interval = 0; /* Interval between LCP echo-requests */
int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */
@@ -427,9 +427,7 @@ static char *option_source; /* string saying where the option came from */
* parse_args - parse a string of arguments from the command line.
*/
int
-parse_args(argc, argv)
- int argc;
- char **argv;
+parse_args(int argc, char **argv)
{
char *arg;
struct cmd *cmdp;
@@ -482,9 +480,7 @@ parse_args(argc, argv)
* if specified.
*/
void
-scan_args(argc, argv)
- int argc;
- char **argv;
+scan_args(int argc, char **argv)
{
char *arg;
struct cmd *cmdp;
@@ -524,8 +520,7 @@ usage()
* showhelp - print out usage message and exit.
*/
static int
-showhelp(argv)
- char **argv;
+showhelp(char **argv)
{
if (phase == PHASE_INITIALIZE) {
usage();
@@ -538,8 +533,7 @@ showhelp(argv)
* showversion - print out the version number and exit.
*/
static int
-showversion(argv)
- char **argv;
+showversion(char **argv)
{
if (phase == PHASE_INITIALIZE) {
fprintf(stderr, "pppd version %s patch level %d%s\n",
@@ -554,11 +548,7 @@ showversion(argv)
* and interpret them.
*/
int
-options_from_file(filename, must_exist, check_prot, priv)
- char *filename;
- int must_exist;
- int check_prot;
- int priv;
+options_from_file(char *filename, int must_exist, int check_prot, int priv)
{
FILE *f;
int i, newline, ret;
@@ -695,8 +685,7 @@ option_error(char *fmt, ...)
* readable - check if a file is readable by the real user.
*/
static int
-readable(fd)
- int fd;
+readable(int fd)
{
uid_t uid;
int ngroups, i;
@@ -726,11 +715,7 @@ readable(fd)
* \<newline> is ignored.
*/
int
-getword(f, word, newlinep, filename)
- FILE *f;
- char *word;
- int *newlinep;
- char *filename;
+getword(FILE *f, char *word, int *newlinep, char *filename)
{
int c, len, escape;
int quoted, comment;
@@ -971,10 +956,7 @@ getword(f, word, newlinep, filename)
* number_option - parse an unsigned numeric parameter for an option.
*/
static int
-number_option(str, valp, base)
- char *str;
- u_int32_t *valp;
- int base;
+number_option(char *str, u_int32_t *valp, int base)
{
char *ptr;
@@ -994,9 +976,7 @@ number_option(str, valp, base)
* if there is an error.
*/
static int
-int_option(str, valp)
- char *str;
- int *valp;
+int_option(char *str, int *valp)
{
u_int32_t v;
@@ -1015,8 +995,7 @@ int_option(str, valp)
* readfile - take commands from a file.
*/
static int
-readfile(argv)
- char **argv;
+readfile(char **argv)
{
return options_from_file(*argv, 1, 1, privileged_option);
}
@@ -1026,8 +1005,7 @@ readfile(argv)
* Name may not contain /../, start with / or ../, or end in /..
*/
static int
-callfile(argv)
- char **argv;
+callfile(char **argv)
{
char *fname, *arg, *p;
int l, ok;
@@ -1070,8 +1048,7 @@ callfile(argv)
* setdebug - Set debug (command line argument).
*/
static int
-setdebug(argv)
- char **argv;
+setdebug(char **argv)
{
debug++;
return (1);
@@ -1081,8 +1058,7 @@ setdebug(argv)
* setkdebug - Set kernel debugging level.
*/
static int
-setkdebug(argv)
- char **argv;
+setkdebug(char **argv)
{
return int_option(*argv, &kdebugflag);
}
@@ -1092,8 +1068,7 @@ setkdebug(argv)
* setpdebug - Set libpcap debugging level.
*/
static int
-setpdebug(argv)
- char **argv;
+setpdebug(char **argv)
{
return int_option(*argv, &dflag);
}
@@ -1102,8 +1077,7 @@ setpdebug(argv)
* setpassfilter - Set the pass filter for packets
*/
static int
-setpassfilter(argv)
- char **argv;
+setpassfilter(char **argv)
{
pc.linktype = DLT_PPP;
pc.snapshot = PPP_HDRLEN;
@@ -1118,8 +1092,7 @@ setpassfilter(argv)
* setactivefilter - Set the active filter for packets
*/
static int
-setactivefilter(argv)
- char **argv;
+setactivefilter(char **argv)
{
pc.linktype = DLT_PPP;
pc.snapshot = PPP_HDRLEN;
@@ -1135,8 +1108,7 @@ setactivefilter(argv)
* noopt - Disable all options.
*/
static int
-noopt(argv)
- char **argv;
+noopt(char **argv)
{
BZERO((char *) &lcp_wantoptions[0], sizeof (struct lcp_options));
BZERO((char *) &lcp_allowoptions[0], sizeof (struct lcp_options));
@@ -1150,8 +1122,7 @@ noopt(argv)
* noaccomp - Disable Address/Control field compression negotiation.
*/
static int
-noaccomp(argv)
- char **argv;
+noaccomp(char **argv)
{
lcp_wantoptions[0].neg_accompression = 0;
lcp_allowoptions[0].neg_accompression = 0;
@@ -1163,8 +1134,7 @@ noaccomp(argv)
* noasyncmap - Disable async map negotiation.
*/
static int
-noasyncmap(argv)
- char **argv;
+noasyncmap(char **argv)
{
lcp_wantoptions[0].neg_asyncmap = 0;
lcp_allowoptions[0].neg_asyncmap = 0;
@@ -1176,8 +1146,7 @@ noasyncmap(argv)
* noip - Disable IP and IPCP.
*/
static int
-noip(argv)
- char **argv;
+noip(char **argv)
{
ipcp_protent.enabled_flag = 0;
return (1);
@@ -1188,8 +1157,7 @@ noip(argv)
* nomagicnumber - Disable magic number negotiation.
*/
static int
-nomagicnumber(argv)
- char **argv;
+nomagicnumber(char **argv)
{
lcp_wantoptions[0].neg_magicnumber = 0;
lcp_allowoptions[0].neg_magicnumber = 0;
@@ -1201,8 +1169,7 @@ nomagicnumber(argv)
* nomru - Disable mru negotiation.
*/
static int
-nomru(argv)
- char **argv;
+nomru(char **argv)
{
lcp_wantoptions[0].neg_mru = 0;
lcp_allowoptions[0].neg_mru = 0;
@@ -1214,8 +1181,7 @@ nomru(argv)
* setmru - Set MRU for negotiation.
*/
static int
-setmru(argv)
- char **argv;
+setmru(char **argv)
{
u_int32_t mru;
@@ -1231,8 +1197,7 @@ setmru(argv)
* setmru - Set the largest MTU we'll use.
*/
static int
-setmtu(argv)
- char **argv;
+setmtu(char **argv)
{
u_int32_t mtu;
@@ -1267,8 +1232,7 @@ setcbcp(argv)
* nopcomp - Disable Protocol field compression negotiation.
*/
static int
-nopcomp(argv)
- char **argv;
+nopcomp(char **argv)
{
lcp_wantoptions[0].neg_pcompression = 0;
lcp_allowoptions[0].neg_pcompression = 0;
@@ -1281,8 +1245,7 @@ nopcomp(argv)
* LCP configure-requests).
*/
static int
-setpassive(argv)
- char **argv;
+setpassive(char **argv)
{
lcp_wantoptions[0].passive = 1;
return (1);
@@ -1294,8 +1257,7 @@ setpassive(argv)
* until we get one from the peer).
*/
static int
-setsilent(argv)
- char **argv;
+setsilent(char **argv)
{
lcp_wantoptions[0].silent = 1;
return 1;
@@ -1306,8 +1268,7 @@ setsilent(argv)
* nopap - Disable PAP authentication with peer.
*/
static int
-nopap(argv)
- char **argv;
+nopap(char **argv)
{
refuse_pap = 1;
return (1);
@@ -1318,8 +1279,7 @@ nopap(argv)
* reqpap - Require PAP authentication from peer.
*/
static int
-reqpap(argv)
- char **argv;
+reqpap(char **argv)
{
lcp_wantoptions[0].neg_upap = 1;
setauth(NULL);
@@ -1330,8 +1290,7 @@ reqpap(argv)
* nochap - Disable CHAP authentication with peer.
*/
static int
-nochap(argv)
- char **argv;
+nochap(char **argv)
{
refuse_chap = 1;
return (1);
@@ -1342,8 +1301,7 @@ nochap(argv)
* reqchap - Require CHAP authentication from peer.
*/
static int
-reqchap(argv)
- char **argv;
+reqchap(char **argv)
{
lcp_wantoptions[0].neg_chap = 1;
setauth(NULL);
@@ -1355,8 +1313,7 @@ reqchap(argv)
* setnovj - disable vj compression
*/
static int
-setnovj(argv)
- char **argv;
+setnovj(char **argv)
{
ipcp_wantoptions[0].neg_vj = 0;
ipcp_allowoptions[0].neg_vj = 0;
@@ -1368,8 +1325,7 @@ setnovj(argv)
* setnovjccomp - disable VJ connection-ID compression
*/
static int
-setnovjccomp(argv)
- char **argv;
+setnovjccomp(char **argv)
{
ipcp_wantoptions[0].cflag = 0;
ipcp_allowoptions[0].cflag = 0;
@@ -1381,8 +1337,7 @@ setnovjccomp(argv)
* setvjslots - set maximum number of connection slots for VJ compression
*/
static int
-setvjslots(argv)
- char **argv;
+setvjslots(char **argv)
{
int value;
@@ -1402,8 +1357,7 @@ setvjslots(argv)
* setconnector - Set a program to connect to a serial line
*/
static int
-setconnector(argv)
- char **argv;
+setconnector(char **argv)
{
connector = strdup(*argv);
if (connector == NULL)
@@ -1418,8 +1372,7 @@ setconnector(argv)
* setdisconnector - Set a program to disconnect from the serial line
*/
static int
-setdisconnector(argv)
- char **argv;
+setdisconnector(char **argv)
{
disconnector = strdup(*argv);
if (disconnector == NULL)
@@ -1434,8 +1387,7 @@ setdisconnector(argv)
* setwelcomer - Set a program to welcome a client after connection
*/
static int
-setwelcomer(argv)
- char **argv;
+setwelcomer(char **argv)
{
welcomer = strdup(*argv);
if (welcomer == NULL)
@@ -1450,8 +1402,7 @@ setwelcomer(argv)
* setmaxconnect - Set the maximum connect time
*/
static int
-setmaxconnect(argv)
- char **argv;
+setmaxconnect(char **argv)
{
int value;
@@ -1473,8 +1424,7 @@ setmaxconnect(argv)
* setdomain - Set domain name to append to hostname
*/
static int
-setdomain(argv)
- char **argv;
+setdomain(char **argv)
{
if (!privileged_option) {
option_error("using the domain option requires root privilege");
@@ -1495,8 +1445,7 @@ setdomain(argv)
* setasyncmap - add bits to asyncmap (what we request peer to escape).
*/
static int
-setasyncmap(argv)
- char **argv;
+setasyncmap(char **argv)
{
u_int32_t asyncmap;
@@ -1512,8 +1461,7 @@ setasyncmap(argv)
* setescape - add chars to the set we escape on transmission.
*/
static int
-setescape(argv)
- char **argv;
+setescape(char **argv)
{
int n, ret;
char *p, *endp;
@@ -1544,8 +1492,7 @@ setescape(argv)
* setspeed - Set the speed.
*/
static int
-setspeed(arg)
- char *arg;
+setspeed(char *arg)
{
char *ptr;
int spd;
@@ -1562,9 +1509,7 @@ setspeed(arg)
* setdevname - Set the device name.
*/
static int
-setdevname(cp, quiet)
- char *cp;
- int quiet;
+setdevname(char *cp, int quiet)
{
struct stat statbuf;
char dev[PATH_MAX];
@@ -1601,8 +1546,7 @@ setdevname(cp, quiet)
* setipaddr - Set the IP address
*/
static int
-setipaddr(arg)
- char *arg;
+setipaddr(char *arg)
{
struct hostent *hp;
char *colon;
@@ -1672,8 +1616,7 @@ setipaddr(arg)
* setnoipdflt - disable setipdefault()
*/
static int
-setnoipdflt(argv)
- char **argv;
+setnoipdflt(char **argv)
{
disable_defaultip = 1;
return 1;
@@ -1684,8 +1627,7 @@ setnoipdflt(argv)
* setipcpaccl - accept peer's idea of our address
*/
static int
-setipcpaccl(argv)
- char **argv;
+setipcpaccl(char **argv)
{
ipcp_wantoptions[0].accept_local = 1;
return 1;
@@ -1696,8 +1638,7 @@ setipcpaccl(argv)
* setipcpaccr - accept peer's idea of its address
*/
static int
-setipcpaccr(argv)
- char **argv;
+setipcpaccr(char **argv)
{
ipcp_wantoptions[0].accept_remote = 1;
return 1;
@@ -1708,8 +1649,7 @@ setipcpaccr(argv)
* setnetmask - set the netmask to be used on the interface.
*/
static int
-setnetmask(argv)
- char **argv;
+setnetmask(char **argv)
{
struct in_addr ina;
@@ -1723,24 +1663,21 @@ setnetmask(argv)
}
static int
-setcrtscts(argv)
- char **argv;
+setcrtscts(char **argv)
{
crtscts = 1;
return (1);
}
static int
-setnocrtscts(argv)
- char **argv;
+setnocrtscts(char **argv)
{
crtscts = -1;
return (1);
}
static int
-setxonxoff(argv)
- char **argv;
+setxonxoff(char **argv)
{
lcp_wantoptions[0].asyncmap |= 0x000A0000; /* escape ^S and ^Q */
lcp_wantoptions[0].neg_asyncmap = 1;
@@ -1750,24 +1687,21 @@ setxonxoff(argv)
}
static int
-setnodetach(argv)
- char **argv;
+setnodetach(char **argv)
{
nodetach = 1;
return (1);
}
static int
-setupdetach(argv)
- char **argv;
+setupdetach(char **argv)
{
nodetach = -1;
return (1);
}
static int
-setdemand(argv)
- char **argv;
+setdemand(char **argv)
{
demand = 1;
persist = 1;
@@ -1775,48 +1709,42 @@ setdemand(argv)
}
static int
-setmodem(argv)
- char **argv;
+setmodem(char **argv)
{
modem = 1;
return 1;
}
static int
-setmodem_chat(argv)
- char **argv;
+setmodem_chat(char **argv)
{
modem_chat = 1;
return 1;
}
static int
-setlocal(argv)
- char **argv;
+setlocal(char **argv)
{
modem = 0;
return 1;
}
static int
-setlock(argv)
- char **argv;
+setlock(char **argv)
{
lockflag = 1;
return 1;
}
static int
-setusehostname(argv)
- char **argv;
+setusehostname(char **argv)
{
usehostname = 1;
return 1;
}
static int
-setname(argv)
- char **argv;
+setname(char **argv)
{
if (!privileged_option) {
option_error("using the name option requires root privilege");
@@ -1827,24 +1755,21 @@ setname(argv)
}
static int
-setuser(argv)
- char **argv;
+setuser(char **argv)
{
strlcpy(user, argv[0], MAXNAMELEN);
return 1;
}
static int
-setremote(argv)
- char **argv;
+setremote(char **argv)
{
strlcpy(remote_name, argv[0], MAXNAMELEN);
return 1;
}
static int
-setauth(argv)
- char **argv;
+setauth(char **argv)
{
auth_required = 1;
if (privileged_option > auth_req_info.priv) {
@@ -1855,8 +1780,7 @@ setauth(argv)
}
static int
-setnoauth(argv)
- char **argv;
+setnoauth(char **argv)
{
if (auth_required && privileged_option < auth_req_info.priv) {
if (auth_req_info.source == NULL)
@@ -1871,8 +1795,7 @@ setnoauth(argv)
}
static int
-setdefaultroute(argv)
- char **argv;
+setdefaultroute(char **argv)
{
if (!ipcp_allowoptions[0].default_route) {
option_error("defaultroute option is disabled");
@@ -1883,8 +1806,7 @@ setdefaultroute(argv)
}
static int
-setnodefaultroute(argv)
- char **argv;
+setnodefaultroute(char **argv)
{
ipcp_allowoptions[0].default_route = 0;
ipcp_wantoptions[0].default_route = 0;
@@ -1892,8 +1814,7 @@ setnodefaultroute(argv)
}
static int
-setproxyarp(argv)
- char **argv;
+setproxyarp(char **argv)
{
if (!ipcp_allowoptions[0].proxy_arp) {
option_error("proxyarp option is disabled");
@@ -1904,8 +1825,7 @@ setproxyarp(argv)
}
static int
-setnoproxyarp(argv)
- char **argv;
+setnoproxyarp(char **argv)
{
ipcp_wantoptions[0].proxy_arp = 0;
ipcp_allowoptions[0].proxy_arp = 0;
@@ -1913,24 +1833,21 @@ setnoproxyarp(argv)
}
static int
-setpersist(argv)
- char **argv;
+setpersist(char **argv)
{
persist = 1;
return 1;
}
static int
-setnopersist(argv)
- char **argv;
+setnopersist(char **argv)
{
persist = 0;
return 1;
}
static int
-setdologin(argv)
- char **argv;
+setdologin(char **argv)
{
uselogin = 1;
return 1;
@@ -1941,15 +1858,13 @@ setdologin(argv)
*/
static int
-setlcpechointv(argv)
- char **argv;
+setlcpechointv(char **argv)
{
return int_option(*argv, &lcp_echo_interval);
}
static int
-setlcpechofails(argv)
- char **argv;
+setlcpechofails(char **argv)
{
return int_option(*argv, &lcp_echo_fails);
}
@@ -1958,114 +1873,98 @@ setlcpechofails(argv)
* Functions to set timeouts, max transmits, etc.
*/
static int
-setlcptimeout(argv)
- char **argv;
+setlcptimeout(char **argv)
{
return int_option(*argv, &lcp_fsm[0].timeouttime);
}
static int
-setlcpterm(argv)
- char **argv;
+setlcpterm(char **argv)
{
return int_option(*argv, &lcp_fsm[0].maxtermtransmits);
}
static int
-setlcpconf(argv)
- char **argv;
+setlcpconf(char **argv)
{
return int_option(*argv, &lcp_fsm[0].maxconfreqtransmits);
}
static int
-setlcpfails(argv)
- char **argv;
+setlcpfails(char **argv)
{
return int_option(*argv, &lcp_fsm[0].maxnakloops);
}
static int
-setipcptimeout(argv)
- char **argv;
+setipcptimeout(char **argv)
{
return int_option(*argv, &ipcp_fsm[0].timeouttime);
}
static int
-setipcpterm(argv)
- char **argv;
+setipcpterm(char **argv)
{
return int_option(*argv, &ipcp_fsm[0].maxtermtransmits);
}
static int
-setipcpconf(argv)
- char **argv;
+setipcpconf(char **argv)
{
return int_option(*argv, &ipcp_fsm[0].maxconfreqtransmits);
}
static int
-setipcpfails(argv)
- char **argv;
+setipcpfails(char **argv)
{
return int_option(*argv, &lcp_fsm[0].maxnakloops);
}
static int
-setpaptimeout(argv)
- char **argv;
+setpaptimeout(char **argv)
{
return int_option(*argv, &upap[0].us_timeouttime);
}
static int
-setpapreqtime(argv)
- char **argv;
+setpapreqtime(char **argv)
{
return int_option(*argv, &upap[0].us_reqtimeout);
}
static int
-setpapreqs(argv)
- char **argv;
+setpapreqs(char **argv)
{
return int_option(*argv, &upap[0].us_maxtransmits);
}
static int
-setchaptimeout(argv)
- char **argv;
+setchaptimeout(char **argv)
{
return int_option(*argv, &chap[0].timeouttime);
}
static int
-setchapchal(argv)
- char **argv;
+setchapchal(char **argv)
{
return int_option(*argv, &chap[0].max_transmits);
}
static int
-setchapintv(argv)
- char **argv;
+setchapintv(char **argv)
{
return int_option(*argv, &chap[0].chal_interval);
}
static int
-noccp(argv)
- char **argv;
+noccp(char **argv)
{
ccp_protent.enabled_flag = 0;
return 1;
}
static int
-setbsdcomp(argv)
- char **argv;
+setbsdcomp(char **argv)
{
int rbits, abits;
char *str, *endp;
@@ -2100,8 +1999,7 @@ setbsdcomp(argv)
}
static int
-setnobsdcomp(argv)
- char **argv;
+setnobsdcomp(char **argv)
{
ccp_wantoptions[0].bsd_compress = 0;
ccp_allowoptions[0].bsd_compress = 0;
@@ -2109,8 +2007,7 @@ setnobsdcomp(argv)
}
static int
-setdeflate(argv)
- char **argv;
+setdeflate(char **argv)
{
int rbits, abits;
char *str, *endp;
@@ -2146,8 +2043,7 @@ setdeflate(argv)
}
static int
-setnodeflate(argv)
- char **argv;
+setnodeflate(char **argv)
{
ccp_wantoptions[0].deflate = 0;
ccp_allowoptions[0].deflate = 0;
@@ -2155,8 +2051,7 @@ setnodeflate(argv)
}
static int
-setnodeflatedraft(argv)
- char **argv;
+setnodeflatedraft(char **argv)
{
ccp_wantoptions[0].deflate_draft = 0;
ccp_allowoptions[0].deflate_draft = 0;
@@ -2164,8 +2059,7 @@ setnodeflatedraft(argv)
}
static int
-setpred1comp(argv)
- char **argv;
+setpred1comp(char **argv)
{
ccp_wantoptions[0].predictor_1 = 1;
ccp_allowoptions[0].predictor_1 = 1;
@@ -2173,8 +2067,7 @@ setpred1comp(argv)
}
static int
-setnopred1comp(argv)
- char **argv;
+setnopred1comp(char **argv)
{
ccp_wantoptions[0].predictor_1 = 0;
ccp_allowoptions[0].predictor_1 = 0;
@@ -2182,8 +2075,7 @@ setnopred1comp(argv)
}
static int
-setipparam(argv)
- char **argv;
+setipparam(char **argv)
{
ipparam = strdup(*argv);
if (ipparam == NULL)
@@ -2193,23 +2085,20 @@ setipparam(argv)
}
static int
-setpapcrypt(argv)
- char **argv;
+setpapcrypt(char **argv)
{
cryptpap = 1;
return 1;
}
static int
-setidle(argv)
- char **argv;
+setidle(char **argv)
{
return int_option(*argv, &idle_time_limit);
}
static int
-setholdoff(argv)
- char **argv;
+setholdoff(char **argv)
{
return int_option(*argv, &holdoff);
}
@@ -2218,8 +2107,7 @@ setholdoff(argv)
* setdnsaddr - set the dns address(es)
*/
static int
-setdnsaddr(argv)
- char **argv;
+setdnsaddr(char **argv)
{
struct in_addr ina;
struct hostent *hp;
@@ -2249,8 +2137,7 @@ setdnsaddr(argv)
* the caller to the existing WINS server on a Windows NT platform.
*/
static int
-setwinsaddr(argv)
- char **argv;
+setwinsaddr(char **argv)
{
struct in_addr ina;
struct hostent *hp;
@@ -2276,8 +2163,7 @@ setwinsaddr(argv)
#ifdef MSLANMAN
static int
-setmslanman(argv)
- char **argv;
+setmslanman(char **argv)
{
ms_lanman = 1;
return (1);