Re: OpenLDAP/nss_ldap/pam_ldap

From: Timur I. Bakeyev <timur_at_com.bat.ru>
Date: Wed, 29 Oct 2003 00:14:41 +0100
Hi, Steve!

On Tue, Oct 28, 2003 at 02:52:51PM -0800, Steve Lee wrote:
> Question ?
> 
> I am using FreeBSD 5.1   
> 
> I have gotten FreeBSD 5.1 to authenticate user remotely 
> ssh ing to the box.  They can log in, but when they log 
> in, the system shows their userid instead of the username
> when you do a ps.   this tells me something might be
> wrong with nss_ldap.  but not sure what i am doing wrong.
> 
> I can do "id <username>"  which it returns the user information.
> 
> does anyone have an idea what i didn't do during my setup of
> OpenLDAP/nss_ldap/pam_ldap  ?  Thanks.

I would like to confirm that such weirdness exists... I do use
nss_ldap and also noticed, that some of the programs, like ls,
show numeric id of the user, when other, like top, show normal
username, retrieved from LDAP server.

Short investigation brought me to the conclusion, that the behaviour
differs depending if the program was linked against libc statically
or dynamically...

This short code exposes the problem:

#include <stdio.h>
#include <pwd.h>

int main () {
    struct passwd *pw = getpwuid(1002);
    printf("%s\n", (pw) ? pw->pw_name : "none");
}

Instead of 1002 put the uid of the user from LDAP.

If you compile this program as:

gcc test.c -o test

Which normally implies dynamic linking, when you should get username in 
the output.

If you compile it as:

gcc -static test.c -o test

When "none" will be printed instead...

So, the problem lays somewhere in the libc, in the way, how getpwuid and
friends work in the dynamic and static context with NSS... I don't know,
is this a bug or a feature :) If first, then, probably, PR should be created.

With regards,
	    Timur.
Received on Tue Oct 28 2003 - 14:14:49 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:26 UTC