Compare commits
No commits in common. "c8" and "imports/c9/sed-4.8-9.el9" have entirely different histories.
c8
...
imports/c9
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1 @@
|
|||||||
SOURCES/sed-4.5.tar.xz
|
SOURCES/sed-4.8.tar.xz
|
||||||
|
@ -1 +1 @@
|
|||||||
6635c344956ef928cc33aca798ad20c6c1ea25f7 SOURCES/sed-4.5.tar.xz
|
61bd770062d49cdab3f0f45df473e2bf950ba266 SOURCES/sed-4.8.tar.xz
|
||||||
|
@ -1,281 +0,0 @@
|
|||||||
diff -urN sed-4.3/sed/execute.c sed-4.3.new00/sed/execute.c
|
|
||||||
--- sed-4.3/sed/execute.c 2012-03-16 10:13:31.000000000 +0100
|
|
||||||
+++ sed-4.3.new00/sed/execute.c 2014-02-10 14:40:25.603629422 +0100
|
|
||||||
@@ -703,11 +703,13 @@
|
|
||||||
if (strcmp(in_place_extension, "*") != 0)
|
|
||||||
{
|
|
||||||
char *backup_file_name = get_backup_file_name(target_name);
|
|
||||||
- ck_rename (target_name, backup_file_name, input->out_file_name);
|
|
||||||
+ (copy_instead_of_rename?ck_fccopy:ck_rename)
|
|
||||||
+ (target_name, backup_file_name, input->out_file_name);
|
|
||||||
free (backup_file_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
- ck_rename (input->out_file_name, target_name, input->out_file_name);
|
|
||||||
+ (copy_instead_of_rename?ck_fcmove:ck_rename)
|
|
||||||
+ (input->out_file_name, target_name, input->out_file_name);
|
|
||||||
cancel_cleanup ();
|
|
||||||
free (input->out_file_name);
|
|
||||||
}
|
|
||||||
diff -urN sed-4.3/sed/sed.c sed-4.3.new00/sed/sed.c
|
|
||||||
--- sed-4.3/sed/sed.c 2012-03-16 10:13:31.000000000 +0100
|
|
||||||
+++ sed-4.3.new00/sed/sed.c 2014-02-10 17:37:19.381273509 +0100
|
|
||||||
@@ -56,6 +56,10 @@
|
|
||||||
/* How do we edit files in-place? (we don't if NULL) */
|
|
||||||
char *in_place_extension = NULL;
|
|
||||||
|
|
||||||
+ /* Do we use copy or rename when in in-place edit mode? (boolean
|
|
||||||
+ value, non-zero for copy, zero for rename).*/
|
|
||||||
+ int copy_instead_of_rename = 0;
|
|
||||||
+
|
|
||||||
/* The mode to use to read/write files, either "r"/"w" or "rb"/"wb". */
|
|
||||||
char const *read_mode = "r";
|
|
||||||
char const *write_mode = "w";
|
|
||||||
@@ -117,11 +121,16 @@
|
|
||||||
fprintf(out, _(" -i[SUFFIX], --in-place[=SUFFIX]\n\
|
|
||||||
edit files in place (makes backup if SUFFIX supplied)\n"));
|
|
||||||
-#if defined WIN32 || defined _WIN32 || defined __CYGWIN__ \
|
|
||||||
- || defined MSDOS || defined __EMX__
|
|
||||||
- fprintf(out, _(" -b, --binary\n\
|
|
||||||
- open files in binary mode (CR+LFs are not" \
|
|
||||||
- " processed specially)\n"));
|
|
||||||
+ fprintf(out, _(" -c, --copy\n\
|
|
||||||
+ use copy instead of rename when shuffling files in -i mode\n"));
|
|
||||||
+ fprintf(out, _(" -b, --binary\n"
|
|
||||||
+#if ! ( defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(MSDOS) || defined(__EMX__) )
|
|
||||||
+" does nothing; for compatibility with WIN32/CYGWIN/MSDOS/EMX (\n"
|
|
||||||
+#endif
|
|
||||||
+" open files in binary mode (CR+LFs are not treated specially)"
|
|
||||||
+#if ! ( defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(MSDOS) || defined(__EMX__) )
|
|
||||||
+ ")"
|
|
||||||
#endif
|
|
||||||
+ "\n"));
|
|
||||||
fprintf(out, _(" -l N, --line-length=N\n\
|
|
||||||
specify the desired line-wrap length for the `l' command\n"));
|
|
||||||
fprintf(out, _(" --posix\n\
|
|
||||||
@@ -138,8 +149,10 @@
|
|
||||||
the output buffers more often\n"));
|
|
||||||
fprintf(out, _(" -z, --null-data\n\
|
|
||||||
separate lines by NUL characters\n"));
|
|
||||||
- fprintf(out, _(" --help display this help and exit\n"));
|
|
||||||
- fprintf(out, _(" --version output version information and exit\n"));
|
|
||||||
+ fprintf(out, _(" --help\n\
|
|
||||||
+ display this help and exit\n"));
|
|
||||||
+ fprintf(out, _(" --version\n\
|
|
||||||
+ output version information and exit\n"));
|
|
||||||
fprintf(out, _("\n\
|
|
||||||
If no -e, --expression, -f, or --file option is given, then the first\n\
|
|
||||||
non-option argument is taken as the sed script to interpret. All\n\
|
|
||||||
@@ -158,9 +171,9 @@
|
|
||||||
main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
#ifdef REG_PERL
|
|
||||||
-#define SHORTOPTS "bsnrzRuEe:f:l:i::V:"
|
|
||||||
+#define SHORTOPTS "bcsnrzRuEe:f:l:i::"
|
|
||||||
#else
|
|
||||||
-#define SHORTOPTS "bsnrzuEe:f:l:i::V:"
|
|
||||||
+#define SHORTOPTS "bcsnrzuEe:f:l:i::"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum { SANDBOX_OPTION = CHAR_MAX+1 };
|
|
||||||
@@ -172,6 +185,7 @@
|
|
||||||
{"expression", 1, NULL, 'e'},
|
|
||||||
{"file", 1, NULL, 'f'},
|
|
||||||
{"in-place", 2, NULL, 'i'},
|
|
||||||
+ {"copy", 0, NULL, 'c'},
|
|
||||||
{"line-length", 1, NULL, 'l'},
|
|
||||||
{"null-data", 0, NULL, 'z'},
|
|
||||||
{"zero-terminated", 0, NULL, 'z'},
|
|
||||||
@@ -246,6 +260,10 @@
|
|
||||||
follow_symlinks = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
+ case 'c':
|
|
||||||
+ copy_instead_of_rename = true;
|
|
||||||
+ break;
|
|
||||||
+
|
|
||||||
case 'i':
|
|
||||||
separate_files = true;
|
|
||||||
if (optarg == NULL)
|
|
||||||
@@ -272,9 +290,11 @@
|
|
||||||
posixicity = POSIXLY_BASIC;
|
|
||||||
break;
|
|
||||||
|
|
||||||
- case 'b':
|
|
||||||
+ case 'b':
|
|
||||||
+#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(MSDOS) || defined(__EMX__)
|
|
||||||
read_mode = "rb";
|
|
||||||
write_mode = "wb";
|
|
||||||
+#endif
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'E':
|
|
||||||
@@ -314,6 +334,12 @@
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ if (copy_instead_of_rename && in_place_extension == NULL)
|
|
||||||
+ {
|
|
||||||
+ fprintf (stderr, _("Error: -c used without -i.\n"));
|
|
||||||
+ usage(4);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if (!the_program)
|
|
||||||
{
|
|
||||||
if (optind < argc)
|
|
||||||
diff -urN sed-4.3/sed/sed.h sed-4.3.new00/sed/sed.h
|
|
||||||
--- sed-4.3/sed/sed.h 2012-07-25 12:33:09.000000000 +0200
|
|
||||||
+++ sed-4.3.new00/sed/sed.h 2014-02-10 14:40:25.602629419 +0100
|
|
||||||
@@ -230,6 +230,10 @@
|
|
||||||
/* How do we edit files in-place? (we don't if NULL) */
|
|
||||||
extern char *in_place_extension;
|
|
||||||
|
|
||||||
+/* Do we use copy or rename when in in-place edit mode? (boolean
|
|
||||||
+ value, non-zero for copy, zero for rename).*/
|
|
||||||
+extern int copy_instead_of_rename;
|
|
||||||
+
|
|
||||||
/* The mode to use to read and write files, either "rt"/"w" or "rb"/"wb". */
|
|
||||||
extern char const *read_mode;
|
|
||||||
extern char const *write_mode;
|
|
||||||
diff -urN sed-4.3/sed/utils.c sed-4.3.new00/sed/utils.c
|
|
||||||
--- sed-4.3/sed/utils.c 2012-03-16 10:13:31.000000000 +0100
|
|
||||||
+++ sed-4.3.new00/sed/utils.c 2014-02-10 14:40:25.603629422 +0100
|
|
||||||
@@ -27,6 +27,7 @@
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <limits.h>
|
|
||||||
+#include <fcntl.h>
|
|
||||||
|
|
||||||
#include "unlocked-io.h"
|
|
||||||
#include "utils.h"
|
|
||||||
@@ -363,31 +364,106 @@
|
|
||||||
#endif /* ENABLE_FOLLOW_SYMLINKS */
|
|
||||||
}
|
|
||||||
|
|
||||||
-/* Panic on failing rename */
|
|
||||||
+/* Panic on failing unlink */
|
|
||||||
void
|
|
||||||
-ck_rename (const char *from, const char *to, const char *unlink_if_fail)
|
|
||||||
+ck_unlink (const char *name)
|
|
||||||
{
|
|
||||||
- int rd = rename (from, to);
|
|
||||||
- if (rd != -1)
|
|
||||||
- return;
|
|
||||||
+ if (unlink (name) == -1)
|
|
||||||
+ panic (_("cannot remove %s: %s"), name, strerror (errno));
|
|
||||||
+}
|
|
||||||
|
|
||||||
- if (unlink_if_fail)
|
|
||||||
+/* Attempt to unlink denoted file if operation rd failed. */
|
|
||||||
+static int
|
|
||||||
+_unlink_if_fail (rd, unlink_if_fail)
|
|
||||||
+ int rd;
|
|
||||||
+ const char *unlink_if_fail;
|
|
||||||
+{
|
|
||||||
+ if (rd == -1 && unlink_if_fail)
|
|
||||||
{
|
|
||||||
int save_errno = errno;
|
|
||||||
+ ck_unlink (unlink_if_fail);
|
|
||||||
+ errno = save_errno;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return rd != -1;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* Copy contents between files. */
|
|
||||||
+static int
|
|
||||||
+_copy (from, to)
|
|
||||||
+ const char *from, *to;
|
|
||||||
+{
|
|
||||||
+ static char buf[4096];
|
|
||||||
+
|
|
||||||
+ FILE *infile, *outfile;
|
|
||||||
+ int c, retval = 0;
|
|
||||||
errno = 0;
|
|
||||||
- unlink (unlink_if_fail);
|
|
||||||
|
|
||||||
- /* Failure to remove the temporary file is more severe,
|
|
||||||
- so trigger it first. */
|
|
||||||
- if (errno != 0)
|
|
||||||
- panic (_("cannot remove %s: %s"), unlink_if_fail, strerror (errno));
|
|
||||||
+ infile = fopen (from, "r");
|
|
||||||
+ if (infile == NULL)
|
|
||||||
+ return -1;
|
|
||||||
|
|
||||||
- errno = save_errno;
|
|
||||||
+ outfile = fopen (to, "w");
|
|
||||||
+ if (outfile == NULL)
|
|
||||||
+ {
|
|
||||||
+ fclose (infile);
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ while (1)
|
|
||||||
+ {
|
|
||||||
+ size_t bytes_in = fread (buf, 1, sizeof (buf), infile);
|
|
||||||
+ size_t bytes_out;
|
|
||||||
+ if (bytes_in == 0)
|
|
||||||
+ {
|
|
||||||
+ if (ferror (infile))
|
|
||||||
+ retval = -1;
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ bytes_out = fwrite (buf, 1, bytes_in, outfile);
|
|
||||||
+ if (bytes_out != bytes_in)
|
|
||||||
+ {
|
|
||||||
+ retval = -1;
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
+ fclose (outfile);
|
|
||||||
+ fclose (infile);
|
|
||||||
+
|
|
||||||
+ return retval;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* Panic on failing rename */
|
|
||||||
+void
|
|
||||||
+ck_rename (from, to, unlink_if_fail)
|
|
||||||
+ const char *from, *to;
|
|
||||||
+ const char *unlink_if_fail;
|
|
||||||
+{
|
|
||||||
+ if (!_unlink_if_fail (rename (from, to), unlink_if_fail))
|
|
||||||
panic (_("cannot rename %s: %s"), from, strerror (errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
+/* Attempt to copy file contents between the files. */
|
|
||||||
+void
|
|
||||||
+ck_fccopy (from, to, unlink_if_fail)
|
|
||||||
+ const char *from, *to;
|
|
||||||
+ const char *unlink_if_fail;
|
|
||||||
+{
|
|
||||||
+ if (!_unlink_if_fail (_copy (from, to), unlink_if_fail))
|
|
||||||
+ panic (_("cannot copy %s to %s: %s"), from, to, strerror (errno));
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* Copy contents between files, and then unlink the source. */
|
|
||||||
+void
|
|
||||||
+ck_fcmove (from, to, unlink_if_fail)
|
|
||||||
+ const char *from, *to;
|
|
||||||
+ const char *unlink_if_fail;
|
|
||||||
+{
|
|
||||||
+ ck_fccopy (from, to, unlink_if_fail);
|
|
||||||
+ ck_unlink (from);
|
|
||||||
+}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
diff -urN sed-4.3/sed/utils.h sed-4.3.new00/sed/utils.h
|
|
||||||
--- sed-4.3/sed/utils.h 2012-03-16 10:13:31.000000000 +0100
|
|
||||||
+++ sed-4.3.new00/sed/utils.h 2014-02-10 14:40:25.603629422 +0100
|
|
||||||
@@ -33,6 +33,8 @@
|
|
||||||
FILE * ck_mkstemp (char **p_filename, const char *tmpdir, const char *base,
|
|
||||||
const char *mode) _GL_ARG_NONNULL ((1, 2, 3, 4));
|
|
||||||
void ck_rename (const char *from, const char *to, const char *unlink_if_fail);
|
|
||||||
+void ck_fccopy (const char *from, const char *to, const char *unlink_if_fail);
|
|
||||||
+void ck_fcmove (const char *from, const char *to, const char *unlink_if_fail);
|
|
||||||
|
|
||||||
void *ck_malloc (size_t size);
|
|
||||||
void *xmalloc (size_t size);
|
|
29
SOURCES/sed-b-flag.patch
Normal file
29
SOURCES/sed-b-flag.patch
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
From 613057152c4f6caba22a15ed2ff0aeb9c4ce6a83 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jakub Martisko <jamartis@redhat.com>
|
||||||
|
Date: Wed, 5 Feb 2020 15:50:15 +0100
|
||||||
|
Subject: [PATCH] enable the -b option on all platforms
|
||||||
|
|
||||||
|
---
|
||||||
|
sed/sed.c | 5 +++++
|
||||||
|
1 file changed, 5 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/sed/sed.c b/sed/sed.c
|
||||||
|
index f75e4b6..1ca5839 100644
|
||||||
|
--- a/sed/sed.c
|
||||||
|
+++ b/sed/sed.c
|
||||||
|
@@ -174,7 +174,12 @@ Usage: %s [OPTION]... {script-only-if-no-other-script} [input-file]...\n\
|
||||||
|
fprintf (out, _(" -b, --binary\n\
|
||||||
|
open files in binary mode (CR+LFs are not" \
|
||||||
|
" processed specially)\n"));
|
||||||
|
+#else
|
||||||
|
+ fprintf (out, _(" -b, --binary\n\
|
||||||
|
+ does nothing; for compatibility with WIN32/CYGWIN/MSDOS/EMX \n\
|
||||||
|
+ (open files in binary mode; CR+LF are not processed specially)\n" ));
|
||||||
|
#endif
|
||||||
|
+
|
||||||
|
fprintf (out, _(" -l N, --line-length=N\n\
|
||||||
|
specify the desired line-wrap length for the `l' command\n"));
|
||||||
|
fprintf (out, _(" --posix\n\
|
||||||
|
--
|
||||||
|
2.24.1
|
||||||
|
|
247
SOURCES/sed-c-flag.patch
Normal file
247
SOURCES/sed-c-flag.patch
Normal file
@ -0,0 +1,247 @@
|
|||||||
|
From f336bde91e3fd9c3c2960aa548b8917eb1216678 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jakub Martisko <jamartis@redhat.com>
|
||||||
|
Date: Thu, 6 Feb 2020 15:26:33 +0100
|
||||||
|
Subject: [PATCH] -c flag
|
||||||
|
|
||||||
|
---
|
||||||
|
sed/execute.c | 18 +++++++++--
|
||||||
|
sed/sed.c | 20 +++++++++++-
|
||||||
|
sed/sed.h | 4 +++
|
||||||
|
sed/utils.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
sed/utils.h | 2 ++
|
||||||
|
5 files changed, 127 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/sed/execute.c b/sed/execute.c
|
||||||
|
index c5f07cc..4e5f5b3 100644
|
||||||
|
--- a/sed/execute.c
|
||||||
|
+++ b/sed/execute.c
|
||||||
|
@@ -670,11 +670,25 @@ closedown (struct input *input)
|
||||||
|
if (strcmp (in_place_extension, "*") != 0)
|
||||||
|
{
|
||||||
|
char *backup_file_name = get_backup_file_name (target_name);
|
||||||
|
- ck_rename (target_name, backup_file_name, input->out_file_name);
|
||||||
|
+ if (copy_instead_of_rename)
|
||||||
|
+ {
|
||||||
|
+ ck_fccopy (target_name, backup_file_name, input->out_file_name);
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ ck_rename (target_name, backup_file_name, input->out_file_name);
|
||||||
|
+ }
|
||||||
|
free (backup_file_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
- ck_rename (input->out_file_name, target_name, input->out_file_name);
|
||||||
|
+ if (copy_instead_of_rename)
|
||||||
|
+ {
|
||||||
|
+ ck_fcmove (input->out_file_name, target_name, input->out_file_name);
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ ck_rename (input->out_file_name, target_name, input->out_file_name);
|
||||||
|
+ }
|
||||||
|
cancel_cleanup ();
|
||||||
|
free (input->out_file_name);
|
||||||
|
}
|
||||||
|
diff --git a/sed/sed.c b/sed/sed.c
|
||||||
|
index 1ca5839..745159e 100644
|
||||||
|
--- a/sed/sed.c
|
||||||
|
+++ b/sed/sed.c
|
||||||
|
@@ -67,6 +67,10 @@ bool debug = false;
|
||||||
|
/* How do we edit files in-place? (we don't if NULL) */
|
||||||
|
char *in_place_extension = NULL;
|
||||||
|
|
||||||
|
+/* Do we use copy or rename when in in-place edit mode? (boolean
|
||||||
|
+ + value, non-zero for copy, zero for rename).*/
|
||||||
|
+int copy_instead_of_rename = 0;
|
||||||
|
+
|
||||||
|
/* The mode to use to read/write files, either "r"/"w" or "rb"/"wb". */
|
||||||
|
char const *read_mode = "r";
|
||||||
|
char const *write_mode = "w";
|
||||||
|
@@ -170,6 +174,10 @@ Usage: %s [OPTION]... {script-only-if-no-other-script} [input-file]...\n\
|
||||||
|
#endif
|
||||||
|
fprintf (out, _(" -i[SUFFIX], --in-place[=SUFFIX]\n\
|
||||||
|
edit files in place (makes backup if SUFFIX supplied)\n"));
|
||||||
|
+
|
||||||
|
+ fprintf(out, _(" -c, --copy\n\
|
||||||
|
+ use copy instead of rename when shuffling files in -i mode\n"));
|
||||||
|
+
|
||||||
|
#if O_BINARY
|
||||||
|
fprintf (out, _(" -b, --binary\n\
|
||||||
|
open files in binary mode (CR+LFs are not" \
|
||||||
|
@@ -214,7 +222,7 @@ specified, then the standard input is read.\n\
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
-#define SHORTOPTS "bsnrzuEe:f:l:i::V:"
|
||||||
|
+#define SHORTOPTS "bcsnrzuEe:f:l:i::V:"
|
||||||
|
|
||||||
|
enum { SANDBOX_OPTION = CHAR_MAX+1,
|
||||||
|
DEBUG_OPTION
|
||||||
|
@@ -228,6 +236,7 @@ main (int argc, char **argv)
|
||||||
|
{"file", 1, NULL, 'f'},
|
||||||
|
{"in-place", 2, NULL, 'i'},
|
||||||
|
{"line-length", 1, NULL, 'l'},
|
||||||
|
+ {"copy", 0, NULL, 'c'},
|
||||||
|
{"null-data", 0, NULL, 'z'},
|
||||||
|
{"zero-terminated", 0, NULL, 'z'},
|
||||||
|
{"quiet", 0, NULL, 'n'},
|
||||||
|
@@ -306,6 +315,10 @@ main (int argc, char **argv)
|
||||||
|
follow_symlinks = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
+ case 'c':
|
||||||
|
+ copy_instead_of_rename = true;
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
case 'i':
|
||||||
|
separate_files = true;
|
||||||
|
IF_LINT (free (in_place_extension));
|
||||||
|
@@ -376,6 +389,11 @@ main (int argc, char **argv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (copy_instead_of_rename && in_place_extension == NULL)
|
||||||
|
+ {
|
||||||
|
+ fprintf (stderr, _("Error: -c used without -i.\n"));
|
||||||
|
+ usage(4);
|
||||||
|
+ }
|
||||||
|
if (!the_program)
|
||||||
|
{
|
||||||
|
if (optind < argc)
|
||||||
|
diff --git a/sed/sed.h b/sed/sed.h
|
||||||
|
index 1c8e83a..0859e72 100644
|
||||||
|
--- a/sed/sed.h
|
||||||
|
+++ b/sed/sed.h
|
||||||
|
@@ -236,6 +236,10 @@ extern countT lcmd_out_line_len;
|
||||||
|
/* How do we edit files in-place? (we don't if NULL) */
|
||||||
|
extern char *in_place_extension;
|
||||||
|
|
||||||
|
+/* Do we use copy or rename when in in-place edit mode? (boolean
|
||||||
|
+ value, non-zero for copy, zero for rename).*/
|
||||||
|
+extern int copy_instead_of_rename;
|
||||||
|
+
|
||||||
|
/* The mode to use to read and write files, either "rt"/"w" or "rb"/"wb". */
|
||||||
|
extern char const *read_mode;
|
||||||
|
extern char const *write_mode;
|
||||||
|
diff --git a/sed/utils.c b/sed/utils.c
|
||||||
|
index 9576dd1..371d5a9 100644
|
||||||
|
--- a/sed/utils.c
|
||||||
|
+++ b/sed/utils.c
|
||||||
|
@@ -25,6 +25,7 @@
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <limits.h>
|
||||||
|
+#include <fcntl.h>
|
||||||
|
|
||||||
|
#include "binary-io.h"
|
||||||
|
#include "unlocked-io.h"
|
||||||
|
@@ -400,7 +401,92 @@ ck_rename (const char *from, const char *to, const char *unlink_if_fail)
|
||||||
|
panic (_("cannot rename %s: %s"), from, strerror (errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* Downstream -c related functions */
|
||||||
|
|
||||||
|
+/* Panic on failing unlink */
|
||||||
|
+void
|
||||||
|
+ck_unlink (const char *name)
|
||||||
|
+{
|
||||||
|
+ if (unlink (name) == -1)
|
||||||
|
+ panic (_("cannot remove %s: %s"), name, strerror (errno));
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/* Attempt to unlink denoted file if operation rd failed. */
|
||||||
|
+static int
|
||||||
|
+_unlink_if_fail (int rd,const char * unlink_if_fail)
|
||||||
|
+{
|
||||||
|
+ if (rd == -1 && unlink_if_fail)
|
||||||
|
+ {
|
||||||
|
+ int save_errno = errno;
|
||||||
|
+ ck_unlink (unlink_if_fail);
|
||||||
|
+ errno = save_errno;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return rd != -1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/* Copy contents between files. */
|
||||||
|
+static int
|
||||||
|
+_copy (from, to)
|
||||||
|
+ const char *from, *to;
|
||||||
|
+{
|
||||||
|
+ static char buf[4096];
|
||||||
|
+
|
||||||
|
+ FILE *infile, *outfile;
|
||||||
|
+ int c, retval = 0;
|
||||||
|
+ errno = 0;
|
||||||
|
+
|
||||||
|
+ infile = fopen (from, "r");
|
||||||
|
+ if (infile == NULL)
|
||||||
|
+ return -1;
|
||||||
|
+
|
||||||
|
+ outfile = fopen (to, "w");
|
||||||
|
+ if (outfile == NULL)
|
||||||
|
+ {
|
||||||
|
+ fclose (infile);
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ while (1)
|
||||||
|
+ {
|
||||||
|
+ size_t bytes_in = fread (buf, 1, sizeof (buf), infile);
|
||||||
|
+ size_t bytes_out;
|
||||||
|
+ if (bytes_in == 0)
|
||||||
|
+ {
|
||||||
|
+ if (ferror (infile))
|
||||||
|
+ retval = -1;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ bytes_out = fwrite (buf, 1, bytes_in, outfile);
|
||||||
|
+ if (bytes_out != bytes_in)
|
||||||
|
+ {
|
||||||
|
+ retval = -1;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ fclose (outfile);
|
||||||
|
+ fclose (infile);
|
||||||
|
+
|
||||||
|
+ return retval;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/* Attempt to copy file contents between the files. */
|
||||||
|
+void
|
||||||
|
+ck_fccopy (const char *from,const char *to, const char *unlink_if_fail)
|
||||||
|
+{
|
||||||
|
+ if (!_unlink_if_fail (_copy (from, to), unlink_if_fail))
|
||||||
|
+ panic (_("cannot copy %s to %s: %s"), from, to, strerror (errno));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+/* Copy contents between files, and then unlink the source. */
|
||||||
|
+void
|
||||||
|
+ck_fcmove (const char *from, const char *to,const char *unlink_if_fail)
|
||||||
|
+{
|
||||||
|
+ ck_fccopy (from, to, unlink_if_fail);
|
||||||
|
+ ck_unlink (from);
|
||||||
|
+}
|
||||||
|
|
||||||
|
|
||||||
|
/* Implement a variable sized buffer of `stuff'. We don't know what it is,
|
||||||
|
diff --git a/sed/utils.h b/sed/utils.h
|
||||||
|
index 47a029e..0aba107 100644
|
||||||
|
--- a/sed/utils.h
|
||||||
|
+++ b/sed/utils.h
|
||||||
|
@@ -40,6 +40,8 @@ size_t ck_getdelim (char **text, size_t *buflen, char buffer_delimiter,
|
||||||
|
FILE * ck_mkstemp (char **p_filename, const char *tmpdir, const char *base,
|
||||||
|
const char *mode) _GL_ARG_NONNULL ((1, 2, 3, 4));
|
||||||
|
void ck_rename (const char *from, const char *to, const char *unlink_if_fail);
|
||||||
|
+void ck_fccopy (const char *from, const char *to, const char *unlink_if_fail);
|
||||||
|
+void ck_fcmove (const char *from, const char *to, const char *unlink_if_fail);
|
||||||
|
|
||||||
|
void *ck_malloc (size_t size);
|
||||||
|
void *ck_realloc (void *ptr, size_t size);
|
||||||
|
--
|
||||||
|
2.24.1
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
diff --git a/sed/utils.c b/sed/utils.c
|
|
||||||
index 4028d98..2e74654 100644
|
|
||||||
--- a/sed/utils.c
|
|
||||||
+++ b/sed/utils.c
|
|
||||||
@@ -181,7 +181,7 @@ ck_mkstemp (char **p_filename, const char *tmpdir,
|
|
||||||
/* The ownership might change, so omit some permissions at first
|
|
||||||
so unauthorized users cannot nip in before the file is ready.
|
|
||||||
mkstemp forces O_BINARY on cygwin, so use mkostemp instead. */
|
|
||||||
- mode_t save_umask = umask (0700);
|
|
||||||
+ mode_t save_umask = umask (0077);
|
|
||||||
int fd = mkostemp (template, 0);
|
|
||||||
umask (save_umask);
|
|
||||||
if (fd == -1)
|
|
@ -1,12 +0,0 @@
|
|||||||
--- a/sed-4.5/testsuite/inplace-selinux.sh 2018-03-31 06:33:01.000000000 +0200
|
|
||||||
+++ b/sed-4.5/testsuite/inplace-selinux.sh 2021-10-05 17:10:32.259956822 +0200
|
|
||||||
@@ -24,6 +24,9 @@
|
|
||||||
chcon -u system_u a || skip_ "chcon doesn't work"
|
|
||||||
chcon -u user_u a || skip_ "chcon doesn't work"
|
|
||||||
|
|
||||||
+cp --preserve=context ./a ./b 2>&1 | grep "cannot preserve security context" >/dev/null && skip_ "cannot preserve security context without an SELinux-enabled kernel"
|
|
||||||
+
|
|
||||||
+
|
|
||||||
# Create the first file and symlink pointing at it.
|
|
||||||
echo "Hello World" > inplace-selinux-file || framework_failure_
|
|
||||||
ln -s ./inplace-selinux-file inplace-selinux-link || framework_failure_
|
|
105
SPECS/sed.spec
105
SPECS/sed.spec
@ -2,20 +2,18 @@
|
|||||||
|
|
||||||
Summary: A GNU stream text editor
|
Summary: A GNU stream text editor
|
||||||
Name: sed
|
Name: sed
|
||||||
Version: 4.5
|
Version: 4.8
|
||||||
Release: 5%{?dist}
|
Release: 9%{?dist}
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
Group: Applications/Text
|
|
||||||
URL: http://sed.sourceforge.net/
|
URL: http://sed.sourceforge.net/
|
||||||
Source0: ftp://ftp.gnu.org/pub/gnu/sed/sed-%{version}.tar.xz
|
Source0: ftp://ftp.gnu.org/pub/gnu/sed/sed-%{version}.tar.xz
|
||||||
Source1: http://sed.sourceforge.net/sedfaq.txt
|
Source1: http://sed.sourceforge.net/sedfaq.txt
|
||||||
Patch0: sed-4.2.2-binary_copy_args.patch
|
Patch0: sed-b-flag.patch
|
||||||
Patch2: sed-fuse.patch
|
Patch1: sed-c-flag.patch
|
||||||
Patch3: sed-selinux-testsuite.patch
|
BuildRequires: make
|
||||||
BuildRequires: glibc-devel, libselinux-devel, libacl-devel, automake, autoconf
|
BuildRequires: glibc-devel, libselinux-devel, libacl-devel, automake, autoconf, gcc
|
||||||
BuildRequires: perl-Getopt-Long
|
BuildRequires: perl-Getopt-Long
|
||||||
Requires(post): /sbin/install-info
|
BuildRequires: perl(FileHandle)
|
||||||
Requires(preun): /sbin/install-info
|
|
||||||
|
|
||||||
Provides: /bin/sed
|
Provides: /bin/sed
|
||||||
|
|
||||||
@ -31,13 +29,16 @@ specified in a script file or from the command line.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
%patch0 -p1 -b .copy
|
%patch0 -p1
|
||||||
%patch2 -p1
|
%patch1 -p1
|
||||||
%patch3 -p2
|
|
||||||
|
|
||||||
|
sed -e 's/1729576/EPERM/' \
|
||||||
|
-i gnulib-tests/test-{strerror_r,perror2}.c
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%configure --without-included-regex
|
%configure --without-included-regex
|
||||||
make %{_smp_mflags}
|
%make_build
|
||||||
install -m 644 -p %{SOURCE1} sedfaq.txt
|
install -m 644 -p %{SOURCE1} sedfaq.txt
|
||||||
gzip -9 sedfaq.txt
|
gzip -9 sedfaq.txt
|
||||||
|
|
||||||
@ -48,50 +49,72 @@ echo ====================TESTING END=====================
|
|||||||
|
|
||||||
%install
|
%install
|
||||||
rm -rf ${RPM_BUILD_ROOT}
|
rm -rf ${RPM_BUILD_ROOT}
|
||||||
make DESTDIR=$RPM_BUILD_ROOT install
|
%make_install
|
||||||
rm -f ${RPM_BUILD_ROOT}/%{_infodir}/dir
|
rm -f ${RPM_BUILD_ROOT}/%{_infodir}/dir
|
||||||
|
|
||||||
%find_lang %{name}
|
%find_lang %{name}
|
||||||
|
|
||||||
%post
|
|
||||||
/sbin/install-info %{_infodir}/sed.info.gz %{_infodir}/dir || &> /dev/null
|
|
||||||
:
|
|
||||||
|
|
||||||
%preun
|
|
||||||
if [ $1 = 0 ]; then
|
|
||||||
/sbin/install-info --delete %{_infodir}/sed.info.gz %{_infodir}/dir || &> /dev/null
|
|
||||||
fi
|
|
||||||
:
|
|
||||||
|
|
||||||
%files -f %{name}.lang
|
%files -f %{name}.lang
|
||||||
%defattr(-,root,root)
|
|
||||||
%{!?_licensedir:%global license %%doc}
|
%{!?_licensedir:%global license %%doc}
|
||||||
%license COPYING
|
%license COPYING
|
||||||
%doc BUGS NEWS THANKS README AUTHORS sedfaq.txt.gz
|
%doc BUGS NEWS THANKS README AUTHORS sedfaq.txt.gz
|
||||||
%{_bindir}/sed
|
%{_bindir}/sed
|
||||||
%{_infodir}/*.info*
|
%{_infodir}/sed.info*
|
||||||
%{_mandir}/man*/*
|
%{_mandir}/man1/sed.1*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Tue Oct 05 2021 Jakub Martisko <jamartis@redhat.com> - 4.5-5
|
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 4.8-9
|
||||||
- Minor cleanup - remove unused patch from the spec file too (related to 4.5-3)
|
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
|
||||||
- Resolves: rhbz#1869253
|
Related: rhbz#1991688
|
||||||
|
|
||||||
* Tue Oct 05 2021 Jakub Martisko <jamartis@redhat.com> - 4.5-4
|
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 4.8-8
|
||||||
- Skip selinux test when selinux is not working
|
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
|
||||||
- Resolves: rhbz#1905777
|
|
||||||
|
|
||||||
* Tue Oct 05 2021 Jakub Martisko <jamartis@redhat.com> - 4.5-3
|
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 4.8-7
|
||||||
- Minor cleanup - remove unused patch from the git
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||||
- Resolves: rhbz#1869253
|
|
||||||
|
|
||||||
* Mon May 18 2020 Jakub Martisko <jamartis@redhat.com> - 4.5-2
|
* Mon Aug 17 2020 Jakub Martisko <jamartis@redhat.com> - 4.8-6
|
||||||
- fix "in-place edits on FUSE filesystems create files with all-zero mode bits"
|
- Minor spec cleanup
|
||||||
- Resolves: #1835761
|
|
||||||
|
|
||||||
* Mon Apr 09 2018 Jakub Martisko <jamartis@redhat.com> - 4.5-1
|
* Mon Aug 03 2020 Jakub Martisko <jamartis@redhat.com> - 4.8-5
|
||||||
|
- Use make macros
|
||||||
|
|
||||||
|
* Mon Aug 03 2020 Jakub Martisko <jamartis@redhat.com> - 4.8-4
|
||||||
|
- Replace some hardcoded constants in the gnulib-testsuite
|
||||||
|
... that caused build failures on arm7
|
||||||
|
|
||||||
|
* Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.8-3
|
||||||
|
- Second attempt - Rebuilt for
|
||||||
|
https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
|
||||||
|
|
||||||
|
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.8-2
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
|
||||||
|
|
||||||
|
* Tue Feb 11 2020 Jakub Martisko <jamartis@redhat.com> - 4.8-1
|
||||||
|
- Rebase to 4.8
|
||||||
|
- Refresh the downstream patch and split it into two
|
||||||
|
|
||||||
|
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.5-5
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||||
|
|
||||||
|
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.5-4
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||||
|
|
||||||
|
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.5-3
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
|
||||||
|
|
||||||
|
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.5-2
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||||
|
|
||||||
|
* Tue Apr 03 2018 Jakub Martisko <jamartis@redhat.com> - 4.5-1
|
||||||
- Rebase to 4.5
|
- Rebase to 4.5
|
||||||
- Drop patch from 4.4-4 (is included in the upstream archive)
|
- Drop patches from 4.4-4 and 4.4-7
|
||||||
|
|
||||||
|
* Thu Mar 08 2018 Jakub Martisko <jamartis@redhat.com> - 4.4-7
|
||||||
|
- Fix build failure with glibc-2.28
|
||||||
|
|
||||||
|
* Thu Mar 08 2018 Jakub Martisko <jamartis@redhat.com> - 4.4-6
|
||||||
|
- Add gcc to BuildRequires
|
||||||
|
|
||||||
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.4-5
|
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.4-5
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
|
||||||
|
Loading…
Reference in New Issue
Block a user