4.1.20060426-alt1

- Updated to OpenBSD CVS snapshot dated 2006/04/26.
- Changed crontab to use $TMPDIR for creating temporary file.
This commit is contained in:
Дмитрий Левин 2006-05-01 15:06:32 +00:00
parent 1110eceed2
commit e6a9ee02f1
23 changed files with 444 additions and 288 deletions

View File

@ -2,7 +2,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/linux.mk vixie-cron-4.1.20040916/li
--- vixie-cron-4.1.20040916.orig/linux.mk 1970-01-01 03:00:00 +0300
+++ vixie-cron-4.1.20040916/linux.mk 2004-11-03 01:16:51 +0300
@@ -0,0 +1,30 @@
+DESTDIR=$(RPM_BUILD_ROOT)
+DESTDIR=
+MANDIR=$(DESTDIR)/usr/share/man/
+
+CFLAGS += -I. -I../../include $(RPM_OPT_FLAGS) -DLINT
@ -10,7 +10,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/linux.mk vixie-cron-4.1.20040916/li
+.PHONY: clean install maninstall proginstall
+
+$(PROG): $(SRCS:.c=.o)
+ $(LINK.o) $+ $(LDFLAGS) -o $@
+ $(LINK.o) $^ $(LDLIBS) -o $@
+
+clean:
+ $(RM) $(PROG) $(SRCS:.c=.o)
@ -55,7 +55,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.bin/crontab/Makefile vixie-cron
PROG= crontab
-SRCS= crontab.c misc.c entry.c env.c
+SRCS= crontab.c misc.c entry.c env.c closeall.c ../../lib/libc/gen/pw_dup.c
CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../../usr.sbin/cron -DDEBUGGING=0
CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../../usr.sbin/cron -DDEBUGGING=0
BINGRP =crontab
BINMODE=2555
MAN= crontab.1 crontab.5

View File

@ -332,7 +332,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/Makefile vixie-cron-4
- misc.c env.c popen.c atrun.c closeall.c ../../lib/libc/gen/pw_dup.c
+ misc.c env.c popen.c atrun.c closeall.c pam_auth.c ../../lib/libc/gen/pw_dup.c
CFLAGS+=-I${.CURDIR}
+LDFLAGS+=-lpam
+LDLIBS+=-lpam
MAN= cron.8
#.include <bsd.prog.mk>
@ -352,7 +352,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/pam_auth.c vixie-cron
+
+ if (setresuid (uid, uid, -1))
+ {
+ log_it ("CRON", getpid (), "xfork: seteuid failed",
+ log_it ("CRON", getpid (), "xfork: setresuid failed",
+ strerror (errno));
+ return -1;
+ }
@ -365,7 +365,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/pam_auth.c vixie-cron
+ {
+ if (!pid)
+ _exit (1);
+ log_it ("CRON", getpid (), "xfork: seteuid failed",
+ log_it ("CRON", getpid (), "xfork: setresuid failed",
+ strerror (errno));
+ return -1;
+ }
@ -378,7 +378,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/pam_auth.c vixie-cron
+
+#include <security/pam_appl.h>
+
+static pam_handle_t *pamh = 0;
+static pam_handle_t *pamh = NULL;
+static const struct pam_conv cron_conv = { 0 };
+
+int
@ -393,7 +393,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/pam_auth.c vixie-cron
+ log_close ();
+ if (retval != PAM_SUCCESS)
+ {
+ pamh = 0;
+ pamh = NULL;
+ log_it ("CRON", getpid (), "pam_start failed",
+ pam_strerror (pamh, retval));
+ return 0;
@ -405,7 +405,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/pam_auth.c vixie-cron
+ log_it ("CRON", getpid (), "pam_authenticate failed",
+ pam_strerror (pamh, retval));
+ pam_end (pamh, retval);
+ pamh = 0;
+ pamh = NULL;
+ return 0;
+ }
+ retval = pam_acct_mgmt (pamh, PAM_SILENT);
@ -415,7 +415,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/pam_auth.c vixie-cron
+ log_it ("CRON", getpid (), "pam_acct_mgmt failed",
+ pam_strerror (pamh, retval));
+ pam_end (pamh, retval);
+ pamh = 0;
+ pamh = NULL;
+ return 0;
+ }
+ retval = pam_open_session (pamh, PAM_SILENT);
@ -425,7 +425,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/pam_auth.c vixie-cron
+ log_it ("CRON", getpid (), "pam_open_session failed",
+ pam_strerror (pamh, retval));
+ pam_end (pamh, retval);
+ pamh = 0;
+ pamh = NULL;
+ return 0;
+ }
+
@ -447,7 +447,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/pam_auth.c vixie-cron
+ log_it ("CRON", getpid (), "pam_setcred failed",
+ pam_strerror (pamh, retval));
+ pam_end (pamh, retval);
+ pamh = 0;
+ pamh = NULL;
+ log_close ();
+ return 0;
+ }
@ -463,7 +463,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/pam_auth.c vixie-cron
+
+ pam_close_session (pamh, 0);
+ pam_end (pamh, 0);
+ pamh = 0;
+ pamh = NULL;
+ log_close ();
+}
+
@ -475,7 +475,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/pam_auth.c vixie-cron
+cron_pam_child_close (void)
+{
+ pam_end (pamh, PAM_DATA_SILENT);
+ pamh = 0;
+ pamh = NULL;
+ log_close ();
+}
+

View File

@ -54,9 +54,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/Makefile vixie-cron-4
SRCS= cron.c database.c user.c entry.c job.c do_command.c \
misc.c env.c popen.c atrun.c closeall.c pam_auth.c ../../lib/libc/gen/pw_dup.c
-CFLAGS+=-I${.CURDIR}
-LDFLAGS+=-lpam
-LDLIBS+=-lpam
+CFLAGS+=-I${.CURDIR} -DHAVE_SETPROCTITLE=1
+LDFLAGS+=-lpam -lsetproctitle
+LDLIBS+=-lpam -lsetproctitle
MAN= cron.8
#.include <bsd.prog.mk>

View File

