From aa69617b79d139b2f6dd59ca158cc65893d3bfa7 Mon Sep 17 00:00:00 2001 From: brian Date: Sat, 13 Nov 1999 16:18:40 +0000 Subject: Don't insist on 4 digit umasks in ``set server''. Pointed out by: joerg --- usr.sbin/ppp/command.c | 22 ++++++++++------------ usr.sbin/ppp/ppp.8 | 5 +---- usr.sbin/ppp/ppp.8.m4 | 5 +---- 3 files changed, 12 insertions(+), 20 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index b742a75..47a83e0 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -1179,9 +1179,6 @@ SetStoppedTimeout(struct cmdargs const *arg) return -1; } -#define ismask(x) \ - (*x == '0' && strlen(x) == 4 && strspn(x+1, "0123456789.") == 3) - static int SetServer(struct cmdargs const *arg) { @@ -1189,6 +1186,7 @@ SetServer(struct cmdargs const *arg) if (arg->argc > arg->argn && arg->argc < arg->argn+4) { const char *port, *passwd, *mask; + int mlen; /* What's what ? */ port = arg->argv[arg->argn]; @@ -1198,8 +1196,13 @@ SetServer(struct cmdargs const *arg) } else if (arg->argc == arg->argn + 3) { passwd = arg->argv[arg->argn+1]; mask = arg->argv[arg->argn+2]; - if (!ismask(mask)) + mlen = strlen(mask); + if (mlen == 0 || mlen > 4 || strspn(mask, "01234567") != mlen || + (mlen == 4 && *mask != '0')) { + log_Printf(LogWARN, "%s %s: %s: Invalid mask\n", + arg->argv[arg->argn - 2], arg->argv[arg->argn - 1], mask); return -1; + } } else if (strcasecmp(port, "none") == 0) { if (server_Close(arg->bundle)) log_Printf(LogPHASE, "Disabled server port.\n"); @@ -1214,15 +1217,10 @@ SetServer(struct cmdargs const *arg) mode_t imask; char *ptr, name[LINE_LEN + 12]; - if (mask != NULL) { - unsigned m; - - if (sscanf(mask, "%o", &m) == 1) - imask = m; - else - return -1; - } else + if (mask == NULL) imask = (mode_t)-1; + else for (imask = mlen = 0; mask[mlen]; mlen++) + imask = (imask * 8) + mask[mlen] - '0'; ptr = strstr(port, "%d"); if (ptr) { diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index afd228b..7337192 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -4499,10 +4499,7 @@ If you wish to specify a local domain socket, .Ar LocalName must be specified as an absolute file name, otherwise it is assumed to be the name or number of a TCP port. You must specify the octal umask -that should be used with local domain sockets as a four character octal -number beginning with -.Sq 0 . -Refer to +to be used with a local domain socket. Refer to .Xr umask 2 for umask details. Refer to .Xr services 5 diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4 index afd228b..7337192 100644 --- a/usr.sbin/ppp/ppp.8.m4 +++ b/usr.sbin/ppp/ppp.8.m4 @@ -4499,10 +4499,7 @@ If you wish to specify a local domain socket, .Ar LocalName must be specified as an absolute file name, otherwise it is assumed to be the name or number of a TCP port. You must specify the octal umask -that should be used with local domain sockets as a four character octal -number beginning with -.Sq 0 . -Refer to +to be used with a local domain socket. Refer to .Xr umask 2 for umask details. Refer to .Xr services 5 -- cgit v1.1