#!/usr/bin/perl # # New user script # # This script gets called from a web form where users apply for usership # on your server. It creates a executable file that you as admin can # just run and the user gets created without headaches. $| = 1; if ($ENV{'REQUEST_METHOD'} eq 'POST') { $base="/hamster/home"; chop($date = `date`); chop($ddd = `date +\%j\%H\%M`); print "Content-type: text/html\n\n"; print <<"HTML"; New user details completed MY OWN LOGO

New User Application

HTML read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs=split(/&/, $buffer); foreach $pair(@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $contents{$name} = $value; $contents{'remoteip'} = $ENV{'REMOTE_ADDR'}; # print "$contents{$name} = $value
\n"; } # Check if some-one gave in a bullshit form. if (($contents{'fname'} eq '') or ($contents{'sname1'} eq '')) { print <<"HTML";
Dear person working from machine or proxy $ENV{'REMOTE_ADDR'}, do WE have some news for you:

Oh boy! You cannot even complete a form! How do you think it makes you look? At least fill in a Full name and one username, else this form is useless!

Please take some time and consider if you are really capable of using a computer and if you should apply for usership. If your previous attempt to fill in a form turned out like this then we do not consider you a good canidate. Take a deep breath. Use your browsers BACK button and try again!


HTML exit; } else { ; } print <<"HTML"; Thank you for taking the time to complete the form. Please read the following information carefully. Use your browsers save function to save this page to a file. It will act as a receipt of your new (possible) user account.

If we think that the IP $contents{'remoteip'} that you appear to work from is not in our domain, extra effort will be made to ensure that you are in fact a valid applicant.

This is how your details will appear to others:

Name $contents{'fname'} HTML if ($contents{'addtitle'} eq 'addmytitle') { print <<"HTML"; ,$contents{'title'} HTML } else { ; } print <<"HTML"; $contents{'fname'}
Office$contents{'office'}
Username choices:$contents{'sname1'}, $contents{'sname2'} or $contents{'sname3'}
Work Tel: $contents{'wtel'}Home Tel: $contents{'htel'}
Stud/ID number: $contents{'idnum'}
Birthdate: $contents{'bidate'}

You will most probably granted the first choice of username, unless it clashes with an existing name, is too short or too close to a swearing word.

PLEASE PHONE netadmin at 555-5555 to arrange a password for your account $contents{'reff'} is your reference person or study leader that will be contacted at email address $contents{'refmail'}. Your account might be stopped if the reference person does not know you or give us a good reason to do so.

Reason why you would like to be a network user: $contents{'whyi'}

You rate yourself a $contents{'skill'} computer user that will be using $contents{'os'} as your primary operating system. You also have some knowlage on $contents{'oos1'} $contents{'oos2'} $contents{'oos3'} $contents{'oos4'} $contents{'oos5'} $contents{'oos6'} $contents{'oos7'} $contents{'oos8'} $contents{'oos9'}

