BUG: cvs 1.10.2, read-only files, and Windows NT

BUG: cvs 1.10.2, read-only files, and Windows NT

Post by Justin Morga » Sun, 27 Sep 1998 04:00:00



Hello,

I've been having the same problem Charles describes below (see attached). My
Windows NT cvs client won't rename a read-only file on our exported Unix
repository. Unix clients, on the other hand, have no problem with the
rename. So NT cvs only works with non-read-only files, which is very
limiting. (I guess we could fix this problem by making all files in our
repository read/write, but this is not a safe solution.)

If anyone out there has fixed the rename() problem, could you send me your
cvs.exe executable.?  It would be greatly appreciated!

I tested this on the latest CVS 1.10.2 for Windows; I really hope the fix
makes it into CVS 1.10.3. This problem may be a significant issue for
organizations that want to use CVS on Windows NT, such as AT&T Wireless.

Regards,

---
Justin Morgan
AT&T Wireless Services

Begin forwarded message:

Organization Qwest Communications +1.303.285.0194 Denver Colorado
Date Wed, 15 Jul 1998 17:21:08 -0600
Newsgroups comp.software.config-mgmt
Message-ID <>

To Whom it may concern,

I have noticed a problem with CVS for the last few revisions
in which a commit on a Netware server will generate the
error "Permission Denied". This is due to the use of
rename() on a read-only file. On other file systems,
it seems the standard library call to rename() allows
this. Anyway, to get around the problem, you must add the
following code to windows-NT\filesubr.c , approximately line
397 :

(add) chmod(from, S_IWRITE);
if (rename (from, to) < 0)
error (1, errno, "cannot rename file %s to %s", from, to);
(add) chmod(to, S_IREAD);

I made this change on version cvs-1.9.28 and compiled it with
VC 5.0; works for me.

I am not sending a bug report because I'm not sure who to send
it to and assume those that keep it up check this newsgroup
anyway.

For what it's worth,
Charles Appel

 
 
 

BUG: cvs 1.10.2, read-only files, and Windows NT

Post by Johannes Stezenbac » Tue, 29 Sep 1998 04:00:00


I was able to reproduce this bug (repository on a netware
server). However, your suggested fix would make all renamed
files read only, so I extended this to preserve the original
file mode. The following patch is against filesubr.c
from cvs 1.10.2:

