diff options
author | Tycho Andersen <tycho@docker.com> | 2017-03-14 21:08:11 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2017-03-16 10:06:43 +0000 |
commit | 6ea01c2b7f22db87a0259a1bc53e249427a7cf0f (patch) | |
tree | 663481d2610473b22eddbd58389ffad3107f214f /testing/libsemanage | |
parent | b336118caf32616d8c5cf69c2eaf38683685898b (diff) | |
download | aports-6ea01c2b7f22db87a0259a1bc53e249427a7cf0f.tar.bz2 aports-6ea01c2b7f22db87a0259a1bc53e249427a7cf0f.tar.xz |
testing/libsemanage: initial import
Signed-off-by: Tycho Andersen <tycho@docker.com>
Diffstat (limited to 'testing/libsemanage')
-rw-r--r-- | testing/libsemanage/0001-libsemanage-remove-use-of-getpwent_r.patch | 133 | ||||
-rw-r--r-- | testing/libsemanage/APKBUILD | 30 |
2 files changed, 163 insertions, 0 deletions
diff --git a/testing/libsemanage/0001-libsemanage-remove-use-of-getpwent_r.patch b/testing/libsemanage/0001-libsemanage-remove-use-of-getpwent_r.patch new file mode 100644 index 0000000000..9547e8d0d4 --- /dev/null +++ b/testing/libsemanage/0001-libsemanage-remove-use-of-getpwent_r.patch @@ -0,0 +1,133 @@ +From 687398b9df5a8fc2d17bd9d83e067812980ec853 Mon Sep 17 00:00:00 2001 +From: Tycho Andersen <tycho@docker.com> +Date: Tue, 14 Mar 2017 13:57:35 -0700 +Subject: [PATCH] libsemanage: remove use of getpwent_r + +getpwent_r isn't really re-entrant, and the _r version is a GNU extension, +which won't work with libcs that don't implement it. Let's just use +getpwent instead. + +Signed-off-by: Tycho Andersen <tycho@docker.com> +--- + src/genhomedircon.c | 54 ++++++++++++++++++----------------------- + 1 file changed, 24 insertions(+), 30 deletions(-) + +diff --git a/src/genhomedircon.c b/libsemanage/src/genhomedircon.c +index 465dd88..839280b 100644 +--- a/src/genhomedircon.c ++++ b/src/genhomedircon.c +@@ -290,14 +290,11 @@ static semanage_list_t *get_home_dirs(genhomedircon_settings_t * s) + semanage_list_t *homedir_list = NULL; + semanage_list_t *shells = NULL; + fc_match_handle_t hand; +- char *rbuf = NULL; + char *path = NULL; +- long rbuflen; + uid_t temp, minuid = 500, maxuid = 60000; + int minuid_set = 0; +- struct passwd pwstorage, *pwbuf; ++ struct passwd *pwbuf; + struct stat buf; +- int retval; + + path = semanage_findval(PATH_ETC_USERADD, "HOME", "="); + if (path && *path) { +@@ -362,14 +359,18 @@ static semanage_list_t *get_home_dirs(genhomedircon_settings_t * s) + free(path); + path = NULL; + +- rbuflen = sysconf(_SC_GETPW_R_SIZE_MAX); +- if (rbuflen <= 0) +- goto fail; +- rbuf = malloc(rbuflen); +- if (rbuf == NULL) +- goto fail; + setpwent(); +- while ((retval = getpwent_r(&pwstorage, rbuf, rbuflen, &pwbuf)) == 0) { ++ while (1) { ++ errno = 0; ++ pwbuf = getpwent(); ++ if (!pwbuf) { ++ if (errno) { ++ WARN(s->h_semanage, "Error while fetching users. " ++ "Returning list so far."); ++ } ++ break; ++ } ++ + if (pwbuf->pw_uid < minuid || pwbuf->pw_uid > maxuid) + continue; + if (!semanage_list_find(shells, pwbuf->pw_shell)) +@@ -413,23 +414,16 @@ static semanage_list_t *get_home_dirs(genhomedircon_settings_t * s) + path = NULL; + } + +- if (retval && retval != ENOENT) { +- WARN(s->h_semanage, "Error while fetching users. " +- "Returning list so far."); +- } +- + if (semanage_list_sort(&homedir_list)) + goto fail; + + endpwent(); +- free(rbuf); + semanage_list_destroy(&shells); + + return homedir_list; + + fail: + endpwent(); +- free(rbuf); + free(path); + semanage_list_destroy(&homedir_list); + semanage_list_destroy(&shells); +@@ -1063,9 +1057,7 @@ static int get_group_users(genhomedircon_settings_t * s, + char *grbuf = NULL; + struct group grstorage, *group = NULL; + +- long prbuflen; +- char *pwbuf = NULL; +- struct passwd pwstorage, *pw = NULL; ++ struct passwd *pw = NULL; + + grbuflen = sysconf(_SC_GETGR_R_SIZE_MAX); + if (grbuflen <= 0) +@@ -1102,15 +1094,18 @@ static int get_group_users(genhomedircon_settings_t * s, + } + } + +- prbuflen = sysconf(_SC_GETPW_R_SIZE_MAX); +- if (prbuflen <= 0) +- goto cleanup; +- pwbuf = malloc(prbuflen); +- if (pwbuf == NULL) +- goto cleanup; +- + setpwent(); +- while ((retval = getpwent_r(&pwstorage, pwbuf, prbuflen, &pw)) == 0) { ++ while (1) { ++ errno = 0; ++ pw = getpwent(); ++ if (!pw) { ++ if (errno) { ++ WARN(s->h_semanage, "Error while fetching groups. " ++ "Returning list so far."); ++ } ++ break; ++ } ++ + // skip users who also have this group as their + // primary group + if (lfind(pw->pw_name, group->gr_mem, &nmembers, +@@ -1129,7 +1124,6 @@ static int get_group_users(genhomedircon_settings_t * s, + retval = STATUS_SUCCESS; + cleanup: + endpwent(); +- free(pwbuf); + free(grbuf); + + return retval; +-- +2.9.3 + diff --git a/testing/libsemanage/APKBUILD b/testing/libsemanage/APKBUILD new file mode 100644 index 0000000000..d4f2278df4 --- /dev/null +++ b/testing/libsemanage/APKBUILD @@ -0,0 +1,30 @@ +# Contributor: Tycho Andersen <tycho@docker.com> +# Maintainer: Tycho Andersen <tycho@docker.com> +pkgname=libsemanage +pkgver=2.6 +pkgrel=0 +pkgdesc="SELinux binary policy manipulation library " +url="https://github.com/SELinuxProject/selinux/wiki" +arch="all" +license="LGPLv2+" +depends="" +depends_dev="" +makedepends="$depends_dev libselinux-dev libsepol-dev bzip2-dev ustr-dev bison flex" +install="" +subpackages="$pkgname-dev $pkgname-doc" +source="https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20161014/libsemanage-$pkgver.tar.gz + 0001-libsemanage-remove-use-of-getpwent_r.patch" +builddir="$srcdir/libsemanage-$pkgver" + +build() { + cd "$builddir" + make || return 1 +} + +package() { + cd "$builddir" + make DESTDIR="$pkgdir" install || return 1 +} + +sha512sums="38741d6e6f7a2669bfeee362e42d6bfd720cceeaf61331e329b2210fdc070444e529656ce86dd82e94aa248eafcfaea4c5d013d9cce76c1039be6fc6a6b2c790 libsemanage-2.6.tar.gz +ef5040bc015673266fc46284a8dc84b3316d6dd7bcc3a2c4ba4dd6e2d35a0d0c6984e72648c60739e4d97570941b7da07a6a2c98959c3b446bc0cae706d23441 0001-libsemanage-remove-use-of-getpwent_r.patch" |