LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-23-2011, 11:38 PM   #1
asifbasha
Member
 
Registered: Feb 2009
Posts: 98

Rep: Reputation: 15
php code to change password


hai to all


I have the following php code to print the output in the browser

1) <?php

$one=exec("pwd");

echo $one; //output : /root/docs

$two=exec("ls -l");

echo $two; //output :drwxr-xr-x 9 root root 4096 Apr 3 04:40 .


$three=exec("smbpasswd -a bob");

echo $three; //output : prints some garbage values ..

?>

but when i execute the above code , $three is not working ... I am in a situation to change a password for samba users from php code .... any ideas will help me

Thanks in advance to all
 
Old 06-24-2011, 01:22 AM   #2
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
first of all, smbpasswd needs to be run as root to add a user or change a different user's password
second, it's an interactive program, that is to say it prompts for input, so executing it in that fassion via php is probably not going to work
 
Old 06-24-2011, 01:34 AM   #3
asifbasha
Member
 
Registered: Feb 2009
Posts: 98

Original Poster
Rep: Reputation: 15
Thanks for your reply

please suggest me some ideas , to execute this above code in any other fashion ..
 
Old 06-24-2011, 04:42 AM   #4
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
I don't see what this is good for but you can run php scripts from command line too. Maybe you havte to install php CLI...
Then you can run it as root, or sudo...

another idea, but VERY DANGEROUS:
add the apache user to the sudoers and give him appropiate rights regarding smbpasswd->
man visudo

Last edited by j-ray; 06-24-2011 at 05:09 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Change my root password in Debian Linux if I have the current password? panseluta Linux - Newbie 2 12-28-2008 02:02 AM
Locking out a user when password expires, but allowing them to change their password kaplan71 Linux - Security 5 06-27-2008 07:12 PM
LXer: How to change Linux /UNIX system password-using a web based PHP script user interface LXer Syndicated Linux News 0 08-05-2006 08:33 PM
How can I change e-mail password(or linux account password) with php in website?? yusuf Programming 1 05-28-2004 09:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:14 PM.

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