diff options
author | ache <ache@FreeBSD.org> | 1997-11-02 17:22:20 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1997-11-02 17:22:20 +0000 |
commit | 0402968a2b6c49a5b82b706dac505c3779bafe25 (patch) | |
tree | e1c75675fd764dbd3ee0a0c6ede362981d7bce12 /usr.sbin/cron/lib | |
parent | cd43239919002f0f18ab8b9197cd3d2a1141b109 (diff) | |
download | FreeBSD-src-0402968a2b6c49a5b82b706dac505c3779bafe25.zip FreeBSD-src-0402968a2b6c49a5b82b706dac505c3779bafe25.tar.gz |
Log run-time parsing errors now
Use getpwnam before getpwuid since two users with same uids can exists
(affects new login classes code only)
The same fixes as in inetd: by default run `system crontab things' with
daemon login class now, not restrict them to user class breaking
compatibility with old way (so-called nobody limits problem)
Implement user[:group][/login-class] syntax in system crontab
for more flexible control (the same as in inetd)
Diffstat (limited to 'usr.sbin/cron/lib')
-rw-r--r-- | usr.sbin/cron/lib/Makefile | 3 | ||||
-rw-r--r-- | usr.sbin/cron/lib/entry.c | 49 |
2 files changed, 47 insertions, 5 deletions
diff --git a/usr.sbin/cron/lib/Makefile b/usr.sbin/cron/lib/Makefile index 5c61065..5270131 100644 --- a/usr.sbin/cron/lib/Makefile +++ b/usr.sbin/cron/lib/Makefile @@ -1,7 +1,8 @@ LIB= cron SRCS= entry.c env.c misc.c -CFLAGS+= -I${.CURDIR}/../cron +CFLAGS+=-I${.CURDIR}/../cron +CFLAGS+=-DLOGIN_CAP NOPIC= yes NOPROFILE= yes diff --git a/usr.sbin/cron/lib/entry.c b/usr.sbin/cron/lib/entry.c index 39ff0df..b7dba59 100644 --- a/usr.sbin/cron/lib/entry.c +++ b/usr.sbin/cron/lib/entry.c @@ -17,7 +17,7 @@ #if !defined(lint) && !defined(LINT) static const char rcsid[] = - "$Id: entry.c,v 1.6 1997/02/22 16:05:06 peter Exp $"; + "$Id: entry.c,v 1.7 1997/09/15 06:39:21 charnier Exp $"; #endif /* vix 26jan87 [RCS'd; rest of log is in RCS file] @@ -28,11 +28,17 @@ static const char rcsid[] = #include "cron.h" - +#include <grp.h> +#ifdef LOGIN_CAP +#include <login_cap.h> +#endif typedef enum ecode { e_none, e_minute, e_hour, e_dom, e_month, e_dow, - e_cmd, e_timespec, e_username + e_cmd, e_timespec, e_username, e_group +#ifdef LOGIN_CAP + , e_class +#endif } ecode_e; static char get_list __P((bitstr_t *, int, int, char *[], int, FILE *)), @@ -51,6 +57,10 @@ static char *ecodes[] = "bad command", "bad time specifier", "bad username", + "bad group name", +#ifdef LOGIN_CAP + "bad class name", +#endif }; @@ -58,6 +68,10 @@ void free_entry(e) entry *e; { +#ifdef LOGIN_CAP + if (e->class != NULL) + free(e->class); +#endif free(e->cmd); env_free(e->envp); free(e); @@ -224,6 +238,8 @@ load_entry(file, error_func, pw, envp) if (!pw) { char *username = cmd; /* temp buffer */ + char *s, *group; + struct group *grp; Debug(DPARS, ("load_entry()...about to parse username\n")) ch = get_string(username, MAX_COMMAND, file, " \t"); @@ -234,12 +250,37 @@ load_entry(file, error_func, pw, envp) goto eof; } +#ifdef LOGIN_CAP + if ((s = strrchr(username, '/')) != NULL) { + *s = '\0'; + e->class = strdup(s + 1); + } else + e->class = strdup(RESOURCE_RC); + if (login_getclass(e->class) == NULL) { + ecode = e_class; + goto eof; + } +#endif + grp = NULL; + if ((s = strrchr(username, ':')) != NULL) { + *s = '\0'; + if ((grp = getgrnam(s + 1)) == NULL) { + ecode = e_group; + goto eof; + } + } + pw = getpwnam(username); if (pw == NULL) { ecode = e_username; goto eof; } - Debug(DPARS, ("load_entry()...uid %d, gid %d\n",e->uid,e->gid)) + if (grp != NULL) + pw->pw_gid = grp->gr_gid; + Debug(DPARS, ("load_entry()...uid %d, gid %d\n",pw->pw_uid,pw->pw_gid)) +#ifdef LOGIN_CAP + Debug(DPARS, ("load_entry()...class %s\n",e->class)) +#endif } if (pw->pw_expire && time(NULL) >= pw->pw_expire) { |