For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > May 2005 > File_Passwd and shadow passwords









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author File_Passwd and shadow passwords
Aaron Gould

2005-05-09, 8:57 pm

Can anyone tell me if File_Passwd can work with shadow password files?

The following snippet of code is allowing alterations to the /etc/passwd
file, and an "x" is inserted into the password field (which is
expected). Shadow remains untouched...

include_once('File/Passwd.php');

$passwd = &File_Passwd::factory('Unix');
$passwd->setFile('/etc/passwd');
$passwd->useMap(true);
$passwd->load();
$extra = array('pass'=>'testpass', 'home'=>'/home/testuser',
'gecos'=>'Added by script...', 'shell'=>'/bin/bash');
$passwd->addUser('testuser', 'testpass', $extra);
$passwd->save();

I've been through the docs, and all I can see is that a PEAR_Error is
thrown when a shadow password configuration is detected. Does this
simply mean it doesn't have that capability? Google is rather dry on
relevant information too.

Thanks,
--
Aaron Gould
Programmer/Systems Administrator
PARTS CANADA
Michael Wallner

2005-05-13, 4:04 pm

Hi Aaron Gould, you wrote:

> Can anyone tell me if File_Passwd can work with shadow password files?
>
> The following snippet of code is allowing alterations to the /etc/passwd
> file, and an "x" is inserted into the password field (which is
> expected). Shadow remains untouched...


Sorry for the late answer, but I'm currently lacking time.

This question has been asked some time ago, please search the
archive for a wrapper function; it basically creates two
File_Passwd_Unix objects, one for /etc/passwd and one for
/etc/shadow. Please note that you must not specify the password in
the "extra" fields and that you need to define the extra fields map
for the shadow file manually.

Regards,
--
Michael - < mike(@)php.net >

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com