bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Small bug in CVS 1.11.1p1


From: Petter Reinholdtsen
Subject: Small bug in CVS 1.11.1p1
Date: Thu, 20 Dec 2001 01:19:44 +0100

I've just discovered a small bug in how CVS 1.11.1p1 decides which
user name to use during 'cvs commit'.  The problem appears when
running as effective user root.

The code in question fist check the uid of the current user.  If it is
zero (0), getlogin() is used to fetch a better username.  If
getlogin() fails, the environment variables LOGNAME and USER are used
instead.  I believe the result from getlogin() should be checked, to
avoid accepting 'root' as the current user.  If 0==uio and
"root"==getlogin(), the environment variables should be used instead.

I'm trying to run 'cvs commit' at the end of a long script (which has
to run as root), and want the following to work:

  LOGNAME=pere cvs commit -m "Autobuilder status update (from cron)" files...

This do not work.  The following patch fixes the problem.

diff -ur cvs-1.11.1p1/src/subr.c cvs-1.11.1p1-pere/src/subr.c
--- cvs-1.11.1p1/src/subr.c     Thu Apr 19 21:34:04 2001
+++ cvs-1.11.1p1-pere/src/subr.c        Thu Dec 20 01:09:49 2001
@@ -355,10 +355,11 @@
     uid = getuid ();
     if (uid == (uid_t) 0)
     {
-       char *name;
+       char *name = getlogin();

-       /* super-user; try getlogin() to distinguish */
-       if (((name = getlogin ()) || (name = getenv("LOGNAME")) ||
+       /* super-user; try getlogin() to distinguish, don't accept 'root' */
+       if (((0 != strcmp("root", name)) ||
+            (name = getenv("LOGNAME")) ||
             (name = getenv("USER"))) && *name)
        {
            cache = xstrdup (name);

Please fix this in a future version of CVS.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]