From dd15d1ed4787f79b3b1ffbda8e04f22a80c2afab Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Mar 05 2015 13:31:47 +0000 Subject: import libnfsidmap-0.25-11.el7 --- diff --git a/SOURCES/libnfsidmap-0.25-nobody.patch b/SOURCES/libnfsidmap-0.25-nobody.patch new file mode 100644 index 0000000..22a9f50 --- /dev/null +++ b/SOURCES/libnfsidmap-0.25-nobody.patch @@ -0,0 +1,108 @@ +commit f139de79d91e7773b5b98fe5aca5570f77c7aee9 +Author: Christian Seiler +Date: Wed Aug 13 12:42:14 2014 -0400 + + libnfsidmap: respect Nobody-User/Nobody-Group + + Previous behavior of libnfsidmap was to do a name lookup of + nobody@DEFAULTDOMAIN (for both user and group), which does not match + the behavior of rpc.idmapd. + + This patch makes libnfsidmap respect Nobody-User/Nobody-Group for + lookups, thus making the nfsidmap utility properly handle the case if + nobody@DEFAULTDOMAIN does not directly map to any user/group on the + system. + + Signed-off-by: Christian Seiler + Signed-off-by: Steve Dickson + +diff --git a/libnfsidmap.c b/libnfsidmap.c +index 92bc493..ec5c141 100644 +--- a/libnfsidmap.c ++++ b/libnfsidmap.c +@@ -62,6 +62,8 @@ static struct conf_list *local_realms; + int idmap_verbosity = 0; + static struct mapping_plugin **nfs4_plugins = NULL; + static struct mapping_plugin **gss_plugins = NULL; ++uid_t nobody_uid = (uid_t)-1; ++gid_t nobody_gid = (gid_t)-1; + + #ifndef PATH_PLUGINS + #define PATH_PLUGINS "/usr/lib/libnfsidmap" +@@ -228,6 +230,7 @@ int nfs4_init_name_mapping(char *conffile) + int ret = -ENOENT; + int dflt = 0; + struct conf_list *nfs4_methods, *gss_methods; ++ char *nobody_user, *nobody_group; + + /* XXX: need to be able to reload configurations... */ + if (nfs4_plugins) /* already succesfully initialized */ +@@ -324,6 +327,49 @@ int nfs4_init_name_mapping(char *conffile) + if (load_plugins(gss_methods, &gss_plugins) == -1) + goto out; + } ++ ++ nobody_user = conf_get_str("Mapping", "Nobody-User"); ++ if (nobody_user) { ++ size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX); ++ struct passwd *buf; ++ struct passwd *pw = NULL; ++ int err; ++ ++ buf = malloc(sizeof(*buf) + buflen); ++ if (buf) { ++ err = getpwnam_r(nobody_user, buf, ((char *)buf) + sizeof(*buf), buflen, &pw); ++ if (err == 0 && pw != NULL) ++ nobody_uid = pw->pw_uid; ++ else ++ IDMAP_LOG(1, ("libnfsidmap: Nobody-User (%s) not found: %s\n", ++ nobody_user, strerror(errno))); ++ free(buf); ++ } else ++ IDMAP_LOG(0,("libnfsidmap: Nobody-User: no memory : %s\n", ++ nobody_user, strerror(errno))); ++ } ++ ++ nobody_group = conf_get_str("Mapping", "Nobody-Group"); ++ if (nobody_group) { ++ size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX); ++ struct group *buf; ++ struct group *gr = NULL; ++ int err; ++ ++ buf = malloc(sizeof(*buf) + buflen); ++ if (buf) { ++ err = getgrnam_r(nobody_group, buf, ((char *)buf) + sizeof(*buf), buflen, &gr); ++ if (err == 0 && gr != NULL) ++ nobody_gid = gr->gr_gid; ++ else ++ IDMAP_LOG(1, ("libnfsidmap: Nobody-Group (%s) not found: %s\n", ++ nobody_group, strerror(errno))); ++ free(buf); ++ } else ++ IDMAP_LOG(0,("libnfsidmap: Nobody-Group: no memory : %s\n", ++ nobody_group, strerror(errno))); ++ } ++ + ret = 0; + out: + if (ret) { +@@ -453,6 +499,18 @@ static int set_id_to_nobody(int *id, int is_uid) + int rc = 0; + const char name[] = "nobody@"; + char nobody[strlen(name) + strlen(get_default_domain()) + 1]; ++ ++ /* First try to see whether a Nobody-User/Nobody-Group was ++ * configured, before we try to do a full lookup for the ++ * NFS nobody user. */ ++ if (is_uid && nobody_uid != (uid_t)-1) { ++ *id = (int)nobody_uid; ++ return 0; ++ } else if (!is_uid && nobody_gid != (gid_t)-1) { ++ *id = (int)nobody_gid; ++ return 0; ++ } ++ + strcpy(nobody, name); + strcat(nobody, get_default_domain()); + diff --git a/SOURCES/libnfsidmap-0.25-strrchr.patch b/SOURCES/libnfsidmap-0.25-strrchr.patch new file mode 100644 index 0000000..7b1e7a2 --- /dev/null +++ b/SOURCES/libnfsidmap-0.25-strrchr.patch @@ -0,0 +1,22 @@ +commit 309a89975a50bf53c408233a1bb5b10fd579ca30 +Author: Signed-off-by: Shijoe Panjikkaran +Date: Wed Apr 30 13:19:34 2014 -0400 + + nss: use strrchr() instead of strchr() to get the last occurrence of "@" + + Signed-off-by: Shijoe Panjikkaran + Signed-off-by: Steve Dickson + +diff --git a/nss.c b/nss.c +index b2b1227..f8129fe 100644 +--- a/nss.c ++++ b/nss.c +@@ -135,7 +135,7 @@ static char *strip_domain(const char *name, const char *domain) + char *l = NULL; + int len; + +- c = strchr(name, '@'); ++ c = strrchr(name, '@'); + if (c == NULL && domain != NULL) + goto out; + if (c == NULL && domain == NULL) { diff --git a/SOURCES/libnfsidmap-0.25-warnings.patch b/SOURCES/libnfsidmap-0.25-warnings.patch new file mode 100644 index 0000000..223a689 --- /dev/null +++ b/SOURCES/libnfsidmap-0.25-warnings.patch @@ -0,0 +1,253 @@ +diff -up libnfsidmap-0.25/configure.ac.orig libnfsidmap-0.25/configure.ac +--- libnfsidmap-0.25/configure.ac.orig 2014-10-21 10:56:09.384577000 -0400 ++++ libnfsidmap-0.25/configure.ac 2014-10-21 10:56:09.382575000 -0400 +@@ -0,0 +1,67 @@ ++# -*- Autoconf -*- ++# Process this file with autoconf to produce a configure script. ++ ++AC_PREREQ([2.68]) ++AC_INIT([libnfsidmap],[0.25],[linux-nfs@vger.kernel.org]) ++AC_CONFIG_SRCDIR([nfsidmap.h]) ++AC_CONFIG_MACRO_DIR([m4]) ++AM_INIT_AUTOMAKE ++LT_INIT ++ ++# Checks for programs. ++AC_PROG_CC ++ ++# Checks for libraries. ++ ++AC_ARG_ENABLE([ldap], ++ [AS_HELP_STRING([--disable-ldap],[Disable support for LDAP @<:@default=detect@:>@])]) ++if test "x$enable_ldap" != "xno" ; then ++ AC_CHECK_HEADER([ldap.h], ++ [AC_CHECK_LIB([ldap], [ldap_initialize], ++ [have_ldap="yes"],[have_ldap="no"])], ++ [have_ldap="no"]) ++ if test "x$have_ldap" = "xyes" ; then ++ AC_DEFINE([ENABLE_LDAP], 1, [Enable LDAP Support]) ++ elif test "x$enable_ldap$have_ldap" = "xyesno" ; then ++ AC_MSG_ERROR(LDAP support not found!) ++ fi ++fi ++AM_CONDITIONAL(ENABLE_LDAP, test "x$have_ldap" = "xyes") ++ ++# Should we build gums mapping library? ++AC_ARG_ENABLE([gums], ++ [AS_HELP_STRING([--enable-gums],[Enable support for the GUMS mapping library @<:@default=false@:>@])]) ++if test "x$enable_gums" = "xyes" ; then ++ AC_DEFINE([ENABLE_GUMS], 1, [Enable GUMS mapping library support]) ++fi ++AM_CONDITIONAL(ENABLE_GUMS, test "x$enable_gums" = "xyes") ++ ++#Where do the Plugins live ++AC_ARG_WITH(pluginpath, ++ [AS_HELP_STRING([--with-pluginpath=/foo],[Causes the library to look in /foo instead of /usr/lib/libnfsidmap for plugins ++ ])], ++ path_plugins=$withval, ++ path_plugins="" ++ ) ++if test -n "$path_plugins" ; then ++ AC_DEFINE_UNQUOTED(PATH_PLUGINS, "$path_plugins", ++ [Define this to change the plugins path]) ++fi ++AM_CONDITIONAL(PATH_PLUGINS, test -n "$path_plugins") ++ ++AC_CONFIG_HEADERS([./config.h]) ++# Checks for header files. ++AC_HEADER_STDC ++AC_CHECK_HEADERS([stdlib.h string.h unistd.h errno.h]) ++ ++# Checks for typedefs, structures, and compiler characteristics. ++AC_TYPE_UID_T ++AC_TYPE_SIZE_T ++ ++# Checks for library functions. ++AC_FUNC_MALLOC ++AC_CHECK_FUNCS([strchr strdup]) ++ ++AC_CONFIG_FILES([Makefile]) ++AC_CONFIG_FILES([libnfsidmap.pc]) ++AC_OUTPUT +diff -up libnfsidmap-0.25/configure.in.orig libnfsidmap-0.25/configure.in +--- libnfsidmap-0.25/configure.in.orig 2011-12-05 15:48:54.000000000 -0500 ++++ libnfsidmap-0.25/configure.in 2014-10-21 10:56:09.388579000 -0400 +@@ -1,67 +0,0 @@ +-# -*- Autoconf -*- +-# Process this file with autoconf to produce a configure script. +- +-AC_PREREQ([2.68]) +-AC_INIT([libnfsidmap],[0.25],[linux-nfs@vger.kernel.org]) +-AC_CONFIG_SRCDIR([nfsidmap.h]) +-AC_CONFIG_MACRO_DIR([m4]) +-AM_INIT_AUTOMAKE +-LT_INIT +- +-# Checks for programs. +-AC_PROG_CC +- +-# Checks for libraries. +- +-AC_ARG_ENABLE([ldap], +- [AS_HELP_STRING([--disable-ldap],[Disable support for LDAP @<:@default=detect@:>@])]) +-if test "x$enable_ldap" != "xno" ; then +- AC_CHECK_HEADER([ldap.h], +- [AC_CHECK_LIB([ldap], [ldap_initialize], +- [have_ldap="yes"],[have_ldap="no"])], +- [have_ldap="no"]) +- if test "x$have_ldap" = "xyes" ; then +- AC_DEFINE([ENABLE_LDAP], 1, [Enable LDAP Support]) +- elif test "x$enable_ldap$have_ldap" = "xyesno" ; then +- AC_MSG_ERROR(LDAP support not found!) +- fi +-fi +-AM_CONDITIONAL(ENABLE_LDAP, test "x$have_ldap" = "xyes") +- +-# Should we build gums mapping library? +-AC_ARG_ENABLE([gums], +- [AS_HELP_STRING([--enable-gums],[Enable support for the GUMS mapping library @<:@default=false@:>@])]) +-if test "x$enable_gums" = "xyes" ; then +- AC_DEFINE([ENABLE_GUMS], 1, [Enable GUMS mapping library support]) +-fi +-AM_CONDITIONAL(ENABLE_GUMS, test "x$enable_gums" = "xyes") +- +-#Where do the Plugins live +-AC_ARG_WITH(pluginpath, +- [AS_HELP_STRING([--with-pluginpath=/foo],[Causes the library to look in /foo instead of /usr/lib/libnfsidmap for plugins +- ])], +- path_plugins=$withval, +- path_plugins="" +- ) +-if test -n "$path_plugins" ; then +- AC_DEFINE_UNQUOTED(PATH_PLUGINS, "$path_plugins", +- [Define this to change the plugins path]) +-fi +-AM_CONDITIONAL(PATH_PLUGINS, test -n "$path_plugins") +- +-AC_CONFIG_HEADERS([./config.h]) +-# Checks for header files. +-AC_HEADER_STDC +-AC_CHECK_HEADERS([stdlib.h string.h unistd.h errno.h]) +- +-# Checks for typedefs, structures, and compiler characteristics. +-AC_TYPE_UID_T +-AC_TYPE_SIZE_T +- +-# Checks for library functions. +-AC_FUNC_MALLOC +-AC_CHECK_FUNCS([strchr strdup]) +- +-AC_CONFIG_FILES([Makefile]) +-AC_CONFIG_FILES([libnfsidmap.pc]) +-AC_OUTPUT +diff -up libnfsidmap-0.25/libnfsidmap.c.orig libnfsidmap-0.25/libnfsidmap.c +--- libnfsidmap-0.25/libnfsidmap.c.orig 2014-10-21 10:55:29.626400000 -0400 ++++ libnfsidmap-0.25/libnfsidmap.c 2014-10-21 10:56:21.180926000 -0400 +@@ -98,7 +98,7 @@ static char * toupper_str(char *s) + return s; + } + +-static int id_as_chars(char *name, int *id) ++static int id_as_chars(char *name, uid_t *id) + { + long int value = strtol(name, NULL, 10); + +@@ -494,7 +494,7 @@ int nfs4_name_to_gid(char *name, gid_t * + RUN_TRANSLATIONS(name_to_gid, 0, name, gid); + } + +-static int set_id_to_nobody(int *id, int is_uid) ++static int set_id_to_nobody(uid_t *id, uid_t is_uid) + { + int rc = 0; + const char name[] = "nobody@"; +@@ -504,10 +504,10 @@ static int set_id_to_nobody(int *id, int + * configured, before we try to do a full lookup for the + * NFS nobody user. */ + if (is_uid && nobody_uid != (uid_t)-1) { +- *id = (int)nobody_uid; ++ *id = (uid_t)nobody_uid; + return 0; + } else if (!is_uid && nobody_gid != (gid_t)-1) { +- *id = (int)nobody_gid; ++ *id = (uid_t)nobody_gid; + return 0; + } + +@@ -542,7 +542,7 @@ int nfs4_group_owner_to_gid(char *name, + if (rc && id_as_chars(name, gid)) + rc = 0; + else if (rc) +- rc = set_id_to_nobody(gid, 0); ++ rc = set_id_to_nobody((uid_t *)gid, 0); + return rc; + } + +diff -up libnfsidmap-0.25/static.c.orig libnfsidmap-0.25/static.c +--- libnfsidmap-0.25/static.c.orig 2014-10-21 10:55:29.588399000 -0400 ++++ libnfsidmap-0.25/static.c 2014-10-21 10:56:21.186926000 -0400 +@@ -39,6 +39,7 @@ + #include + #include + #include ++#include + + #include "queue.h" + #include "cfg.h" +@@ -268,7 +269,6 @@ static int static_name_to_gid(char *name + + static int static_uid_to_name(uid_t uid, char *domain, char *name, size_t len) + { +- struct passwd *pw; + struct uid_mapping * um; + + for (um = LIST_FIRST (&uid_mappings[uid_hash (uid)]); um; +@@ -284,7 +284,6 @@ static int static_uid_to_name(uid_t uid, + + static int static_gid_to_name(gid_t gid, char *domain, char *name, size_t len) + { +- struct group *gr; + struct gid_mapping * gm; + + for (gm = LIST_FIRST (&gid_mappings[gid_hash (gid)]); gm; +@@ -305,7 +304,6 @@ static int static_gid_to_name(gid_t gid, + + static int static_init() { + int err; +- uid_t uid; + struct conf_list * princ_list = NULL; + struct conf_list_node * cln, *next; + struct uid_mapping * unode; +@@ -367,7 +365,7 @@ static int static_init() { + next = TAILQ_NEXT (cln, link); + + gr = static_getgrnam(cln->field, NULL, &err); +- if (!pw) { ++ if (!gr) { + continue; + } + +@@ -376,19 +374,19 @@ static int static_init() { + { + warnx("static_init: calloc (1, %lu) failed", + (unsigned long)sizeof *gnode); +- free(pw); ++ free(gr); + return -ENOMEM; + } +- gnode->gid = pw->pw_uid; ++ gnode->gid = gr->gr_gid; + gnode->principal = strdup(cln->field); + + gnode->localgroup = conf_get_str("Static", cln->field); + if (!gnode->localgroup) { +- free(pw); ++ free(gr); + return -ENOENT; + } + +- free(pw); ++ free(gr); + + LIST_INSERT_HEAD (&gid_mappings[gid_hash(gnode->gid)], gnode, link); + } diff --git a/SOURCES/libnfsidmap-0.25-zero-ids.patch b/SOURCES/libnfsidmap-0.25-zero-ids.patch new file mode 100644 index 0000000..a037570 --- /dev/null +++ b/SOURCES/libnfsidmap-0.25-zero-ids.patch @@ -0,0 +1,30 @@ +commit 3226c06989186d9cd60ba146df4e2898fee5047b +Author: Steve Dickson +Date: Wed Apr 30 11:14:22 2014 -0400 + + libnfsidmap: id_as_chars() fails zero value ids. + + Root has a zero value id which is valid and + should not be mapped to nfsnobody + + Signed-off-by: Steve Dickson + +diff --git a/libnfsidmap.c b/libnfsidmap.c +index 641d766..92bc493 100644 +--- a/libnfsidmap.c ++++ b/libnfsidmap.c +@@ -99,8 +99,12 @@ static char * toupper_str(char *s) + static int id_as_chars(char *name, int *id) + { + long int value = strtol(name, NULL, 10); +- if (value == 0) +- return 0; ++ ++ if (value == 0) { ++ /* zero value ids are valid */ ++ if (strcmp(name, "0") != 0) ++ return 0; ++ } + *id = (int)value; + return 1; + } diff --git a/SPECS/libnfsidmap.spec b/SPECS/libnfsidmap.spec index c3c3ab4..6f87062 100644 --- a/SPECS/libnfsidmap.spec +++ b/SPECS/libnfsidmap.spec @@ -3,7 +3,7 @@ Summary: NFSv4 User and Group ID Mapping Library Name: libnfsidmap Version: 0.25 -Release: 9%{?dist} +Release: 11%{?dist} Provides: nfs-utils-lib Obsoletes: nfs-utils-lib URL: http://www.citi.umich.edu/projects/nfsv4/linux/ @@ -12,6 +12,10 @@ License: BSD Source0: http://www.citi.umich.edu/projects/nfsv4/linux/libnfsidmap/%{name}-%{version}.tar.gz Patch001: libnfsidmap-0.26-rc3.patch +Patch002: libnfsidmap-0.25-zero-ids.patch +Patch003: libnfsidmap-0.25-nobody.patch +Patch004: libnfsidmap-0.25-strrchr.patch +Patch005: libnfsidmap-0.25-warnings.patch Group: System Environment/Libraries BuildRoot: %{_tmppath}/%{name}-%{version}-root @@ -39,6 +43,19 @@ developing programs which use the libnfsidmap library. %patch001 -p1 +# +# RHEL7.1 +# +# 1093093 - chown does not respect NFSv4 no_root_squash +%patch002 -p1 +# 1129790 - libnfsidmap: respect Nobody-User/Nobody-Group +%patch003 -p1 +# 1114053 - RFE: Make rpcidmap and NFS accept full qualified usernames as a user. +%patch004 -p1 +# 1152658 - A large number of warning occur when the source is compiled +%patch005 -p1 +rm -f configure.in + %build ./autogen.sh %configure --disable-static --with-pluginpath=%{_root_libdir}/%name @@ -80,6 +97,14 @@ rm -rf %{buildroot} %{_root_libdir}/*.so %changelog +* Tue Oct 21 2014 Steve Dickson 0.25-11 +- Accept full qualified usernames a a user (bz 1114053) +- Removed a number of warnings (bz 1152658) + +* Wed Sep 17 2014 Steve Dickson 0.25-10 +- id_as_chars() fails zero value ids (bz 1093093) +- respect Nobody-User/Nobody-Group (bz 1129790) + * Fri Jan 24 2014 Daniel Mach - 0.25-9 - Mass rebuild 2014-01-24