------------ filesubr.diff -----------------------------------
Index: ccvs/filesubr.c
diff -c ccvs/filesubr.c:1.1 ccvs/filesubr.c:1.2
*** ccvs/filesubr.c:1.1 Mon Sep 28 11:29:54 1998
--- ccvs/filesubr.c     Mon Sep 28 11:33:47 1998
***************
*** 377,382 ****
--- 377,384 ----
      const char *from;
      const char *to;
  {
+     int readonly = 0;
+
      if (trace)
  #ifdef SERVER_SUPPORT
        (void) fprintf (stderr, "%c-> rename(%s,%s)\n",
***************
*** 387,397 ****
      if (noexec)
        return;

!     /* Win32 unlink is stupid --- it fails if the file is read-only  */
      chmod(to, S_IWRITE);
      unlink(to);
      if (rename (from, to) < 0)
        error (1, errno, "cannot rename file %s to %s", from, to);
  }

  /*
--- 389,404 ----
      if (noexec)
        return;

!     /* Win32 unlink/rename is stupid --- it fails if the file is read-only  */
      chmod(to, S_IWRITE);
      unlink(to);
+     readonly = !iswritable(from);
+     if (readonly)
+       chmod(from, S_IWRITE);
      if (rename (from, to) < 0)
        error (1, errno, "cannot rename file %s to %s", from, to);
+     if (readonly)
+       chmod(to, S_IREAD);
  }

  /*
------------ filesubr.diff -----------------------------------


> I have noticed a problem with CVS for the last few revisions
> in which a commit on a Netware server will generate the
> error "Permission Denied". This is due to the use of
> rename() on a read-only file. On other file systems,
> it seems the standard library call to rename() allows
> this. Anyway, to get around the problem, you must add the
> following code to windows-NT\filesubr.c , approximately line
> 397 :

> (add) chmod(from, S_IWRITE);
> if (rename (from, to) < 0)
> error (1, errno, "cannot rename file %s to %s", from, to);
> (add) chmod(to, S_IREAD);

--
Johannes Stezenbach, Systementwickler
Propack Data GmbH, D-76131 Karlsruhe, Vincenz-Priessnitz-Str. 1
Tel: 0721/9650-850 Fax: 0721/9650-888  http://www.propack-data.de/

 
 
 

BUG: cvs 1.10.2, read-only files, and Windows NT

Post by Johannes Stezenbac » Tue, 29 Sep 1998 04:00:00


CVS 1.10.2 for NT:

While my last patch solved the problem with commit on
netware volumes, I found a related problem with "cvs init":
An initial "cvs init" fails, and much worse, a repeated
"cvs init" destroys the CVSROOT content in the CVS repository.

I had a look at the macintosh files and took the same way
to do the following patch, witch is still against the
CVS 1.10.2 distribution files (i.e. forget about my last
patch, filesub.diff). wnt.diff will modify config.h
and filesubr.c in the windows-NT subdirectory of the
source distribution.

------------ wnt.diff -----------------------------------
Index: ccvs/config.h
diff -c ccvs/config.h:1.1 ccvs/config.h:1.2
*** ccvs/config.h:1.1   Thu Jun 11 22:58:58 1998
--- ccvs/config.h       Mon Sep 28 16:03:15 1998
***************
*** 240,245 ****
--- 240,249 ----
  #define CVS_LSTAT wnt_lstat
  extern int wnt_lstat ();

+ /* win32 rename() does not work for read only files */
+ #define CVS_RENAME wnt_rename
+ extern int wnt_rename ();
+
  /* This function doesn't exist under Windows NT; we
     provide a stub.  */
  extern int readlink (char *path, char *buf, int buf_size);
Index: ccvs/filesubr.c
diff -c ccvs/filesubr.c:1.1 ccvs/filesubr.c:1.2
*** ccvs/filesubr.c:1.1 Thu Jun 11 22:59:00 1998
--- ccvs/filesubr.c     Mon Sep 28 16:03:15 1998
***************
*** 370,375 ****
--- 370,400 ----
  }

  /*
+  * rename for NT which works for read only files;
+  * used for CVS_RENAME in config.h
+  */
+ int
+ wnt_rename (from, to)
+     const char *from;
+     const char *to;
+ {
+     int result, save_errno;
+     int readonly = !iswritable(from);
+     if (readonly)
+       chmod(from, S_IWRITE);
+     result = rename (from, to);
+     save_errno = errno;
+     if (readonly) {
+       if (result == 0)
+           chmod(to, S_IREAD);
+       else
+           chmod(from, S_IREAD);
+       errno = save_errno;
+     }
+     return result;
+ }
+
+ /*
   * Rename a file and die if it fails
   */
  void
***************
*** 390,396 ****
      /* Win32 unlink is stupid --- it fails if the file is read-only  */
      chmod(to, S_IWRITE);
      unlink(to);
!     if (rename (from, to) < 0)
        error (1, errno, "cannot rename file %s to %s", from, to);
  }

--- 415,421 ----
      /* Win32 unlink is stupid --- it fails if the file is read-only  */
      chmod(to, S_IWRITE);
      unlink(to);
!     if (CVS_RENAME (from, to) < 0)
        error (1, errno, "cannot rename file %s to %s", from, to);
  }
------------ wnt.diff -----------------------------------

--
Johannes Stezenbach, Systementwickler
Propack Data GmbH, D-76131 Karlsruhe, Vincenz-Priessnitz-Str. 1
Tel: 0721/9650-850 Fax: 0721/9650-888  http://www.propack-data.de/