Package: nfs-user-server Severity: normal Tags: patch Hi,
the ugidd in nfs-user-server source package (2.2beta47-22) does not produce the right values for the group and the user ID of 'nobody'/'nogroup' on my debian system. In ugid.h, there is a hardcoded value of "-2" for the UID and GID. This value would be correct (at least on my system) if casted to an uint16, but you (and the kernel) use it as an uint32 value which produces absurd IDs. I have appended a patch which solves this problem and should work where the nobody/nogroup user is called nobody/nogroup, which is on (hopefully) every debian system. BTW: I have found no written information that the nfs-kernel-server does not work with ugidd (at least it seems not to anything with the ugidd information). Maybe I missed something, but I suggest that yo put a small note into your README. BTW#2: Similar things happen for numerical-only IDs on an nfs-user-server and this patch does not solve them as the user/group ID is mapped earlier in the nfs daemon itself. The authentication system should probably be integrated into the ugidd daemon as well. Should I file separate bug reports for these two issues? Best regards, Onno -- System Information: Debian Release: testing/unstable APT prefers testing APT policy: (990, 'testing'), (600, 'stable'), (300, 'unstable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.12ok Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)
diff -Nudr nfs-user-server-2.2beta47/ugidd.c nfs-user-server-2.2beta47.new/ugidd.c --- nfs-user-server-2.2beta47/ugidd.c 2006-04-24 23:19:36.000000000 +0200 +++ nfs-user-server-2.2beta47.new/ugidd.c 2006-04-24 23:15:55.000000000 +0200 @@ -263,11 +263,15 @@ struct passwd *pw; bzero(&res, sizeof(res)); - if ((pw = getpwnam(*argp)) == NULL) - res = NOBODY; - else - res = pw->pw_uid; - + if ((pw = getpwnam(*argp)) == NULL) { + /* To prevent dereferencing a NULL pointer, + use the old NOBODY as a last-resort fallback. */ + if ((pw = getpwnam("nobody")) == NULL) { + res=FAIL_NOBODY; + return (&res); + } + } + res = pw->pw_uid; return (&res); } @@ -281,11 +285,15 @@ struct group *gr; bzero(&res, sizeof(res)); - if ((gr = getgrnam(*argp)) == NULL) - res = NOBODY; - else - res = gr->gr_gid; - + if ((gr = getgrnam(*argp)) == NULL) { + /* To prevent dereferencing a NULL pointer, + use the old NOGROUP as a last-resort fallback. */ + if ((gr = getgrnam("nogroup")) == NULL) { + res=FAIL_NOGROUP; + return (&res); + } + } + res = gr->gr_gid; return (&res); } diff -Nudr nfs-user-server-2.2beta47/ugid.h nfs-user-server-2.2beta47.new/ugid.h --- nfs-user-server-2.2beta47/ugid.h 1997-12-12 14:16:21.000000000 +0100 +++ nfs-user-server-2.2beta47.new/ugid.h 2006-04-24 23:15:53.000000000 +0200 @@ -10,7 +10,14 @@ #include <rpc/rpc.h> #define MAXUGLEN 64 -#define NOBODY -2 + +/* The following two values are only used as a fallback if lookup of 'nobody' or 'nogroup' + in /etc/passwd resp. /etc/group fails. Depending on the bit length of int, the would-be + value in these two files etc. the values may well be wrong and lead to 'funny' UID/GID + lookups. */ +#define FAIL_NOBODY -2 +#define FAIL_NOGROUP -2 + #define WILDCARD -1 typedef char *ugname;