#!/usr/bin/perl # # This program is designed to be run inside CVSROOT. It may be checked # in there if desired (although it need not be added to checkoutlist). # It takes two or three command-line arguments, creates a line for the # CVS passwd file, and appends it to that file. The first argument # is the login, the second is the password, and the third is the # account this login is mapped to. There is provision for putting # a default account in this program. # #Copyright 2002, David H. Thornley. #Permission granted to use under Gnu General Public License, version 2 or later. #This license is available at http://www.thornleyweb.com/perl/license.html #No warranty, express or implied, except by separate agreement. my($default_account) = ""; my($salt_characters) = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123 456789./"; my ($login) = shift; my ($password) = shift; my ($account) = shift || $default_account; srand(time()); my($letter1) = substr($salt_characters, rand(64), 1); my($letter2) = substr($salt_characters, rand(64), 1); my($salt) = "$letter1$letter2"; my($encrypted) = crypt($password, $salt); my($line) = "$login:$encrypted"; if ($account) { $line = $line . ":$account"; } open PASSWD, ">>passwd" or die "No passwd file found"; print PASSWD "$line\n"; close PASSWD;