How to change Linux user password from PHP code?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vinod_bujji
Forum Newbie
Posts: 3
Joined: Tue Jun 03, 2003 4:52 am
Location: hyderabad

How to change Linux user password from PHP code?

Post by vinod_bujji »

hi
I want to change the password of the linux/unix user. For e.g In my linux system the user name is "vinod" and the password is "vinod12". Please can anyone give me the solution to change the password of the linux user from PHP code. I want to change it through programatically using PHP . If anyone can help me or give me the solution i will be very thankful to u friends. Can anyone give me some steps inthe form of phpfile please?
with regards
vinod
User avatar
r337ard
Forum Commoner
Posts: 29
Joined: Tue Apr 15, 2003 6:14 am
Contact:

Post by r337ard »

its almost totally unlikely you'd be able to do that with php, because its permission set is unable to read the password file in a unix environment. php would need to be run under a group account that had this access, which means no shared host worth its servers would have this set up. if you installed php yourself on your own linux box, you could assign its group permission to access whatever file your linux passwords are stored in.

then its possible
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

search gave me this:
this
User avatar
r337ard
Forum Commoner
Posts: 29
Joined: Tue Apr 15, 2003 6:14 am
Contact:

Post by r337ard »

Let your program connect on the telnet port, logon with root....
And just change the pass....
interesting workaround :)
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

Hey, it works for me... :)
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

Changing your own account password (the same account as the owner of the php-files being processed) is possible, if the Apache server is suexec enabled, make a 0700 permitted script and it will run as your own user and you can now run the passwd command... Most (sane) systems and cgi-wrappers wont allow doing this as root..

A different approach would be to have the script add an entry to a file or a database an dthen make a cron-job that checks this database and performs the queued commands, a great deal of caution and security aware thinking should be a part of it..
terfle
Forum Newbie
Posts: 2
Joined: Thu Nov 20, 2003 5:24 pm
Location: Bozeman

Solution?

Post by terfle »

Does anyone have a script written that does this?

I've looked everywhere and haven't found one written in PHP, if anyone has this please let me know.
terfle
Forum Newbie
Posts: 2
Joined: Thu Nov 20, 2003 5:24 pm
Location: Bozeman

Anybody??

Post by terfle »

Anybody, any ideas? :?
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

My idea as posted above would work... one script posts to a file, a cron-job (scheduler) does the actual change...
Post Reply