reasonable level of POSIX compliance.
-/* $OpenBSD: crontab.c,v 1.65 2014/11/26 18:34:52 millert Exp $ */
+/* $OpenBSD: crontab.c,v 1.66 2015/01/14 17:27:13 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
break;
#endif
case 'u':
- if (MY_UID(pw) != ROOT_UID) {
+ if (getuid() != ROOT_UID) {
fprintf(stderr,
"must be privileged to use -u\n");
exit(EXIT_FAILURE);
goto done;
}
-#ifdef HAVE_FCHOWN
if (fchown(fileno(tmp), pw->pw_uid, -1) < OK) {
perror("fchown");
fclose(tmp);
error = -2;
goto done;
}
-#else
- if (chown(TempFilename, pw->pw_uid, -1) < OK) {
- perror("chown");
- fclose(tmp);
- error = -2;
- goto done;
- }
-#endif
if (fclose(tmp) == EOF) {
perror("fclose");
-/* $OpenBSD: externs.h,v 1.12 2014/10/29 04:39:02 deraadt Exp $ */
+/* $OpenBSD: externs.h,v 1.13 2015/01/14 17:27:13 millert Exp $ */
/* Copyright 1993,1994 by Paul Vixie
* All rights reserved
#include <sys/types.h>
#include <sys/time.h>
#include <sys/wait.h>
-#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <bitstring.h>
#include <ctype.h>
-#ifndef isascii
-#define isascii(c) ((unsigned)(c)<=0177)
-#endif
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#endif
#define TZONE(tm) tzname[(tm).tm_isdst]
-#if (defined(BSD)) && (BSD >= 198606) || defined(__linux)
-# define HAVE_FCHOWN
-# define HAVE_FCHMOD
-#endif
-
-#if (defined(BSD)) && (BSD >= 199103) || defined(__linux)
-# define HAVE_SAVED_UIDS
-#endif
-
-#define MY_UID(pw) getuid()
-#define MY_GID(pw) getgid()
-
-/* getopt() isn't part of POSIX. some systems define it in <stdlib.h> anyway.
- * of those that do, some complain that our definition is different and some
- * do not. to add to the misery and confusion, some systems define getopt()
- * in ways that we cannot predict or comprehend, yet do not define the adjunct
- * external variables needed for the interface.
- */
-#if (!defined(BSD) || (BSD < 198911))
-int getopt(int, char * const *, const char *);
-#endif
-
-#if (!defined(BSD) || (BSD < 199103))
-extern char *optarg;
-extern int optind, opterr, optopt;
-#endif
-
-/* digital unix needs this but does not give us a way to identify it.
- */
-extern int flock(int, int);
-
-/* not all systems who provide flock() provide these definitions.
- */
-#ifndef LOCK_SH
-# define LOCK_SH 1
-#endif
-#ifndef LOCK_EX
-# define LOCK_EX 2
-#endif
-#ifndef LOCK_NB
-# define LOCK_NB 4
-#endif
-#ifndef LOCK_UN
-# define LOCK_UN 8
-#endif
-
#ifndef WCOREDUMP
# define WCOREDUMP(st) (((st) & 0200) != 0)
#endif
-/* $OpenBSD: misc.c,v 1.48 2014/10/26 22:16:16 guenther Exp $ */
+/* $OpenBSD: misc.c,v 1.49 2015/01/14 17:27:13 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
void
set_cron_uid(void) {
-#if defined(BSD) || defined(POSIX)
if (seteuid(ROOT_UID) < OK) {
perror("seteuid");
exit(EXIT_FAILURE);
}
-#else
- if (setuid(ROOT_UID) < OK) {
- perror("setuid");
- exit(EXIT_FAILURE);
- }
-#endif
}
void
#if defined(SYSLOG)
if (!syslog_open) {
-# ifdef LOG_DAEMON
openlog(ProgramName, LOG_PID, FACILITY);
-# else
- openlog(ProgramName, LOG_PID);
-# endif
syslog_open = TRUE; /* assume openlog success */
}
}
#endif /*MAIL_DATE*/
-#ifdef HAVE_SAVED_UIDS
static gid_t save_egid;
int swap_gids() { save_egid = getegid(); return (setegid(getgid())); }
int swap_gids_back() { return (setegid(save_egid)); }
-#else /*HAVE_SAVED_UIDS*/
-int swap_gids() { return (setregid(getegid(), getgid())); }
-int swap_gids_back() { return (swap_gids()); }
-#endif /*HAVE_SAVED_UIDS*/
/* Return the offset from GMT in seconds (algorithm taken from sendmail).
*