I tried to start OpenOffice today on my Red Hat 5 workstation and nothing happened. Starting from the command line I saw this error:
(soffice.bin:14419): GLib-WARNING **: getpwuid_r(): failed due to unknown user id (118141)
The user id (118141) is my Active Directory login mapped to a local UID on my Linux workstation. To make a long story short, the ncsd daemon was not running and getpwuid_r() exhibited strange (to me at least) behavior. Starting ncsd immediately let OpenOffice start.
In the process of testing this I whipped up this C program to test the getpwuid_r() function.
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <pwd.h>
int main(int argc, char *argv[]){
if(argc != 2){
exit(1);
}
uid_t me = atoi(argv[1]);
struct passwd pwbuf;
char buf[2048];
struct passwd *pwbufp;
int ret = getpwuid_r(me, &pwbuf, buf, 2048, &pwbufp);
if(ret == 0){
printf("OK %s\n", pwbuf.pw_name);
} else {
printf("Failed, returned %d\n", ret);
}
exit(0);
}
I observed that when the ncsd daemon not running getpwuid_r() would return info correctly for entries in /etc/passwd but not others. Any uid not in /etc/passwd would be returned as if it was the last entry in /etc/passwd. For example, the last entry on my workstation happens to be uid 26, user postgres. Any uid that I passed to the check program that did not exist in /etc/passwd was returned as postgres. Weird. I didn’t investigate any further once Google provided the ncsd hint.