On Jun 7, 2011, at 12:04 AM, Andrew Hanushevsky wrote:

> Hi Matevz,
> What Brian referred to is the traceid information. It has nothing to do with user identity but a short-hand to differentiate users strictly for logging purposes. The traceid comes via the login protocol which limits the "username" in the traceid to 8 characters and is unchangeable without seriously changing the protocol (which will not happen any time soon). The authenticated information is what should be used if you need to know the exact user.

There's two things here, no?  The wire protocol, and what gets used internally.  It's locally a huge issue to have the 8-character limit for authorization and logging, as almost none of our user accounts are 8 characters (in fact, about 3,000 of them are not uniquely identifiable by using only 8 characters).


> The use of cuserid() is a different story. Note that for BSD we do use getpwuid(). Anyway, the segment of the code you are looking at is actually part of Socks4 support. For BSD the full username would be sent but would be truncated later to 8 characters during login. So, it really doesn't matter that it gets truncated early. That said, the cuserid() function should likely be replaced with the GetUserName() function that is used everywhere else.
> Andy
> -----Original Message----- From: Matevz Tadel
> Sent: Monday, June 06, 2011 8:58 PM
> To: xrootd-l
> Cc: Brian Bockelman
> Subject: Length of reported username
> Hi,
> Brian told me that the printout of client's username has a limit of 8 characters
> and as this is frequently too little for grid-username-slots I decided to have
> to look into it.
> So, I traced it down to usege of cuserid() in XrdClient/,
> function:
>   int XrdClientSock::Socks4Handshake(int sockid);
> This function always returns at most L_cuserid - 1 characters, which is 8. So,
> the username is truncated already in client, during handshake.
> Here's what GNU manpage says about cuserid():
>      Nobody knows precisely what cuserid() does; avoid it in  portable pro-
>      grams.   Or  avoid  it  altogether: use getpwuid(geteuid()) instead, if
>      that is what you meant.  Do not use cuserid().
> I played with this a bit on my machine, mini program attached. That's what I get
> with a specially created username: :)
> [root@greed tmp]# sudo -u alongusername666 ./xxx
> getlogin='matevz'; _r='matevz', ret=0
> cuserid='alonguse'
> getpwuid='alongusername666' -- 0x7fff7513b2c0 vs 0x7fff7513b2c0
> I can provide a patch using getpwuid(geteuid()) ... but can't really test it on
> anything but GNU/Linux.
> Cheers,
> Matevz