[OK, let me explain why this is such a mess. How we got here, and how to get out. In the Olden Days, CVS would set various environment variables (including $USER) with putenv. This was to pass them to RCS (back when CVS called RCS) as well as to the administrative files (loginfo, &c). That is the first red herring: In some of my past changes I was confused, or not thinking very carefully about the case of RCS versus the other case. The second red herring is putenv versus execve. The latter is in POSIX and the former is not, so CVS should be rewritten to not use putenv. However, in the past this got somewhat confused with the other issues. At one point it seemed to me the Clean Thing to have CVS substitute its own "internal variables" in the administrative files, rather than environment variables. While this might work better on non-unix, on the whole it looks pretty ugly to me now. Now, in other contexts, environment variables don't work well. In particular, the client still _should_ be getting user-set variables with a global -s option, rather than trying to suck up everything in the environment and send it to the server. So, to address the specific issue of getting the CVS username rather than the system username, putting $USER in the loginfo file itself (not a script which it might invoke) is a reference to an internal variable, not an environment variable, and as far as I know the internal variable (not the environment variable) does refer to the CVS username not the system username (as of CVS 1.9.27 or so). So I'm not sure what all the answers are but I'll say what _not_ to do (IMHO, of course): * Don't make rash changes. That is, think through the issue and where we want to go and how to get there. I mean, sure, I understand the concept of an expedient fix, or not having to discuss something to death before acting, but it seems to me that this whole mess has developed through a series of quick fixes and that more quick fixes will tend to compound the problem. Here is what we perhaps should do: 1. Change putenv to execve, where CVS currently already calls putenv. This should be possible without any user-visible behaviors, and if so it should be relatively uncontroversial (although it might be good to ask before making the change). 2. Write up a design for communicating information to server plug-ins. This might be just a relatively straightforward change to put the internal variables and user variables back into environment variables, or it might be more far-reaching (CGI and FastCGI are successful examples of plug-in interfaces which are far more clean than what CVS has). Circulate such design(s) and see what people think. I will mention one particularly thorny issue: how to try to make the interface portable beyond unix. I don't really know what the deal is in terms of CGI versus WinCGI versus whatever on Windows, for example. It might end up being desirable to mostly punt this issue, I don't know. Another example is that regular expressions are not a convenient way to specify particular directories/files. Like I said, I'm not expressing an opinion about whether this should be dealt with at the same time as the environment variable versus internal variable thing. -kingdon] To: sperber@informatik.uni-tuebingen.de (Michael Sperber \[Mr. Preprocessor\]) Cc: info-cvs@gnu.org Subject: Re :How to prepare correct logs when SystemAuth=no From: Sudish Joseph Date: 09 May 1998 02:44:50 -0400 Michael Sperber writes: >>>>>> "Jim" == Jim Kingdon writes: >>> Does CVS communicate the committer's name to loginfo scripts in any >>> way I could use? Jim> $USER does the right thing, I think. Check the documentation for details. > No, it doesn't. Otherwise I wouldn't get "root" in my logs all the > time. Now I'm not sure if $USER is "root" or if it's unset, but I'll > check if you want me to. The enclosed patch adds a new environment variable, CVS_USER, that does what you want. It is against 1.9.18. We've used it for a few months now. -Sudish Index: doc/cvs.texinfo =================================================================== RCS file: /b/cvsroot/misc/cvs/doc/cvs.texinfo,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- cvs.texinfo 1997/12/19 21:24:55 1.1.1.1 +++ cvs.texinfo 1997/12/22 19:43:15 1.2 @@ -11620,6 +11620,13 @@ @item USER Username of the user running @sc{cvs} (on the @sc{cvs} server machine). + +@item CVS_USER +This is set to the username provided by the user when +the pserver or kserver access methods are used, and to +the empty string otherwise. (CVS_USER and USER may +differ when @file{$CVSROOT/CVSROOT/passwd} is used to +map cvs usernames to system usernames.) @end table If you want to pass a value to the administrative files Index: src/server.c =================================================================== RCS file: /b/cvsroot/misc/cvs/src/server.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- server.c 1997/12/19 21:24:53 1.1.1.1 +++ server.c 1997/12/22 19:43:18 1.2 @@ -4384,10 +4384,10 @@ umask (0); #if HAVE_PUTENV - /* Set LOGNAME and USER in the environment, in case they are - already set to something else. */ + /* Set LOGNAME, USER and CVS_USER in the environment, in case they + are already set to something else. */ { - char *env; + char *env, *cvs_user; env = xmalloc (sizeof "LOGNAME=" + strlen (username)); (void) sprintf (env, "LOGNAME=%s", username); @@ -4396,6 +4396,11 @@ env = xmalloc (sizeof "USER=" + strlen (username)); (void) sprintf (env, "USER=%s", username); (void) putenv (env); + + cvs_user = NULL != CVS_Username ? CVS_Username : ""; + env = xmalloc (sizeof "CVS_USER=" + strlen (cvs_user)); + (void) sprintf (env, "CVS_USER=%s", cvs_user); + (void) putenv (env); } #endif /* HAVE_PUTENV */ }