in reply to Can the username be represented differently ?

Hi,

Thanks to everyone for your help. I'm not too sure about using the crypt() function though, looks a bit hard for me. Now, it we put out the email headers like this now:

X-Source-Dir: /home/32149/public_html

how do we (or the sysadmin person) use Perl to convert it back to the username ??

Peter
  • Comment on Re: Can the username be represented differently ?

Replies are listed 'Best First'.
Re^2: Can the username be represented differently ?
by peterr (Scribe) on Jun 28, 2004 at 06:54 UTC
    It's okay, I found out:

    $newname = getpwuid($uid); print "newname: $newname";


    Works too. :D

    Peter
      Given the number 32149, who can convert this back to the username ?

      1. Obviously I can, as I'm the user and it works okay.
      2. Hopefully the 'sysadmin' can.
      3. What about other users on the same server ?
      4. Can anyone else convert the number back to the username ?

      Peter

        1. Yes
        2. Yes
        3. Yes
        4. Yes*

        * But they would probably have to hack it.

        Try this (the $ is the system prompt):

        $ grep 3214 /etc/passwd | head

        This will show you the usernames/UID/GUIDs of all the users on your system (with a UID/GUID that m/3214/ to limit the result set as you have 32K users on that box)

        cheers

        tachyon

        The best answer of course, is "Try it and see". On my box at least, any user can get the user name back from the uid. There might be ways to prevent this, but I'm not sure if that would break other stuff.