1 /* Copyright 1988,1990,1993,1994 by Paul Vixie
6 * Copyright (c) 1997 by Internet Software Consortium
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
13 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
14 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
15 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
18 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
22 #if !defined(lint) && !defined(LINT)
23 static const char rcsid[] = "$Id: user.c,v 1.2 1998/08/14 00:32:41 vixie Exp $";
26 /* vix 26jan87 [log is in RCS file]
31 static char *User_name;
39 for (e = u->crontab; e != NULL; e = ne) {
47 log_error(const char *msg)
49 log_it(User_name, getpid(), "PARSE", msg);
52 /* NULL pw implies syscrontab */
54 load_user(int crontab_fd, struct passwd *pw, const char *name)
56 char envstr[MAX_ENVSTR];
63 if (!(file = fdopen(crontab_fd, "r"))) {
64 warn("fdopen on crontab_fd in load_user");
68 Debug(DPARS, ("load_user()\n"))
70 /* file is open. build user entry, then read the crontab file.
72 if ((u = (user *) malloc(sizeof(user))) == NULL) {
76 if ((u->name = strdup(name)) == NULL) {
84 * init environment. this will be copied/augmented for each entry.
86 if ((envp = env_init()) == NULL) {
95 while ((status = load_env(envstr, file)) >= OK) {
102 User_name = u->name; /* for log_error */
103 e = load_entry(file, log_error, pw, envp);
105 e->next = u->crontab;
110 if ((tenvp = env_set(envp, envstr))) {
124 Debug(DPARS, ("...load_user() done\n"))