[bcn-pm] Extra

Christof Damian christofadamian.net
Dij Feb 9 00:27:37 PST 2006


On Thu, 09 Feb 2006, Jose Pedro Andres Garcia wrote:
> Buenas:
>     Me he encontrado con un error muy raro, y no se si es tema de perl, 
> o si es problema de Debian.
> Os cuento:
>     Intento validar usuarios del sistema, cojiendo el password 
> encriptado y el uid con la funcion getpwnam.
>     El codigo de ejemplo seria este:
> 
> foreach ( 'root', 'macklus' ) {
>         if ( getpwnam ( $_ ) ) {

try this instead:

          if ( defined getpwnam ( $_ ) ) {

or change maybe even better:

foreach ( 'root', 'macklus' ) {
        if ( my ($upass,$uid) = (getpwnam( $_ ))[1,2] ) {
                print "RECIBO: $upass, $uid\n";
        } else {
                print "ERROR: Usuario $_ no se devuelve !\n";
        }
}

you will see the encrypted password entry usually only if you are
root, because it is stored in the shadow file.

christof

(sorry about my lack of spanish)
-- 
Christof Damian         
christof at damian.net


Més informació de la llista de correu Barcelona-pm