LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-07-2004, 06:59 AM   #1
spank
Member
 
Registered: Aug 2003
Location: Romania
Distribution: Ubuntu 6.06
Posts: 278

Rep: Reputation: 30
adduzer php problem


Code:
root@dumbrava /home/apache/continut/download/prj # cat adduzer
#!/bin/bash

# 
# ./adduzer user parola tip
# user: username
# parola: passwd
# tip: 0 shelluser, 1 mailuser

if [ $3 = "0" ]; then
     adduser -p '$2' $1
     echo $1 >> /etc/vsftpd.ftpusers
   else adduser -s /sbin/nologin -p '$2' -d /home/mailusr/$1 $1
fi
this is the bash script that i want to exec via a php
Code:
<?
$user=$_POST['user'];
$pass=$_POST['pass'];
$tip=$_POST['re'];
if($user==NULL){?> <font face="Verdana" size="2" color="#FF0000">Ai uitat useru'</font>
<?
}
else if($pass==NULL){?> <font face="Verdana" size="2" color="#FF0000">Ejti nebun ? Ai uitat parola.</font>
<?}
else if($tip==NULL) {?> <font face="Verdana" size="2" color="#FF0000">Ce cont sa fac? Shell sau mail ?</font>
<?}
else {
mail("admin@nbasarab.ro","Adduser $user","-------------------------\nAm creeat useru: $user\nParola: $pass\nTip user: $tip\n-------------------------","From: root@nbasarab.ro\n");
?>
<font face="Verdana" size="2" color="#000000">
<b>
USER:<?echo " $user"?></br>TIP:<?echo " $tip"?></br> trimit log la admin@xxx.ro</br></br>norok :)
</b>
</font>
<?
$pass=crypt($pass,CRYPT_MD5);
if($tip==shell) exec("adduzer $user $pass 0");
if($tip==mail) exec("adduzer $user $pass 1");
}
?>
and I do a:

Code:
  # chown root:apache adduzer
  # chmod 4750 adduzer
why doesnt it work ? I want this script to be able to create shell or mail users. I think the problem is in the exec lines... but i`m not sure.
Please help!
Tanks!
 
Old 04-07-2004, 08:31 AM   #2
sdpeelejr
Member
 
Registered: Mar 2004
Location: South Carolina
Distribution: Fedora Core 1, Mandrake Linux 10.0
Posts: 51

Rep: Reputation: 15
What exactly isn't working?
 
Old 04-08-2004, 05:14 AM   #3
spank
Member
 
Registered: Aug 2003
Location: Romania
Distribution: Ubuntu 6.06
Posts: 278

Original Poster
Rep: Reputation: 30
it doesnt exec properly the bashscript. for example i want to create a php that restarts my box. how can i do that ?
i've created a test.php
<?
print(exec(quit.sh));
?>

and quit.sh
#!/bin/bash

reboot

anything else ?
 
  


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
php apache or php cgi - php learner rblampain Linux - Security 3 12-17-2004 11:10 PM
New to PHP and Postgressql. Is this a PHP problem or a sql problem. Please help sendas4 Linux - General 2 11-05-2004 01:54 PM
Problem getting PHP to recognize MySQL, Using PHP 4.0 and MySQL 4.0.20 d2army Programming 4 06-27-2004 08:54 PM
RH9: PHP session problem (or Apache problem) fengcn Red Hat 0 12-01-2003 06:32 PM
Apache php index.php problem neurotic Linux - Software 3 11-18-2003 06:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:59 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