summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Nugent <davidn@FreeBSD.org>1997-01-20 15:31:33 +0000
committerDavid Nugent <davidn@FreeBSD.org>1997-01-20 15:31:33 +0000
commitb25b7bc1bec8041b6492b6aa48d9efb49e7a3eec (patch)
tree791753da7da49f4e5788d8e7c7020eba15588a12
parent7aa571fe7e89d4785191963d3e06bc8b7641fbb3 (diff)
Notes
-rw-r--r--usr.sbin/cron/cron/Makefile2
-rw-r--r--usr.sbin/cron/cron/do_command.c15
2 files changed, 17 insertions, 0 deletions
diff --git a/usr.sbin/cron/cron/Makefile b/usr.sbin/cron/cron/Makefile
index 27d2a3a807d5..a81be73d3a0c 100644
--- a/usr.sbin/cron/cron/Makefile
+++ b/usr.sbin/cron/cron/Makefile
@@ -4,6 +4,8 @@ PROG= cron
SRCS= cron.c database.c do_command.c job.c user.c popen.c
MAN8= cron.8
+CFLAGS+=-DLOGIN_CAP
+
.if exists(${.OBJDIR}/../lib)
LDDESTDIR+= -L${.OBJDIR}/../lib
DPADD+= ${.OBJDIR}/../lib/libcron.a
diff --git a/usr.sbin/cron/cron/do_command.c b/usr.sbin/cron/cron/do_command.c
index 736fe8930e6c..3898705da576 100644
--- a/usr.sbin/cron/cron/do_command.c
+++ b/usr.sbin/cron/cron/do_command.c
@@ -28,6 +28,9 @@ static char rcsid[] = "$FreeBSD$";
#if defined(SYSLOG)
# include <syslog.h>
#endif
+#if defined(LOGIN_CAP)
+# include <login_cap.h>
+#endif
static void child_process __P((entry *, user *)),
@@ -77,6 +80,10 @@ child_process(e, u)
register char *input_data;
char *usernm, *mailto;
int children = 0;
+# if defined(LOGIN_CAP)
+ struct passwd *pwd = getpwuid(e->uid);
+ login_cap_t *lc = login_getclass(pwd);
+# endif
Debug(DPROC, ("[%d] child_process('%s')\n", getpid(), e->cmd))
@@ -212,6 +219,13 @@ child_process(e, u)
*/
do_univ(u);
+# if defined(LOGIN_CAP)
+ /* Set user's entire context, but skip the environment
+ * as cron provides a separate interface for this
+ */
+ setusercontext(lc, pwd, e->uid, LOGIN_SETALL & ~(LOGIN_SETPATH|LOGIN_SETENV));
+ login_close(lc);
+# else
/* set our directory, uid and gid. Set gid first, since once
* we set uid, we've lost root privledges.
*/
@@ -221,6 +235,7 @@ child_process(e, u)
# endif
setlogin(usernm);
setuid(e->uid); /* we aren't root after this... */
+#endif
chdir(env_get("HOME", e->envp));
/* exec the command.