LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-19-2009, 12:34 AM   #1
asifbasha
Member
 
Registered: Feb 2009
Posts: 98

Rep: Reputation: 15
need help reagrding useradd command in fedora 10


hai to all
i have created a bash script called useradding to add user in my fedora system ,when i execute that script as ./useradding it creates a user in my system without prompting any thing because i have specified encryped password in that script ,it works fine and i can able to login with that user name and password clearly ,

And i am handling a mail server so i have designed a php page ,so when i call my bash script form my browser it is not creating any user in my system ,before that i have already given permission for apache to execute useradd command by editing visudo file

And i am getting error in apache error log as unable to lock password file" and also "sudo command need tty to run,"
my scripts are as follows

(sample script examples)
#!/bin/bash
#script name ----useradding in fedora
useradd test

<?php
$cmd=("sudo /var/www/html/useradding");
exec($cmd);
?>
and i have used passthru ,system,commands of php ..nothing is working
any ideas,suggestions will be helpful to me

and thanks in advance...
 
Old 08-19-2009, 12:41 AM   #2
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

Rep: Reputation: Disabled
What are the permissions on the script?
 
Old 08-19-2009, 12:42 AM   #3
karamarisan
Member
 
Registered: Jul 2009
Location: Illinois, US
Distribution: Fedora 11
Posts: 374

Rep: Reputation: 55
You should use the [ CODE ] tags. They make code and configs stand out and infinitely easier to read.

As your second error says, sudo needs a terminal to run. I believe there is a sudoers option to lift this restriction (man is your friend). setuid may also help, though you have to be very careful using it.

That said, this is kind of a strange thing you're doing. What's the context of all this?
 
Old 08-19-2009, 06:08 AM   #4
asifbasha
Member
 
Registered: Feb 2009
Posts: 98

Original Poster
Rep: Reputation: 15
thanks for your ideas

why i am doing is that i have to make a php page so that the users can able to create login's in my mail server

Last edited by asifbasha; 08-19-2009 at 06:10 AM.
 
Old 08-19-2009, 08:34 AM   #5
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

Rep: Reputation: Disabled
Did any suggestion work? What was the issue?
 
Old 08-19-2009, 10:53 AM   #6
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: root
Distribution: Slackware & BSD
Posts: 1,669

Rep: Reputation: 498Reputation: 498Reputation: 498Reputation: 498Reputation: 498
asifbasha,

A shell script, invoked by PHP code running in the web server runs as same user as that of the web server where under normal conditions no user is allowed to change UID to root.

To have your work done you may need a small C program. There is an example in C but I don't know if it will work for you, try this. For comparison see this also.

Hope it helps.

Last edited by malekmustaq; 08-19-2009 at 10:57 AM.
 
Old 08-19-2009, 06:15 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,363

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You'll need to give apache (or whatever user it runs as eg nobody, www) rights in the sudoers file.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] useradd command a7mlinux Linux - General 8 08-12-2009 01:20 PM
command useradd on fedora core6 nouhoun Linux - Newbie 2 10-29-2007 10:28 AM
useradd command Wolvastur Linux - Newbie 9 01-25-2005 10:01 AM
useradd command johnpayback Linux - Newbie 5 08-13-2002 10:22 AM
useradd command allancondino Linux - General 5 04-27-2002 12:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration