From d72ffaead4a4410fe7b91570d290baac991a69eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Thu, 31 Mar 2022 12:13:56 +0200 Subject: [PATCH] shell: add preceding newline to delimiter at uses heredoc redirection to pass the script being executed into user's defined $SHELL. However, the heredoc delimiter is directly concatenated to the script's contents; if these contents do not end with a newline, the delimiter is attached to the last line of the script. This patch adds a single newline to be always emmited before the delimiter. This guarantees the delimiter is always on it's own line. In case a newline is already present at the end of the original script, this simply adds a single empty line; I cannot think of any complication that could result from that. Resolves: rhbz#2070450 --- at-3.2.2-shell.patch | 10 +++++----- at.spec | 7 +++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/at-3.2.2-shell.patch b/at-3.2.2-shell.patch index 16c55f8..9e383b8 100644 --- a/at-3.2.2-shell.patch +++ b/at-3.2.2-shell.patch @@ -4,13 +4,13 @@ diff -ur b/at.c a/at.c @@ -62,11 +62,8 @@ #include #include - + -#ifdef TM_IN_SYS_TIME #include -#else #include -#endif - + #ifdef HAVE_UNISTD_H #include @@ -245,6 +242,12 @@ @@ -23,13 +23,13 @@ diff -ur b/at.c a/at.c + + gettimeofday(&tv, &tz); + srandom(getpid()+tv.tv_usec); - + /* Install the signal handler for SIGINT; terminate after removing the * spool file if necessary @@ -492,6 +495,9 @@ fprintf(fp, " || {\n\t echo 'Execution directory " "inaccessible' >&2\n\t exit 1\n}\n"); - + + i = random(); + fprintf(fp, "${SHELL:-/bin/sh} << \'marcinDELIMITER%08lx\'\n", i); + @@ -41,7 +41,7 @@ diff -ur b/at.c a/at.c fprintf(stderr, "\n"); } - fprintf(fp, "\n"); -+ fprintf(fp, "marcinDELIMITER%08lx\n", i); ++ fprintf(fp, "\nmarcinDELIMITER%08lx\n", i); if (ferror(fp)) panic("Output error"); fflush(fp); diff --git a/at.spec b/at.spec index c2b4bd4..fe37818 100644 --- a/at.spec +++ b/at.spec @@ -3,7 +3,7 @@ Summary: Job spooling tools Name: at Version: 3.2.5 -Release: 2%{?dist} +Release: 3%{?dist} # http://packages.debian.org/changelogs/pool/main/a/at/current/copyright # + install-sh is MIT license with changes under Public Domain License: GPLv3+ and GPLv2+ and ISC and MIT and Public Domain @@ -164,9 +164,12 @@ chown root:root %{_localstatedir}/spool/at/.SEQ %attr(0644,root,root) /%{_unitdir}/atd.service %changelog +* Thu Mar 31 2022 Jan Staněk - 3.2.5-3 +- Add preceding newline to delimiter in at-3.2.2-shell.patch + * Tue Mar 08 2022 Ondřej Pohořelský - 3.2.5-2 - Add mising directory and batch-job script into at-3.2.5-make.patch -- Defined datadir in %%install section and listed batch-job in %%files section +- Defined datadir in %%install section and listed batch-job in %%files section * Tue Mar 01 2022 Ondřej Pohořelský - 3.2.5-1 - Update to new upstream release