2021-05-03 20:43:38 +02:00
|
|
|
diff -uNr cronie-1.5.7/src/cron.c cronie-1.5.7.mod/src/cron.c
|
|
|
|
--- cronie-1.5.7/src/cron.c 2021-01-22 11:29:39.000000000 +0000
|
|
|
|
+++ cronie-1.5.7.mod/src/cron.c 2021-05-03 18:37:15.040789324 +0000
|
2022-03-23 21:37:59 +01:00
|
|
|
@@ -186,7 +186,9 @@
|
2020-07-08 23:53:36 +02:00
|
|
|
fprintf(stderr, " -p permit any crontab\n");
|
2022-03-23 21:37:59 +01:00
|
|
|
fprintf(stderr, " -P inherit PATH from environment instead of using default value");
|
|
|
|
fprintf(stderr, " of \"%s\"\n", _PATH_DEFPATH);
|
2020-07-08 23:53:36 +02:00
|
|
|
+#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");
|
2022-03-23 21:37:59 +01:00
|
|
|
@@ -691,7 +693,11 @@
|
2020-07-08 23:53:36 +02:00
|
|
|
static void parse_args(int argc, char *argv[]) {
|
|
|
|
int argch;
|
|
|
|
|
2022-03-23 21:37:59 +01:00
|
|
|
+#ifdef __ANDROID__
|
|
|
|
+ while (-1 != (argch = getopt(argc, argv, "hnfpsiPx:m:V"))) {
|
|
|
|
+#else
|
|
|
|
while (-1 != (argch = getopt(argc, argv, "hnfpsiPx:m:cV"))) {
|
|
|
|
+#endif
|
2020-07-08 23:53:36 +02:00
|
|
|
switch (argch) {
|
|
|
|
case 'x':
|
|
|
|
if (!set_debug_flags(optarg))
|
2022-03-23 21:37:59 +01:00
|
|
|
@@ -716,9 +722,11 @@
|
2020-07-08 23:53:36 +02:00
|
|
|
case 'm':
|
|
|
|
strncpy(MailCmd, optarg, MAX_COMMAND);
|
|
|
|
break;
|
|
|
|
+#ifndef __ANDROID__
|
|
|
|
case 'c':
|
|
|
|
EnableClustering = 1;
|
|
|
|
break;
|
|
|
|
+#endif
|
|
|
|
case 'V':
|
|
|
|
puts(PACKAGE_STRING);
|
|
|
|
exit(EXIT_SUCCESS);
|
2021-05-03 20:43:38 +02:00
|
|
|
diff -uNr cronie-1.5.7/src/crontab.c cronie-1.5.7.mod/src/crontab.c
|
|
|
|
--- cronie-1.5.7/src/crontab.c 2021-03-19 10:15:42.000000000 +0000
|
|
|
|
+++ cronie-1.5.7.mod/src/crontab.c 2021-05-03 18:40:24.992789931 +0000
|
|
|
|
@@ -81,15 +81,15 @@
|
|
|
|
};
|
2020-07-08 23:53:36 +02:00
|
|
|
|
|
|
|
# ifdef WITH_SELINUX
|
2021-05-03 20:43:38 +02:00
|
|
|
-static const char *getoptargs = "u:lerisncx:VT";
|
|
|
|
+static const char *getoptargs = "lerisx:VT";
|
2020-07-08 23:53:36 +02:00
|
|
|
# else
|
2021-05-03 20:43:38 +02:00
|
|
|
-static const char *getoptargs = "u:lerincx:VT";
|
|
|
|
+static const char *getoptargs = "lerix:VT";
|
2020-07-08 23:53:36 +02:00
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# ifdef WITH_SELINUX
|
2021-05-03 20:43:38 +02:00
|
|
|
-static const char *getoptargs = "u:lerisncVT";
|
|
|
|
+static const char *getoptargs = "lerisVT";
|
2020-07-08 23:53:36 +02:00
|
|
|
# else
|
2021-05-03 20:43:38 +02:00
|
|
|
-static const char *getoptargs = "u:lerincVT";
|
|
|
|
+static const char *getoptargs = "leriVT";
|
2020-07-08 23:53:36 +02:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
#ifdef WITH_SELINUX
|
2021-05-03 20:43:38 +02:00
|
|
|
@@ -127,13 +127,10 @@
|
2020-07-08 23:53:36 +02:00
|
|
|
fprintf(stderr, " %s -n [hostname]\n", ProgramName);
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
fprintf(stderr, "Options:\n");
|
2021-05-03 20:43:38 +02:00
|
|
|
- fprintf(stderr, " -u <user> define user\n");
|
2020-07-08 23:53:36 +02:00
|
|
|
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");
|
2021-05-03 20:43:38 +02:00
|
|
|
- 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");
|
|
|
|
fprintf(stderr, " -T <file> test a crontab file syntax\n");
|
2020-07-08 23:53:36 +02:00
|
|
|
#ifdef WITH_SELINUX
|
|
|
|
fprintf(stderr, " -s selinux context\n");
|
2021-05-03 20:43:38 +02:00
|
|
|
@@ -167,6 +164,7 @@
|
2020-07-08 23:53:36 +02:00
|
|
|
#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",
|
2021-05-03 20:43:38 +02:00
|
|
|
@@ -175,7 +173,7 @@
|
2020-07-08 23:53:36 +02:00
|
|
|
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,
|
2021-05-03 20:43:38 +02:00
|
|
|
@@ -228,7 +226,7 @@
|
2020-07-08 23:53:36 +02:00
|
|
|
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);
|
2021-05-03 20:43:38 +02:00
|
|
|
@@ -251,6 +249,7 @@
|
2020-07-08 23:53:36 +02:00
|
|
|
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");
|
2021-05-03 20:43:38 +02:00
|
|
|
@@ -278,6 +277,7 @@
|
2020-07-08 23:53:36 +02:00
|
|
|
usage("username too long");
|
|
|
|
(void) strcpy(User, optarg);
|
|
|
|
break;
|
|
|
|
+#endif // __ANDROID__
|
|
|
|
case 'l':
|
|
|
|
if (Option != opt_unknown)
|
|
|
|
usage("only one operation permitted");
|
2021-05-03 20:43:38 +02:00
|
|
|
@@ -309,6 +309,7 @@
|
2020-07-08 23:53:36 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
+#ifndef __ANDROID__
|
|
|
|
case 'n':
|
|
|
|
if (MY_UID(pw) != ROOT_UID) {
|
2021-05-03 20:43:38 +02:00
|
|
|
fprintf(stderr, "must be privileged to set host with -n\n");
|
|
|
|
@@ -331,6 +332,7 @@
|
2020-07-08 23:53:36 +02:00
|
|
|
}
|
|
|
|
Option = opt_hostget;
|
|
|
|
break;
|
|
|
|
+#endif
|
|
|
|
case 'V':
|
|
|
|
puts(PACKAGE_STRING);
|
|
|
|
exit(EXIT_SUCCESS);
|
2021-05-03 20:43:38 +02:00
|
|
|
@@ -663,6 +665,7 @@
|
2020-07-08 23:53:36 +02:00
|
|
|
goto fatal;
|
|
|
|
case 0:
|
|
|
|
/* child */
|
|
|
|
+#ifndef __ANDROID__
|
|
|
|
if (setgid(MY_GID(pw)) < 0) {
|
|
|
|
perror("setgid(getgid())");
|
|
|
|
exit(ERROR_EXIT);
|
2021-05-03 20:43:38 +02:00
|
|
|
@@ -671,6 +674,7 @@
|
2020-07-08 23:53:36 +02:00
|
|
|
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);
|
2021-05-03 20:43:38 +02:00
|
|
|
@@ -878,6 +882,7 @@
|
|
|
|
file_owner = (getgid() == geteuid() &&
|
|
|
|
getgid() == getegid()) ? ROOT_UID : pw->pw_uid;
|
2020-07-08 23:53:36 +02:00
|
|
|
|
|
|
|
+#ifndef __ANDROID__
|
|
|
|
#ifdef HAVE_FCHOWN
|
|
|
|
if (fchown(fileno(tmp), file_owner, (gid_t)-1) < OK) {
|
|
|
|
perror("fchown");
|
2021-05-03 20:43:38 +02:00
|
|
|
@@ -893,6 +898,7 @@
|
2020-07-08 23:53:36 +02:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
if (fclose(tmp) == EOF) {
|
|
|
|
perror("fclose");
|
2021-05-03 20:43:38 +02:00
|
|
|
diff -uNr cronie-1.5.7/src/misc.c cronie-1.5.7.mod/src/misc.c
|
|
|
|
--- cronie-1.5.7/src/misc.c 2019-05-07 12:45:40.000000000 +0000
|
|
|
|
+++ cronie-1.5.7.mod/src/misc.c 2021-05-03 18:37:15.040789324 +0000
|
2020-07-08 23:53:36 +02:00
|
|
|
@@ -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;
|
2021-05-03 20:43:38 +02:00
|
|
|
diff -uNr cronie-1.5.7/src/security.c cronie-1.5.7.mod/src/security.c
|
|
|
|
--- cronie-1.5.7/src/security.c 2021-01-22 11:29:39.000000000 +0000
|
|
|
|
+++ cronie-1.5.7.mod/src/security.c 2021-05-03 18:37:15.040789324 +0000
|
2020-07-08 23:53:36 +02:00
|
|
|
@@ -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);
|