Administration


After migrating my company from a CVSNT server which ran on Windows to a CVS server that runs on Linux, and thinking everything went fine, I suddenly received a complaint about binary files checking out as ascii, which cause them to break.
after an investiation, I found that CVSNT has a slightly differnt repository version than the what CVS is using.
specifically, CVSNT uses “kopt b” to specify a binary file, while CVS is using “expand @b@;”.
once this was clear, I wrote this little script, that fixes all the “broken” files (files that have kopen b and does not have expand @b”), and add the “expand @b@” line to the.

before you use it, backup your repository.
for each “file,v” the script is modifying, a new backup file named “file,v.bak” is created, and the original file is fixed.
after you fix your repository make sure to tell your users to update all the binary files.


find . -not -name "*,v.bak" -exec grep -q "kopt.*b" \{\} \; -not -exec grep -q "expand.*@b@;" \{\} \; -print0  | xargs -0 -i sh -c  "echo conv {};cp \"{}\" \"{}.bak\";cat \"{}.bak\" | sed 2a\"expand  @b@;\" > \"{}\""

CVS supports virtual users, which have access to the repository, but not to the system.
Those users names and passwords are stored in CVSROOT/passwd file, but there is no standard method CVS provides to add users to this file.
So, how do you add a user to cvs CVSROOT/passwd file?
cvs passwd file has the following stucture:
user_name:hashed_password[:real_user]

the first row is the user name which the user is aware of (what he preceives as his user name).
the second row is the user password, encrypted with the standard unix crypt() function.
the third row is an optional real user name to map this user to. this is useful if you want all users to act under the same user.
in my case, I wanted all users to act under the user ‘cvs’ with the group ‘cvs’.
I wrote this script, which uses htpasswd, which is a standard apache tool, to create the passwd file.
(change /cvs to your actual repository path)
add-cvs-user:


#!/bin/bash
if [ $# = 0 ]; then
  echo user name not specified
  exit
fi
PASS=`htpasswd -n $1`
echo $PASS:cvs >> /cvs/CVSROOT/passwd

make sure you change the file ownership to root:root, and change the permissions for it so that only root can read its content.