diff options
Diffstat (limited to 'community/at/0004-shell-add-preceding-newline-to-delimiter.patch')
-rw-r--r-- | community/at/0004-shell-add-preceding-newline-to-delimiter.patch | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/community/at/0004-shell-add-preceding-newline-to-delimiter.patch b/community/at/0004-shell-add-preceding-newline-to-delimiter.patch new file mode 100644 index 00000000000..30620f7a16d --- /dev/null +++ b/community/at/0004-shell-add-preceding-newline-to-delimiter.patch @@ -0,0 +1,68 @@ +Patch-Source: https://src.fedoraproject.org/rpms/at/blob/f36/f/at-3.2.2-shell.patch +-- +From d72ffaead4a4410fe7b91570d290baac991a69eb Mon Sep 17 00:00:00 2001 +From: Jan Staněk <jstanek@redhat.com> +Date: Mar 31 2022 10:13:56 +0000 +Subject: 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 + +diff -ur b/at.c a/at.c +--- b/at.c ++++ a/at.c +@@ -62,11 +62,8 @@ + #include <stdlib.h> + #include <string.h> + +-#ifdef TM_IN_SYS_TIME + #include <sys/time.h> +-#else + #include <time.h> +-#endif + + #ifdef HAVE_UNISTD_H + #include <unistd.h> +@@ -245,6 +242,12 @@ + int kill_errno; + int rc; + int mailsize = 128; ++ struct timeval tv; ++ struct timezone tz; ++ long int i; ++ ++ 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); ++ + istty = isatty(fileno(stdin)); + if (istty) { + runtime = localtime(&runtimer); +@@ -512,7 +518,7 @@ + if (istty) { + fprintf(stderr, "<EOT>\n"); + } +- fprintf(fp, "\n"); ++ fprintf(fp, "\nmarcinDELIMITER%08lx\n", i); + if (ferror(fp)) + panic("Output error"); + fflush(fp); |