Yes....I tried compiling the code but the makefile failed due to some vague
reason...once the compile stopped i lost enthu to look at the source...I was
hoping I could cut this short by asking on teh mailing list...:)
I will look at teh source again..
Thx,
Arni
----- Original Message -----
From: David S Edwards <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, November 30, 1999 12:31 PM
Subject: Re: file locks..
> Have you tried looking at the source code for useradd to see what
mechanism
> it uses to lock the passwd file?
>
>
> At 06:19 AM 11/30/99 -0500, you wrote:
> >I have all this in place..bu the file locks is what is troubling me...
> >
> >Thx,
> >Ani
> >
> >
> > > I agree....
> > >
> > >
> > > see attached perl script for example...
> > > this is a cgi for adding users (I know *really big shudder*) that
> > > someone on this list previously asket for...
> > > it even creates the passwd salt/hash for the useradd...
> > >
> > > "Yoink!" wrote:
> > > >
> > > > On Mon, 29 Nov 1999, Arni Raghu wrote:
> > > > > Tired of adding/deleting users manually..I am writing my own perl
> >scripts to
> > > > > automate the tasks for me...this I do by directly writing to the
> >passwd and
> > > > > shadow files...(because I do not want to use Expect in the perl
> >code)..It
> > > > > works great and has eased my admin tasks to an extent..
> > > >
> > > > What's wrong with adduser and userdel?
> > > >
> > > > --
> > > > \ \/ / _ |~\ _ In God We Trust. All Others Pay Cash.
> > > > > < / \|\ /|+-< | | "The world is a comedy to those that
think,
> > > > / /\ \\_/| \/ ||__)|_| a tragedy to those who feel." - Horace
> >Walpole
> > > >
> > > > --
> > > > To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe"
> > > > as the Subject.
> >
> >
>
>---------------------------------------------------------------------------
-
> >----
> >
> >
> > > #!/usr/bin/perl
> > > ###########################################################
> > > # This program is Copyright under the GPL (yada yada yada)
> > > # Abuse it at your will just email me any improvements
> > > # please! --Mike Cathey ([EMAIL PROTECTED])
> > > # The purpose of this script is farily self explanatory.
> > > # It calls useradd and passwd to change the name of a user.
> > > # It also checks to see if a user by the requested username
> > > # already exists on the system.
> > > ###########################################################
> > > # We have to define where the system utils are first.
> > > # because it is the easiest and quickest way that I can
> > > # think of, I am going to parse through /etc/passwd (please
> > > # use shadow passwds) to find out if the username requested
> > > # is already in use.
> > > #
> > > # NOTE: I am not implementing any kind of username check
> > > # (eg. username/password limit). You might want
> > > # to add that if you expect to have problems in that
> > > # area.
> > >
> > > $path_to_homedir = "/"; # path to create home directories
> > > $useradd = "/usr/sbin/useradd"; # path to useradd
> > > $userlist = "</etc/passwd"; # open readonly
> > >
> > > # now we parse the form input
> > >
> > > $formdata=<STDIN>;
> > > $formdata=~s/\s+$//;
> > > foreach (split(/&/, $formdata)) {
> > > ($name, $value)=split(/=/, $_);
> > > $name=~s/\+/ /g;
> > > $name=~s/%([0-9|A-F]{2})/pack(C,hex($1))/eg;
> > > $value=~s/\+/ /g;
> > > $value=~s/%([0-9|A-F]{2})/pack(C,hex($1))/eg;
> > > if ($value eq "") {
> > > &exit($name);
> > > }
> > > push (@print, $name);
> > > $data{$name}=$value;
> > > }
> > > $username = $data{'username'};
> > > $password = $data{'password'};
> > >
> > > # create a 'random' salt and then use
> > > # the crypt function to creat the hashed password
> > >
> > > $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand
64];
> > > $passwordhash = crypt($password,$salt);
> > >
> > > open(ULIST,"$userlist") || die "Error can't open: $!";
> > > @userlist = <ULIST>;
> > >
> > > foreach $line (@userlist) {
> > > if ($line =~ /.*$username.*/i) {
> > > $name = "user exists";
> > > &exit($name);
> > > }
> > > }
> > >
> > > system("$useradd $username -m -d $path_to_homedir$username -p
> >$passwordhash");
> > >
> > > # then we print the success page
> > >
> > > print "Content-type: text/html\n\n";
> > > print "<html>\n<head>\n<title>Done!</title>\n</head>\n<body
> >bgcolor=\"ffffff\">\n";
> > > print "The username $username was added<br>\n";
> > > print "with the password $password.<br>\n";
> > > print "</body>\n</html>\n";
> > >
> > > sub exit {
> > > local ($name)=@_;
> > > print "Content-type: text/html\n\n";
> > > print "<html>\n<head>\n<title>Error!</title>\n</head>\n<body
> >bgcolor=\"ffffff\">\n";
> > > if ($name eq "user exists") {
> > > print "This username is already taken.<br>\n";
> > > print "Please return back and enter<br>\n";
> > > print "another username.<br>\n";
> > > }
> > > else
> >
> > > print "Your must fill in the $name field to process this
form.<br>\n";
> > > print " Please return back and do it. Thank you.<br>\n";
> > > }
> > > print "</body>\n</html>\n";
> > > }
> > >
> >
> >
> >--
> >To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
> >as the Subject.
>
>
> --
> To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
> as the Subject.
>
>
--
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.