kiss-repository

personal kiss repository
git clone git://git.ckyln.com/~cem/kiss-repository.git
Log | Files | Refs | Submodules | README | LICENSE

nvi-08-tempfile_umask.patch (917B)


      1 #! /bin/sh /usr/share/dpatch/dpatch-run
      2 ## 08tempfile_umask.dpatch by  <hesso@pool.math.tu-berlin.de>
      3 ##
      4 ## DP: No description.
      5 
      6 @DPATCH@
      7 diff -Naur nvi-1.81.6.orig/common/exf.c nvi-1.81.6/common/exf.c
      8 --- nvi-1.81.6.orig/common/exf.c	2008-05-01 18:10:45.000000000 +0200
      9 +++ nvi-1.81.6/common/exf.c	2008-05-01 18:13:23.000000000 +0200
     10 @@ -207,16 +207,21 @@
     11  	 */
     12  	oname = frp->name;
     13  	if (LF_ISSET(FS_OPENERR) || oname == NULL || !exists) {
     14 +		mode_t orig_umask;
     15  		if (opts_empty(sp, O_TMP_DIRECTORY, 0))
     16  			goto err;
     17 +		orig_umask = umask(0);
     18 +		umask(orig_umask & 0177);
     19  		(void)snprintf(tname, sizeof(tname),
     20  		    "%s/vi.XXXXXX", O_STR(sp, O_TMP_DIRECTORY));
     21  		if ((fd = mkstemp(tname)) == -1) {
     22 +			umask(orig_umask);
     23  			msgq(sp, M_SYSERR,
     24  			    "237|Unable to create temporary file");
     25  			goto err;
     26  		}
     27  		(void)close(fd);
     28 +		umask(orig_umask);
     29  
     30  		if (frp->name == NULL)
     31  			F_SET(frp, FR_TMPFILE);