Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37906232
en ru br
ALT Linux repos
S:6.20.00-alt4
5.0: 6.16.00-alt1
4.1: 6.16.00-alt0.M41.1
4.0: 6.14.00-alt2
3.0: 6.14.00-alt1

Group :: Shells
RPM: tcsh

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: tcsh-6.14.00-suse-owl-alt-shtmp.patch
Download


diff -Naur tcsh-6.12.00.orig/sh.c tcsh-6.12.00/sh.c
--- tcsh-6.14.00/sh.c.orig	2005-03-21 23:26:36 +0200
+++ tcsh-6.14.00/sh.c	2005-04-07 15:24:55 +0300
@@ -737,7 +737,10 @@
 	shtemp = Strspl(SAVE(strtmp2), doldol);	/* For << */
     }
 #else /* !WINNT_NATIVE */
-    shtemp = Strspl(STRtmpsh, doldol);	/* For << */
+    {
+    char *tmpdir = getenv ("TMPDIR") ?: "/tmp";
+    shtemp = Strspl(SAVE(tmpdir), SAVE("/sh.XXXXXX")); /* For << */
+    }
 #endif /* WINNT_NATIVE */
 
     /*
diff -Naur tcsh-6.12.00.orig/sh.dol.c tcsh-6.12.00/sh.dol.c
--- tcsh-6.14.00/sh.dol.c.orig	2004-12-25 23:15:06 +0200
+++ tcsh-6.14.00/sh.dol.c	2005-04-07 15:40:14 +0300
@@ -1023,45 +1023,27 @@
     eChar  c;
     Char   *Dv[2];
     Char    obuf[BUFSIZE + 1], lbuf[BUFSIZE], mbuf[BUFSIZE];
-    int     ocnt, lcnt, mcnt;
+    int     ocnt, lcnt, mcnt, fd;
     Char *lbp, *obp, *mbp;
     Char  **vp;
     int    quoted;
-    char   *tmp;
-#ifndef WINNT_NATIVE
-    struct timeval tv;
+    char   *tmp, *dot;
 
-again:
-#endif /* WINNT_NATIVE */
     tmp = short2str(shtemp);
-#ifndef O_CREAT
-# define O_CREAT 0
-    if (creat(tmp, 0600) < 0)
+    dot = strrchr(tmp, '.');
+    if (!dot)
+	stderror(ERR_NAME | ERR_NOMATCH);
+    strcpy(dot, ".XXXXXX");
+
+    if ((fd = mkstemp(tmp)) < 0)
 	stderror(ERR_SYSTEM, tmp, strerror(errno));
-#endif
-    (void) close(0);
-#ifndef O_TEMPORARY
-# define O_TEMPORARY 0
-#endif
-#ifndef O_EXCL
-# define O_EXCL 0
-#endif
-    if (open(tmp, O_RDWR|O_CREAT|O_EXCL|O_TEMPORARY|O_LARGEFILE, 0600) == -1) {
-	int oerrno = errno;
-#ifndef WINNT_NATIVE
-	if (errno == EEXIST) {
-	    if (unlink(tmp) == -1) {
-		(void) gettimeofday(&tv, NULL);
-		shtemp = Strspl(STRtmpsh, putn((((int)tv.tv_sec) ^ 
-		    ((int)tv.tv_usec) ^ ((int)getpid())) & 0x00ffffff));
-	    }
-	    goto again;
-	}
-#endif /* WINNT_NATIVE */
-	(void) unlink(tmp);
-	errno = oerrno;
- 	stderror(ERR_SYSTEM, tmp, strerror(errno));
+
+    if (fd != 0) {
+      if (dup2(fd, 0) < 0)
+	stderror(ERR_SYSTEM, "dup2", strerror(errno));
+      (void) close(fd);
     }
+
     (void) unlink(tmp);		/* 0 0 inode! */
     Dv[0] = term;
     Dv[1] = NULL;
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin