1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-24 11:45:18 +03:00
aports/community/at/0004-shell-add-preceding-newline-to-delimiter.patch
2022-07-05 16:49:06 +02:00

68 lines
1.9 KiB
Diff

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);