[needs test case. -kingdon] From: Warren Jones Subject: Check for writable history file not always needed To: bug-cvs@gnu.org Date: Mon, 1 Feb 1999 15:36:32 -0800 (PST) If the user doesn't have write permission for the CVSROOT/history file, CVS will fail with a message like this: cvs annotate: Sorry, you don't have read/write access to the history file cvs [annotate aborted]: /blah/blah/CVSROOT/history: Permission denied This failure seems unnecessary when cvs is run with the "-l" flag, which turns off history logging. I'm including a patch which will skip the check for a writable history file when the "-l" flag is present. Does this patch seem reasonable, or are there some issues that I've overlooked? The primary motive for this patch is to allow a web interface to CVS to run the annotate command without giving world write permission to the history file. The web interface typically runs with the limited permission of httpd or nobody. (http://linux.fh-heilbronn.de/~zeller/cgi/cvsweb.cgi/) Actually, there are a number of CVS commands that don't ever write to the history file (including annotate). A more complete solution might involve checking to see if the current command is one that keeps a history before checking for write permission. I haven't made a patch for this change, but if I did, it would probably involve the lookup_command_attribute() function, which might add another status bit (CVS_CMD_NO_HISTORY?) to its return value. Can anyone comment of the usefulness of such a change? -------------------------------------------------------------------- Warren Jones | To keep every cog and wheel is the first Fluke Corporation | precaution of intelligent tinkering. Everett, Washington, USA | -- Aldo Leopold Index: main.c =================================================================== RCS file: /usr0/sweng/src/active/CVS.repo/cvs/src/main.c,v retrieving revision 1.5 diff -c -r1.5 main.c *** main.c 1998/10/16 15:51:17 1.5 --- main.c 1999/01/27 19:42:54 *************** *** 980,986 **** } (void) strcat (path, "/"); (void) strcat (path, CVSROOTADM_HISTORY); ! if (isfile (path) && !isaccessible (path, R_OK | W_OK)) { save_errno = errno; error (0, 0, "Sorry, you don't have read/write access to the history file"); --- 980,986 ---- } (void) strcat (path, "/"); (void) strcat (path, CVSROOTADM_HISTORY); ! if (!logoff && isfile (path) && !isaccessible (path, R_OK | W_OK)) { save_errno = errno; error (0, 0, "Sorry, you don't have read/write access to the history file"); Index: server.c =================================================================== RCS file: /usr0/sweng/src/active/CVS.repo/cvs/src/server.c,v retrieving revision 1.1.1.8 diff -c -r1.1.1.8 server.c *** server.c 1998/10/12 23:32:55 1.1.1.8 --- server.c 1999/01/27 19:44:07 *************** *** 814,820 **** } (void) strcat (path, "/"); (void) strcat (path, CVSROOTADM_HISTORY); ! if (isfile (path) && !isaccessible (path, R_OK | W_OK)) { save_errno = errno; pending_error_text = malloc (80 + strlen (path)); --- 814,820 ---- } (void) strcat (path, "/"); (void) strcat (path, CVSROOTADM_HISTORY); ! if (!logoff && isfile (path) && !isaccessible (path, R_OK | W_OK)) { save_errno = errno; pending_error_text = malloc (80 + strlen (path));