move from unstable: at

This commit is contained in:
Leonid Pliushch 2020-12-30 14:19:57 +02:00
parent d8fbe7cebc
commit d062dd3516
No known key found for this signature in database
GPG Key ID: 45F2964132545795
10 changed files with 429 additions and 0 deletions

View File

@ -0,0 +1,66 @@
diff -uNr at-3.2.1/Makefile.in at-3.2.1.mod/Makefile.in
--- at-3.2.1/Makefile.in 2019-08-04 15:16:16.000000000 +0300
+++ at-3.2.1.mod/Makefile.in 2020-01-02 20:33:10.058931466 +0200
@@ -93,41 +93,40 @@
$(CC) -c $(CFLAGS) $(DEFS) $*.c
install: all
- $(INSTALL) -g root -o root -m 755 -d $(IROOT)$(etcdir)
- $(INSTALL) -g root -o root -m 755 -d $(IROOT)$(bindir)
- $(INSTALL) -g root -o root -m 755 -d $(IROOT)$(sbindir)
- $(INSTALL) -g root -o root -m 755 -d $(IROOT)$(docdir)
- $(INSTALL) -g root -o root -m 755 -d $(IROOT)$(atdocdir)
- $(INSTALL) -g $(DAEMON_GROUPNAME) -o $(DAEMON_USERNAME) -m 755 -d $(IROOT)$(ATSPOOL_DIR) $(IROOT)$(ATJOB_DIR)
+ $(INSTALL) -m 755 -d $(IROOT)$(etcdir)
+ $(INSTALL) -m 755 -d $(IROOT)$(bindir)
+ $(INSTALL) -m 755 -d $(IROOT)$(sbindir)
+ $(INSTALL) -m 755 -d $(IROOT)$(docdir)
+ $(INSTALL) -m 755 -d $(IROOT)$(atdocdir)
+ $(INSTALL) -m 755 -d $(IROOT)$(ATSPOOL_DIR) $(IROOT)$(ATJOB_DIR)
chmod 1770 $(IROOT)$(ATSPOOL_DIR) $(IROOT)$(ATJOB_DIR)
touch $(IROOT)$(LFILE)
chmod 600 $(IROOT)$(LFILE)
- chown $(DAEMON_USERNAME):$(DAEMON_GROUPNAME) $(IROOT)$(LFILE)
- test -f $(IROOT)$(etcdir)/at.allow || test -f $(IROOT)$(etcdir)/at.deny || $(INSTALL) -o root -g $(DAEMON_GROUPNAME) -m 640 at.deny $(IROOT)$(etcdir)/
- $(INSTALL) -g $(DAEMON_GROUPNAME) -o $(DAEMON_USERNAME) -m 6755 at $(IROOT)$(bindir)
+ test -f $(IROOT)$(etcdir)/at.allow || test -f $(IROOT)$(etcdir)/at.deny || $(INSTALL) -m 640 at.deny $(IROOT)$(etcdir)/
+ $(INSTALL) -m 6755 at $(IROOT)$(bindir)
$(LN_S) -f at $(IROOT)$(bindir)/atq
$(LN_S) -f at $(IROOT)$(bindir)/atrm
- $(INSTALL) -g root -o root -m 755 batch $(IROOT)$(bindir)
- $(INSTALL) -d -o root -g root -m 755 $(IROOT)$(man1dir)
- $(INSTALL) -d -o root -g root -m 755 $(IROOT)$(man5dir)
- $(INSTALL) -d -o root -g root -m 755 $(IROOT)$(man8dir)
- $(INSTALL) -g root -o root -m 755 atd $(IROOT)$(sbindir)
- $(INSTALL) -g root -o root -m 755 atrun $(IROOT)$(sbindir)
- $(INSTALL) -g root -o root -m 644 at.1 $(IROOT)$(man1dir)/
+ $(INSTALL) -m 755 batch $(IROOT)$(bindir)
+ $(INSTALL) -d -m 755 $(IROOT)$(man1dir)
+ $(INSTALL) -d -m 755 $(IROOT)$(man5dir)
+ $(INSTALL) -d -m 755 $(IROOT)$(man8dir)
+ $(INSTALL) -m 755 atd $(IROOT)$(sbindir)
+ $(INSTALL) -m 755 atrun $(IROOT)$(sbindir)
+ $(INSTALL) -m 644 at.1 $(IROOT)$(man1dir)/
cd $(IROOT)$(man1dir) && $(LN_S) -f at.1 atq.1 && $(LN_S) -f at.1 batch.1 && $(LN_S) -f at.1 atrm.1
- $(INSTALL) -g root -o root -m 644 atd.8 $(IROOT)$(man8dir)/
+ $(INSTALL) -m 644 atd.8 $(IROOT)$(man8dir)/
sed "s,\$${exec_prefix},$(exec_prefix),g" <atrun.8>tmpman
- $(INSTALL) -g root -o root -m 644 tmpman $(IROOT)$(man8dir)/atrun.8
+ $(INSTALL) -m 644 tmpman $(IROOT)$(man8dir)/atrun.8
rm -f tmpman
- $(INSTALL) -g root -o root -m 644 at.allow.5 $(IROOT)$(man5dir)/
+ $(INSTALL) -m 644 at.allow.5 $(IROOT)$(man5dir)/
cd $(IROOT)$(man5dir) && $(LN_S) -f at.allow.5 at.deny.5
- $(INSTALL) -g root -o root -m 644 $(DOCS) $(IROOT)$(atdocdir)
+ $(INSTALL) -m 644 $(DOCS) $(IROOT)$(atdocdir)
rm -f $(IROOT)$(mandir)/cat1/at.1* $(IROOT)$(mandir)/cat1/batch.1* \
$(IROOT)$(mandir)/cat1/atq.1*
rm -f $(IROOT)$(mandir)/cat1/atd.8*
if test x"$(systemdsystemunitdir)" != xno; then \
- $(INSTALL) -o root -g root -m 755 -d $(IROOT)$(systemdsystemunitdir); \
- $(INSTALL) -o root -g root -m 644 atd.service $(IROOT)$(systemdsystemunitdir); \
+ $(INSTALL) -m 755 -d $(IROOT)$(systemdsystemunitdir); \
+ $(INSTALL) -m 644 atd.service $(IROOT)$(systemdsystemunitdir); \
fi
dist: checkin $(DIST) $(LIST) Filelist.asc

View File

@ -0,0 +1,97 @@
diff -uNr at-3.2.1/at.c at-3.2.1.mod/at.c
--- at-3.2.1/at.c 2019-08-04 15:16:16.000000000 +0300
+++ at-3.2.1.mod/at.c 2020-01-02 20:33:14.106959504 +0200
@@ -81,6 +81,11 @@
#include "posixtm.h"
#include "privs.h"
+#ifdef PIDFILE
+#undef PIDFILE
+#define PIDFILE "@TERMUX_PREFIX@/var/run/atd.pid"
+#endif
+
/* Macros */
#ifndef ATJOB_MX
@@ -151,9 +156,9 @@
We need the unprivileged uid here since the file is owned by the real
(not effective) uid.
*/
- setregid(real_gid, effective_gid);
+// setregid(real_gid, effective_gid);
unlink(atfile);
- setregid(effective_gid, real_gid);
+// setregid(effective_gid, real_gid);
/*
PRIV_END
*/
@@ -389,7 +394,7 @@
perr("Cannot open input file %.500s", atinput);
}
- fprintf(fp, "#!/bin/sh\n# atrun uid=%d gid=%d\n# mail %s %d\n",
+ fprintf(fp, "#!@TERMUX_PREFIX@/bin/sh\n# atrun uid=%d gid=%d\n# mail %s %d\n",
real_uid, real_gid, mailname, send_mail);
/* Write out the umask at the time of invocation
@@ -694,7 +699,7 @@
We need the unprivileged uid here since the file is owned by the real
(not effective) uid.
*/
- setregid(real_gid, effective_gid);
+ //setregid(real_gid, effective_gid);
if (queue == '=') {
fprintf(stderr, "Warning: deleting running job\n");
@@ -704,7 +709,7 @@
rc = EXIT_FAILURE;
}
- setregid(effective_gid, real_gid);
+ //setregid(effective_gid, real_gid);
done = 1;
break;
@@ -714,7 +719,7 @@
FILE *fp;
int ch;
- setregid(real_gid, effective_gid);
+ //setregid(real_gid, effective_gid);
fp = fopen(dirent->d_name, "r");
if (fp) {
@@ -727,7 +732,7 @@
perr("Cannot open %.500s", dirent->d_name);
rc = EXIT_FAILURE;
}
- setregid(effective_gid, real_gid);
+ //setregid(effective_gid, real_gid);
}
break;
@@ -778,6 +783,7 @@
RELINQUISH_PRIVS
+#ifndef __ANDROID__
if ((pwe = getpwnam(DAEMON_USERNAME)) == NULL)
perr("Cannot get uid for " DAEMON_USERNAME);
@@ -787,6 +793,7 @@
perr("Cannot get gid for " DAEMON_GROUPNAME);
daemon_gid = ge->gr_gid;
+#endif
/* Eat any leading paths
*/
@@ -969,7 +976,7 @@
It also alows a warning diagnostic to be printed. Because of the
possible variance, we always output the diagnostic. */
- fprintf(stderr, "warning: commands will be executed using /bin/sh\n");
+ fprintf(stderr, "warning: commands will be executed using @TERMUX_PREFIX@/bin/sh\n");
writefile(timer, queue);
break;

View File

@ -0,0 +1,112 @@
diff -uNr at-3.2.1/atd.c at-3.2.1.mod/atd.c
--- at-3.2.1/atd.c 2019-08-04 15:16:16.000000000 +0300
+++ at-3.2.1.mod/atd.c 2020-01-02 20:33:14.106959504 +0200
@@ -92,7 +92,7 @@
/* Macros */
#define BATCH_INTERVAL_DEFAULT 60
-#define CHECK_INTERVAL 3600
+#define CHECK_INTERVAL 5
/* Global variables */
@@ -321,7 +321,7 @@
* fact and return.
*/
PRIV_START
- rc = link(filename, newname);
+ rc = symlink(filename, newname);
PRIV_END
if (rc == -1) {
syslog(LOG_WARNING, "could not lock job %lu: %m", jobno);
@@ -397,7 +397,7 @@
* NFS and works with local file systems. It's not clear where
* the bug is located. -Joey
*/
- sprintf(fmt, "#!/bin/sh\n# atrun uid=%%d gid=%%d\n# mail %%%ds %%d",
+ sprintf(fmt, "#!@TERMUX_PREFIX@/bin/sh\n# atrun uid=%%d gid=%%d\n# mail %%%ds %%d",
mailsize );
if (fscanf(stream, fmt,
@@ -409,9 +409,11 @@
pabort("illegal mail name %.300s in job %8lu (%.300s)", mailname,
jobno, filename);
+#ifndef __ANDROID__
if (nuid != uid)
pabort("Job %8lu (%.500s) - userid %d does not match file uid %d",
jobno, filename, nuid, uid);
+#endif
/* We are now committed to executing this script. Unlink the
* original.
@@ -435,11 +437,14 @@
if ((fd_out = open(filename,
O_RDWR | O_CREAT | O_EXCL, S_IWUSR | S_IRUSR)) < 0)
perr("Cannot create output file");
+
+#ifndef __ANDROID__
PRIV_START
if (fchown(fd_out, uid, ngid) == -1)
syslog(LOG_WARNING, "Warning: could not change owner of output file for job %li to %i:%i: %s",
jobno, uid, ngid, strerror(errno));
PRIV_END
+#endif
write_string(fd_out, "Subject: Output from your job ");
write_string(fd_out, jobbuf);
@@ -503,6 +508,7 @@
}
#endif
+#ifndef __ANDROID__
if (initgroups(pentry->pw_name, pentry->pw_gid))
perr("Cannot initialize the supplementary group access list");
@@ -511,11 +517,12 @@
if (setuid(uid) < 0)
perr("Cannot set user id");
+#endif
chdir("/");
- if (execle("/bin/sh", "sh", (char *) NULL, nenvp) != 0)
- perr("Exec failed for /bin/sh");
+ if (execle("@TERMUX_PREFIX@/bin/sh", "sh", (char *) NULL, nenvp) != 0)
+ perr("Exec failed for @TERMUX_PREFIX@/bin/sh");
PRIV_END
}
@@ -571,6 +578,7 @@
PRIV_START
+#ifndef __ANDROID__
if (initgroups(pentry->pw_name, pentry->pw_gid))
perr("Cannot initialize the supplementary group access list");
@@ -579,6 +587,7 @@
if (setuid(uid) < 0)
perr("Cannot set user id");
+#endif
chdir ("/");
@@ -804,6 +813,7 @@
* daemon is fine.
*/
+#ifndef __ANDROID__
if ((pwe = getpwnam(DAEMON_USERNAME)) == NULL)
perr("Cannot get uid for " DAEMON_USERNAME);
@@ -815,6 +825,7 @@
daemon_gid = ge->gr_gid;
RELINQUISH_PRIVS_ROOT(daemon_uid, daemon_gid)
+#endif
#ifndef LOG_CRON
#define LOG_CRON LOG_DAEMON

View File

@ -0,0 +1,9 @@
diff -uNr at-3.2.1/atrun.in at-3.2.1.mod/atrun.in
--- at-3.2.1/atrun.in 2019-08-04 15:16:16.000000000 +0300
+++ at-3.2.1.mod/atrun.in 2020-01-02 20:33:14.107959511 +0200
@@ -1,4 +1,4 @@
#! /bin/sh
prefix=@prefix@
exec_prefix=@exec_prefix@
-exec @sbindir@/atd -s "$@"
+exec @bindir@/atd -s "$@"

View File

@ -0,0 +1,15 @@
diff -uNr at-3.2.1/daemon.c at-3.2.1.mod/daemon.c
--- at-3.2.1/daemon.c 2019-08-04 15:16:16.000000000 +0300
+++ at-3.2.1.mod/daemon.c 2020-01-02 20:33:14.107959511 +0200
@@ -51,6 +51,11 @@
int daemon_debug = 0;
int daemon_foreground = 0;
+#ifdef PIDFILE
+#undef PIDFILE
+#define PIDFILE "@TERMUX_PREFIX@/var/run/atd.pid"
+#endif
+
static int
lock_fd(int fd)
{

View File

@ -0,0 +1,13 @@
diff -uNr at-3.2.1/getloadavg.c at-3.2.1.mod/getloadavg.c
--- at-3.2.1/getloadavg.c 2019-08-04 15:16:16.000000000 +0300
+++ at-3.2.1.mod/getloadavg.c 2020-01-02 20:33:06.650907870 +0200
@@ -69,9 +69,6 @@
#include <config.h>
#endif
-#include "lisp.h"
-#include "sysfile.h" /* for encapsulated open, close, read, write */
-
#ifndef HAVE_GETLOADAVG
/* The existing Emacs configuration files define a macro called

View File

@ -0,0 +1,27 @@
diff -uNr at-3.2.1/panic.c at-3.2.1.mod/panic.c
--- at-3.2.1/panic.c 2019-08-04 15:16:16.000000000 +0300
+++ at-3.2.1.mod/panic.c 2020-01-02 20:33:14.107959511 +0200
@@ -57,9 +57,9 @@
*/
fprintf(stderr, "%s: %s\n", namep, a);
if (fcreated) {
- setregid(real_gid, effective_gid);
+ //setregid(real_gid, effective_gid);
unlink(atfile);
- setregid(effective_gid, real_gid);
+ //setregid(effective_gid, real_gid);
}
exit(EXIT_FAILURE);
@@ -79,9 +79,9 @@
perror(buf);
if (fcreated) {
- setregid(real_gid, effective_gid);
+ //setregid(real_gid, effective_gid);
unlink(atfile);
- setregid(effective_gid, real_gid);
+ //setregid(effective_gid, real_gid);
}
exit(EXIT_FAILURE);

View File

@ -0,0 +1,33 @@
diff -uNr at-3.2.1/perm.c at-3.2.1.mod/perm.c
--- at-3.2.1/perm.c 2019-08-04 15:16:16.000000000 +0300
+++ at-3.2.1.mod/perm.c 2020-01-02 20:33:14.107959511 +0200
@@ -108,28 +108,7 @@
int
check_permission()
{
- uid_t uid = geteuid();
- struct passwd *pentry;
- int allow = 0, deny = 1;
-
- if (uid == 0)
- return 1;
-
- if ((pentry = getpwuid(uid)) == NULL) {
- perror("Cannot access user database");
- exit(EXIT_FAILURE);
- }
-
- allow = user_in_file(ETCDIR "/at.allow", pentry->pw_name);
- if (allow==0 || allow==1)
- return allow;
-
- /* There was an error while looking for pw_name in at.allow.
- * Check at.deny only when at.allow doesn't exist.
- */
-
- deny = user_in_file(ETCDIR "/at.deny", pentry->pw_name);
- return deny == 0;
+ return 1;
}

View File

@ -0,0 +1,20 @@
diff -uNr at-3.2.1/privs.h at-3.2.1.mod/privs.h
--- at-3.2.1/privs.h 2019-08-04 15:16:16.000000000 +0300
+++ at-3.2.1.mod/privs.h 2020-01-02 20:33:14.107959511 +0200
@@ -144,3 +144,16 @@
#error "Cannot implement user ID swapping without setreuid or setresuid"
#endif
#endif
+
+#ifdef __ANDROID__
+#undef RELINQUISH_PRIVS
+#define RELINQUISH_PRIVS
+#undef RELINQUISH_PRIVS_ROOT
+#define RELINQUISH_PRIVS_ROOT(a,b)
+#undef PRIV_START
+#define PRIV_START
+#undef PRIV_END
+#define PRIV_END
+#undef REDUCE_PRIV
+#define REDUCE_PRIV(a, b)
+#endif

37
packages/at/build.sh Normal file
View File

@ -0,0 +1,37 @@
TERMUX_PKG_HOMEPAGE=http://blog.calhariz.com/index.php/tag/at
TERMUX_PKG_DESCRIPTION="AT and batch delayed command scheduling utility and daemon"
TERMUX_PKG_LICENSE="GPL-2.0"
TERMUX_PKG_MAINTAINER="Leonid Pliushch <leonid.pliushch@gmail.com>"
TERMUX_PKG_VERSION=3.2.1
TERMUX_PKG_REVISION=5
TERMUX_PKG_SRCURL=http://software.calhariz.com/at/at_${TERMUX_PKG_VERSION}.orig.tar.gz
TERMUX_PKG_SHA256=aabe6e5cb6dd19fe9fb25c2747492f2db38762b95ea41b86f949609c39fb55c4
TERMUX_PKG_SUGGESTS="termux-services"
TERMUX_PKG_BUILD_IN_SRC=true
# Force make -j1.
TERMUX_MAKE_PROCESSES=1
# Setting loadavg_mx to 8.0 as most devices (8 core)
# do not have loadavg below 5-6.
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
ac_cv_path_SENDMAIL=$TERMUX_PREFIX/bin/sendmail
--with-loadavg_mx=8.0
--with-etcdir=$TERMUX_PREFIX/etc
--with-jobdir=$TERMUX_PREFIX/var/spool/atd
--with-atspool=$TERMUX_PREFIX/var/spool/atd
"
# at.allow and at.deny are not supported in Termux.
TERMUX_PKG_RM_AFTER_INSTALL="
share/man/man5
"
TERMUX_PKG_SERVICE_SCRIPT=("atd" "mkdir -p $TERMUX_PREFIX/var/run && exec atd")
termux_step_create_debscripts() {
cat <<- EOF > ./postinst
#!${TERMUX_PREFIX}/bin/sh
mkdir -p $TERMUX_PREFIX/var/run
EOF
}