Re: [ANNOUNCEMENT] File_Passwd-1.0b1 (beta) Released.

From: Date: Tue, 04 Nov 2003 20:06:50 +0000
Subject: Re: [ANNOUNCEMENT] File_Passwd-1.0b1 (beta) Released.
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-8760@lists.php.net to get a copy of this message
Hi Frederic Trudeau, you wrote: > The support for *Nix type passwd file is every nice. Is > support for shadow file will be supported in a near futur ? Well I've thought about that a bit, but seems not reasonable enough to me... In fact anyone could do that by using another File_Passwd_Unix object supplying the right "name map" and implementig common methods in ones app. Quick/dirty/easy example: --- ### --- require_once 'File/Passwd/Unix.php'; $passwd = &new File_Passwd_Unix('/etc/passwd'); $shadow = &new File_Passwd_Unix('/etc/shadow'); $shadow_map = array( 'pass', 'lastm', 'minage', 'maxage', 'expire_warn', 'expire_disable', 'disabled_since', 'reserved' ); $shadow->setMap($shadow_map); $passwd->load(); $shadow->load(); function passwd($user, $pass, $uid, $gid, $shell, $home) { // properties for /etc/passwd $p = array( 'uid' => $uid, 'gid' => $gid, 'shell' => $shell, 'home' => $home ); // default properties for /etc/shadow $s = array( 'lastm' => round(time()/(60*60*24*365)), 'minage' => 0, 'maxage' => 99999, 'expire_warn' => 7 ); if ($passwd->userExists($user)) { $passwd->modUser($user, $p); $shadow->changePasswd($user, $pass); } else { $passwd->addUser($user, $pass, $p); $shadow->addUser($user, $pass, $s); } } passwd('mike', 'secret', 501, 500, '/bin/bash', '/home/mike'); passwd('fred', 'secure', 502, 500, '/bin/csh', '/home/fred'); $passwd->save(); $shadow->save(); --- ### --- Regards, -- Michael - < mike(@)php.net >

Attachment: [application/pgp-signature]
« previous php.pear.general (#8760) next »