#!/usr/local/bin/perl ####################################################################### # lindner # 1.3 # 1994/12/12 16:59:05 # /home/arcwelder/GopherSrc/CVS/gopher+/gopherd/scripts/add-account,v # Exp # # Paul Lindner, University of Minnesota DCS. # # Copyright 1994 by the Regents of the University of Minnesota # see the file "Copyright" in the distribution for conditions of use. ####################################################################### # MODULE: add-account # # A script to add a new user to the system # Basically requires folks to register before using a secure area. # It adds entries to {gopher-data}/etc/passwd # # To INSTALL place this script in the directory {gopher-data}/bin # Then put a link file like this on your server: # # Type=0? # Name=Register a New Account # Path=0/bin/add-new-account # Host=+ # Port=+ ####################################################################### # Revision History: # add-account,v # Revision 1.3 1994/12/12 16:59:05 lindner # Fix incorrect passwd file format # # Revision 1.2 1994/12/11 18:07:25 lindner # Formatting changes # # Revision 1.1 1994/12/11 17:58:27 lindner # New script # ####################################################################### $fname = <>; chop($fname); $lname = <>; chop($lname); $email = <>; chop($email); $pw = <>; chop($pw); $pw2 = <>; chop($pw2); die "Please specify a first name\n" if ($fname eq ""); die "Please specify a last name\n" if ($lname eq ""); die "Please specify a first name\n" if ($email eq ""); die "Passwords do not match, please try again\n" if (!($pw eq $pw2)); $email =~ /^([\S]+)@([\S]+)/; $username = $1; $host = $2; print "Creating account for $fname $lname as $username\n"; open(pw, "<../etc/passwd") || die "Cannot open password file for reading\n"; while () { ($pwname) = split(/:/); if ($pwname eq $username) { die "Sorry, your username is already in use.\n" } } close(pw); # # Add a new account # $cryptpw = crypt($pw, "Zq"); $line = "$username:$cryptpw:999:10:$fname $lname <$email>:/:/bin/false\n"; open(pw , ">>../etc/passwd") || die "Could not open password file for writing\n"; print pw "$line"; close(pw); print "Your account $username, was added successfully to the gopher system\n"; print "The password you have chosen will work momentarily\n";