/*-
* Copyright (c) 1988, 1993, 1994
* The Regents of the University of California. All rights reserved.
+ * Copyright (c) 2002 Networks Associates Technology, Inc.
+ * All rights reserved.
+ *
+ * Portions of this software were developed for the FreeBSD Project by
+ * ThinkSec AS and NAI Labs, the Security Research Division of Network
+ * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035
+ * ("CBOSS"), as part of the DARPA CHATS research program.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
*/
#ifndef lint
-static const char sccsid[] = "@(#)util.c 8.4 (Berkeley) 4/2/94";
+#if 0
+static char sccsid[] = "@(#)util.c 8.4 (Berkeley) 4/2/94";
+#endif
#endif /* not lint */
-
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <ctype.h>
-#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "chpass.h"
-#include "pathnames.h"
static const char *months[] =
{ "January", "February", "March", "April", "May", "June",
}
}
}
- if (!(t = strtok((char *)NULL, " \t,")) || !isdigit(*t))
+ if (!(t = strtok(NULL, " \t,")) || !isdigit(*t))
goto bad;
day = atoi(t);
- if (!(t = strtok((char *)NULL, " \t,")) || !isdigit(*t))
+ if (!(t = strtok(NULL, " \t,")) || !isdigit(*t))
goto bad;
year = atoi(t);
if (day < 1 || day > 31 || month < 1 || month > 12)
return (0);
}
-char *
+int
ok_shell(char *name)
{
char *p, *sh;
setusershell();
while ((sh = getusershell())) {
- if (!strcmp(name, sh))
- return (name);
+ if (!strcmp(name, sh)) {
+ endusershell();
+ return (1);
+ }
+ /* allow just shell name, but use "real" path */
+ if ((p = strrchr(sh, '/')) && strcmp(name, p + 1) == 0) {
+ endusershell();
+ return (1);
+ }
+ }
+ endusershell();
+ return (0);
+}
+
+char *
+dup_shell(char *name)
+{
+ char *p, *sh, *ret;
+
+ setusershell();
+ while ((sh = getusershell())) {
+ if (!strcmp(name, sh)) {
+ endusershell();
+ return (strdup(name));
+ }
/* allow just shell name, but use "real" path */
- if ((p = strrchr(sh, '/')) && strcmp(name, p + 1) == 0)
- return (sh);
+ if ((p = strrchr(sh, '/')) && strcmp(name, p + 1) == 0) {
+ ret = strdup(sh);
+ endusershell();
+ return (ret);
+ }
}
+ endusershell();
return (NULL);
}