termux-packages/packages/cronie/single-user-mode.patch

226 lines
6.2 KiB
Diff
Raw Normal View History

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
@@ -184,7 +184,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");
2021-05-03 20:43:38 +02:00
@@ -689,7 +691,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))
2021-05-03 20:43:38 +02:00
@@ -713,9 +715,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);
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 @@
};
# ifdef WITH_SELINUX
2021-05-03 20:43:38 +02:00
-static const char *getoptargs = "u:lerisncx:VT";
+static const char *getoptargs = "lerisx:VT";
# else
2021-05-03 20:43:38 +02:00
-static const char *getoptargs = "u:lerincx:VT";
+static const char *getoptargs = "lerix:VT";
# endif
#else
# ifdef WITH_SELINUX
2021-05-03 20:43:38 +02:00
-static const char *getoptargs = "u:lerisncVT";
+static const char *getoptargs = "lerisVT";
# else
2021-05-03 20:43:38 +02:00
-static const char *getoptargs = "u:lerincVT";
+static const char *getoptargs = "leriVT";
# endif
#endif
#ifdef WITH_SELINUX
2021-05-03 20:43:38 +02:00
@@ -127,13 +127,10 @@
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");
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");
#ifdef WITH_SELINUX
fprintf(stderr, " -s selinux context\n");
2021-05-03 20:43:38 +02:00
@@ -167,6 +164,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",
2021-05-03 20:43:38 +02:00
@@ -175,7 +173,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,
2021-05-03 20:43:38 +02:00
@@ -228,7 +226,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);
2021-05-03 20:43:38 +02:00
@@ -251,6 +249,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");
2021-05-03 20:43:38 +02:00
@@ -278,6 +277,7 @@
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 @@
}
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 @@
}
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 @@
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 @@
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;
+#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 @@
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
@@ -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
@@ -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);