Developer Tools Blog

Evolphin, Version Control, Visual Workflow, Collaboration software, Version Cue, Subversion

Howto get CVS user name inside a CVS Loginfo trigger

March 5th, 2007 by rahul

THE PROBLEM

CVS allows you tp specify a run-as user-name in the CVSROOT/passwd file. So for example if we use the following syntax in CVSROOT/passwd file:

john:12$2#&65:cvsadmin
greshim:ac2$2#&65:cvsadmin

The above tells the CVS server to launch/fork the CVS process with the effective user-id as ‘cvsadmin‘ instead of say CVS user ‘john‘ who may have executed the commit command. This allows the CVS administrator to maintaina separation between system user and the CVS user. It allows the admin to avoid polluting UNIX file level permissions inside the CVSROOT.

However the problem is how does a CVS trigger like Loginfo get hold of the actual CVS user on whose behalf the run-as user is executing the CVS command ? If the trigger script uses ‘whoami’ to query the user it would get the effective user-id like ‘cvsadmin’ instead of ‘john’.

THE SOLUTION

Instead of querying for effective user-id from within the trigger script, just pass a $USER variable as an argument to the trigger script in the trigger definition file. For example:

The following `loginfo' file, together with the tiny shell-script below, appends all log messages to the file `$CVSROOT/CVSROOT/commitlog', and any commits to the administrative files (inside the `CVSROOT' directory) are also logged in `/usr/adm/cvsroot-log'. Commits to the `prog1' directory are mailed to ceder.

ALL             cvs-log $CVSROOT/CVSROOT/commitlog $USER
^CVSROOT(/|$)   cvs-log /usr/adm/cvsroot-log $USER
^prog1(/|$)     Mail -s "%p %s" ceder

Inside the trigger script you can query the passed command line argument for the actual CVS user name.

Posted in CVS, Software Configuration Management | No Comments »

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.