Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: check deleted .zwc files



Bart Schaefer wrote:

> On Jun 13, 10:59am, Sven Wischnowsky wrote:
> }
> } For 3. (zwc rewritten in place): I don't see a solution either, but was
> } thinking about implementing what you suggested (unlinking the file and
> } chmod()ing it). Should we just do that?
> 
> I'd say so, if there are no better ideas.

Nobody spoke up, so here is the patch that makes zcompile unlink() the
zwc file first and makes it use mode 0444 when creating these files.
Should it use 0400, so that system administrators have to chmod it by
hand?

That hunk in zwcstat() avoids a `unused variable' variable warning if
HAVE_FSTAT is not defined.


Bye
  Sven

Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.22
diff -u -r1.22 parse.c
--- Src/parse.c	2001/06/09 18:06:32	1.22
+++ Src/parse.c	2001/06/18 07:29:58
@@ -2544,7 +2544,8 @@
     if (!strsfx(FD_EXT, dump))
 	dump = dyncat(dump, FD_EXT);
 
-    if ((dfd = open(dump, O_WRONLY|O_CREAT, 0600)) < 0) {
+    unlink(dump);
+    if ((dfd = open(dump, O_WRONLY|O_CREAT, 0444)) < 0) {
 	zwarnnam(nam, "can't write zwc file: %s", dump, 0);
 	return 1;
     }
@@ -2675,7 +2676,8 @@
     if (!strsfx(FD_EXT, dump))
 	dump = dyncat(dump, FD_EXT);
 
-    if ((dfd = open(dump, O_WRONLY|O_CREAT, 0600)) < 0) {
+    unlink(dump);
+    if ((dfd = open(dump, O_WRONLY|O_CREAT, 0444)) < 0) {
 	zwarnnam(nam, "can't write zwc file: %s", dump, 0);
 	return 1;
     }
@@ -2779,10 +2781,10 @@
 static int
 zwcstat(char *filename, struct stat *buf, FuncDump dumps)
 {
-    FuncDump f;
-    
     if (stat(filename, buf)) {
 #ifdef HAVE_FSTAT
+        FuncDump f;
+    
 	for (f = dumps; f; f = f->next) {
 	    if (!strncmp(filename, f->filename, strlen(f->filename)) &&
 		!fstat(f->fd, buf))

-- 
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author