From e9e8ac2fedf3ea3ea5175c649e5f8c75beeaf9e5deecd9f6d5c706ac0d00bf55 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Thu, 22 Aug 2019 12:31:22 +0000 Subject: [PATCH 1/2] Add tcsh-6.21.00-sighup-deadlock.patch, port tcsh-6.18.03-history-file-locking.patch now tcsh-6.21.0-history-file-locking.patch OBS-URL: https://build.opensuse.org/package/show/shells/tcsh?expand=0&rev=80 --- ... => tcsh-6.21.0-history-file-locking.patch | 53 +++++++++---------- tcsh-6.21.00-sighup-deadlock.patch | 50 +++++++++++++++++ tcsh.changes | 8 +++ tcsh.spec | 5 +- 4 files changed, 87 insertions(+), 29 deletions(-) rename tcsh-6.18.03-history-file-locking.patch => tcsh-6.21.0-history-file-locking.patch (94%) create mode 100644 tcsh-6.21.00-sighup-deadlock.patch diff --git a/tcsh-6.18.03-history-file-locking.patch b/tcsh-6.21.0-history-file-locking.patch similarity index 94% rename from tcsh-6.18.03-history-file-locking.patch rename to tcsh-6.21.0-history-file-locking.patch index c57c247..110c75d 100644 --- a/tcsh-6.18.03-history-file-locking.patch +++ b/tcsh-6.21.0-history-file-locking.patch @@ -14,18 +14,18 @@ https://bugzilla.redhat.com/show_bug.cgi?id=879371 Changes by Fridolin Pokorny --- - sh.c | 102 ++++++++++++++++++++++++++++++++++++------------- - sh.decls.h | 4 + - sh.dol.c | 2 - sh.err.c | 16 +++++++ - sh.h | 18 ++++++++ - sh.hist.c | 126 +++++++++++++++++++++++++++++-------------------------------- - sh.lex.c | 8 +-- - sh.sem.c | 2 - 8 files changed, 178 insertions(+), 100 deletions(-) + sh.c | 102 +++++++++++++++++++++++++++++++++++++-------------- + sh.decls.h | 4 +- + sh.dol.c | 2 - + sh.err.c | 16 ++++++++ + sh.h | 18 +++++++++ + sh.hist.c | 122 ++++++++++++++++++++++++++++++------------------------------- + sh.lex.c | 8 ++-- + sh.sem.c | 2 - + 8 files changed, 178 insertions(+), 96 deletions(-) --- sh.c -+++ sh.c 2019-05-09 08:16:41.673852638 +0000 ++++ sh.c 2019-08-22 12:07:57.729632215 +0000 @@ -138,6 +138,7 @@ struct saved_state { int cantell; struct Bin B; @@ -245,7 +245,7 @@ Changes by Fridolin Pokorny /* --- sh.decls.h -+++ sh.decls.h 2019-05-09 08:16:41.673852638 +0000 ++++ sh.decls.h 2019-08-22 12:07:57.729632215 +0000 @@ -37,6 +37,7 @@ */ extern Char *gethdir (const Char *); @@ -272,7 +272,7 @@ Changes by Fridolin Pokorny extern void sethistory (int); --- sh.dol.c -+++ sh.dol.c 2019-05-09 08:16:41.673852638 +0000 ++++ sh.dol.c 2019-08-22 12:07:57.729632215 +0000 @@ -1117,6 +1117,6 @@ again: *obp = 0; tmp = short2str(obuf); @@ -282,7 +282,7 @@ Changes by Fridolin Pokorny cleanup_until(&inheredoc); } --- sh.err.c -+++ sh.err.c 2019-05-09 08:16:41.677852563 +0000 ++++ sh.err.c 2019-08-22 12:07:57.733632140 +0000 @@ -511,6 +511,22 @@ open_cleanup(void *xptr) } @@ -307,7 +307,7 @@ Changes by Fridolin Pokorny { DIR *dir; --- sh.h -+++ sh.h 2019-05-09 08:16:41.677852563 +0000 ++++ sh.h 2019-08-22 12:07:57.733632140 +0000 @@ -49,6 +49,24 @@ # include #endif @@ -334,7 +334,7 @@ Changes by Fridolin Pokorny typedef unsigned long intptr_t; #endif --- sh.hist.c -+++ sh.hist.c 2019-05-09 08:36:00.679789483 +0000 ++++ sh.hist.c 2019-08-22 12:24:42.518825681 +0000 @@ -32,6 +32,8 @@ #include "sh.h" #include /* for rename(2), grr. */ @@ -531,15 +531,15 @@ Changes by Fridolin Pokorny rechist(Char *fname, int ref) { - Char *snum, *rs; -- int fp, ftmp, oldidfds; +- int fp, ftmp, oldidfds, phup_disabled_tmp; + Char *snum; -+ int fd = -1, ftmp, oldidfds; ++ int fd = -1, ftmp, oldidfds, phup_disabled_tmp; struct varent *shist; - char path[MAXPATHLEN]; struct stat st; static Char *dumphist[] = {STRhistory, STRmhT, 0, 0}; -@@ -1290,50 +1283,49 @@ rechist(Char *fname, int ref) +@@ -1294,35 +1287,37 @@ rechist(Char *fname, int ref) cleanup_push(lockpath, dotlock_cleanup); #endif } @@ -561,6 +561,7 @@ Changes by Fridolin Pokorny - if (fp == -1) { - didfds = oldidfds; - cleanup_until(fname); +- phup_disabled = phup_disabled_tmp; - return; + if (fd <= 0) { + /* Open .history file for writing (if not open yet). */ @@ -593,13 +594,9 @@ Changes by Fridolin Pokorny + SHOUT = ftmp; + } didfds = oldidfds; --#ifndef WINNT_NATIVE -- (void)rename(path, short2str(fname)); --#else -- (void)ReplaceFile( short2str(fname),path,NULL,0,NULL,NULL); --#endif - cleanup_until(fname); - } + #ifndef WINNT_NATIVE + (void)rename(path, short2str(fname)); +@@ -1335,11 +1330,12 @@ rechist(Char *fname, int ref) /* This is the entry point for loading history data from a file. */ @@ -615,7 +612,7 @@ Changes by Fridolin Pokorny if (fname != NULL) loadhist_cmd[2] = fname; -@@ -1342,17 +1334,19 @@ loadhist(Char *fname, int mflg) +@@ -1348,17 +1344,19 @@ loadhist(Char *fname, int mflg) else loadhist_cmd[2] = STRtildothist; @@ -640,7 +637,7 @@ Changes by Fridolin Pokorny void --- sh.lex.c -+++ sh.lex.c 2019-05-09 08:16:41.677852563 +0000 ++++ sh.lex.c 2019-08-22 12:07:57.733632140 +0000 @@ -1608,7 +1608,7 @@ wide_read(int fildes, Char *buf, size_t /* Throwing away possible partial multibyte characters on error if the stream is not seekable */ @@ -678,7 +675,7 @@ Changes by Fridolin Pokorny fbuf = xcalloc(2, sizeof(Char **)); fblocks = 1; --- sh.sem.c -+++ sh.sem.c 2019-05-09 08:16:41.677852563 +0000 ++++ sh.sem.c 2019-08-22 12:07:57.733632140 +0000 @@ -905,7 +905,7 @@ doio(struct command *t, int *pipein, int fd = xopen(tmp, O_WRONLY|O_APPEND|O_LARGEFILE); #else /* !O_APPEND */ diff --git a/tcsh-6.21.00-sighup-deadlock.patch b/tcsh-6.21.00-sighup-deadlock.patch new file mode 100644 index 0000000..7a8110b --- /dev/null +++ b/tcsh-6.21.00-sighup-deadlock.patch @@ -0,0 +1,50 @@ +tcsh can deadlock with itself if savehist is confgured with "merge" and +"lock", and two SIGHUPs are received in rapid succession. The +mechanism of the deadlock is the first SIGHUP triggers a rechist() and +while that rechist() is executing (and after it has created the lock +file), another SIGHUP triggers a another rechist() which then waits +forever for the lock the the first rechist() created to be released +(which will never happen). + +--- + tcsh-6.21.00/sh.hist.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- tcsh-6.21.00/sh.hist.c ++++ tcsh-6.21.00/sh.hist.c 2019-08-22 12:05:25.800474245 +0000 +@@ -1219,7 +1219,7 @@ void + rechist(Char *fname, int ref) + { + Char *snum, *rs; +- int fp, ftmp, oldidfds; ++ int fp, ftmp, oldidfds, phup_disabled_tmp; + struct varent *shist; + char path[MAXPATHLEN]; + struct stat st; +@@ -1227,6 +1227,10 @@ rechist(Char *fname, int ref) + + if (fname == NULL && !ref) + return; ++ ++ phup_disabled_tmp = phup_disabled; ++ phup_disabled = 1; ++ + /* + * If $savehist is just set, we use the value of $history + * else we use the value in $savehist +@@ -1301,6 +1305,7 @@ rechist(Char *fname, int ref) + if (fp == -1) { + didfds = oldidfds; + cleanup_until(fname); ++ phup_disabled = phup_disabled_tmp; + return; + } + /* Try to preserve ownership and permissions of the original history file */ +@@ -1325,6 +1330,7 @@ rechist(Char *fname, int ref) + (void)ReplaceFile( short2str(fname),path,NULL,0,NULL,NULL); + #endif + cleanup_until(fname); ++ phup_disabled = phup_disabled_tmp; + } + + diff --git a/tcsh.changes b/tcsh.changes index 9b98039..38ec6e8 100644 --- a/tcsh.changes +++ b/tcsh.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Thu Aug 22 12:27:18 UTC 2019 - Dr. Werner Fink + +- Add patch tcsh-6.21.00-sighup-deadlock.patch from upstream list + * Do not (re)run SIGHUP handler during rewrite history + * Port and rename patch tcsh-6.18.03-history-file-locking.patch + which now becomes tcsh-6.21.0-history-file-locking.patch + ------------------------------------------------------------------- Thu May 9 08:50:56 UTC 2019 - Dr. Werner Fink diff --git a/tcsh.spec b/tcsh.spec index 2f31002..3bbdba0 100644 --- a/tcsh.spec +++ b/tcsh.spec @@ -32,8 +32,10 @@ Patch2: tcsh-6.16.00-norm-cmd.dif Patch4: tcsh-6.18.03-colorls.dif Patch5: tcsh-6.17.06-dspmbyte.dif Patch6: tcsh-6.18.03-catalogs.dif +# PATCH-FIX-UPSTREAM Do not (re)run SIGHUP handler during rewrite history +Patch7: tcsh-6.21.00-sighup-deadlock.patch # PATCH-FIX-SUSE add history file locking (bsc#901076) -Patch9: tcsh-6.18.03-history-file-locking.patch +Patch9: tcsh-6.21.0-history-file-locking.patch Patch10: tcsh-6.18.03-history-merge.dif # PATCH-FIX-SUSE fix history file locking: first unlock then close Patch11: tcsh-6.19.00-history-file-locking-order.patch @@ -64,6 +66,7 @@ correction, a history mechanism, job control, and a C-like syntax. %patch4 -b .colorls %patch5 -b .dspmbyte %patch6 -b .catalogs +%patch7 -p1 -b .sighup %patch9 -b .histlock %patch10 -b .histmerg %patch11 -b .histlckord From b895230f545b3784d80c8e6b36800ac99975f761ddd90ef0008a2b64aa2b5993 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Thu, 22 Aug 2019 13:04:42 +0000 Subject: [PATCH 2/2] . OBS-URL: https://build.opensuse.org/package/show/shells/tcsh?expand=0&rev=81 --- tcsh-6.20.00-avoid-dotlock-for-fcntl.patch | 4 +- tcsh-6.21.0-history-file-locking.patch | 49 ++++++++++++---------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/tcsh-6.20.00-avoid-dotlock-for-fcntl.patch b/tcsh-6.20.00-avoid-dotlock-for-fcntl.patch index 4cb1917..7367d41 100644 --- a/tcsh-6.20.00-avoid-dotlock-for-fcntl.patch +++ b/tcsh-6.20.00-avoid-dotlock-for-fcntl.patch @@ -4,7 +4,7 @@ --- sh.hist.c +++ sh.hist.c 2017-07-19 10:01:20.795354927 +0000 -@@ -1274,6 +1274,11 @@ rechist(Char *fname, int ref) +@@ -1278,6 +1278,11 @@ rechist(Char *fname, int ref) } if (merge) { @@ -16,7 +16,7 @@ if (lock) { #ifndef WINNT_NATIVE char *lockpath = strsave(short2str(fname)); -@@ -1283,6 +1288,7 @@ rechist(Char *fname, int ref) +@@ -1287,6 +1292,7 @@ rechist(Char *fname, int ref) cleanup_push(lockpath, dotlock_cleanup); #endif } diff --git a/tcsh-6.21.0-history-file-locking.patch b/tcsh-6.21.0-history-file-locking.patch index 110c75d..64a3cb8 100644 --- a/tcsh-6.21.0-history-file-locking.patch +++ b/tcsh-6.21.0-history-file-locking.patch @@ -14,18 +14,18 @@ https://bugzilla.redhat.com/show_bug.cgi?id=879371 Changes by Fridolin Pokorny --- - sh.c | 102 +++++++++++++++++++++++++++++++++++++-------------- - sh.decls.h | 4 +- - sh.dol.c | 2 - - sh.err.c | 16 ++++++++ - sh.h | 18 +++++++++ - sh.hist.c | 122 ++++++++++++++++++++++++++++++------------------------------- - sh.lex.c | 8 ++-- - sh.sem.c | 2 - - 8 files changed, 178 insertions(+), 96 deletions(-) + sh.c | 102 ++++++++++++++++++++++++++++++++++++------------ + sh.decls.h | 4 + + sh.dol.c | 2 + sh.err.c | 16 +++++++ + sh.h | 18 ++++++++ + sh.hist.c | 127 ++++++++++++++++++++++++++++--------------------------------- + sh.lex.c | 8 +-- + sh.sem.c | 2 + 8 files changed, 178 insertions(+), 101 deletions(-) --- sh.c -+++ sh.c 2019-08-22 12:07:57.729632215 +0000 ++++ sh.c 2019-08-22 13:02:31.780361102 +0000 @@ -138,6 +138,7 @@ struct saved_state { int cantell; struct Bin B; @@ -245,7 +245,7 @@ Changes by Fridolin Pokorny /* --- sh.decls.h -+++ sh.decls.h 2019-08-22 12:07:57.729632215 +0000 ++++ sh.decls.h 2019-08-22 13:02:31.780361102 +0000 @@ -37,6 +37,7 @@ */ extern Char *gethdir (const Char *); @@ -272,7 +272,7 @@ Changes by Fridolin Pokorny extern void sethistory (int); --- sh.dol.c -+++ sh.dol.c 2019-08-22 12:07:57.729632215 +0000 ++++ sh.dol.c 2019-08-22 13:02:31.780361102 +0000 @@ -1117,6 +1117,6 @@ again: *obp = 0; tmp = short2str(obuf); @@ -282,7 +282,7 @@ Changes by Fridolin Pokorny cleanup_until(&inheredoc); } --- sh.err.c -+++ sh.err.c 2019-08-22 12:07:57.733632140 +0000 ++++ sh.err.c 2019-08-22 13:02:31.780361102 +0000 @@ -511,6 +511,22 @@ open_cleanup(void *xptr) } @@ -307,7 +307,7 @@ Changes by Fridolin Pokorny { DIR *dir; --- sh.h -+++ sh.h 2019-08-22 12:07:57.733632140 +0000 ++++ sh.h 2019-08-22 13:02:31.784361027 +0000 @@ -49,6 +49,24 @@ # include #endif @@ -334,7 +334,7 @@ Changes by Fridolin Pokorny typedef unsigned long intptr_t; #endif --- sh.hist.c -+++ sh.hist.c 2019-08-22 12:24:42.518825681 +0000 ++++ sh.hist.c 2019-08-22 13:02:44.684119766 +0000 @@ -32,6 +32,8 @@ #include "sh.h" #include /* for rename(2), grr. */ @@ -539,7 +539,7 @@ Changes by Fridolin Pokorny struct stat st; static Char *dumphist[] = {STRhistory, STRmhT, 0, 0}; -@@ -1294,35 +1287,37 @@ rechist(Char *fname, int ref) +@@ -1294,52 +1287,50 @@ rechist(Char *fname, int ref) cleanup_push(lockpath, dotlock_cleanup); #endif } @@ -594,9 +594,14 @@ Changes by Fridolin Pokorny + SHOUT = ftmp; + } didfds = oldidfds; - #ifndef WINNT_NATIVE - (void)rename(path, short2str(fname)); -@@ -1335,11 +1330,12 @@ rechist(Char *fname, int ref) +-#ifndef WINNT_NATIVE +- (void)rename(path, short2str(fname)); +-#else +- (void)ReplaceFile( short2str(fname),path,NULL,0,NULL,NULL); +-#endif + cleanup_until(fname); + phup_disabled = phup_disabled_tmp; + } /* This is the entry point for loading history data from a file. */ @@ -612,7 +617,7 @@ Changes by Fridolin Pokorny if (fname != NULL) loadhist_cmd[2] = fname; -@@ -1348,17 +1344,19 @@ loadhist(Char *fname, int mflg) +@@ -1348,17 +1339,19 @@ loadhist(Char *fname, int mflg) else loadhist_cmd[2] = STRtildothist; @@ -637,7 +642,7 @@ Changes by Fridolin Pokorny void --- sh.lex.c -+++ sh.lex.c 2019-08-22 12:07:57.733632140 +0000 ++++ sh.lex.c 2019-08-22 13:02:31.784361027 +0000 @@ -1608,7 +1608,7 @@ wide_read(int fildes, Char *buf, size_t /* Throwing away possible partial multibyte characters on error if the stream is not seekable */ @@ -675,7 +680,7 @@ Changes by Fridolin Pokorny fbuf = xcalloc(2, sizeof(Char **)); fblocks = 1; --- sh.sem.c -+++ sh.sem.c 2019-08-22 12:07:57.733632140 +0000 ++++ sh.sem.c 2019-08-22 13:02:31.784361027 +0000 @@ -905,7 +905,7 @@ doio(struct command *t, int *pipein, int fd = xopen(tmp, O_WRONLY|O_APPEND|O_LARGEFILE); #else /* !O_APPEND */