Commit 8c182b01 authored by Łukasz Nowak's avatar Łukasz Nowak

- dcron non root, non global system patch


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44919 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e19ba6f7
# Patch to have dcron running as ordinary user and installable without root
# requirement
diff -ru dcron-4.4.org/chuser.c dcron-4.4/chuser.c
--- dcron-4.4.org/chuser.c 2010-01-18 16:27:31.000000000 +0100
+++ dcron-4.4/chuser.c 2011-03-31 16:39:52.000000000 +0200
@@ -14,47 +14,6 @@
int
ChangeUser(const char *user, char *dochdir)
{
- struct passwd *pas;
-
- /*
- * Obtain password entry and change privilages
- */
-
- if ((pas = getpwnam(user)) == 0) {
- printlogf(LOG_ERR, "failed to get uid for %s\n", user);
- return(-1);
- }
- setenv("USER", pas->pw_name, 1);
- setenv("HOME", pas->pw_dir, 1);
- setenv("SHELL", "/bin/sh", 1);
-
- /*
- * Change running state to the user in question
- */
-
- if (initgroups(user, pas->pw_gid) < 0) {
- printlogf(LOG_ERR, "initgroups failed: %s %s\n", user, strerror(errno));
- return(-1);
- }
- if (setregid(pas->pw_gid, pas->pw_gid) < 0) {
- printlogf(LOG_ERR, "setregid failed: %s %d\n", user, pas->pw_gid);
- return(-1);
- }
- if (setreuid(pas->pw_uid, pas->pw_uid) < 0) {
- printlogf(LOG_ERR, "setreuid failed: %s %d\n", user, pas->pw_uid);
- return(-1);
- }
- if (dochdir) {
- /* try to change to $HOME */
- if (chdir(pas->pw_dir) < 0) {
- printlogf(LOG_ERR, "chdir failed: %s %s\n", user, pas->pw_dir);
- /* dochdir is a backup directory, usually /tmp */
- if (chdir(dochdir) < 0) {
- printlogf(LOG_ERR, "chdir failed: %s %s\n", user, dochdir);
- return(-1);
- }
- }
- }
- return(pas->pw_uid);
+ return getpwnam(user);
}
diff -ru dcron-4.4.org/Makefile dcron-4.4/Makefile
--- dcron-4.4.org/Makefile 2010-01-18 16:27:31.000000000 +0100
+++ dcron-4.4/Makefile 2011-03-31 16:01:08.000000000 +0200
@@ -3,7 +3,6 @@
# these variables can be configured by e.g. `make SCRONTABS=/different/path`
PREFIX = /usr/local
-CRONTAB_GROUP = wheel
SCRONTABS = /etc/cron.d
CRONTABS = /var/spool/cron/crontabs
CRONSTAMPS = /var/spool/cron/cronstamps
@@ -20,10 +19,10 @@
SHELL = /bin/sh
-INSTALL = install -o root
+INSTALL = install
INSTALL_PROGRAM = $(INSTALL) -D
-INSTALL_DATA = $(INSTALL) -D -m0644 -g root
-INSTALL_DIR = $(INSTALL) -d -m0755 -g root
+INSTALL_DATA = $(INSTALL) -D -m0644
+INSTALL_DIR = $(INSTALL) -d -m0755
CFLAGS ?= -O2
CFLAGS += -Wall -Wstrict-prototypes
SRCS = main.c subs.c database.c job.c concat.c chuser.c
@@ -44,7 +43,6 @@
echo "SBINDIR = $(SBINDIR)" >> config
echo "BINDIR = $(BINDIR)" >> config
echo "MANDIR = $(MANDIR)" >> config
- echo "CRONTAB_GROUP = $(CRONTAB_GROUP)" >> config
echo "SCRONTABS = $(SCRONTABS)" >> config
echo "CRONTABS = $(CRONTABS)" >> config
echo "CRONSTAMPS = $(CRONSTAMPS)" >> config
@@ -62,13 +60,10 @@
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $< -o $@
install:
- $(INSTALL_PROGRAM) -m0700 -g root crond $(DESTDIR)$(SBINDIR)/crond
- $(INSTALL_PROGRAM) -m4750 -g $(CRONTAB_GROUP) crontab $(DESTDIR)$(BINDIR)/crontab
+ $(INSTALL_PROGRAM) -m0700 crond $(DESTDIR)$(SBINDIR)/crond
+ $(INSTALL_PROGRAM) -m4750 crontab $(DESTDIR)$(BINDIR)/crontab
$(INSTALL_DATA) crontab.1 $(DESTDIR)$(MANDIR)/man1/crontab.1
$(INSTALL_DATA) crond.8 $(DESTDIR)$(MANDIR)/man8/crond.8
- $(INSTALL_DIR) $(DESTDIR)$(SCRONTABS)
- $(INSTALL_DIR) $(DESTDIR)$(CRONTABS)
- $(INSTALL_DIR) $(DESTDIR)$(CRONSTAMPS)
clean: force
rm -f *.o $(PROTOS)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment