Accepting request 254483 from Base:System

1

OBS-URL: https://build.opensuse.org/request/show/254483
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/at?expand=0&rev=67
This commit is contained in:
Stephan Kulow 2014-10-09 10:52:11 +00:00 committed by Git OBS Bridge
commit 352de0fc7d
6 changed files with 168 additions and 78 deletions

View File

@ -0,0 +1,110 @@
--- at-3.1.15.orig/atd.c
+++ at-3.1.15/atd.c
@@ -919,6 +919,54 @@ run_loop()
return next_job;
}
+#ifdef HAVE_CLOCK_GETTIME
+timer_t timer;
+struct itimerspec timeout;
+
+void timer_setup()
+{
+ struct sigevent sev;
+
+ sev.sigev_notify = SIGEV_SIGNAL;
+ sev.sigev_signo = SIGHUP;
+ sev.sigev_value.sival_ptr = &timer;
+
+ memset(&timeout, 0, sizeof(timeout));
+
+ if (timer_create(CLOCK_REALTIME, &sev, &timer) < 0)
+ pabort("unable to create timer");
+}
+
+time_t atd_gettime()
+{
+ struct timespec curtime;
+
+ clock_gettime(CLOCK_REALTIME, &curtime);
+
+ return curtime.tv_sec;
+}
+
+void atd_setalarm(time_t next)
+{
+ timeout.it_value.tv_sec = next;
+ timer_settime(timer, TIMER_ABSTIME, &timeout, NULL);
+ pause();
+}
+#else
+void timer_setup()
+{
+}
+
+time_t atd_gettime()
+{
+ return time(NULL);
+}
+
+void atd_setalarm(time_t next)
+{
+ sleep(next - atd_gettime());
+}
+#endif
/* Global functions */
int
@@ -1032,7 +1080,7 @@ main(int argc, char *argv[])
sigaction(SIGCHLD, &act, NULL);
if (!run_as_daemon) {
- now = time(NULL);
+ now = atd_gettime();
run_loop();
exit(EXIT_SUCCESS);
}
@@ -1055,13 +1103,14 @@ main(int argc, char *argv[])
act.sa_handler = set_term;
sigaction(SIGINT, &act, NULL);
+ timer_setup();
daemon_setup();
do {
- now = time(NULL);
+ now = atd_gettime();
next_invocation = run_loop();
if ((next_invocation > now) && (!hupped)) {
- sleep(next_invocation - now);
+ atd_setalarm(next_invocation);
}
hupped = 0;
} while (!term_signal);
--- at-3.1.15.orig/config.h.in
+++ at-3.1.15/config.h.in
@@ -38,6 +38,9 @@
/* Define to 1 if you have the `getloadavg' function. */
#undef HAVE_GETLOADAVG
+/* Define to 1 if you have the `clock_gettime' function. */
+#undef HAVE_TIMER_CREATE
+
/* Define to 1 if you have the <getopt.h> header file. */
#undef HAVE_GETOPT_H
--- at-3.1.15.orig/configure.ac
+++ at-3.1.15/configure.ac
@@ -254,6 +254,12 @@ AC_ARG_WITH(daemon_username,
)
AC_SUBST(DAEMON_USERNAME)
+dnl check for POSIX timer functions
+AC_SEARCH_LIBS([timer_create],[rt])
+AC_CHECK_FUNCS([timer_create])
+AC_SEARCH_LIBS([clock_gettime],[rt])
+AC_CHECK_FUNCS([clock_gettime])
+
AC_MSG_CHECKING(groupname to run under)
AC_ARG_WITH(daemon_groupname,
[ --with-daemon_groupname=DAEMON_GROUPNAME Groupname to run under (default daemon) ],

View File

@ -0,0 +1,39 @@
commit 482f5962d9584d6110b940f0f51ab5919a6eb8a0
Author: Ansgar Burchardt <ansgar@debian.org>
Date: Sun Sep 28 17:06:12 2014 +0200
at: only retain variables whose name consists of alphanumerics and underscores
Since a recent security update[1] bash might export variables named
BASH_FUNC_*() to the environment which the serialization code in at
cannot handle properly.
[1] <https://www.debian.org/security/2014/dsa-3035>
Index: at-3.1.15/at.c
===================================================================
--- at-3.1.15.orig/at.c
+++ at-3.1.15/at.c
@@ -390,6 +390,22 @@ writefile(time_t runtimer, char queue)
int export = 1;
char *eqp;
+ /* Only accept alphanumerics and underscore in variable names.
+ * Also require the name to not start with a digit.
+ * Some shells don't like other variable names.
+ */
+ {
+ char *p = *atenv;
+ if (isdigit(*p))
+ export = 0;
+ for (; *p != '=' && *p != '\0'; ++p) {
+ if (!isalnum(*p) && *p != '_') {
+ export = 0;
+ break;
+ }
+ }
+ }
+
eqp = strchr(*atenv, '=');
if (ap == NULL)
eqp = *atenv;

View File

@ -1,60 +0,0 @@
From: Jan Engelhardt <jengelh@inai.de>
Date: 2014-09-30 15:15:52.645631792 +0200
X-Status: fixes an upstream issue
Shells generally only allow setting environment variables whose keys
are of the form /^[A-Z_][A-Z0-9_]/i. Exporting anything else is going
to end in disaster (sh throwing syntax errors).
---
at.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
Index: at-3.1.14/at.c
===================================================================
--- at-3.1.14.orig/at.c
+++ at-3.1.14/at.c
@@ -225,6 +225,23 @@ nextjob()
return jobno;
}
+/**
+ * @s: string in the form of "key=value" and \0-terminated
+ * @n: length of key portion
+ */
+static bool legit_key(const char *s, size_t n)
+{
+ /* First char has extra restrictions: must not be a digit */
+ if (!isalpha(*s) && *s != '_')
+ return false;
+ for (; n-- > 0; ++s) {
+ if (!isalnum(*s) && *s != '_')
+ return false;
+ ++s;
+ }
+ return true;
+}
+
static void
writefile(time_t runtimer, char queue)
{
@@ -403,7 +420,10 @@ writefile(time_t runtimer, char queue)
eqp++;
}
- if (export) {
+ if (!export || !legit_key(*atenv, eqp - *atenv)) {
+ continue;
+ }
+
fwrite(*atenv, sizeof(char), eqp - *atenv, fp);
for (ap = eqp; *ap != '\0'; ap++) {
if (*ap == '\n')
@@ -439,7 +459,6 @@ writefile(time_t runtimer, char queue)
fwrite(*atenv, sizeof(char), eqp - *atenv - 1, fp);
fputc('\n', fp);
- }
}
/* Cd to the directory at the time and write out all the
* commands the user supplies from stdin.

View File

@ -1,3 +1,17 @@
-------------------------------------------------------------------
Mon Oct 6 20:32:38 UTC 2014 - lchiquitto@suse.com
- Replace at-sane-envkeys.diff by at-3.1.15-sane-envkeys.patch,
a simpler fix from upstream [bsc#899160]
-------------------------------------------------------------------
Fri Oct 3 15:00:43 UTC 2014 - crrodriguez@opensuse.org
- at-3.1.14-usePOSIXtimers.patch (from Fedora)
Use Posix timers, this
avoid the need of horrible suspend/resume hacks like at.sleep
with pm-utils/systemd
-------------------------------------------------------------------
Tue Sep 30 13:20:21 UTC 2014 - jengelh@inai.de

View File

@ -1,12 +0,0 @@
#!/bin/sh
if systemctl --quiet is-enabled atd; then
case $1/$2 in
pre/*)
systemctl stop atd
;;
post/*)
systemctl restart atd
;;
esac
fi

11
at.spec
View File

@ -27,7 +27,6 @@ Url: ftp://ftp.debian.org/debian/pool/main/a/at
Source: ftp://ftp.debian.org/debian/pool/main/a/at/%{name}_%{version}.orig.tar.gz
Source2: atd.pamd
Source3: sysconfig.atd
Source4: at.sleep
Source5: atd.service
Patch0: at-3.1.14.patch
@ -60,8 +59,10 @@ Patch23: at-secure_getenv.patch
Patch24: at-backport-old-privs.patch
#PATCH-FEATURE-UPSTREAM introduce -o <timeformat> argument for atq (bnc#879402)
Patch25: at-atq-timeformat.patch
Patch26: at-sane-envkeys.diff
#PATCH-FIX-UPSTREAM sanitize environment variables (bnc#899160)
Patch26: at-3.1.15-sane-envkeys.patch
#PATCH-FIX-OPENSUSE use posix timers to avoid the need of suspend/resume hacks.
Patch27: at-3.1.14-usePOSIXtimers.patch
BuildRequires: autoconf >= 2.69
BuildRequires: automake
BuildRequires: bison
@ -107,7 +108,7 @@ This program allows you to run jobs at specified times.
%patch24 -p1
%patch25
%patch26 -p1
%patch27 -p1
%build
rm -fv y.tab.c y.tab.h lex.yy.c lex.yy.o y.tab.o
autoreconf -fiv
@ -137,7 +138,6 @@ mkdir docs
mv %{buildroot}/%{_prefix}/doc/at/* docs/
%{__install} -D -m 0644 %{S:5} %{buildroot}%{_unitdir}/atd.service
%{__install} -D -m 0755 %{S:4} %{buildroot}%{_prefix}/lib/systemd/system-sleep/atd.sh
%{__ln_s} -f %{_sbindir}/service %{buildroot}%{_sbindir}/rcatd
%{__install} -m644 %SOURCE2 %{buildroot}%{_sysconfdir}/pam.d/atd
@ -180,6 +180,5 @@ mv %{buildroot}/%{_prefix}/doc/at/* docs/
%attr(600,at,at) %{_localstatedir}/spool/atjobs/.SEQ
%{_localstatedir}/adm/fillup-templates/sysconfig.atd
%{_unitdir}/atd.service
%{_prefix}/lib/systemd/system-sleep/atd.sh
%changelog