finalize the busybox deprecation, add cronie as busybox crond replacement (#5499)
This commit is contained in:
parent
81daf09779
commit
17d5dfc0a6
@ -2,16 +2,14 @@ TERMUX_PKG_HOMEPAGE=https://busybox.net/
|
||||
TERMUX_PKG_DESCRIPTION="Tiny versions of many common UNIX utilities into a single small executable"
|
||||
TERMUX_PKG_LICENSE="GPL-2.0"
|
||||
TERMUX_PKG_VERSION=1.31.1
|
||||
TERMUX_PKG_REVISION=10
|
||||
TERMUX_PKG_REVISION=11
|
||||
TERMUX_PKG_SRCURL=https://busybox.net/downloads/busybox-${TERMUX_PKG_VERSION}.tar.bz2
|
||||
TERMUX_PKG_SHA256=d0f940a72f648943c1f2211e0e3117387c31d765137d92bd8284a3fb9752a998
|
||||
TERMUX_PKG_BUILD_IN_SRC=true
|
||||
# We replace env in the old coreutils package:
|
||||
TERMUX_PKG_CONFLICTS="coreutils (<< 8.25-4)"
|
||||
|
||||
TERMUX_PKG_SERVICE_SCRIPT=(
|
||||
"telnetd" 'exec busybox telnetd -F'
|
||||
"ftpd" 'exec busybox tcpsvd -vE 0.0.0.0 8021 busybox ftpd $HOME'
|
||||
"crond" 'exec busybox crond -f -d 0 2>&1'
|
||||
)
|
||||
|
||||
termux_step_pre_configure() {
|
||||
@ -43,28 +41,6 @@ termux_step_post_make_install() {
|
||||
install -Dm700 busybox_unstripped $PREFIX/bin/busybox
|
||||
fi
|
||||
|
||||
# Utilities (like crond/crontab) are useful but not available
|
||||
# as standalone package in Termux.
|
||||
#
|
||||
# Few notes:
|
||||
#
|
||||
# * runsv, runsvdir, sv - for things like in https://github.com/termux/termux-packages/pull/3460.
|
||||
# * tcpsvd - required for ftpd applet.
|
||||
#
|
||||
rm -Rf $TERMUX_PREFIX/bin/applets
|
||||
mkdir -p $TERMUX_PREFIX/bin/applets
|
||||
cd $TERMUX_PREFIX/bin/applets
|
||||
for f in crond crontab inotifyd lsusb runsv runsvdir sendmail sv svlogd; do
|
||||
ln -s ../busybox $f
|
||||
done
|
||||
unset f
|
||||
|
||||
# Install busybox man page
|
||||
mkdir -p $TERMUX_PREFIX/share/man/man1
|
||||
cp $TERMUX_PKG_SRCDIR/docs/busybox.1 $TERMUX_PREFIX/share/man/man1
|
||||
|
||||
# Needed for 'crontab -e' to work out of the box:
|
||||
local _CRONTABS=$TERMUX_PREFIX/var/spool/cron/crontabs
|
||||
mkdir -p $_CRONTABS
|
||||
echo "Used by the busybox crontab and crond tools" > $_CRONTABS/README.termux
|
||||
# Install busybox man page.
|
||||
install -Dm600 -t $TERMUX_PREFIX/share/man/man1 $TERMUX_PKG_SRCDIR/docs/busybox.1
|
||||
}
|
||||
|
26
packages/cronie/build.sh
Normal file
26
packages/cronie/build.sh
Normal file
@ -0,0 +1,26 @@
|
||||
TERMUX_PKG_HOMEPAGE=https://github.com/cronie-crond/cronie/
|
||||
TERMUX_PKG_DESCRIPTION="Daemon that runs specified programs at scheduled times and related tools"
|
||||
TERMUX_PKG_LICENSE="BSD"
|
||||
TERMUX_PKG_VERSION=1.5.5
|
||||
TERMUX_PKG_SRCURL=https://github.com/cronie-crond/cronie/releases/download/cronie-${TERMUX_PKG_VERSION}/cronie-${TERMUX_PKG_VERSION}.tar.gz
|
||||
TERMUX_PKG_SHA256=be34c79505e5544323281854744b9955ff16b160ee569f9df7c0dddae5720eac
|
||||
TERMUX_PKG_DEPENDS="bash"
|
||||
TERMUX_PKG_RECOMMENDS="nano"
|
||||
TERMUX_PKG_SUGGESTS="termux-services"
|
||||
TERMUX_PKG_CONFLICTS="busybox (<< 1.31.1-11)"
|
||||
|
||||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
|
||||
--disable-anacron
|
||||
--disable-pam
|
||||
--with-editor=$TERMUX_PREFIX/bin/nano
|
||||
"
|
||||
|
||||
TERMUX_PKG_SERVICE_SCRIPT=("crond" 'exec crond -n -s')
|
||||
|
||||
termux_step_create_debscripts() {
|
||||
cat <<- EOF > ./postinst
|
||||
#!$TERMUX_PREFIX/bin/sh
|
||||
mkdir -p $TERMUX_PREFIX/var/run
|
||||
mkdir -p $TERMUX_PREFIX/var/spool/cron
|
||||
EOF
|
||||
}
|
58
packages/cronie/fix-hardcoded-paths.patch
Normal file
58
packages/cronie/fix-hardcoded-paths.patch
Normal file
@ -0,0 +1,58 @@
|
||||
diff -uNr cronie-1.5.5/configure cronie-1.5.5.mod/configure
|
||||
--- cronie-1.5.5/configure 2019-10-31 18:15:15.000000000 +0200
|
||||
+++ cronie-1.5.5.mod/configure 2020-07-08 23:00:30.440689636 +0300
|
||||
@@ -5281,7 +5281,7 @@
|
||||
|
||||
|
||||
|
||||
-$as_echo "#define MAILARG \"/usr/sbin/sendmail\"" >>confdefs.h
|
||||
+$as_echo "#define MAILARG \"@TERMUX_PREFIX@/bin/sendmail\"" >>confdefs.h
|
||||
|
||||
|
||||
|
||||
diff -uNr cronie-1.5.5/src/cron.c cronie-1.5.5.mod/src/cron.c
|
||||
--- cronie-1.5.5/src/cron.c 2019-04-15 11:33:30.000000000 +0300
|
||||
+++ cronie-1.5.5.mod/src/cron.c 2020-07-08 22:58:28.492184173 +0300
|
||||
@@ -299,7 +299,7 @@
|
||||
|
||||
log_it("CRON", getpid(), "STARTUP", PACKAGE_VERSION, 0);
|
||||
|
||||
- if (!SyslogOutput && MailCmd[0] == '\0' && access("/usr/sbin/sendmail", X_OK) != 0) {
|
||||
+ if (!SyslogOutput && MailCmd[0] == '\0' && access("@TERMUX_PREFIX@/bin/sendmail", X_OK) != 0) {
|
||||
SyslogOutput=1;
|
||||
log_it("CRON", pid, "INFO","Syslog will be used instead of sendmail.", 0);
|
||||
}
|
||||
diff -uNr cronie-1.5.5/src/crontab.c cronie-1.5.5.mod/src/crontab.c
|
||||
--- cronie-1.5.5/src/crontab.c 2019-10-31 16:50:32.000000000 +0200
|
||||
+++ cronie-1.5.5.mod/src/crontab.c 2020-07-08 23:28:56.896277856 +0300
|
||||
@@ -466,7 +466,7 @@
|
||||
if ((getuid() == geteuid()) && (getgid() == getegid())) {
|
||||
tmpdir = getenv("TMPDIR");
|
||||
}
|
||||
- return tmpdir ? tmpdir : "/tmp";
|
||||
+ return tmpdir ? tmpdir : "@TERMUX_PREFIX@/tmp";
|
||||
}
|
||||
|
||||
static char *host_specific_filename(const char *prefix, const char *suffix)
|
||||
diff -uNr cronie-1.5.5/src/pathnames.h cronie-1.5.5.mod/src/pathnames.h
|
||||
--- cronie-1.5.5/src/pathnames.h 2017-01-17 17:53:50.000000000 +0200
|
||||
+++ cronie-1.5.5.mod/src/pathnames.h 2020-07-08 23:28:41.980210171 +0300
|
||||
@@ -46,15 +46,15 @@
|
||||
#define REBOOT_LOCK PIDDIR "cron.reboot"
|
||||
|
||||
#ifndef _PATH_BSHELL
|
||||
-# define _PATH_BSHELL "/bin/sh"
|
||||
+# define _PATH_BSHELL "@TERMUX_PREFIX@/bin/sh"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DEFPATH
|
||||
-# define _PATH_DEFPATH "/usr/bin:/bin"
|
||||
+# define _PATH_DEFPATH "@TERMUX_PREFIX@/bin"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_TMP
|
||||
-# define _PATH_TMP "/tmp"
|
||||
+# define _PATH_TMP "@TERMUX_PREFIX@/tmp"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DEVNULL
|
24
packages/cronie/getdtablesize.patch
Normal file
24
packages/cronie/getdtablesize.patch
Normal file
@ -0,0 +1,24 @@
|
||||
diff -uNr cronie-1.5.5/src/do_command.c cronie-1.5.5.mod/src/do_command.c
|
||||
--- cronie-1.5.5/src/do_command.c 2019-10-31 16:50:32.000000000 +0200
|
||||
+++ cronie-1.5.5.mod/src/do_command.c 2020-07-08 22:41:21.655980267 +0300
|
||||
@@ -238,7 +238,7 @@
|
||||
*/
|
||||
{
|
||||
char *shell = env_get("SHELL", jobenv);
|
||||
- int fd, fdmax = TMIN(getdtablesize(), MAX_CLOSE_FD);
|
||||
+ int fd, fdmax = TMIN(sysconf(_SC_OPEN_MAX), MAX_CLOSE_FD);
|
||||
|
||||
/* close all unwanted open file descriptors */
|
||||
for(fd = STDERR + 1; fd < fdmax; fd++) {
|
||||
diff -uNr cronie-1.5.5/src/popen.c cronie-1.5.5.mod/src/popen.c
|
||||
--- cronie-1.5.5/src/popen.c 2019-07-08 11:55:22.000000000 +0300
|
||||
+++ cronie-1.5.5.mod/src/popen.c 2020-07-08 22:47:34.725757271 +0300
|
||||
@@ -79,7 +79,7 @@
|
||||
return (NULL);
|
||||
|
||||
if (!pids) {
|
||||
- if ((fds = getdtablesize()) <= 0)
|
||||
+ if ((fds = sysconf(_SC_OPEN_MAX)) <= 0)
|
||||
return (NULL);
|
||||
if (fds > MAX_CLOSE_FD)
|
||||
fds = MAX_CLOSE_FD; /* avoid allocating too much memory */
|
365
packages/cronie/manpages.patch
Normal file
365
packages/cronie/manpages.patch
Normal file
@ -0,0 +1,365 @@
|
||||
diff -uNr cronie-1.5.5/man/cron.8 cronie-1.5.5.mod/man/cron.8
|
||||
--- cronie-1.5.5/man/cron.8 2017-09-14 14:34:58.000000000 +0300
|
||||
+++ cronie-1.5.5.mod/man/cron.8 2020-07-09 00:39:44.598999871 +0300
|
||||
@@ -27,7 +27,7 @@
|
||||
crond \- daemon to execute scheduled commands
|
||||
.SH SYNOPSIS
|
||||
.B crond
|
||||
-.RB [ -c " | " -h " | " -i " | " -n " | " -p " | " -P " | " -s " | " -m \fP\fI<mail command>\fP ]
|
||||
+.RB [ -h " | " -i " | " -n " | " -p " | " -P " | " -s " | " -m \fP\fI<mail command>\fP ]
|
||||
.br
|
||||
.B crond
|
||||
.B -x
|
||||
@@ -37,28 +37,12 @@
|
||||
.B -V
|
||||
.SH DESCRIPTION
|
||||
.I Cron
|
||||
-is started from
|
||||
-.I /etc/rc.d/init.d
|
||||
-or
|
||||
-.I /etc/init.d
|
||||
-when classical sysvinit scripts are used. In case systemd is enabled, then unit file is installed into
|
||||
-.I /lib/systemd/system/crond.service
|
||||
-and daemon is started by
|
||||
-.I systemctl start crond.service
|
||||
-command. It returns immediately, thus, there is no need to need to start it with
|
||||
-the '&' parameter.
|
||||
-.PP
|
||||
-.I Cron
|
||||
searches
|
||||
-.I /var/spool/cron
|
||||
-for crontab files which are named after accounts in
|
||||
-.I /etc/passwd;
|
||||
-The found crontabs are loaded into the memory.
|
||||
-.I Cron
|
||||
-also searches for
|
||||
-.I /etc/anacrontab
|
||||
-and any files in the
|
||||
-.I /etc/cron.d
|
||||
+.I @TERMUX_PREFIX@/var/spool/cron
|
||||
+for crontab file which is being loaded into the memory.
|
||||
+.I Cron
|
||||
+also searches for any files in the
|
||||
+.I @TERMUX_PREFIX@/etc/cron.d
|
||||
directory, which have a different format (see
|
||||
.BR crontab (5)).
|
||||
.I Cron
|
||||
@@ -74,7 +58,7 @@
|
||||
There are two ways how changes in crontables are checked. The first
|
||||
method is checking the modtime of a file. The second method is using the
|
||||
inotify support. Using of inotify is logged in the
|
||||
-.I /var/log/cron
|
||||
+.I @TERMUX_PREFIX@/var/log/cron
|
||||
log after the daemon is started. The inotify support checks for changes
|
||||
in all crontables and accesses the hard disk only when a change is
|
||||
detected.
|
||||
@@ -88,21 +72,12 @@
|
||||
used when inotify can not be initialized.
|
||||
.PP
|
||||
.I Cron
|
||||
-checks these files and directories:
|
||||
-.TP
|
||||
-.IR /etc/crontab
|
||||
-system crontab. Nowadays the file is empty by default. Originally it
|
||||
-was usually used to run daily, weekly, monthly jobs. By default these
|
||||
-jobs are now run through anacron which reads
|
||||
-.IR /etc/anacrontab
|
||||
-configuration file. See
|
||||
-.BR anacrontab (5)
|
||||
-for more details.
|
||||
+checks these directories:
|
||||
.TP
|
||||
-.IR /etc/cron.d/
|
||||
+.IR @TERMUX_PREFIX@/etc/cron.d/
|
||||
directory that contains system cronjobs stored for different users.
|
||||
.TP
|
||||
-.IR /var/spool/cron
|
||||
+.IR @TERMUX_PREFIX@/var/spool/cron
|
||||
directory that contains user crontables created by the
|
||||
.IR crontab
|
||||
command.
|
||||
@@ -129,18 +104,6 @@
|
||||
It is possible to use different time zones for crontables. See
|
||||
.BR crontab (5)
|
||||
for more information.
|
||||
-.SS PAM Access Control
|
||||
-.IR Cron
|
||||
-supports access control with PAM if the system has PAM installed. For
|
||||
-more information, see
|
||||
-.BR pam (8).
|
||||
-A PAM configuration file for
|
||||
-.IR crond
|
||||
-is installed in
|
||||
-.IR /etc/pam.d/crond .
|
||||
-The daemon loads the PAM environment from the pam_env module. This can
|
||||
-be overridden by defining specific settings in the appropriate crontab
|
||||
-file.
|
||||
.SH "OPTIONS"
|
||||
.TP
|
||||
.B "\-h"
|
||||
@@ -163,11 +126,7 @@
|
||||
.TP
|
||||
.B "\-n"
|
||||
Tells the daemon to run in the foreground. This can be useful when
|
||||
-starting it out of init. With this option is needed to change pam setting.
|
||||
-.I /etc/pam.d/crond
|
||||
-must not enable
|
||||
-.I pam_loginuid.so
|
||||
-module.
|
||||
+starting it out of init.
|
||||
.TP
|
||||
.B "\-p"
|
||||
Allows
|
||||
@@ -177,9 +136,6 @@
|
||||
.B "\-P"
|
||||
Don't set PATH. PATH is instead inherited from the environment.
|
||||
.TP
|
||||
-.B "\-c"
|
||||
-This option enables clustering support, as described below.
|
||||
-.TP
|
||||
.B "\-s"
|
||||
This option will direct
|
||||
.I Cron
|
||||
@@ -205,46 +161,6 @@
|
||||
.I Cron
|
||||
was built to use
|
||||
.IR syslog (3).
|
||||
-.SH CLUSTERING SUPPORT
|
||||
-In this version of
|
||||
-.IR Cron
|
||||
-it is possible to use a network-mounted shared
|
||||
-.I /var/spool/cron
|
||||
-across a cluster of hosts and specify that only one of the hosts should
|
||||
-run the crontab jobs in this directory at any one time. This is done by
|
||||
-starting
|
||||
-.I Cron
|
||||
-with the
|
||||
-.B \-c
|
||||
-option, and have the
|
||||
-.I /var/spool/cron/.cron.hostname
|
||||
-file contain just one line, which represents the hostname of whichever
|
||||
-host in the cluster should run the jobs. If this file does not exist, or
|
||||
-the hostname in it does not match that returned by
|
||||
-.BR gethostname (2),
|
||||
-then all crontab files in this directory are ignored. This has no effect
|
||||
-on cron jobs specified in the
|
||||
-.I /etc/crontab
|
||||
-file or on files in the
|
||||
-.I /etc/cron.d
|
||||
-directory. These files are always run and considered host-specific.
|
||||
-.PP
|
||||
-Rather than editing
|
||||
-.I /var/spool/cron/.cron.hostname
|
||||
-directly, use the
|
||||
-.B \-n
|
||||
-option of
|
||||
-.BR crontab (1)
|
||||
-to specify the host.
|
||||
-.PP
|
||||
-You should ensure that all hosts in a cluster, and the file server from
|
||||
-which they mount the shared crontab directory, have closely synchronised
|
||||
-clocks, e.g., using
|
||||
-.BR ntpd (8),
|
||||
-otherwise the results will be very unpredictable.
|
||||
-.PP
|
||||
-Using cluster sharing automatically disables inotify support, because
|
||||
-inotify cannot be relied on with network-mounted shared file systems.
|
||||
.SH CAVEATS
|
||||
All
|
||||
.BR crontab
|
||||
diff -uNr cronie-1.5.5/man/cronnext.1 cronie-1.5.5.mod/man/cronnext.1
|
||||
--- cronie-1.5.5/man/cronnext.1 2019-04-08 17:00:11.000000000 +0300
|
||||
+++ cronie-1.5.5.mod/man/cronnext.1 2020-07-09 00:39:32.430945000 +0300
|
||||
@@ -33,10 +33,9 @@
|
||||
.TP
|
||||
.B \-s
|
||||
Do not consider the system crontab, usually the
|
||||
-.I /etc/crontab
|
||||
+.I @TERMUX_PREFIX@/etc/crontab
|
||||
file. The system crontab usually contains the hourly, daily, weekly and
|
||||
-montly crontabs, which might be better dealt with
|
||||
-.BR anacron (8).
|
||||
+montly crontabs.
|
||||
.TP
|
||||
.BI \-a
|
||||
Use the crontabs installed in the system in addition to the ones passed as
|
||||
diff -uNr cronie-1.5.5/man/crontab.1 cronie-1.5.5.mod/man/crontab.1
|
||||
--- cronie-1.5.5/man/crontab.1 2019-10-31 16:50:32.000000000 +0200
|
||||
+++ cronie-1.5.5.mod/man/crontab.1 2020-07-09 00:39:44.598999871 +0300
|
||||
@@ -27,25 +27,14 @@
|
||||
crontab \- maintains crontab files for individual users
|
||||
.SH SYNOPSIS
|
||||
.B crontab
|
||||
-.RB [ -u
|
||||
-.IR user ]
|
||||
.RI < "file"
|
||||
.RB | \ - >
|
||||
.br
|
||||
.B crontab
|
||||
-.RB [ -u
|
||||
-.IR user ]
|
||||
.RB < -l " | " -r " | " -e >\ [ -i ]
|
||||
.RB [ -s ]
|
||||
.br
|
||||
.B crontab
|
||||
-.BR -n \ [
|
||||
-.IR "hostname " ]
|
||||
-.br
|
||||
-.B crontab
|
||||
-.BR -c
|
||||
-.br
|
||||
-.B crontab
|
||||
.BR -V
|
||||
.SH DESCRIPTION
|
||||
.I Crontab
|
||||
@@ -55,72 +44,16 @@
|
||||
.BR cron (8)
|
||||
daemon. Each user can have their own crontab, and though these are files
|
||||
in
|
||||
-.IR /var/spool/ ,
|
||||
-they are not intended to be edited directly. For SELinux in MLS mode,
|
||||
-you can define more crontabs for each range. For more information, see
|
||||
-.BR selinux (8).
|
||||
-.PP
|
||||
-In this version of
|
||||
-.IR Cron
|
||||
-it is possible to use a network-mounted shared
|
||||
-.I /var/spool/cron
|
||||
-across a cluster of hosts and specify that only one of the hosts should
|
||||
-run the crontab jobs in the particular directory at any one time. You
|
||||
-may also use
|
||||
-.BR crontab
|
||||
-from any of these hosts to edit the same shared set of crontab files, and
|
||||
-to set and query which host should run the crontab jobs.
|
||||
-.PP
|
||||
-Scheduling cron jobs with
|
||||
-.BR crontab
|
||||
-can be allowed or disallowed for different users. For this purpose, use the
|
||||
-.I cron.allow
|
||||
-and
|
||||
-.I cron.deny
|
||||
-files. If the
|
||||
-.I cron.allow
|
||||
-file exists, a user must be listed in it to be allowed to use
|
||||
-.BR crontab .
|
||||
-If the
|
||||
-.I cron.allow
|
||||
-file does not exist but the
|
||||
-.I cron.deny
|
||||
-file does exist, then a user must
|
||||
-.I not
|
||||
-be listed in the
|
||||
-.I cron.deny
|
||||
-file in order to use
|
||||
-.BR crontab.
|
||||
-If neither of these files exist, then only the super user is allowed to use
|
||||
-.BR crontab .
|
||||
-.PP
|
||||
-Another way to restrict the scheduling of cron jobs beyond
|
||||
-.BR crontab
|
||||
-is to use PAM authentication in
|
||||
-.I /etc/security/access.conf
|
||||
-to set up users, which are allowed or disallowed to use
|
||||
-.BR crontab
|
||||
-or modify system cron jobs in the
|
||||
-.IR /etc/cron.d/
|
||||
-directory.
|
||||
+.IR @TERMUX_PREFIX@/var/spool/ ,
|
||||
+they are not intended to be edited directly.
|
||||
.PP
|
||||
The temporary directory can be set in an environment variable. If it is
|
||||
not set by the user, the
|
||||
-.I /tmp
|
||||
+.I @TERMUX_PREFIX@/tmp
|
||||
directory is used.
|
||||
.PP
|
||||
.SH "OPTIONS"
|
||||
.TP
|
||||
-.B "\-u"
|
||||
-Specifies the name of the user whose crontab is to be modified. If this
|
||||
-option is not used,
|
||||
-.BR crontab
|
||||
-examines "your" crontab, i.e., the crontab of the person executing the
|
||||
-command. If no crontab exists for a particular user, it is created for
|
||||
-them the first time the
|
||||
-.B crontab -u
|
||||
-command is used under their username.
|
||||
-.TP
|
||||
.B "\-l"
|
||||
Displays the current crontab on standard output.
|
||||
.TP
|
||||
@@ -147,74 +80,11 @@
|
||||
documentation of MLS_LEVEL in
|
||||
.BR crontab (5).
|
||||
.TP
|
||||
-.B "\-n"
|
||||
-This option is relevant only if
|
||||
-.BR cron (8)
|
||||
-was started with the
|
||||
-.B \-c
|
||||
-option, to enable clustering support. It is used to set the host in the
|
||||
-cluster which should run the jobs specified in the crontab files in the
|
||||
-.I /var/spool/cron
|
||||
-directory. If a hostname is supplied, the host whose hostname returned
|
||||
-by
|
||||
-.BR gethostname (2)
|
||||
-matches the supplied hostname, will be selected to run the selected cron jobs subsequently. If there
|
||||
-is no host in the cluster matching the supplied hostname, or you explicitly specify
|
||||
-an empty hostname, then the selected jobs will not be run at all. If the hostname
|
||||
-is omitted, the name of the local host returned by
|
||||
-.BR gethostname (2)
|
||||
-is used. Using this option has no effect on the
|
||||
-.I /etc/crontab
|
||||
-file and the files in the
|
||||
-.I /etc/cron.d
|
||||
-directory, which are always run, and considered host-specific. For more
|
||||
-information on clustering support, see
|
||||
-.BR cron (8).
|
||||
-.TP
|
||||
-.B "\-c"
|
||||
-This option is only relevant if
|
||||
-.BR cron (8)
|
||||
-was started with the
|
||||
-.B \-c
|
||||
-option, to enable clustering support. It is used to query which host in
|
||||
-the cluster is currently set to run the jobs specified in the crontab
|
||||
-files in the directory
|
||||
-.I /var/spool/cron
|
||||
-, as set using the
|
||||
-.B \-n
|
||||
-option.
|
||||
-.TP
|
||||
.B "\-V"
|
||||
Print version and exit.
|
||||
-.SH CAVEATS
|
||||
-The files
|
||||
-.I cron.allow
|
||||
-and
|
||||
-.I cron.deny
|
||||
-cannot be used to restrict the execution of cron jobs; they only restrict the
|
||||
-use of
|
||||
-.BR crontab .
|
||||
-In particular, restricting access to
|
||||
-.BR crontab
|
||||
-has no effect on an existing
|
||||
-.I crontab
|
||||
-of a user. Its jobs will continue to be executed until the crontab is removed.
|
||||
-.PP
|
||||
-The files
|
||||
-.I cron.allow
|
||||
-and
|
||||
-.I cron.deny
|
||||
-must be readable by the user invoking
|
||||
-.BR crontab .
|
||||
-If this is not the case, then they are treated as non-existent.
|
||||
.SH "SEE ALSO"
|
||||
.BR crontab (5),
|
||||
.BR cron (8)
|
||||
-.SH FILES
|
||||
-.nf
|
||||
-/etc/cron.allow
|
||||
-/etc/cron.deny
|
||||
-.fi
|
||||
.SH STANDARDS
|
||||
The
|
||||
.I crontab
|
234
packages/cronie/single-user-mode.patch
Normal file
234
packages/cronie/single-user-mode.patch
Normal file
@ -0,0 +1,234 @@
|
||||
diff -uNr cronie-1.5.5/src/cron.c cronie-1.5.5.mod/src/cron.c
|
||||
--- cronie-1.5.5/src/cron.c 2019-04-15 11:33:30.000000000 +0300
|
||||
+++ cronie-1.5.5.mod/src/cron.c 2020-07-09 00:31:25.288737591 +0300
|
||||
@@ -187,7 +187,9 @@
|
||||
fprintf(stderr, " -n run in foreground\n");
|
||||
fprintf(stderr, " -p permit any crontab\n");
|
||||
fprintf(stderr, " -P use PATH=\"%s\"\n", _PATH_DEFPATH);
|
||||
+#ifndef __ANDROID__
|
||||
fprintf(stderr, " -c enable clustering support\n");
|
||||
+#endif
|
||||
fprintf(stderr, " -s log into syslog instead of sending mails\n");
|
||||
fprintf(stderr, " -V print version and exit\n");
|
||||
fprintf(stderr, " -x <flag> print debug information\n");
|
||||
@@ -691,7 +693,7 @@
|
||||
static void parse_args(int argc, char *argv[]) {
|
||||
int argch;
|
||||
|
||||
- while (-1 != (argch = getopt(argc, argv, "hnpsiPx:m:cV"))) {
|
||||
+ while (-1 != (argch = getopt(argc, argv, "hnpsiPx:m:V"))) {
|
||||
switch (argch) {
|
||||
case 'x':
|
||||
if (!set_debug_flags(optarg))
|
||||
@@ -715,9 +717,11 @@
|
||||
case 'm':
|
||||
strncpy(MailCmd, optarg, MAX_COMMAND);
|
||||
break;
|
||||
+#ifndef __ANDROID__
|
||||
case 'c':
|
||||
EnableClustering = 1;
|
||||
break;
|
||||
+#endif
|
||||
case 'V':
|
||||
puts(PACKAGE_STRING);
|
||||
exit(EXIT_SUCCESS);
|
||||
diff -uNr cronie-1.5.5/src/crontab.c cronie-1.5.5.mod/src/crontab.c
|
||||
--- cronie-1.5.5/src/crontab.c 2019-10-31 16:50:32.000000000 +0200
|
||||
+++ cronie-1.5.5.mod/src/crontab.c 2020-07-09 00:31:25.288737591 +0300
|
||||
@@ -75,15 +75,15 @@
|
||||
static const char *Options[] = {"???", "list", "delete", "edit", "replace", "hostset", "hostget"};
|
||||
|
||||
# ifdef WITH_SELINUX
|
||||
-static const char *getoptargs = "u:lerisncx:V";
|
||||
+static const char *getoptargs = "u:lerisx:V";
|
||||
# else
|
||||
-static const char *getoptargs = "u:lerincx:V";
|
||||
+static const char *getoptargs = "u:lerix:V";
|
||||
# endif
|
||||
#else
|
||||
# ifdef WITH_SELINUX
|
||||
-static const char *getoptargs = "u:lerisncV";
|
||||
+static const char *getoptargs = "u:lerisV";
|
||||
# else
|
||||
-static const char *getoptargs = "u:lerincV";
|
||||
+static const char *getoptargs = "u:leriV";
|
||||
# endif
|
||||
#endif
|
||||
#ifdef WITH_SELINUX
|
||||
@@ -115,16 +115,22 @@
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, " %s [options] file\n", ProgramName);
|
||||
fprintf(stderr, " %s [options]\n", ProgramName);
|
||||
+#ifndef __ANDROID__
|
||||
fprintf(stderr, " %s -n [hostname]\n", ProgramName);
|
||||
+#endif
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Options:\n");
|
||||
+#ifndef __ANDROID__
|
||||
fprintf(stderr, " -u <user> define user\n");
|
||||
+#endif
|
||||
fprintf(stderr, " -e edit user's crontab\n");
|
||||
fprintf(stderr, " -l list user's crontab\n");
|
||||
fprintf(stderr, " -r delete user's crontab\n");
|
||||
fprintf(stderr, " -i prompt before deleting\n");
|
||||
+#ifndef __ANDROID__
|
||||
fprintf(stderr, " -n <host> set host in cluster to run users' crontabs\n");
|
||||
fprintf(stderr, " -c get host in cluster to run users' crontabs\n");
|
||||
+#endif
|
||||
#ifdef WITH_SELINUX
|
||||
fprintf(stderr, " -s selinux context\n");
|
||||
#endif
|
||||
@@ -157,6 +163,7 @@
|
||||
#endif
|
||||
parse_args(argc, argv); /* sets many globals, opens a file */
|
||||
check_spool_dir();
|
||||
+#ifndef __ANDROID__
|
||||
if (!allowed(RealUser, CRON_ALLOW, CRON_DENY)) {
|
||||
fprintf(stderr,
|
||||
"You (%s) are not allowed to use this program (%s)\n",
|
||||
@@ -165,7 +172,7 @@
|
||||
log_it(RealUser, Pid, "AUTH", "crontab command not allowed", 0);
|
||||
exit(ERROR_EXIT);
|
||||
}
|
||||
-
|
||||
+#endif
|
||||
#if defined(WITH_PAM)
|
||||
if (getuid() != 0 && cron_start_pam(pw) != PAM_SUCCESS) {
|
||||
fprintf(stderr,
|
||||
@@ -214,7 +221,7 @@
|
||||
int argch;
|
||||
|
||||
if (!(pw = getpwuid(getuid()))) {
|
||||
- fprintf(stderr, "%s: your UID isn't in the passwd file.\n",
|
||||
+ fprintf(stderr, "%s: your UID is unknown.\n",
|
||||
ProgramName);
|
||||
fprintf(stderr, "bailing out.\n");
|
||||
exit(ERROR_EXIT);
|
||||
@@ -237,6 +244,7 @@
|
||||
usage("bad debug option");
|
||||
break;
|
||||
#endif
|
||||
+#ifndef __ANDROID__
|
||||
case 'u':
|
||||
if (MY_UID(pw) != ROOT_UID) {
|
||||
fprintf(stderr, "must be privileged to use -u\n");
|
||||
@@ -264,6 +272,7 @@
|
||||
usage("username too long");
|
||||
(void) strcpy(User, optarg);
|
||||
break;
|
||||
+#endif // __ANDROID__
|
||||
case 'l':
|
||||
if (Option != opt_unknown)
|
||||
usage("only one operation permitted");
|
||||
@@ -290,6 +299,7 @@
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
+#ifndef __ANDROID__
|
||||
case 'n':
|
||||
if (MY_UID(pw) != ROOT_UID) {
|
||||
fprintf(stderr,
|
||||
@@ -315,6 +325,7 @@
|
||||
}
|
||||
Option = opt_hostget;
|
||||
break;
|
||||
+#endif
|
||||
case 'V':
|
||||
puts(PACKAGE_STRING);
|
||||
exit(EXIT_SUCCESS);
|
||||
@@ -630,6 +641,7 @@
|
||||
goto fatal;
|
||||
case 0:
|
||||
/* child */
|
||||
+#ifndef __ANDROID__
|
||||
if (setgid(MY_GID(pw)) < 0) {
|
||||
perror("setgid(getgid())");
|
||||
exit(ERROR_EXIT);
|
||||
@@ -638,6 +650,7 @@
|
||||
perror("setuid(getuid())");
|
||||
exit(ERROR_EXIT);
|
||||
}
|
||||
+#endif
|
||||
if (!glue_strings(q, sizeof q, editor, Filename, ' ')) {
|
||||
fprintf(stderr, "%s: editor command line too long\n", ProgramName);
|
||||
exit(ERROR_EXIT);
|
||||
@@ -896,6 +909,7 @@
|
||||
|
||||
file_owner = (getgid() == geteuid() && getgid() == getegid()) ? ROOT_UID : pw->pw_uid;
|
||||
|
||||
+#ifndef __ANDROID__
|
||||
#ifdef HAVE_FCHOWN
|
||||
if (fchown(fileno(tmp), file_owner, (gid_t)-1) < OK) {
|
||||
perror("fchown");
|
||||
@@ -911,6 +925,7 @@
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
if (fclose(tmp) == EOF) {
|
||||
perror("fclose");
|
||||
diff -uNr cronie-1.5.5/src/misc.c cronie-1.5.5.mod/src/misc.c
|
||||
--- cronie-1.5.5/src/misc.c 2019-05-07 15:45:40.000000000 +0300
|
||||
+++ cronie-1.5.5.mod/src/misc.c 2020-07-09 00:31:21.068718342 +0300
|
||||
@@ -228,6 +228,9 @@
|
||||
}
|
||||
|
||||
void set_cron_uid(void) {
|
||||
+#ifdef __ANDROID__
|
||||
+ return;
|
||||
+#endif
|
||||
#if defined(BSD) || defined(POSIX)
|
||||
if (seteuid(ROOT_UID) < OK) {
|
||||
perror("seteuid");
|
||||
@@ -650,6 +653,7 @@
|
||||
}
|
||||
#endif /*MAIL_DATE */
|
||||
|
||||
+#ifndef __ANDROID__
|
||||
#ifdef HAVE_SAVED_UIDS
|
||||
static uid_t save_euid;
|
||||
static gid_t save_egid;
|
||||
@@ -675,7 +679,15 @@
|
||||
return (swap_uids());
|
||||
}
|
||||
#endif /*HAVE_SAVED_UIDS */
|
||||
+#else
|
||||
+int swap_uids(void) {
|
||||
+ return 0;
|
||||
+}
|
||||
|
||||
+int swap_uids_back(void) {
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif
|
||||
size_t strlens(const char *last, ...) {
|
||||
va_list ap;
|
||||
size_t ret = 0;
|
||||
diff -uNr cronie-1.5.5/src/security.c cronie-1.5.5.mod/src/security.c
|
||||
--- cronie-1.5.5/src/security.c 2019-04-15 11:33:30.000000000 +0300
|
||||
+++ cronie-1.5.5.mod/src/security.c 2020-07-09 00:31:25.288737591 +0300
|
||||
@@ -235,6 +235,10 @@
|
||||
}
|
||||
|
||||
int cron_change_groups(struct passwd *pw) {
|
||||
+#ifdef __ANDROID__
|
||||
+ return 0;
|
||||
+#endif
|
||||
+
|
||||
pid_t pid = getpid();
|
||||
|
||||
if (setgid(pw->pw_gid) != 0) {
|
||||
@@ -259,10 +263,12 @@
|
||||
}
|
||||
|
||||
int cron_change_user_permanently(struct passwd *pw, char *homedir) {
|
||||
+#ifndef __ANDROID__
|
||||
if (setreuid(pw->pw_uid, pw->pw_uid) != 0) {
|
||||
log_it("CRON", getpid(), "ERROR", "setreuid failed", errno);
|
||||
return -1;
|
||||
}
|
||||
+#endif
|
||||
|
||||
if (chdir(homedir) == -1) {
|
||||
log_it("CRON", getpid(), "ERROR chdir failed", homedir, errno);
|
Loading…
Reference in New Issue
Block a user