File: add-account

package info (click to toggle)
gopher 2.3-2
  • links: PTS
  • area: non-free
  • in suites: hamm
  • size: 2,364 kB
  • ctags: 2,030
  • sloc: ansic: 22,451; perl: 1,950; sh: 1,510; makefile: 397; asm: 1
file content (83 lines) | stat: -rwxr-xr-x 2,399 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/local/bin/perl
#######################################################################
# $Author: lindner $
# $Revision: 1.3 $
# $Date: 1994/12/12 16:59:05 $
# $Source: /home/arcwelder/GopherSrc/CVS/gopher+/gopherd/scripts/add-account,v $
# $State: 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:
# $Log: 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 (<pw>) {
	($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";