\begin{Gareth Walters}
> Here is what I use to add users, its not pretty but it works.
> and outputs it in the cvs passwd form ie
> cvsusername:cryptpasswd:systemusername
>
>
> #!/usr/bin/perl
> use strict;
> use Getopt::Std;
> our($opt_f,$opt_c,$opt_u,$opt_p);
> getopt('fcup');
> #check command line options make sense
> if ( (!$opt_f) || (!$opt_c) || (!$opt_u) || (!$opt_p)){
> print "usage:\n$0\t -f filename -c cvs_username -u
> unix_username -p passwd\n";
> exit(1);
> }
> # adding a user
> my $outp = crypt($opt_p,substr($opt_p,0,2));
> open(Ufile, ">> $opt_f") or die "cannot open password file: $!";
> print Ufile "$opt_c:$outp:$opt_u\n";
> exit(0);
gus chokes and strongly recommends the following patch:
(especially for passwords of 2 characters or less..)
- my $outp = crypt($opt_p,substr($opt_p,0,2));
+ my $salt = join '', ('.','/',0..9,'A'..'Z','a'..'z')[rand 64, rand 64];
+ my $outp = crypt($opt_p, $salt);
--
- Gus
--
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug