On 12/23/2016 06:22 PM, G. Schlisio wrote:
>> Georg
>>
>> Replying to my own post: on re-reading the specification, it looks clear
>>
>> "On success, *getpwnam_r*() and *getpwuid_r*() return zero, and set
>> /*result/ to /pwd/. If no matching password record was found, these
>> functions return 0 and store NULL in /*result/. In case of error, an
>> error number is returned, and NULL is stored in /*result/. "
>>
>> So it's the various implementations that may be deviating from this:
>>
>> "Experiments on various UNIX-like systems show that lots of different
>> values occur in this situation: 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK,
>> EPERM and probably others."
>>
>> In the case reported it is returning EINVAL (invalid argument). What
>> version of glibc are you using?
>>
>> John
>>
> we are running the glibc 2.24 from the official archlinux repository,
> last rebuild of glibc happened in early august this year and was no part
> of the update in question.
> georg
I saw a change in glibc 2.24 relating to EINVAL in the
nss/getXXbyYY_r.c. However that would not fit with the fact the you've
been using that version for some time without this issue, so I'm not
sure about it.
I think it would be useful to do another level of debugging to confirm
the issue. The following program is the example test program from the
getpwnam_r linux manual. Would you be able to compile it and run it on
the server that has the issue?
cc -o test test.c
then
./test AAAAAAAA
If it behaves properly it should say "not found". If it demonstrates the
error you were seeing originally, it should give a message about invalid
argument.
John
----------test.c-----------------
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
int
main(int argc, char *argv[])
{
struct passwd pwd;
struct passwd *result;
char *buf;
size_t bufsize;
int s;
if (argc != 2) {
fprintf(stderr, "Usage: %s username\n", argv[0]);
exit(EXIT_FAILURE);
}
bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
if (bufsize == -1) /* Value was indeterminate */
bufsize = 16384; /* Should be more than enough */
buf = malloc(bufsize);
if (buf == NULL) {
perror("malloc");
exit(EXIT_FAILURE);
}
s = getpwnam_r(argv[1], &pwd, buf, bufsize, &result);
if (result == NULL) {
if (s == 0)
printf("Not found\n");
else {
errno = s;
perror("getpwnam_r");
}
exit(EXIT_FAILURE);
}
printf("Name: %s; UID: %ld\n", pwd.pw_gecos, (long) pwd.pw_uid);
exit(EXIT_SUCCESS);
}