Solved

How to add new system user with perl cgi?

Posted on 2000-03-21
5
149 Views
Last Modified: 2010-03-05
I want to build a new system user with perl cgi,I use the
command like this:
$a=system "/usr/sbin/useradd $username";
But after the program is run,$a got a "256" error.How can I do?
Please help me!
Thanks
0
Comment
Question by:fatworm
5 Comments
 
LVL 3

Accepted Solution

by:
alien_life_form earned 20 total points
ID: 2643863
Greetings.

You want to add a new system user with *CGI*?

First caveat:
Don't. If your box is Linux as it seems you can enable linuxconf web access, fire your browser on port 98 (I think) and get a perfectly good - not to mention much safer - interface to creating users and many, many other system tasks.

But if you *must* go through a CGI, you should take note that your webserver is in all  likelyhood running as a non-privileged user (usually nobody). useradd will laugh sardonically at any attempt of the script to execute it. So you should make your script setuid root, which is a gaping security hole and a catastrophe in waiting.

If you're going to do it, you might as well do chmod +s /usr/sbin/useradd - which allows everybody and my cat to create  a user on the box, and keep the cgi in user space. Security will not be much worse - it will be close to 'worst' either way. And, BTW, I think that way you'll get a user with no password, which makes things even more interesting.

Cheers,
    alf
0
 
LVL 6

Expert Comment

by:christopher sagayam
ID: 2644043
For ALL your WEB BASED ADMINISTRATIVE needs just download the perl script  at

http://www.webmin.com/webmin/

and you can open the source code and see what is in it ?

0
 

Expert Comment

by:hakimus
ID: 2644413
Well, if you wan, you can to do someprogram in perl taht:
create the user in /etc/passwd, create the user directoyr, and so on :)

This is taht you wan?
If (answer=yes) {
emailto (hakimus@usa.net)
and_wait_for_program.code
}
Cheers!
0
 

Expert Comment

by:hakimus
ID: 2644414
Well, if you wan, you can to do someprogram in perl taht:
create the user in /etc/passwd, create the user directoyr, and so on :)

This is that you wan?
If (answer=yes) {
emailto (hakimus@usa.net)
and_wait_for_program.code
}
Cheers!
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2645035
fatworm,

can you pl attach your PERL code??

that way we can give you an more accurate/exact answer.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
perl match and sort unique result 2 141
.properties file to call function/method 9 61
Export Variables in Perl 3 85
Create an automated page index 9 50
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question