summaryrefslogtreecommitdiffstats
path: root/crypto/kerberosIV/appl/bsd/sysv_default.c
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>1997-09-04 06:04:33 +0000
committermarkm <markm@FreeBSD.org>1997-09-04 06:04:33 +0000
commita8a89cfaf983bc64f4b42f7c35209a5a36dd0fe8 (patch)
tree0b84977f19022a965f8c6145f067f951173f6290 /crypto/kerberosIV/appl/bsd/sysv_default.c
downloadFreeBSD-src-a8a89cfaf983bc64f4b42f7c35209a5a36dd0fe8.zip
FreeBSD-src-a8a89cfaf983bc64f4b42f7c35209a5a36dd0fe8.tar.gz
Initial import of KTH eBones. This has been cleaned up to only include
the "core" Kerberos functionality. The rest of the userland will get their own changes later.
Diffstat (limited to 'crypto/kerberosIV/appl/bsd/sysv_default.c')
-rw-r--r--crypto/kerberosIV/appl/bsd/sysv_default.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/crypto/kerberosIV/appl/bsd/sysv_default.c b/crypto/kerberosIV/appl/bsd/sysv_default.c
new file mode 100644
index 0000000..cb36b84
--- /dev/null
+++ b/crypto/kerberosIV/appl/bsd/sysv_default.c
@@ -0,0 +1,95 @@
+/* Author: Wietse Venema <wietse@wzv.win.tue.nl> */
+
+#include "bsd_locl.h"
+
+RCSID("$Id: sysv_default.c,v 1.9 1997/03/31 01:47:59 assar Exp $");
+
+#include "sysv_default.h"
+
+ /*
+ * Default values for stuff that can be read from the defaults file. The
+ * SunOS 5.1 documentation is incomplete and often disagrees with reality.
+ */
+
+static char default_umask_value[] = "022";
+
+char *default_console = 0;
+char *default_altsh = "YES";
+char *default_passreq = "NO";
+char *default_timezone= 0;
+char *default_hz = 0;
+char *default_path = _PATH_DEFPATH;
+char *default_supath = _PATH_DEFSUPATH;
+char *default_ulimit = 0;
+char *default_timeout = "60";
+char *default_umask = default_umask_value;
+char *default_sleep = "4";
+char *default_maxtrys = "5";
+
+static struct sysv_default {
+ char **valptr;
+ char *prefix;
+ int prefix_len;
+} defaults[] = {
+ {&default_console, "CONSOLE=", sizeof("CONSOLE=") -1},
+ {&default_altsh, "ALTSHELL=", sizeof("ALTSHELL=") -1},
+ {&default_passreq, "PASSREQ=", sizeof("PASSREQ=") -1},
+ {&default_timezone, "TIMEZONE=", sizeof("TIMEZONE=") -1},
+ {&default_hz, "HZ=", sizeof("HZ=") -1},
+ {&default_path, "PATH=", sizeof("PATH=") -1},
+ {&default_supath, "SUPATH=", sizeof("SUPATH=") -1},
+ {&default_ulimit, "ULIMIT=", sizeof("ULIMIT=") -1},
+ {&default_timeout, "TIMEOUT=", sizeof("TIMEOUT=") -1},
+ {&default_umask, "UMASK=", sizeof("UMASK=") -1},
+ {&default_sleep, "SLEEPTIME=", sizeof("SLEEPTIME=") -1},
+ {&default_maxtrys, "MAXTRYS=", sizeof("MAXTRYS=") -1},
+ {0},
+};
+
+#define trim(s) { \
+ char *cp = s + strlen(s); \
+ while (cp > s && isspace(cp[-1])) \
+ cp--; \
+ *cp = 0; \
+}
+
+/* sysv_defaults - read login defaults file */
+
+void
+sysv_defaults()
+{
+ struct sysv_default *dp;
+ FILE *fp;
+ char buf[BUFSIZ];
+
+ if ((fp = fopen(_PATH_ETC_DEFAULT_LOGIN, "r"))) {
+
+ /* Stupid quadratic algorithm. */
+
+ while (fgets(buf, sizeof(buf), fp)) {
+
+ /* Skip comments and blank lines. */
+
+ if (buf[0] == '#')
+ continue;
+ trim(buf);
+ if (buf[0] == 0)
+ continue;
+
+ /* Assign defaults from file. */
+
+#define STREQN(x,y,l) (x[0] == y[0] && strncmp(x,y,l) == 0)
+
+ for (dp = defaults; dp->valptr; dp++) {
+ if (STREQN(buf, dp->prefix, dp->prefix_len)) {
+ if ((*(dp->valptr) = strdup(buf + dp->prefix_len)) == 0) {
+ warnx("Insufficient memory resources - try later.");
+ sleepexit(1);
+ }
+ break;
+ }
+ }
+ }
+ fclose(fp);
+ }
+}
OpenPOWER on IntegriCloud