@ -1,23 +0,0 @@
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/do_command.c vixie-cron-4.1.20040916/usr.sbin/cron/do_command.c
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/do_command.c 2004-06-18 02:11:55 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/do_command.c 2004-11-03 00:46:16 +0300
@@ -372,7 +372,7 @@ child_process(entry *e, user *u) {
int ch = getc(in);
if (ch != EOF) {
- FILE *mail;
+ FILE *mail = 0;
int bytes = 1;
int status = 0;
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/env.c vixie-cron-4.1.20040916/usr.sbin/cron/env.c
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/env.c 2004-06-22 07:15:33 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/env.c 2004-11-03 00:46:16 +0300
@@ -206,6 +206,7 @@ load_env(char *envstr, FILE *f) {
else
state++;
break;
+ default: break;
}
}
if (state != FINI && !(state == VALUE && !quotechar)) {

View File

@ -0,0 +1,23 @@
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/do_command.c vixie-cron-4.1.20060426/usr.sbin/cron/do_command.c
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/do_command.c 2004-06-17 22:11:55 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/do_command.c 2004-11-02 21:46:16 +0000
@@ -372,7 +372,7 @@ child_process(entry *e, user *u) {
int ch = getc(in);
if (ch != EOF) {
- FILE *mail;
+ FILE *mail = 0;
int bytes = 1;
int status = 0;
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/env.c vixie-cron-4.1.20060426/usr.sbin/cron/env.c
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/env.c 2005-01-30 20:44:50 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/env.c 2006-04-30 22:13:52 +0000
@@ -205,6 +205,7 @@ load_env(char *envstr, FILE *f) {
else
state++;
break;
+ default: break;
}
}
if (state != FINI && !(state == VALUE && !quotechar)) {

View File

@ -1,7 +1,7 @@
diff -uprk.orig vixie-cron-4.1.20040916.orig/lib/libc/gen/pw_dup.c vixie-cron-4.1.20040916/lib/libc/gen/pw_dup.c
--- vixie-cron-4.1.20040916.orig/lib/libc/gen/pw_dup.c 2003-06-18 01:56:23 +0400
+++ vixie-cron-4.1.20040916/lib/libc/gen/pw_dup.c 2004-12-18 20:20:03 +0300
@@ -35,7 +35,10 @@ struct passwd *
diff -upk.orig vixie-cron-4.1.20060426.orig/lib/libc/gen/pw_dup.c vixie-cron-4.1.20060426/lib/libc/gen/pw_dup.c
--- vixie-cron-4.1.20060426.orig/lib/libc/gen/pw_dup.c 2005-08-08 08:05:34 +0000
+++ vixie-cron-4.1.20060426/lib/libc/gen/pw_dup.c 2006-04-30 22:19:32 +0000
@@ -48,14 +48,19 @@ struct passwd *
pw_dup(const struct passwd *pw)
{
char *cp;
@ -13,37 +13,29 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/lib/libc/gen/pw_dup.c vixie-cron-4.
struct passwd *newpw;
/* Allocate in one big chunk for easy freeing */
@@ -48,10 +51,12 @@ pw_dup(const struct passwd *pw)
psize = strlen(pw->pw_passwd) + 1;
total += psize;
}
total = sizeof(struct passwd);
PW_SIZE(pw_name, nsize);
PW_SIZE(pw_passwd, psize);
+#ifdef LOGIN_CAP
if (pw->pw_class) {
csize = strlen(pw->pw_class) + 1;
total += csize;
}
PW_SIZE(pw_class, csize);
+#endif
if (pw->pw_gecos) {
gsize = strlen(pw->pw_gecos) + 1;
total += gsize;
@@ -84,11 +89,13 @@ pw_dup(const struct passwd *pw)
newpw->pw_passwd = cp;
cp += psize;
}
PW_SIZE(pw_gecos, gsize);
PW_SIZE(pw_dir, dsize);
PW_SIZE(pw_shell, ssize);
@@ -73,7 +78,9 @@ pw_dup(const struct passwd *pw)
PW_COPY(pw_name, nsize);
PW_COPY(pw_passwd, psize);
+#ifdef LOGIN_CAP
if (pw->pw_class) {
(void)memcpy(cp, pw->pw_class, csize);
newpw->pw_class = cp;
cp += csize;
}
PW_COPY(pw_class, csize);
+#endif
if (pw->pw_gecos) {
(void)memcpy(cp, pw->pw_gecos, gsize);
newpw->pw_gecos = cp;
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.bin/at/at.1 vixie-cron-4.1.20040916/usr.bin/at/at.1
--- vixie-cron-4.1.20040916.orig/usr.bin/at/at.1 2003-06-10 13:12:09 +0400
+++ vixie-cron-4.1.20040916/usr.bin/at/at.1 2004-12-18 20:20:03 +0300
@@ -276,20 +276,20 @@ shell, the owner of the login shell will
PW_COPY(pw_gecos, gsize);
PW_COPY(pw_dir, dsize);
PW_COPY(pw_shell, ssize);
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.bin/at/at.1 vixie-cron-4.1.20060426/usr.bin/at/at.1
--- vixie-cron-4.1.20060426.orig/usr.bin/at/at.1 2005-09-30 20:34:25 +0000
+++ vixie-cron-4.1.20060426/usr.bin/at/at.1 2006-04-30 22:16:46 +0000
@@ -273,20 +273,20 @@ shell, the owner of the login shell will
For non-root users, permission to run
.Nm
is determined by the files
@ -69,7 +61,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.bin/at/at.1 vixie-cron-4.1.2004
is checked.
Every username not mentioned in it is then allowed to use
.Nm at .
@@ -297,16 +297,16 @@ If neither exists, only the superuser is
@@ -294,16 +294,16 @@ If neither exists, only the superuser is
.Nm at .
.Pp
An empty
@ -91,9 +83,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.bin/at/at.1 vixie-cron-4.1.2004
deny permission control
.El
.Sh SEE ALSO
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.bin/at/at.c vixie-cron-4.1.20040916/usr.bin/at/at.c
--- vixie-cron-4.1.20040916.orig/usr.bin/at/at.c 2004-06-18 02:09:11 +0400
+++ vixie-cron-4.1.20040916/usr.bin/at/at.c 2004-12-18 20:20:03 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.bin/at/at.c vixie-cron-4.1.20060426/usr.bin/at/at.c
--- vixie-cron-4.1.20060426.orig/usr.bin/at/at.c 2006-04-26 03:01:48 +0000
+++ vixie-cron-4.1.20060426/usr.bin/at/at.c 2006-04-30 22:22:37 +0000
@@ -38,6 +38,8 @@
#include "privs.h"
#include <limits.h>
@ -103,16 +95,35 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.bin/at/at.c vixie-cron-4.1.2004
#define ALARMC 10 /* Number of seconds to wait for timeout */
#define TIMESIZE 50 /* Size of buffer passed to strftime() */
@@ -134,7 +136,7 @@ perr2(const char *a, const char *b)
perr(b);
@@ -62,15 +64,15 @@ char force = 0; /* suppress errors (at
char interactive = 0; /* interactive mode (atrm) */
static int send_mail = 0; /* whether we are sending mail */
-static void sigc(int);
+static __dead void sigc(int);
static void alarmc(int);
static void writefile(const char *, time_t, char);
static void list_jobs(int, char **, int, int);
static time_t ttime(const char *);
static int check_permission(void);
static __dead void panic(const char *);
-static void perr(const char *);
-static void perr2(const char *, const char *);
+static __dead void perr(const char *);
+static __dead void perr2(const char *, const char *);
static __dead void usage(void);
time_t parsetime(int, char **);
@@ -135,7 +137,7 @@ perr2(const char *a, const char *b)
}
/* ARGSUSED */
-static void
+static __dead void
sigc(int signo)
{
/* If the user presses ^C, remove the spool file and exit. */
@@ -512,7 +514,7 @@ list_jobs(int argc, char **argv, int cou
@@ -514,7 +516,7 @@ list_jobs(int argc, char **argv, int cou
PRIV_END;
@ -121,9 +132,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.bin/at/at.c vixie-cron-4.1.2004
perr2("Cannot stat ", AT_DIR);
/*
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.bin/at/atq.1 vixie-cron-4.1.20040916/usr.bin/at/atq.1
--- vixie-cron-4.1.20040916.orig/usr.bin/at/atq.1 2003-06-10 13:12:09 +0400
+++ vixie-cron-4.1.20040916/usr.bin/at/atq.1 2004-12-18 20:20:03 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.bin/at/atq.1 vixie-cron-4.1.20060426/usr.bin/at/atq.1
--- vixie-cron-4.1.20060426.orig/usr.bin/at/atq.1 2003-06-10 09:12:09 +0000
+++ vixie-cron-4.1.20060426/usr.bin/at/atq.1 2006-04-30 22:16:46 +0000
@@ -88,8 +88,8 @@ Jobs that have completed but have not ye
If a name(s) is provided, only those files belonging to that user(s) are
displayed.
@ -135,10 +146,10 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.bin/at/atq.1 vixie-cron-4.1.200
directory containing job files
.El
.Sh SEE ALSO
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.bin/at/atrm.1 vixie-cron-4.1.20040916/usr.bin/at/atrm.1
--- vixie-cron-4.1.20040916.orig/usr.bin/at/atrm.1 2003-06-10 13:12:09 +0400
+++ vixie-cron-4.1.20040916/usr.bin/at/atrm.1 2004-12-18 20:20:03 +0300
@@ -74,8 +74,8 @@ If one or more user names are specified,
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.bin/at/atrm.1 vixie-cron-4.1.20060426/usr.bin/at/atrm.1
--- vixie-cron-4.1.20060426.orig/usr.bin/at/atrm.1 2005-06-23 14:39:35 +0000
+++ vixie-cron-4.1.20060426/usr.bin/at/atrm.1 2006-04-30 22:16:46 +0000
@@ -77,8 +77,8 @@ If one or more user names are specified,
are removed.
Only the superuser may remove other users' jobs.
.Sh FILES
@ -149,10 +160,10 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.bin/at/atrm.1 vixie-cron-4.1.20
directory containing job files
.El
.Sh SEE ALSO
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/atrun.c vixie-cron-4.1.20040916/usr.sbin/cron/atrun.c
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/atrun.c 2004-06-18 02:11:55 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/atrun.c 2004-12-18 20:20:03 +0300
@@ -383,7 +383,9 @@ run_job(atjob *job, char *atfile)
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/atrun.c vixie-cron-4.1.20060426/usr.sbin/cron/atrun.c
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/atrun.c 2005-01-30 20:45:58 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/atrun.c 2006-04-30 22:16:46 +0000
@@ -386,7 +386,9 @@ run_job(atjob *job, char *atfile)
}
/* mark ourselves as different to PS command watchers */
@ -162,9 +173,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/atrun.c vixie-cron-4.
pipe(output_pipe); /* child's stdout/stderr */
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/closeall.c vixie-cron-4.1.20040916/usr.sbin/cron/closeall.c
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/closeall.c 1970-01-01 03:00:00 +0300
+++ vixie-cron-4.1.20040916/usr.sbin/cron/closeall.c 2004-12-18 20:20:03 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/closeall.c vixie-cron-4.1.20060426/usr.sbin/cron/closeall.c
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/closeall.c 1970-01-01 00:00:00 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/closeall.c 2006-04-30 22:16:46 +0000
@@ -0,0 +1,27 @@
+#include <unistd.h>
+#include <errno.h>
@ -193,9 +204,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/closeall.c vixie-cron
+
+ return 0;
+}
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/config.h vixie-cron-4.1.20040916/usr.sbin/cron/config.h
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/config.h 2004-06-18 02:11:55 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/config.h 2004-12-18 20:20:03 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/config.h vixie-cron-4.1.20060426/usr.sbin/cron/config.h
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/config.h 2004-06-17 22:11:55 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/config.h 2006-04-30 22:16:46 +0000
@@ -29,7 +29,7 @@
*/
@ -230,9 +241,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/config.h vixie-cron-4
/* if your OS has a getloadavg() function */
#define HAVE_GETLOADAVG /*-*/
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/cron.8 vixie-cron-4.1.20040916/usr.sbin/cron/cron.8
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/cron.8 2004-06-03 23:56:09 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/cron.8 2004-12-18 20:20:03 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/cron.8 vixie-cron-4.1.20060426/usr.sbin/cron/cron.8
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/cron.8 2005-11-30 11:18:28 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/cron.8 2006-04-30 22:16:46 +0000
@@ -29,7 +29,7 @@
.Nm cron
.Op Fl l Ar load_avg
@ -314,9 +325,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/cron.8 vixie-cron-4.1
-.Pa /etc/crontab
-is used, the mode must be set manually on that file.
+.Xr crontab 1 .
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/cron.c vixie-cron-4.1.20040916/usr.sbin/cron/cron.c
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/cron.c 2004-06-18 02:11:55 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/cron.c 2004-12-18 20:20:03 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/cron.c vixie-cron-4.1.20060426/usr.sbin/cron/cron.c
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/cron.c 2005-11-15 07:02:37 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/cron.c 2006-04-30 22:16:46 +0000
@@ -49,6 +49,8 @@ static cron_db database;
static at_db at_database;
static double batch_maxload = BATCH_MAXLOAD;
@ -345,9 +356,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/cron.c vixie-cron-4.1
bzero((char *)&sact, sizeof sact);
sigemptyset(&sact.sa_mask);
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.1 vixie-cron-4.1.20040916/usr.sbin/cron/crontab.1
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.1 2004-06-18 02:11:55 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/crontab.1 2004-12-18 20:20:03 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/crontab.1 vixie-cron-4.1.20060426/usr.sbin/cron/crontab.1
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/crontab.1 2004-06-17 22:11:55 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/crontab.1 2006-04-30 22:16:46 +0000
@@ -45,7 +45,7 @@ daemon.
Each user can have their own
.Xr crontab 5 ,
@ -408,9 +419,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.1 vixie-cron-
directory of individual crontabs
.El
.Sh DIAGNOSTICS
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.5 vixie-cron-4.1.20040916/usr.sbin/cron/crontab.5
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.5 2004-06-18 02:11:55 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/crontab.5 2004-12-18 20:20:03 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/crontab.5 vixie-cron-4.1.20060426/usr.sbin/cron/crontab.5
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/crontab.5 2004-06-17 22:11:55 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/crontab.5 2006-04-30 22:16:46 +0000
@@ -39,7 +39,7 @@ There may be a system
.Pf ( Pa /etc/crontab )
and each user may have their own
@ -420,10 +431,10 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.5 vixie-cron-
Commands in any given
.Nm
will be
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.c vixie-cron-4.1.20040916/usr.sbin/cron/crontab.c
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.c 2004-09-16 22:34:05 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/crontab.c 2004-12-18 20:20:03 +0300
@@ -60,6 +60,8 @@ static void list_cmd(void),
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/crontab.c vixie-cron-4.1.20060426/usr.sbin/cron/crontab.c
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/crontab.c 2005-11-29 20:43:31 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/crontab.c 2006-04-30 22:28:05 +0000
@@ -58,6 +58,8 @@ static void list_cmd(void),
die(int);
static int replace_cmd(void);
@ -432,7 +443,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.c vixie-cron-
static void
usage(const char *msg) {
fprintf(stderr, "%s: usage error: %s\n", ProgramName, msg);
@@ -78,6 +80,7 @@ main(int argc, char *argv[]) {
@@ -76,6 +78,7 @@ main(int argc, char *argv[]) {
Pid = getpid();
ProgramName = argv[0];
@ -440,10 +451,10 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.c vixie-cron-
setlocale(LC_ALL, "");
@@ -285,8 +288,12 @@ edit_cmd(void) {
@@ -283,8 +286,12 @@ edit_cmd(void) {
FILE *f;
int ch, t, x;
struct stat statbuf;
struct stat statbuf, xstatbuf;
+#ifndef HAVE_FUTIMES
+ struct utimbuf utimebuf;
+#else
@ -453,7 +464,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.c vixie-cron-
WAIT_T waiter;
PID_T pid, xpid;
@@ -312,16 +319,21 @@ edit_cmd(void) {
@@ -310,16 +317,21 @@ edit_cmd(void) {
perror("fstat");
goto fatal;
}
@ -476,7 +487,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.c vixie-cron-
_PATH_TMP) >= sizeof(Filename)) {
fprintf(stderr, "path too long\n");
goto fatal;
@@ -362,7 +374,11 @@ edit_cmd(void) {
@@ -360,7 +372,11 @@ edit_cmd(void) {
perror(Filename);
exit(ERROR_EXIT);
}
@ -488,7 +499,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.c vixie-cron-
again:
rewind(NewCrontab);
if (ferror(NewCrontab)) {
@@ -392,12 +408,16 @@ edit_cmd(void) {
@@ -390,12 +406,16 @@ edit_cmd(void) {
goto fatal;
case 0:
/* child */
@ -508,7 +519,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.c vixie-cron-
exit(ERROR_EXIT);
}
if (snprintf(q, sizeof q, "%s %s", editor, Filename) >= sizeof(q)) {
@@ -447,7 +467,11 @@ edit_cmd(void) {
@@ -445,7 +465,11 @@ edit_cmd(void) {
perror("fstat");
goto fatal;
}
@ -517,21 +528,21 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/crontab.c vixie-cron-
+#else
if (timespeccmp(&mtimespec, &statbuf.st_mtimespec, -) == 0) {
+#endif
fprintf(stderr, "%s: no changes made to crontab\n",
ProgramName);
goto remove;
@@ -508,7 +532,7 @@ replace_cmd(void) {
if (lstat(Filename, &xstatbuf) == 0 &&
statbuf.st_ino != xstatbuf.st_ino) {
fprintf(stderr, "%s: crontab temp file moved, editor "
@@ -514,7 +538,7 @@ replace_cmd(void) {
fprintf(stderr, "%s: Cannot allocate memory.\n", ProgramName);
return (-2);
}
- if (snprintf(TempFilename, sizeof TempFilename, "%s/tmp.XXXXXXXXX", SPOOL_DIR) >=
+ if (snprintf(TempFilename, sizeof TempFilename, "%s/tmp.XXXXXX", SPOOL_DIR) >=
sizeof(TempFilename)) {
- if (snprintf(TempFilename, sizeof TempFilename, "%s/tmp.XXXXXXXXX",
+ if (snprintf(TempFilename, sizeof TempFilename, "%s/tmp.XXXXXX",
SPOOL_DIR) >= sizeof(TempFilename)) {
TempFilename[0] = '\0';
fprintf(stderr, "path too long\n");
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/do_command.c vixie-cron-4.1.20040916/usr.sbin/cron/do_command.c
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/do_command.c 2004-12-18 20:19:50 +0300
+++ vixie-cron-4.1.20040916/usr.sbin/cron/do_command.c 2004-12-18 20:20:03 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/do_command.c vixie-cron-4.1.20060426/usr.sbin/cron/do_command.c
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/do_command.c 2004-11-02 21:46:16 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/do_command.c 2006-04-30 22:16:46 +0000
@@ -70,7 +70,9 @@ child_process(entry *e, user *u) {
Debug(DPROC, ("[%ld] child_process('%s')\n", (long)getpid(), e->cmd))
@ -542,9 +553,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/do_command.c vixie-cr
/* discover some useful and important environment settings
*/
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/externs.h vixie-cron-4.1.20040916/usr.sbin/cron/externs.h
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/externs.h 2004-06-18 02:11:55 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/externs.h 2004-12-18 20:20:03 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/externs.h vixie-cron-4.1.20060426/usr.sbin/cron/externs.h
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/externs.h 2004-06-17 22:11:55 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/externs.h 2006-04-30 22:16:46 +0000
@@ -22,6 +22,9 @@
*/
@ -555,9 +566,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/externs.h vixie-cron-
#include <sys/param.h>
#include <sys/types.h>
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/funcs.h vixie-cron-4.1.20040916/usr.sbin/cron/funcs.h
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/funcs.h 2004-06-18 02:11:55 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/funcs.h 2004-12-18 20:20:03 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/funcs.h vixie-cron-4.1.20060426/usr.sbin/cron/funcs.h
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/funcs.h 2005-01-30 20:44:50 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/funcs.h 2006-04-30 22:16:46 +0000
@@ -66,6 +66,7 @@ char *env_get(char *, char **),
**env_copy(char **),
**env_set(char **, char *);
@ -566,9 +577,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/funcs.h vixie-cron-4.
void mkprint(char *, unsigned char *, int);
user *load_user(int, struct passwd *, const char *),
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/globals.h vixie-cron-4.1.20040916/usr.sbin/cron/globals.h
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/globals.h 2004-06-18 02:11:55 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/globals.h 2004-12-18 20:20:03 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/globals.h vixie-cron-4.1.20060426/usr.sbin/cron/globals.h
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/globals.h 2004-06-17 22:11:55 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/globals.h 2006-04-30 22:16:46 +0000
@@ -57,7 +57,8 @@ XTRN const char *DowNames[]
#endif
;
@ -579,9 +590,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/globals.h vixie-cron-
XTRN int LineNumber INIT(0);
XTRN time_t StartTime INIT(0);
XTRN int NoFork INIT(0);
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/macros.h vixie-cron-4.1.20040916/usr.sbin/cron/macros.h
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/macros.h 2004-06-18 02:11:55 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/macros.h 2004-12-18 20:20:03 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/macros.h vixie-cron-4.1.20060426/usr.sbin/cron/macros.h
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/macros.h 2004-06-17 22:11:55 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/macros.h 2006-04-30 22:16:46 +0000
@@ -46,6 +46,9 @@
#define MAX_COMMAND 1000 /* max length of internally generated cmd */
#define MAX_ENVSTR 1000 /* max length of envvar=value\0 strings */
@ -592,9 +603,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/macros.h vixie-cron-4
#define MAX_UNAME (_PW_NAME_LEN+1) /* max length of username, should be overkill */
#define ROOT_UID 0 /* don't change this, it really must be root */
#define ROOT_USER "root" /* ditto */
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/misc.c vixie-cron-4.1.20040916/usr.sbin/cron/misc.c
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/misc.c 2004-09-17 00:11:09 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/misc.c 2004-12-18 20:20:20 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/misc.c vixie-cron-4.1.20060426/usr.sbin/cron/misc.c
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/misc.c 2005-06-08 18:34:00 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/misc.c 2006-04-30 22:37:44 +0000
@@ -173,13 +173,15 @@ set_cron_uid(void) {
void
set_cron_cwd(void) {
@ -685,13 +696,15 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/misc.c vixie-cron-4.1
}
/* acquire_daemonlock() - write our PID into /etc/cron.pid, unless
@@ -280,23 +301,20 @@ acquire_daemonlock(int closeflag) {
@@ -280,23 +301,31 @@ acquire_daemonlock(int closeflag) {
if (fd == -1) {
pidfile = _PATH_CRON_PID;
- if ((fd = open(pidfile, O_RDWR|O_CREAT|O_EXLOCK|O_NONBLOCK,
- 0644)) == -1) {
- int save_errno = errno;
-
- if (errno != EWOULDBLOCK) {
+ /* Initial mode is 0600 to prevent flock() race/DoS. */
+ if ((fd = open(pidfile, O_RDWR|O_CREAT, 0600)) == -1) {
+ snprintf(buf, sizeof buf, "can't open or create %s: %s",
@ -700,15 +713,20 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/misc.c vixie-cron-4.1
+ log_it("CRON", getpid(), "DEATH", buf);
+ exit(ERROR_EXIT);
+ }
- if (errno != EWOULDBLOCK) {
- snprintf(buf, sizeof buf,
+ /* fd must be > STDERR since we dup fd 0-2 to /dev/null */
+ if (fd <= STDERR) {
+ if (dup2(fd, STDERR + 1) < 0) {
snprintf(buf, sizeof buf,
- "can't open or create %s: %s", pidfile,
- strerror(save_errno));
- fprintf(stderr, "%s: %s\n", ProgramName, buf);
- log_it("CRON", getpid(), "DEATH", buf);
- exit(ERROR_EXIT);
- }
+ "can't dup pid fd: %s", strerror(errno));
fprintf(stderr, "%s: %s\n", ProgramName, buf);
log_it("CRON", getpid(), "DEATH", buf);
exit(ERROR_EXIT);
}
+ close(fd);
+ fd = STDERR + 1;
+ }
+ if (flock(fd, LOCK_EX|LOCK_NB) < OK) {
+ int save_errno = errno;
@ -720,15 +738,27 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/misc.c vixie-cron-4.1
(otherpid = strtol(buf, &ep, 10)) > 0 &&
ep != buf && *ep == '\n' && otherpid != LONG_MAX) {
snprintf(buf, sizeof buf,
@@ -311,6 +329,7 @@ acquire_daemonlock(int closeflag) {
@@ -311,18 +340,7 @@ acquire_daemonlock(int closeflag) {
log_it("CRON", getpid(), "DEATH", buf);
exit(ERROR_EXIT);
}
- /* fd must be > STDERR since we dup fd 0-2 to /dev/null */
- if (fd <= STDERR) {
- if (dup2(fd, STDERR + 1) < 0) {
- snprintf(buf, sizeof buf,
- "can't dup pid fd: %s", strerror(errno));
- fprintf(stderr, "%s: %s\n", ProgramName, buf);
- log_it("CRON", getpid(), "DEATH", buf);
- exit(ERROR_EXIT);
- }
- close(fd);
- fd = STDERR + 1;
- }
+ (void) fchmod(fd, 0644);
(void) fcntl(fd, F_SETFD, 1);
}
@@ -507,11 +526,7 @@ log_it(const char *username, PID_T xpid,
@@ -519,11 +537,7 @@ log_it(const char *username, PID_T xpid,
#if defined(SYSLOG)
if (!syslog_open) {
@ -741,7 +771,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/misc.c vixie-cron-4.1
syslog_open = TRUE; /* assume openlog success */
}
@@ -712,6 +727,10 @@ open_socket(void)
@@ -724,6 +738,10 @@ open_socket(void)
int sock;
mode_t omask;
struct sockaddr_un s_un;
@ -752,7 +782,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/misc.c vixie-cron-4.1
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock == -1) {
@@ -742,12 +761,15 @@ open_socket(void)
@@ -755,26 +773,32 @@ open_socket(void)
}
unlink(s_un.sun_path);
s_un.sun_family = AF_UNIX;
@ -772,12 +802,17 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/misc.c vixie-cron-4.1
fprintf(stderr, "%s: can't bind socket: %s\n",
ProgramName, strerror(errno));
log_it("CRON", getpid(), "DEATH", "can't bind socket");
@@ -759,8 +781,12 @@ open_socket(void)
- umask(omask);
exit(ERROR_EXIT);
}
- umask(omask);
if (listen(sock, SOMAXCONN)) {
fprintf(stderr, "%s: can't listen on socket: %s\n",
ProgramName, strerror(errno));
log_it("CRON", getpid(), "DEATH", "can't listen on socket");
exit(ERROR_EXIT);
}
- chmod(s_un.sun_path, 0660);
- umask(omask);
+#ifdef CRON_GROUP
+ if ((grp = getgrnam(CRON_GROUP)) == NULL) {
+ log_it("CRON", getpid(), "DEATH", "can't find crontab group");
@ -787,7 +822,7 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/misc.c vixie-cron-4.1
return(sock);
}
@@ -779,12 +805,12 @@ poke_daemon(const char *spool_dir, unsig
@@ -794,12 +818,12 @@ poke_daemon(const char *spool_dir, unsig
return;
}
s_un.sun_family = AF_UNIX;
@ -802,9 +837,9 @@ diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/misc.c vixie-cron-4.1
write(sock, &cookie, 1);
else
fprintf(stderr, "%s: warning, cron does not appear to be "
diff -uprk.orig vixie-cron-4.1.20040916.orig/usr.sbin/cron/pathnames.h vixie-cron-4.1.20040916/usr.sbin/cron/pathnames.h
--- vixie-cron-4.1.20040916.orig/usr.sbin/cron/pathnames.h 2004-06-18 02:11:55 +0400
+++ vixie-cron-4.1.20040916/usr.sbin/cron/pathnames.h 2004-12-18 20:20:03 +0300
diff -upk.orig vixie-cron-4.1.20060426.orig/usr.sbin/cron/pathnames.h vixie-cron-4.1.20060426/usr.sbin/cron/pathnames.h
--- vixie-cron-4.1.20060426.orig/usr.sbin/cron/pathnames.h 2004-06-17 22:11:55 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/pathnames.h 2006-04-30 22:16:46 +0000
@@ -33,7 +33,7 @@
* to; SPOOL_DIR, CRON_ALLOW, CRON_DENY, and LOG_FILE
* are all relative to this directory.

View File

@ -0,0 +1,104 @@
--- vixie-cron-4.1.20060426/usr.sbin/cron/crontab.c.orig 2006-04-30 23:34:38 +0000
+++ vixie-cron-4.1.20060426/usr.sbin/cron/crontab.c 2006-05-01 00:11:23 +0000
@@ -286,6 +286,7 @@ check_error(const char *msg) {
static void
edit_cmd(void) {
char n[MAX_FNAME], q[MAX_TEMPSTR], *editor;
+ const char *tmpdir;
FILE *f;
int ch, t, x;
struct stat statbuf, xstatbuf;
@@ -334,12 +335,24 @@ edit_cmd(void) {
(void)signal(SIGINT, SIG_IGN);
(void)signal(SIGQUIT, SIG_IGN);
+ tmpdir = getenv("TMPDIR");
+ if (!tmpdir || !*tmpdir)
+ tmpdir = "/tmp";
if (snprintf(Filename, sizeof Filename, "%s/crontab.XXXXXX",
- _PATH_TMP) >= sizeof(Filename)) {
+ tmpdir) >= sizeof(Filename)) {
fprintf(stderr, "path too long\n");
goto fatal;
}
- if (-1 == (t = mkstemp(Filename))) {
+ if (swap_gids() < OK) {
+ perror("swapping gids");
+ exit(ERROR_EXIT);
+ }
+ t = mkstemp(Filename);
+ if (swap_gids_back() < OK) {
+ perror("swapping gids back");
+ exit(ERROR_EXIT);
+ }
+ if (t < 0) {
perror(Filename);
goto fatal;
}
@@ -376,7 +389,15 @@ edit_cmd(void) {
exit(ERROR_EXIT);
}
#ifndef HAVE_FUTIMES
+ if (swap_gids() < OK) {
+ perror("swapping gids");
+ exit(ERROR_EXIT);
+ }
utime(Filename, &utimebuf);
+ if (swap_gids_back() < OK) {
+ perror("swapping gids back");
+ exit(ERROR_EXIT);
+ }
#else
(void)futimes(t, tv);
#endif
@@ -386,7 +407,14 @@ edit_cmd(void) {
fprintf(stderr, "%s: error while writing new crontab to %s\n",
ProgramName, Filename);
fatal:
+ if (swap_gids() < OK) {
+ perror("swapping gids");
+ exit(ERROR_EXIT);
+ }
unlink(Filename);
+ if (swap_gids_back() < OK) {
+ perror("swapping gids back");
+ }
exit(ERROR_EXIT);
}
@@ -473,11 +501,19 @@ edit_cmd(void) {
#else
if (timespeccmp(&mtimespec, &statbuf.st_mtimespec, -) == 0) {
#endif
+ if (swap_gids() < OK) {
+ perror("swapping gids");
+ exit(ERROR_EXIT);
+ }
if (lstat(Filename, &xstatbuf) == 0 &&
statbuf.st_ino != xstatbuf.st_ino) {
fprintf(stderr, "%s: crontab temp file moved, editor "
"may create backup files improperly\n", ProgramName);
}
+ if (swap_gids_back() < OK) {
+ perror("swapping gids back");
+ exit(ERROR_EXIT);
+ }
fprintf(stderr, "%s: no changes made to crontab\n",
ProgramName);
goto remove;
@@ -518,7 +554,15 @@ edit_cmd(void) {
goto fatal;
}
remove:
+ if (swap_gids() < OK) {
+ perror("swapping gids");
+ exit(ERROR_EXIT);
+ }
unlink(Filename);
+ if (swap_gids_back() < OK) {
+ perror("swapping gids back");
+ exit(ERROR_EXIT);
+ }
done:
log_it(RealUser, Pid, "END EDIT", User);
}

View File

@ -1,6 +1,6 @@
Name: vixie-cron
Version: 4.1.20040916
Release: alt3
Version: 4.1.20060426
Release: alt1
Summary: The Vixie cron daemon for executing specified programs at set times
License: distributable
@ -19,8 +19,8 @@ Requires(post): %post_service
Requires(preun): %preun_service
Requires: vitmp
Patch1: %name-4.1.20040916-alt-warnings.patch
Patch2: %name-4.1.20040916-owl-alt-linux.patch
Patch1: %name-4.1.20060426-alt-warnings.patch
Patch2: %name-4.1.20060426-owl-alt-linux.patch
Patch3: %name-4.1.20040916-owl-vitmp.patch
Patch4: %name-4.1.20040916-owl-crond.patch
Patch5: %name-4.1.20040916-alt-makefile.patch
@ -30,7 +30,8 @@ Patch8: %name-4.1.20040916-alt-sigpipe.patch
Patch9: %name-4.1.20040916-alt-pam.patch
Patch10: %name-4.1.20040916-alt-setlocale.patch
Patch11: %name-4.1.20040916-alt-children.patch
Patch12: %name-4.1.20040916-alt-setproctitle.patch
Patch12: %name-4.1.20060426-owl-tmp.patch
Patch13: %name-4.1.20040916-alt-setproctitle.patch
BuildRequires: libpam-devel, setproctitle-devel
@ -53,7 +54,9 @@ modifications by the NetBSD, OpenBSD, Red Hat, Owl and ALT teams.
%patch10 -p1
%patch11 -p1
%patch12 -p1
%__subst 's/ rcsid)/ "%name-%version-%release")/' usr.sbin/cron/crontab.c
%patch13 -p1
sed -i -e 's/^\(static char const rcsid\[\] =\).*/\1 "%name-%version-%release";/' \
usr.sbin/cron/crontab.c
find -type f -name \*.orig -delete -print
%build
@ -65,7 +68,7 @@ done
mkdir -p %buildroot{%_sysconfdir/cron.d,/var/spool/{cron,at}}
for i in usr.sbin/cron usr.bin/crontab usr.bin/at; do
%makeinstall .CURDIR=. -C "$i"
%makeinstall .CURDIR=. -C "$i" DESTDIR=%buildroot
done
for i in atq atrm batch; do
@ -111,6 +114,10 @@ touch %buildroot%_sysconfdir/{at,cron}.{allow,deny}
%attr(750,root,root) %dir %_sysconfdir/cron.d
%changelog
* Mon May 01 2006 Dmitry V. Levin <ldv@altlinux.org> 4.1.20060426-alt1
- Updated to OpenBSD CVS snapshot dated 2006/04/26.
- Changed crontab to use $TMPDIR for creating temporary file.
* Mon Mar 06 2006 Dmitry V. Levin <ldv@altlinux.org> 4.1.20040916-alt3
- Fixed build with --as-needed.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pw_dup.c,v 1.5 2003/06/17 21:56:23 millert Exp $ */
/* $OpenBSD: pw_dup.c,v 1.7 2005/08/08 08:05:34 espie Exp $ */
/*
* Copyright (c) 2000, 2002 Todd C. Miller <Todd.Miller@courtesan.com>
@ -20,10 +20,6 @@
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$OpenBSD: pw_dup.c,v 1.5 2003/06/17 21:56:23 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <pwd.h>
@ -31,6 +27,23 @@ static const char rcsid[] = "$OpenBSD: pw_dup.c,v 1.5 2003/06/17 21:56:23 miller
#include <stdio.h>
#include <string.h>
#define PW_SIZE(name, size) \
do { \
if (pw->name) { \
size = strlen(pw->name) + 1; \
total += size; \
} \
} while (0)
#define PW_COPY(name, size) \
do { \
if (pw->name) { \
(void)memcpy(cp, pw->name, size); \
newpw->name = cp; \
cp += size; \
} \
} while (0)
struct passwd *
pw_dup(const struct passwd *pw)
{
@ -40,30 +53,13 @@ pw_dup(const struct passwd *pw)
/* Allocate in one big chunk for easy freeing */
total = sizeof(struct passwd);
if (pw->pw_name) {
nsize = strlen(pw->pw_name) + 1;
total += nsize;
}
if (pw->pw_passwd) {
psize = strlen(pw->pw_passwd) + 1;
total += psize;
}
if (pw->pw_class) {
csize = strlen(pw->pw_class) + 1;
total += csize;
}
if (pw->pw_gecos) {
gsize = strlen(pw->pw_gecos) + 1;
total += gsize;
}
if (pw->pw_dir) {
dsize = strlen(pw->pw_dir) + 1;
total += dsize;
}
if (pw->pw_shell) {
ssize = strlen(pw->pw_shell) + 1;
total += ssize;
}
PW_SIZE(pw_name, nsize);
PW_SIZE(pw_passwd, psize);
PW_SIZE(pw_class, csize);
PW_SIZE(pw_gecos, gsize);
PW_SIZE(pw_dir, dsize);
PW_SIZE(pw_shell, ssize);
if ((cp = malloc(total)) == NULL)
return (NULL);
newpw = (struct passwd *)cp;
@ -74,36 +70,13 @@ pw_dup(const struct passwd *pw)
*/
(void)memcpy(newpw, pw, sizeof(struct passwd));
cp += sizeof(struct passwd);
if (pw->pw_name) {
(void)memcpy(cp, pw->pw_name, nsize);
newpw->pw_name = cp;
cp += nsize;
}
if (pw->pw_passwd) {
(void)memcpy(cp, pw->pw_passwd, psize);
newpw->pw_passwd = cp;
cp += psize;
}
if (pw->pw_class) {
(void)memcpy(cp, pw->pw_class, csize);
newpw->pw_class = cp;
cp += csize;
}
if (pw->pw_gecos) {
(void)memcpy(cp, pw->pw_gecos, gsize);
newpw->pw_gecos = cp;
cp += gsize;
}
if (pw->pw_dir) {
(void)memcpy(cp, pw->pw_dir, dsize);
newpw->pw_dir = cp;
cp += dsize;
}
if (pw->pw_shell) {
(void)memcpy(cp, pw->pw_shell, ssize);
newpw->pw_shell = cp;
cp += ssize;
}
PW_COPY(pw_name, nsize);
PW_COPY(pw_passwd, psize);
PW_COPY(pw_class, csize);
PW_COPY(pw_gecos, gsize);
PW_COPY(pw_dir, dsize);
PW_COPY(pw_shell, ssize);
return (newpw);
}

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: at.1,v 1.31 2003/06/10 09:12:09 jmc Exp $
.\" $OpenBSD: at.1,v 1.33 2005/09/30 20:34:25 jaredy Exp $
.\"
.\" Copyright (C) 1993, 1994 Thomas Koenig
.\" Copyright (C) 1993 David Parsons
@ -33,17 +33,18 @@
.Nd queue, examine or delete jobs for later execution
.Sh SYNOPSIS
.Nm at
.Op Fl blmr
.Op Fl blm
.Op Fl f Ar file
.Op Fl q Ar queue
.Fl t Ar time_arg
.Nm at
.Op Fl blmr
.Op Fl blm
.Op Fl f Ar file
.Op Fl q Ar queue
.Ar timespec
.Nm at
.Fl c Ar job Op Ar job ...
.Fl c | r
.Ar job Op Ar job ...
.Nm batch
.Op Fl m
.Op Fl f Ar file
@ -159,10 +160,6 @@ year.
If the
.Ar SS
letter pair is not specified, the value defaults to 0.
.It Fl v
When used in conjunction with the
.Fl l
option, shows completed but not yet deleted jobs in the queue.
.El
.Pp
.Nm at
@ -317,6 +314,7 @@ deny permission control
.Xr cron 8 ,
.Xr sendmail 8
.Sh AUTHORS
.An -nosplit
.Nm at
was mostly written by
.An Thomas Koenig Aq ig25@rz.uni-karlsruhe.de .

View File

@ -1,4 +1,4 @@
/* $OpenBSD: at.c,v 1.42 2004/06/17 22:09:11 millert Exp $ */
/* $OpenBSD: at.c,v 1.46 2006/04/26 03:01:48 cloder Exp $ */
/*
* at.c : Put file into atrun queue
@ -42,7 +42,7 @@
#define TIMESIZE 50 /* Size of buffer passed to strftime() */
#ifndef lint
static const char rcsid[] = "$OpenBSD: at.c,v 1.42 2004/06/17 22:09:11 millert Exp $";
static const char rcsid[] = "$OpenBSD: at.c,v 1.46 2006/04/26 03:01:48 cloder Exp $";
#endif
/* Variables to remove from the job's environment. */
@ -68,7 +68,7 @@ static void writefile(const char *, time_t, char);
static void list_jobs(int, char **, int, int);
static time_t ttime(const char *);
static int check_permission(void);
static void panic(const char *);
static __dead void panic(const char *);
static void perr(const char *);
static void perr2(const char *, const char *);
static __dead void usage(void);
@ -134,6 +134,7 @@ perr2(const char *a, const char *b)
perr(b);
}
/* ARGSUSED */
static void
sigc(int signo)
{
@ -147,6 +148,7 @@ sigc(int signo)
_exit(ERROR_EXIT);
}
/* ARGSUSED */
static void
alarmc(int signo)
{
@ -303,7 +305,7 @@ writefile(const char *cwd, time_t runtimer, char queue)
/*
* Write out the environment. Anything that may look like a special
* character to the shell is quoted, except for \n, which is done
* with a pair of "'s. Dont't export the no_export list (such as
* with a pair of "'s. Don't export the no_export list (such as
* TERM or DISPLAY) because we don't want these.
*/
for (atenv = environ; *atenv != NULL; atenv++) {
@ -417,8 +419,8 @@ writefile(const char *cwd, time_t runtimer, char queue)
static int
byctime(const void *v1, const void *v2)
{
const struct atjob *j1 = *(struct atjob **)v1;
const struct atjob *j2 = *(struct atjob **)v2;
const struct atjob *j1 = *(const struct atjob **)v1;
const struct atjob *j2 = *(const struct atjob **)v2;
return (j1->ctime - j2->ctime);
}
@ -588,6 +590,7 @@ list_jobs(int argc, char **argv, int count_only, int csort)
atjobs[numjobs++] = job;
}
free(uids);
closedir(spool);
if (count_only || numjobs == 0) {
if (numjobs == 0 && !shortformat)
@ -638,7 +641,7 @@ process_jobs(int argc, char **argv, int what)
struct passwd *pw;
time_t runtimer;
uid_t *uids;
char **jobs, *ep, queue;
char **jobs, *ep;
long l;
FILE *fp;
DIR *spool;
@ -700,7 +703,6 @@ process_jobs(int argc, char **argv, int what)
l < 0 || l >= INT_MAX)
continue;
runtimer = (time_t)l;
queue = *(ep + 1);
/* Check runtimer against argv; argc==0 means do all. */
job_matches = (argc == 0) ? 1 : 0;
@ -757,6 +759,7 @@ process_jobs(int argc, char **argv, int what)
while ((ch = getc(fp)) != EOF)
putchar(ch);
fclose(fp);
break;
default:
@ -765,6 +768,8 @@ process_jobs(int argc, char **argv, int what)
}
}
}
closedir(spool);
for (error = 0, i = 0; i < jobs_len; i++) {
if (jobs[i] != NULL) {
if (!force)
@ -887,15 +892,13 @@ usage(void)
case AT:
case CAT:
(void)fprintf(stderr,
"usage: at [-bm] [-f file] [-q queue] -t time_arg\n"
" at [-bm] [-f file] [-q queue] timespec\n"
" at -c job [job ...]\n"
" at -l [-q queue] [job ...]\n"
" at -r job [job ...]\n");
"usage: at [-blm] [-f file] [-q queue] -t time_arg\n"
" at [-blm] [-f file] [-q queue] timespec\n"
" at -c | -r job [job ...]\n");
break;
case ATQ:
(void)fprintf(stderr,
"usage: atq [-cnv] [-q queue] [name...]\n");
"usage: atq [-cnv] [-q queue] [name ...]\n");
break;
case ATRM:
(void)fprintf(stderr,

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: atrm.1,v 1.5 2003/06/10 09:12:09 jmc Exp $
.\" $OpenBSD: atrm.1,v 1.6 2005/06/23 14:39:35 jmc Exp $
.\"
.\" Copyright (c) 1985, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -39,8 +39,11 @@
.Sh SYNOPSIS
.Nm atrm
.Op Fl afi
.Oo Op Ar job
.Op Ar name ... Oc
.Oo
.Op Ar job
.Op Ar name
.Ar ...
.Oc
.Sh DESCRIPTION
.Nm atrm
removes jobs that were created with the

View File

@ -1,4 +1,4 @@
/* $OpenBSD: parsetime.c,v 1.14 2004/06/17 22:09:11 millert Exp $ */
/* $OpenBSD: parsetime.c,v 1.15 2006/04/26 03:01:48 cloder Exp $ */
/*
* parsetime.c - parse time for at(1)
@ -132,7 +132,7 @@ struct {
};
static char **scp; /* scanner - pointer at arglist */
static char scc; /* scanner - count of remaining arguments */
static int scc; /* scanner - count of remaining arguments */
static char *sct; /* scanner - next char pointer in current argument */
static int need; /* scanner - need to advance to next argument */
static char *sc_token; /* scanner - token buffer */
@ -141,7 +141,7 @@ static int sc_tokid; /* scanner - token id */
static int sc_tokplur; /* scanner - is token plural? */
#ifndef lint
static const char rcsid[] = "$OpenBSD: parsetime.c,v 1.14 2004/06/17 22:09:11 millert Exp $";
static const char rcsid[] = "$OpenBSD: parsetime.c,v 1.15 2006/04/26 03:01:48 cloder Exp $";
#endif
/*
@ -341,10 +341,13 @@ plus(struct tm *tm)
switch (token()) {
case WEEKS:
delay *= 7;
/* FALLTHROUGH */
case DAYS:
delay *= 24;
/* FALLTHROUGH */
case HOURS:
delay *= 60;
/* FALLTHROUGH */
case MINUTES:
if (expectplur != sc_tokplur)
fprintf(stderr, "%s: pluralization is wrong\n",
@ -644,8 +647,10 @@ parsetime(int argc, char **argv)
*/
case TEATIME:
hr += 4;
/* FALLTHROUGH */
case NOON:
hr += 12;
/* FALLTHROUGH */
case MIDNIGHT:
if (runtime.tm_hour >= hr) {
runtime.tm_mday++;
@ -655,6 +660,7 @@ parsetime(int argc, char **argv)
runtime.tm_min = 0;
token();
/* fall through to month setting */
/* FALLTHROUGH */
default:
if (month(&runtime) != 0)
return (-1);

View File

@ -1,8 +1,8 @@
# $OpenBSD: Makefile,v 1.4 2002/05/09 21:22:01 millert Exp $
# $OpenBSD: Makefile,v 1.5 2005/12/19 19:12:17 millert Exp $
PROG= crontab
SRCS= crontab.c misc.c entry.c env.c
CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../../usr.sbin/cron -DDEBUGGING=0
CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../../usr.sbin/cron -DDEBUGGING=0
BINGRP =crontab
BINMODE=2555
MAN= crontab.1 crontab.5

View File

@ -1,4 +1,4 @@
/* $OpenBSD: atrun.c,v 1.13 2004/06/17 22:11:55 millert Exp $ */
/* $OpenBSD: atrun.c,v 1.14 2005/01/30 20:45:58 millert Exp $ */
/*
* Copyright (c) 2002-2003 Todd C. Miller <Todd.Miller@courtesan.com>
@ -21,7 +21,7 @@
*/
#if !defined(lint) && !defined(LINT)
static const char rcsid[] = "$OpenBSD: atrun.c,v 1.13 2004/06/17 22:11:55 millert Exp $";
static const char rcsid[] = "$OpenBSD: atrun.c,v 1.14 2005/01/30 20:45:58 millert Exp $";
#endif
#include "cron.h"
@ -87,7 +87,7 @@ scan_atjobs(at_db *old_db, struct timeval *tv)
new_db.head = new_db.tail = NULL;
pending = 0;
while ((file = readdir(atdir))) {
while ((file = readdir(atdir)) != NULL) {
if (stat(file->d_name, &statbuf) != 0 ||
!S_ISREG(statbuf.st_mode))
continue;
@ -113,6 +113,9 @@ scan_atjobs(at_db *old_db, struct timeval *tv)
job = job->next;
free(tjob);
}
closedir(atdir);
fchdir(cwd);
close(cwd);
return (0);
}
job->uid = statbuf.st_uid;

View File

@ -17,7 +17,7 @@
.\" Agency (DARPA) and Air Force Research Laboratory, Air Force
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
.\"
.\" $OpenBSD: cron.8,v 1.26 2004/06/03 19:56:09 millert Exp $
.\" $OpenBSD: cron.8,v 1.27 2005/11/30 11:18:28 jmc Exp $
.\"
.Dd July 6, 2002
.Dt CRON 8
@ -108,7 +108,7 @@ Conversely, if time has moved backward, care is taken to avoid running
jobs twice.
.Pp
Time changes of more than 3 hours are considered to be corrections to
the clock or timezone, and the new time is used immediately.
the clock or time zone, and the new time is used immediately.
.Pp
The options are as follows:
.Bl -tag -width Ds

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cron.c,v 1.36 2004/06/17 22:11:55 millert Exp $ */
/* $OpenBSD: cron.c,v 1.38 2005/11/15 07:02:37 miod Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
@ -22,7 +22,7 @@
*/
#if !defined(lint) && !defined(LINT)
static const char rcsid[] = "$OpenBSD: cron.c,v 1.36 2004/06/17 22:11:55 millert Exp $";
static const char rcsid[] = "$OpenBSD: cron.c,v 1.38 2005/11/15 07:02:37 miod Exp $";
#endif
#define MAIN_PROGRAM
@ -310,7 +310,7 @@ find_jobs(int vtime, cron_db *db, int doWild, int doNonWild) {
user *u;
entry *e;
/* make 0-based values out of these so we can use them as indicies
/* make 0-based values out of these so we can use them as indices
*/
minute = tm->tm_min -FIRST_MINUTE;
hour = tm->tm_hour -FIRST_HOUR;
@ -416,8 +416,10 @@ cron_sleep(int target) {
if (fd >= 0 && fcntl(fd, F_SETFL, O_NONBLOCK) == 0) {
(void) read(fd, &poke, 1);
close(fd);
if (poke & RELOAD_CRON)
if (poke & RELOAD_CRON) {
database.mtime = (time_t)0;
load_database(&database);
}
if (poke & RELOAD_AT) {
/*
* We run any pending at jobs right
@ -425,6 +427,7 @@ cron_sleep(int target) {
* jobs immediately.
*/
gettimeofday(&t2, NULL);
at_database.mtime = (time_t)0;
if (scan_atjobs(&at_database, &t2))
atrun(&at_database,
batch_maxload, t2.tv_sec);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: crontab.c,v 1.46 2004/09/16 18:34:05 deraadt Exp $ */
/* $OpenBSD: crontab.c,v 1.49 2005/11/29 20:43:31 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
@ -21,9 +21,7 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#if !defined(lint) && !defined(LINT)
static char const rcsid[] = "$OpenBSD: crontab.c,v 1.46 2004/09/16 18:34:05 deraadt Exp $";
#endif
static char const rcsid[] = "$OpenBSD: crontab.c,v 1.49 2005/11/29 20:43:31 millert Exp $";
/* crontab - install and manage per-user crontab files
* vix 02may87 [RCS has the rest of the log]
@ -284,7 +282,7 @@ edit_cmd(void) {
char n[MAX_FNAME], q[MAX_TEMPSTR], *editor;
FILE *f;
int ch, t, x;
struct stat statbuf;
struct stat statbuf, xstatbuf;
struct timespec mtimespec;
struct timeval tv[2];
WAIT_T waiter;
@ -448,6 +446,11 @@ edit_cmd(void) {
goto fatal;
}
if (timespeccmp(&mtimespec, &statbuf.st_mtimespec, -) == 0) {
if (lstat(Filename, &xstatbuf) == 0 &&
statbuf.st_ino != xstatbuf.st_ino) {
fprintf(stderr, "%s: crontab temp file moved, editor "
"may create backup files improperly\n", ProgramName);
}
fprintf(stderr, "%s: no changes made to crontab\n",
ProgramName);
goto remove;
@ -461,7 +464,10 @@ edit_cmd(void) {
printf("Do you want to retry the same edit? ");
fflush(stdout);
q[0] = '\0';
(void) fgets(q, sizeof q, stdin);
if (fgets(q, sizeof q, stdin) == NULL) {
putchar('\n');
goto abandon;
}
switch (q[0]) {
case 'y':
case 'Y':
@ -508,8 +514,8 @@ replace_cmd(void) {
fprintf(stderr, "%s: Cannot allocate memory.\n", ProgramName);
return (-2);
}
if (snprintf(TempFilename, sizeof TempFilename, "%s/tmp.XXXXXXXXX", SPOOL_DIR) >=
sizeof(TempFilename)) {
if (snprintf(TempFilename, sizeof TempFilename, "%s/tmp.XXXXXXXXX",
SPOOL_DIR) >= sizeof(TempFilename)) {
TempFilename[0] = '\0';
fprintf(stderr, "path too long\n");
return (-2);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: entry.c,v 1.29 2004/06/22 21:02:19 avsm Exp $ */
/* $OpenBSD: entry.c,v 1.30 2005/01/30 20:44:50 millert Exp $ */
/*
* Copyright 1988,1990,1993,1994 by Paul Vixie
@ -23,7 +23,7 @@
*/
#if !defined(lint) && !defined(LINT)
static char const rcsid[] = "$OpenBSD: entry.c,v 1.29 2004/06/22 21:02:19 avsm Exp $";
static char const rcsid[] = "$OpenBSD: entry.c,v 1.30 2005/01/30 20:44:50 millert Exp $";
#endif
/* vix 26jan87 [RCS'd; rest of log is in RCS file]
@ -71,7 +71,8 @@ free_entry(entry *e) {
* otherwise return a pointer to a new entry.
*/
entry *
load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, char **envp) {
load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw,
char **envp) {
/* this function reads one crontab entry -- the next -- from a file.
* it skips any leading blank lines, ignores comments, and returns
* NULL if for any reason the entry can't be read and parsed.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: env.c,v 1.17 2004/06/22 03:15:33 avsm Exp $ */
/* $OpenBSD: env.c,v 1.18 2005/01/30 20:44:50 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
@ -22,7 +22,7 @@
*/
#if !defined(lint) && !defined(LINT)
static char const rcsid[] = "$OpenBSD: env.c,v 1.17 2004/06/22 03:15:33 avsm Exp $";
static char const rcsid[] = "$OpenBSD: env.c,v 1.18 2005/01/30 20:44:50 millert Exp $";
#endif
#include "cron.h"
@ -187,7 +187,6 @@ load_env(char *envstr, FILE *f) {
}
*str++ = *c++;
break;
case EQ1:
if (*c == '=') {
state++;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: funcs.h,v 1.12 2004/06/17 22:11:55 millert Exp $ */
/* $OpenBSD: funcs.h,v 1.13 2005/01/30 20:44:50 millert Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@ -71,7 +71,8 @@ void mkprint(char *, unsigned char *, int);
user *load_user(int, struct passwd *, const char *),
*find_user(cron_db *, const char *);
entry *load_entry(FILE *, void (*)(const char *), struct passwd *, char **);
entry *load_entry(FILE *,
void (*)(const char *), struct passwd *, char **);
FILE *cron_popen(char *, char *, struct passwd *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: misc.c,v 1.34 2004/09/16 20:11:09 deraadt Exp $ */
/* $OpenBSD: misc.c,v 1.37 2005/06/08 18:34:00 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
@ -22,7 +22,7 @@
*/
#if !defined(lint) && !defined(LINT)
static char const rcsid[] = "$OpenBSD: misc.c,v 1.34 2004/09/16 20:11:09 deraadt Exp $";
static char const rcsid[] = "$OpenBSD: misc.c,v 1.37 2005/06/08 18:34:00 millert Exp $";
#endif
/* vix 26jan87 [RCS has the rest of the log]
@ -311,6 +311,18 @@ acquire_daemonlock(int closeflag) {
log_it("CRON", getpid(), "DEATH", buf);
exit(ERROR_EXIT);
}
/* fd must be > STDERR since we dup fd 0-2 to /dev/null */
if (fd <= STDERR) {
if (dup2(fd, STDERR + 1) < 0) {
snprintf(buf, sizeof buf,
"can't dup pid fd: %s", strerror(errno));
fprintf(stderr, "%s: %s\n", ProgramName, buf);
log_it("CRON", getpid(), "DEATH", buf);
exit(ERROR_EXIT);
}
close(fd);
fd = STDERR + 1;
}
(void) fcntl(fd, F_SETFD, 1);
}
@ -734,6 +746,7 @@ open_socket(void)
"can't make socket non-blocking");
exit(ERROR_EXIT);
}
bzero(&s_un, sizeof(s_un));
if (snprintf(s_un.sun_path, sizeof s_un.sun_path, "%s/%s",
SPOOL_DIR, CRONSOCK) >= sizeof(s_un.sun_path)) {
fprintf(stderr, "%s/%s: path too long\n", SPOOL_DIR, CRONSOCK);
@ -751,8 +764,10 @@ open_socket(void)
fprintf(stderr, "%s: can't bind socket: %s\n",
ProgramName, strerror(errno));
log_it("CRON", getpid(), "DEATH", "can't bind socket");
umask(omask);
exit(ERROR_EXIT);
}
umask(omask);
if (listen(sock, SOMAXCONN)) {
fprintf(stderr, "%s: can't listen on socket: %s\n",
ProgramName, strerror(errno));
@ -760,7 +775,6 @@ open_socket(void)
exit(ERROR_EXIT);
}
chmod(s_un.sun_path, 0660);
umask(omask);
return(sock);
}
@ -772,6 +786,7 @@ poke_daemon(const char *spool_dir, unsigned char cookie) {
(void) utime(spool_dir, NULL); /* old poke method */
bzero(&s_un, sizeof(s_un));
if (snprintf(s_un.sun_path, sizeof s_un.sun_path, "%s/%s",
SPOOL_DIR, CRONSOCK) >= sizeof(s_un.sun_path)) {
fprintf(stderr, "%s: %s/%s: path too long\n",

View File

@ -1,4 +1,4 @@
/* $OpenBSD: popen.c,v 1.19 2003/06/02 04:39:45 millert Exp $ */
/* $OpenBSD: popen.c,v 1.20 2006/04/03 01:31:11 djm Exp $ */
/*
* Copyright (c) 1988, 1993, 1994
@ -41,7 +41,7 @@
#if 0
static const sccsid[] = "@(#)popen.c 8.3 (Berkeley) 4/6/94";
#else
static const char rcsid[] = "$OpenBSD: popen.c,v 1.19 2003/06/02 04:39:45 millert Exp $";
static const char rcsid[] = "$OpenBSD: popen.c,v 1.20 2006/04/03 01:31:11 djm Exp $";
#endif
#endif /* not lint */
@ -72,9 +72,8 @@ cron_popen(char *program, char *type, struct passwd *pw) {
if (!pids) {
if ((fds = sysconf(_SC_OPEN_MAX)) <= 0)
return (NULL);
if (!(pids = (PID_T *)malloc((size_t)(fds * sizeof(PID_T)))))
if (!(pids = calloc(fds, sizeof(PID_T))))
return (NULL);
bzero(pids, fds * sizeof(PID_T));
}
if (pipe(pdes) < 0)
return (NULL);