diff options
author | 1999-03-09 20:37:39 +0000 | |
---|---|---|
committer | 1999-03-09 20:37:39 +0000 | |
commit | 0697c7fb71c5c91b35cda628e20e7cf1aacda422 (patch) | |
tree | ebf9161a6e4e5eec4747f0efd53accd49e5f91f8 | |
parent | add more 'cc' usage, actually overestimating gcc's smartness; also fix currently unused bus macros. kids tested mother approved (diff) | |
download | wireguard-openbsd-0697c7fb71c5c91b35cda628e20e7cf1aacda422.tar.xz wireguard-openbsd-0697c7fb71c5c91b35cda628e20e7cf1aacda422.zip |
If /etc/ppp/ppp.conf doesn't exist, mention that the
configuration file can't be found rather than saying
that the label can't be found.
Pointed out by: Greg Black <gjb@comkey.com.au>
-rw-r--r-- | usr.sbin/ppp/ppp/systems.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/usr.sbin/ppp/ppp/systems.c b/usr.sbin/ppp/ppp/systems.c index 8f19f339063..6649271006a 100644 --- a/usr.sbin/ppp/ppp/systems.c +++ b/usr.sbin/ppp/ppp/systems.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: systems.c,v 1.5 1999/02/06 03:22:48 brian Exp $ + * $Id: systems.c,v 1.6 1999/03/09 20:37:39 brian Exp $ * * TODO: */ @@ -249,6 +249,8 @@ xgets(char *buf, int buflen, FILE *fp) #define SYSTEM_VALIDATE 2 #define SYSTEM_EXEC 3 +/* Returns -2 for ``file not found'' and -1 for ``label not found'' */ + static int ReadSystem(struct bundle *bundle, const char *name, const char *file, struct prompt *prompt, struct datalink *cx, int how) @@ -272,7 +274,7 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file, fp = ID0fopen(filename, "r"); if (fp == NULL) { log_Printf(LogDEBUG, "ReadSystem: Can't open %s.\n", filename); - return (-1); + return -2; } log_Printf(LogDEBUG, "ReadSystem: Checking %s (%s).\n", name, filename); @@ -359,7 +361,7 @@ system_IsValid(const char *name, struct prompt *prompt, int mode) * Note: The ReadSystem() calls only result in calls to the Allow* * functions. arg->bundle will be set to NULL for these commands ! */ - int def, how; + int def, how, rs; def = !strcmp(name, "default"); how = ID0realuid() == 0 ? SYSTEM_EXISTS : SYSTEM_VALIDATE; @@ -367,11 +369,21 @@ system_IsValid(const char *name, struct prompt *prompt, int mode) modeok = 1; modereq = mode; - if (ReadSystem(NULL, "default", CONFFILE, prompt, NULL, how) != 0 && def) - return "Configuration label not found"; + rs = ReadSystem(NULL, "default", CONFFILE, prompt, NULL, how); + + if (!def) { + if (rs == -1) + rs = 0; /* we don't care that ``default'' doesn't exist */ + + if (rs == 0) + rs = ReadSystem(NULL, name, CONFFILE, prompt, NULL, how); - if (!def && ReadSystem(NULL, name, CONFFILE, prompt, NULL, how) != 0) - return "Configuration label not found"; + if (rs == -1) + return "Configuration label not found"; + + if (rs == -2) + return _PATH_PPP "/" CONFFILE ": File not found"; + } if (how == SYSTEM_EXISTS) userok = modeok = 1; |