Please read the section on operating systems carefully to give you a broader understanding on how to connect to the network. HTML if ($contents{'helpme'} eq 'yes') { print <<"HTML"; You are also interrested in giving a helping hand with network related problems. Good! As soon as there is a problem near you, you will be seen as the solution. We'll keep in touch. HTML } else { ; } print <<"HTML";

Your feedback on the questionaire will be stored in a database for future refference. These details will give us direction on how to expand the network services.

You rate the following services:

E-Mail and other communication tools: $contents{'s1'}
WWW for info search and research:$contents{'s2'}
Wordprocessing and office based work:$contents{'s3'}
Cruising internet for fun and pleasure$contents{'s4'}
Engineering apps CADCAM, PCB etc.$contents{'s5'}
Shareware source$contents{'s6'}
Programming apps, VisC, Pascal, VB etc$contents{'s7'}
Storage of files and userdata$contents{'s8'}
Exam results electronic lecture notes.$contents{'s9'}

You would like to see the following services at Our Site (Let's pray together that it will happen soon...):
$contents{'future'}

You think that $contents{'numstaff'} staff member(s) is/are needed to maintain our network.

According to you an amount of $contents{'hypopay'} is fair for a network account per year, as long as you can get the no $contents{'hserv'} service you asked for.


Thank you for submitting this request for a new user account. Your account will be processed by adminuser\@your.domain.name or bigboss\@your.domain.name. Please give us a few days to decide whether you would make a suitable user. It normally takes only a few minutes to create the account if one of us is close-by.

Futher information

You automagically get the following as a bonus:

Follow this link to get more detailed information on the services and how to make use of it.


This automated service creates a file that could create your new account with a single keypress, if the network administrator feels like it. ALL you need to do on your own is to visit the network center to select a password for yourself.Even with the account created it will not be active before you either phone or visit your network admin to set up your password.
Last updated 960916 HTML # Now create email message and mail it. $subject = "New User application - $date"; $sendto = "adminuser\@your.domain.name, bigboss\@your.domain.name"; # open named pip to send mail open (MAIL, "| /usr/sbin/sendmail $sendto") || die "Cannot send mail: $!\n"; # this selects the open handle to send email: select(MAIL); print <<"EMAIL"; Date: $date From: root\@your.domain.name Return-Path: <$contents{'refmail'}> To: $sendto Subject: $subject This is an automated reply to the http://yourweb.site.name/ohform.html script. New user application details - $date Please note: A file was created under $contents{'base'}/httpd/newuser/$contents{'sname1'}.$ddd that can be directly executed by root in order to create the account. EMAIL if ($contents{'addtitle'} eq 'addmytitle') { print <<"EMAIL"; Full name: $contents{'title'} $contents{'fname'} EMAIL } else { print <<"EMAIL"; Full name: $contents{'fname'} EMAIL } print <<"EMAIL"; Working from machine or proxy: $contents{'remoteip'} Title: $contents{'title'} Username1: $contents{'sname1'} Username2: $contents{'sname2'} Username3: $contents{'sname3'} Office: $contents{'office'} WorkPhone: $contents{'wtel'} HomePhone: $contents{'htel'} Birthdate: $contents{'bidate'} Stud/ID number: $contents{'idnum'} Refference Person: $contents{'reff'} Refference Email : $contents{'refmail'} Would like to help with network problems?: $contents{'helpme'} Skill: $contents{'skill'} Primary operating System: $contents{'os'} Knowlage on: $contents{'oos1'} $contents{'oos2'} $contents{'oos3'} $contents{'oos4'} $contents{'oos5'} $contents{'oos6'} $contents{'oos7'} $contents{'oos8'} $contents{'oos9'} Usership plea: $contents{'whyi'} Questionaire ============ Email: $contents{'s1'} WWW: $contents{'s2'} Office: $contents{'s3'} FunGames: $contents{'s4'} Apps: $contents{'s5'} Shareware: $contents{'s6'} Programming: $contents{'s7'} Storage: $contents{'s8'} Exam and notes: $contents{'s9'} Staffnum: $contents{'numstaff'} YearFee: $contents{'hypopay'} ServiceLevel: $contents{'hserv'} ConnectionValue1: $contents{'userv'} ConnectionValue2: $contents{'nserv'} MonthAccount: $contents{'aserv'} AccountMethod: $contents{'aget'} AccountExtra: $contents{'aret'} Services interrested in ======================= BirthdayNotify: $contents{'c0'} VoiceMail: $contents{'c1'} PinupNotice: $contents{'c2'} AppointRemind: $contents{'c3'} GlobalPhoneBook: $contents{'c4'} LocalIRCserver: $contents{'c5'} AutomatedSoftwareInstalls: $contents{'c6'} VoiceDictation: $contents{'c7'} ExamsonComputers: $contents{'c8'} VideoLectures: $contents{'c9'} VideoConference: $contents{'c10'} SharedAppointment: $contents{'c11'} AnimatedMultimedia: $contents{'c12'} StudentResults: $contents{'c13'} HWSFTWMonitor: $contents{'c14'} Please phone the user and ask him/her to come and select a password for themselves. From your friendly automated Webserver running Mars. EMAIL close(MAIL); # Append questionaire to the log. open(CATFILE, ">> /var/log/newusr.questionaire") || die "Cant update newuser questionaire list"; select(CATFILE); print "$contents{'fname'}:"; print "$contents{'skill'}:"; print "$contents{'helpme'}:"; print "$contents{'os'}:"; print "$contents{'oos1'}:"; print "$contents{'oos2'}:"; print "$contents{'oos3'}:"; print "$contents{'oos4'}:"; print "$contents{'oos5'}:"; print "$contents{'oos6'}:"; print "$contents{'oos7'}:"; print "$contents{'oos8'}:"; print "$contents{'oos9'}:"; print "$contents{'s1'}:"; print "$contents{'s2'}:"; print "$contents{'s3'}:"; print "$contents{'s4'}:"; print "$contents{'s5'}:"; print "$contents{'s6'}:"; print "$contents{'s7'}:"; print "$contents{'s8'}:"; print "$contents{'s9'}:"; print "$contents{'hserv'}:"; print "$contents{'userv'}:"; print "$contents{'nserv'}:"; print "$contents{'aserv'}:"; print "$contents{'aget'}:"; print "$contents{'aret'}:"; print "$contents{'c0'}:"; print "$contents{'c1'}:"; print "$contents{'c2'}:"; print "$contents{'c3'}:"; print "$contents{'c4'}:"; print "$contents{'c5'}:"; print "$contents{'c6'}:"; print "$contents{'c7'}:"; print "$contents{'c8'}:"; print "$contents{'c9'}:"; print "$contents{'c10'}:"; print "$contents{'c11'}:"; print "$contents{'c12'}:"; print "$contents{'c13'}:"; print "$contents{'c14'}\n"; close(CATFILE); # Create an autouser script open(NFILE, "> $contents{'base'}/httpd/newuser/$contents{'sname1'}.$ddd") || die "Cannot create autouser file"; select(NFILE); print "#/bin/bash\n\n"; print "/usr/sbin/ohmasteruser \"$contents{'sname1'}\" "; if ($contents{'addtitle'} eq 'addmytitle') { print "\"$contents{'title'} "; } else { print "\""; } print "$contents{'fname'}\" "; print "\"$contents{'office'}\" "; print "\"$contents{'wtel'}\" "; print "\"$contents{'htel'}\" "; print "\"$contents{'bidate'}\"\n"; print "\n\n# Other names if it is a clash: $contents{'sname2'}"; print "\n# Other name: $contents{'sname3'}\n"; close(NFILE); $a=`chmod +x "$contents{'base'}/httpd/newuser/$contents{'sname1'}.$ddd"`; $a=`chmod o-rwx "$contents{'base'}/httpd/newuser/$contents{'sname1'}.$ddd"`; $a=`chmod g-rwx "$contents{'base'}/httpd/newuser/$contents{'sname1'}.$ddd"`; } exit;