diff --git a/.libnfsidmap.metadata b/.libnfsidmap.metadata new file mode 100644 index 0000000..a6a08d4 --- /dev/null +++ b/.libnfsidmap.metadata @@ -0,0 +1 @@ +f52e143d33a3a8a8138be41a90f2cc956f1acea2 SOURCES/libnfsidmap-0.25.tar.gz diff --git a/README.md b/README.md deleted file mode 100644 index 0e7897f..0000000 --- a/README.md +++ /dev/null @@ -1,5 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 - -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/libnfsidmap-0.26-rc3.patch b/SOURCES/libnfsidmap-0.26-rc3.patch new file mode 100644 index 0000000..35eb9f2 --- /dev/null +++ b/SOURCES/libnfsidmap-0.26-rc3.patch @@ -0,0 +1,438 @@ +diff --git a/.gitignore b/.gitignore +index 6244609..d24d727 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -17,18 +17,13 @@ libnfsidmap.pc + libtool + .libs/ + libnfsidmap.la +-libnfsidmap_la-cfg.lo +-libnfsidmap_la-libnfsidmap.lo +-libnfsidmap_la-strlcpy.lo +-nss.lo + nsswitch.la + static.la +-static.lo + umich_ldap.la +-umich_ldap.lo + configure.in~ + m4/ + *.o ++*.lo + cscope.* + config.h + config.h.in +diff --git a/autogen.sh b/autogen.sh +index ee89987..c17f6be 100755 +--- a/autogen.sh ++++ b/autogen.sh +@@ -37,5 +37,6 @@ fi + + aclocal + libtoolize --force --copy +-autoupdate ++autoheader ++automake --add-missing --copy --gnu + autoreconf -vi -Wall +diff --git a/idmapd.conf.5 b/idmapd.conf.5 +index 9c7f1ae..de1bfa9 100644 +--- a/idmapd.conf.5 ++++ b/idmapd.conf.5 +@@ -31,7 +31,7 @@ + .\" + .TH idmapd.conf 5 "19 Nov 2008" + .SH NAME +-idmapd.conf ++idmapd.conf \- configuration file for libnfsidmap + .SH SYNOPSIS + Configuration file for libnfsidmap. Used by idmapd and svcgssd to map NFSv4 name to and from ids. + .SH DESCRIPTION +@@ -234,7 +234,6 @@ Number of seconds before timing out an LDAP request + .\" ------------------------------------------------------------------- + .\" + .SH EXAMPLES +-." + An example + .I /etc/idmapd.conf + file: +@@ -266,7 +265,7 @@ johndoe@OTHER.DOMAIN.ORG = johnny + LDAP_server = ldap.domain.org + LDAP_base = dc=org,dc=domain + +-.fo ++.fi + .\" + .\" ------------------------------------------------------------------- + .\" Additional sections +@@ -275,11 +274,11 @@ LDAP_base = dc=org,dc=domain + .SH SEE ALSO + .BR idmapd (8) + .BR svcgssd (8) +-.".SH COMPATIBILITY +-.".SH STANDARDS +-.".SH ACKNOWLEDGEMENTS +-.".SH AUTHORS +-.".SH HISTORY ++.\".SH COMPATIBILITY ++.\".SH STANDARDS ++.\".SH ACKNOWLEDGEMENTS ++.\".SH AUTHORS ++.\".SH HISTORY + .SH BUGS + Report bugs to +-.".SH CAVEATS ++.\".SH CAVEATS +diff --git a/libnfsidmap.c b/libnfsidmap.c +index 57bb6c3..641d766 100644 +--- a/libnfsidmap.c ++++ b/libnfsidmap.c +@@ -285,8 +285,9 @@ int nfs4_init_name_mapping(char *conffile) + } + buf = malloc(siz); + if (buf) { ++ *buf = 0; + TAILQ_FOREACH(r, &local_realms->fields, link) { +- sprintf(buf, "'%s' ", r->field); ++ sprintf(buf+strlen(buf), "'%s' ", r->field); + } + IDMAP_LOG(1, ("libnfsidmap: Realms list: %s", buf)); + free(buf); +diff --git a/static.c b/static.c +index fffd458..8be87e8 100644 +--- a/static.c ++++ b/static.c +@@ -40,6 +40,7 @@ + #include + #include + ++#include "queue.h" + #include "cfg.h" + #include "nfsidmap.h" + #include "nfsidmap_internal.h" +@@ -57,6 +58,40 @@ struct pwbuf { + char buf[1]; + }; + ++struct grbuf { ++ struct group grbuf; ++ char buf[1]; ++}; ++ ++struct uid_mapping { ++ LIST_ENTRY (uid_mapping) link; ++ uid_t uid; ++ char * principal; ++ char * localname; ++}; ++ ++struct gid_mapping { ++ LIST_ENTRY (gid_mapping) link; ++ gid_t gid; ++ char * principal; ++ char * localgroup; ++}; ++ ++static __inline__ u_int8_t uid_hash (uid_t uid) ++{ ++ return uid % 256; ++} ++ ++static __inline__ u_int8_t gid_hash (gid_t gid) ++{ ++ return gid % 256; ++} ++ ++//Hash tables of uid and guids to principals mappings. ++//We reuse some queue/hash functions from cfg.c. ++LIST_HEAD (uid_mappings, uid_mapping) uid_mappings[256]; ++LIST_HEAD (gid_mappings, gid_mapping) gid_mappings[256]; ++ + static struct passwd *static_getpwnam(const char *name, const char *domain, + int *err_p) + { +@@ -75,12 +110,9 @@ static struct passwd *static_getpwnam(const char *name, const char *domain, + localname = conf_get_str("Static", (char *)name); + if (!localname) { + err = ENOENT; +- goto err; ++ goto err_free_buf; + } + +- IDMAP_LOG(4, ("static_getpwnam: name '%s' mapped to '%s'\n", +- name, localname)); +- + again: + err = getpwnam_r(localname, &buf->pwbuf, buf->buf, buflen, &pw); + +@@ -91,12 +123,15 @@ again: + if (err == 0) + err = ENOENT; + +- IDMAP_LOG(0, ("static_getpwnam: name '%s' not found\n", +- localname)); ++ IDMAP_LOG(0, ("static_getpwnam: localname '%s' for '%s' not found\n", ++ localname, name)); + + goto err_free_buf; + } + ++ IDMAP_LOG(4, ("static_getpwnam: name '%s' mapped to '%s'\n", ++ name, localname)); ++ + *err_p = 0; + return pw; + +@@ -107,6 +142,56 @@ err: + return NULL; + } + ++static struct group *static_getgrnam(const char *name, const char *domain, ++ int *err_p) ++{ ++ struct group *gr; ++ struct grbuf *buf; ++ size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX); ++ char *localgroup; ++ int err; ++ ++ buf = malloc(sizeof(*buf) + buflen); ++ if (!buf) { ++ err = ENOMEM; ++ goto err; ++ } ++ ++ localgroup = conf_get_str("Static", (char *)name); ++ if (!localgroup) { ++ err = ENOENT; ++ goto err_free_buf; ++ } ++ ++again: ++ err = getgrnam_r(localgroup, &buf->grbuf, buf->buf, buflen, &gr); ++ ++ if (err == EINTR) ++ goto again; ++ ++ if (!gr) { ++ if (err == 0) ++ err = ENOENT; ++ ++ IDMAP_LOG(0, ("static_getgrnam: local group '%s' for '%s' not found\n", ++ localgroup, name)); ++ ++ goto err_free_buf; ++ } ++ ++ IDMAP_LOG(4, ("static_getgrnam: group '%s' mapped to '%s'\n", ++ name, localgroup)); ++ ++ *err_p = 0; ++ return gr; ++ ++err_free_buf: ++ free(buf); ++err: ++ *err_p = err; ++ return NULL; ++} ++ + static int static_gss_princ_to_ids(char *secname, char *princ, + uid_t *uid, uid_t *gid, + extra_mapping_params **ex) +@@ -151,14 +236,173 @@ static int static_gss_princ_to_grouplist(char *secname, char *princ, + return -err; + } + ++static int static_name_to_uid(char *name, uid_t *uid) ++{ ++ struct passwd *pw; ++ int err; ++ ++ pw = static_getpwnam(name, NULL, &err); ++ ++ if (pw) { ++ *uid = pw->pw_uid; ++ free(pw); ++ } ++ ++ return -err; ++} ++ ++static int static_name_to_gid(char *name, gid_t *gid) ++{ ++ struct group *gr; ++ int err; ++ ++ gr = static_getgrnam(name, NULL, &err); ++ ++ if (gr) { ++ *gid = gr->gr_gid; ++ free(gr); ++ } ++ ++ return -err; ++} ++ ++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; ++ um = LIST_NEXT (um, link)) { ++ if (um->uid == uid) { ++ strcpy(name, um->principal); ++ return 0; ++ } ++ } ++ ++ return -ENOENT; ++} ++ ++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; ++ gm = LIST_NEXT (gm, link)) { ++ if (gm->gid == gid) { ++ strcpy(name, gm->principal); ++ return 0; ++ } ++ } ++ ++ return -ENOENT; ++} ++ ++/* ++ * We buffer all UID's for which static mappings is defined in advance, so the ++ * uid_to_name functions will be fast enough. ++ */ ++ ++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; ++ struct gid_mapping * gnode; ++ struct passwd * pw = NULL; ++ struct group * gr = NULL; ++ unsigned int i; ++ ++ //init hash_table first ++ for (i = 0; i < sizeof uid_mappings / sizeof uid_mappings[0]; i++) ++ LIST_INIT (&uid_mappings[i]); ++ ++ //get all principals for which we have mappings ++ princ_list = conf_get_tag_list("Static"); ++ ++ if (!princ_list) { ++ return -ENOENT; ++ } ++ ++ /* As we can not distinguish between mappings for users and groups, we try to ++ * resolve all mappings for both cases. ++ */ ++ ++ //resolve uid of localname account for all such principals and cache it ++ for (cln = TAILQ_FIRST (&princ_list->fields); cln; cln = next) ++ { ++ next = TAILQ_NEXT (cln, link); ++ ++ pw = static_getpwnam(cln->field, NULL, &err); ++ if (!pw) { ++ continue; ++ } ++ ++ unode = calloc (1, sizeof *unode); ++ if (!unode) ++ { ++ warnx("static_init: calloc (1, %lu) failed", ++ (unsigned long)sizeof *unode); ++ free(pw); ++ return -ENOMEM; ++ } ++ unode->uid = pw->pw_uid; ++ unode->principal = strdup(cln->field); ++ ++ unode->localname = conf_get_str("Static", cln->field); ++ if (!unode->localname) { ++ free(pw); ++ return -ENOENT; ++ } ++ ++ free(pw); ++ ++ LIST_INSERT_HEAD (&uid_mappings[uid_hash(unode->uid)], unode, link); ++ } ++ ++ //resolve gid of localgroup accounts and cache it ++ for (cln = TAILQ_FIRST (&princ_list->fields); cln; cln = next) ++ { ++ next = TAILQ_NEXT (cln, link); ++ ++ gr = static_getgrnam(cln->field, NULL, &err); ++ if (!pw) { ++ continue; ++ } ++ ++ gnode = calloc (1, sizeof *gnode); ++ if (!gnode) ++ { ++ warnx("static_init: calloc (1, %lu) failed", ++ (unsigned long)sizeof *gnode); ++ free(pw); ++ return -ENOMEM; ++ } ++ gnode->gid = pw->pw_uid; ++ gnode->principal = strdup(cln->field); ++ ++ gnode->localgroup = conf_get_str("Static", cln->field); ++ if (!gnode->localgroup) { ++ free(pw); ++ return -ENOENT; ++ } ++ ++ free(pw); ++ ++ LIST_INSERT_HEAD (&gid_mappings[gid_hash(gnode->gid)], gnode, link); ++ } ++ return 0; ++} ++ + + struct trans_func static_trans = { + .name = "static", +- .init = NULL, +- .name_to_uid = NULL, +- .name_to_gid = NULL, +- .uid_to_name = NULL, +- .gid_to_name = NULL, ++ .init = static_init, ++ .name_to_uid = static_name_to_uid, ++ .name_to_gid = static_name_to_gid, ++ .uid_to_name = static_uid_to_name, ++ .gid_to_name = static_gid_to_name, + .princ_to_ids = static_gss_princ_to_ids, + .gss_princ_to_grouplist = static_gss_princ_to_grouplist, + }; +diff --git a/umich_ldap.c b/umich_ldap.c +index f482b0a..b527c5d 100644 +--- a/umich_ldap.c ++++ b/umich_ldap.c +@@ -32,8 +32,6 @@ + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +-#ifdef ENABLE_LDAP +- + #include + #include + #include +@@ -1302,4 +1300,3 @@ struct trans_func *libnfsidmap_plugin_init() + { + return (&umichldap_trans); + } +-#endif diff --git a/SPECS/libnfsidmap.spec b/SPECS/libnfsidmap.spec new file mode 100644 index 0000000..7c3e76d --- /dev/null +++ b/SPECS/libnfsidmap.spec @@ -0,0 +1,135 @@ +%define _root_libdir /%{_lib} + +Summary: NFSv4 User and Group ID Mapping Library +Name: libnfsidmap +Version: 0.25 +Release: 7%{?dist} +Provides: nfs-utils-lib +Obsoletes: nfs-utils-lib +URL: http://www.citi.umich.edu/projects/nfsv4/linux/ +License: BSD + +Source0: http://www.citi.umich.edu/projects/nfsv4/linux/libnfsidmap/%{name}-%{version}.tar.gz + +Patch001: libnfsidmap-0.26-rc3.patch + +Group: System Environment/Libraries +BuildRoot: %{_tmppath}/%{name}-%{version}-root +BuildRequires: pkgconfig, openldap-devel +BuildRequires: automake, libtool +Requires(postun): /sbin/ldconfig +Requires(pre): /sbin/ldconfig +Requires: openldap + +%description +Library that handles mapping between names and ids for NFSv4. + +%package devel +Summary: Development files for the libnfsidmap library +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Requires: pkgconfig + +%description devel +This package includes header files and libraries necessary for +developing programs which use the libnfsidmap library. + +%prep +%setup -q + +%patch001 -p1 + +%build +./autogen.sh +%configure --disable-static --with-pluginpath=%{_root_libdir}/%name +make %{?_smp_mflags} all + +%install +rm -rf %{buildroot} +make install DESTDIR=%{buildroot} \ + libdir=%{_root_libdir} pkgconfigdir=%{_libdir}/pkgconfig + +mkdir -p %{buildroot}%{_sysconfdir} +mkdir -p %{buildroot}%{_mandir}/man5 + +install -m 644 idmapd.conf %{buildroot}%{_sysconfdir}/idmapd.conf + +# Delete unneeded libtool libs +rm -rf %{buildroot}%{_root_libdir}/*.{a,la} +rm -rf %{buildroot}%{_root_libdir}/%{name}/*.{a,la} + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root,-) +%doc AUTHORS ChangeLog NEWS README COPYING +%config(noreplace) %{_sysconfdir}/idmapd.conf +%{_root_libdir}/*.so.* +%{_root_libdir}/%{name}/*.so +%{_mandir}/*/* + +%files devel +%defattr(0644,root,root,755) +%{_libdir}/pkgconfig/libnfsidmap.pc +%{_includedir}/nfsidmap.h +%{_root_libdir}/*.so + +%changelog +* Mon Aug 19 2013 Ville Skyttä - 0.25-7 +- Updated to latest rc release: libnfsidmap-0-26-rc3 + +* Fri Jul 26 2013 Ville Skyttä - 0.25-6 +- Drop unnecessary doc dir references from specfile. +- Fix bogus dates in %%changelog. + +* Thu Feb 14 2013 Fedora Release Engineering - 0.25-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Thu Jul 19 2012 Fedora Release Engineering - 0.25-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Tue Jun 19 2012 Steve Dickson 0.20-3 +- Updated to latest rc release: libnfsidmap-0-26-rc1 + +* Mon Mar 19 2012 Steve Dickson 0.20-2 +- Fixed Local-Realms debugging (bz 804152) + +* Fri Jan 13 2012 Fedora Release Engineering - 0.25-1 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Tue Dec 6 2011 Steve Dickson 0.20-0 +- Updated to latest release: libnfsidmap-0.25 + +* Mon Nov 14 2011 Steve Dickson 0.24-7 +- Updated to latest rc release: libnfsidmap-0-25-rc3 (bz 753930) + +* Mon Mar 7 2011 Steve Dickson 0.24-6 +- Updated to latest rc release: libnfsidmap-0-25-rc2 + +* Tue Feb 08 2011 Fedora Release Engineering - 0.24-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Fri Jan 14 2011 Steve Dickson 0.24-4 +- Updated to latest rc release: libnfsidmap-0-25-rc1 + +* Wed Dec 22 2010 Steve Dickson 0.24-3 +- Used the newly added --with-pluginpath config flag to + redefine where the plugins live (bz 664641). + +* Fri Dec 10 2010 Steve Dickson 0.24-2 +- Removed the versions from the Provides: and Obsoletes: lines + +* Wed Dec 8 2010 Steve Dickson 0.24-1 +- Updated to latest upstream release: 0.24 +- Obsoleted nfs-utils-lib + +* Tue Dec 7 2010 Steve Dickson 0.23-3 +- Maded corrections in spec per review comments. + +* Fri Dec 3 2010 Steve Dickson 0.23-2 +- Initial commit