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/XrdClientSock.cc:487,
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
getpwuid='alongusername666' -- 0x7fff7513b2c0 vs 0x7fff7513b2c0
I can provide a patch using getpwuid(geteuid()) ... but can't really test it on
anything but GNU/Linux.
gcc xxx.c -o xxx
int ret = getlogin_r(buf, sizeof(buf));
printf("getlogin='%s'; _r='%s', ret=%d\n",
getlogin(), buf, ret);
cuserid(cbuf); /* return value seems random ?? */
uid_t id = geteuid();
struct passwd pwd, *ppwd;
int pret = getpwuid_r(id, &pwd, bufbuf, sizeof(bufbuf), &ppwd);
printf("getpwuid='%s' -- %p vs %p\n", ppwd->pw_name, &pwd, ppwd);