Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: stat & uid

by socketdave (Curate)
on Jul 13, 2005 at 20:51 UTC ( [id://474685]=note: print w/replies, xml ) Need Help??


in reply to stat & uid

If this is on a *nix system and you have read access to /etc/passwd (probably you're either root, or the system uses a shadow file) you could load it into an array and 'grep /^$uid/, @passwd_file_listing' then '$uuid = split /:/, @array_you_put_grep_output_into'...

Replies are listed 'Best First'.
Re^2: stat & uid
by tc1364 (Beadle) on Jul 13, 2005 at 21:24 UTC
    ty
      tc1364, i'd advise you to use the function mentioned by davidrw. my solution will work, but it's ugly, slow and insecure in comparison. sorry about that...

        Let me tell you from experience - looking at /etc/passwd is badness. There are so many ways that someone may not be using /etc/password (NIS/NIS+, PAM, LDAP, ...) that ... well, just don't. By using the getpw* functions, you tap into the same C runtime library that the OS uses to validate logins. Which means you'll get the value as used on the system, and not some random value.

        It's just a good habit to get into. And, besides, File::stat and User::pwent are way too easy to use relative to grepping and spliting the /etc/passwd file. :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://474685]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found