1 /* Copyright 1988,1990,1993 by Paul Vixie
4 * Distribute freely, except: don't remove my name from the source or
5 * documentation (don't take credit for my work), mark your changes (don't
6 * get me blamed for your possible bugs), don't alter or remove this
7 * notice. May be sold if buildable source is provided to buyer. No
8 * warrantee of any kind, express or implied, is included with this
9 * software; use at your own risk, responsibility for damages (if any) to
10 * anyone resulting from the use of this software rests entirely with the
13 * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
14 * I'll try to keep a version up to date. I can be reached as follows:
15 * Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
18 #if !defined(lint) && !defined(LINT)
19 static char rcsid
[] = "$Id: user.c,v 1.1 1994/01/05 20:40:15 jtc Exp $";
22 /* vix 26jan87 [log is in RCS file]
37 for (e
= u
->crontab
; e
!= NULL
; e
= ne
) {
41 for (env
= u
->envp
; *env
; env
++)
49 load_user(crontab_fd
, name
, uid
, gid
, dir
, syscron
)
55 int syscron
; /* system crontab file? */
57 char envstr
[MAX_ENVSTR
];
63 if (!(file
= fdopen(crontab_fd
, "r"))) {
64 perror("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 u
= (user
*) malloc(sizeof(user
));
79 * do auto env settings that the user could reset in the cron tab
81 sprintf(envstr
, "SHELL=%s", _PATH_BSHELL
);
82 u
->envp
= env_set(u
->envp
, envstr
);
84 sprintf(envstr
, "HOME=%s", dir
);
85 u
->envp
= env_set(u
->envp
, envstr
);
89 while ((status
= load_env(envstr
, file
)) >= OK
) {
91 u
->envp
= env_set(u
->envp
, envstr
);
93 if (NULL
!= (e
= load_entry(file
, NULL
, syscron
))) {
101 * do automatic env settings that should have precedence over any
102 * set in the cron tab.
104 sprintf(envstr
, "%s=%s", "LOGNAME", name
);
105 u
->envp
= env_set(u
->envp
, envstr
);
107 sprintf(envstr
, "%s=%s", "USER", name
);
108 u
->envp
= env_set(u
->envp
, envstr
);
112 * done. close file, return pointer to 'user' structure
116 Debug(DPARS
, ("...load_user() done\n"))