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/0001-libsemanage-remove-use-of-getpwent_r.patch | |
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/0001-libsemanage-remove-use-of-getpwent_r.patch')
-rw-r--r-- | testing/libsemanage/0001-libsemanage-remove-use-of-getpwent_r.patch | 133 |
1 files changed, 133 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 + |