Fix patch that Handles substitutions for /

This commit is contained in:
Dan Walsh 2013-05-06 09:43:03 -04:00
parent def2153558
commit 4720ddb09f
2 changed files with 18 additions and 5 deletions

View File

@ -653,19 +653,29 @@ index b9e8002..355730a 100644
hidden_def(get_ordered_context_list) hidden_def(get_ordered_context_list)
diff --git a/libselinux/src/label.c b/libselinux/src/label.c diff --git a/libselinux/src/label.c b/libselinux/src/label.c
index 11f6e96..9bf79c5 100644 index 11f6e96..f5cb52a 100644
--- a/libselinux/src/label.c --- a/libselinux/src/label.c
+++ b/libselinux/src/label.c +++ b/libselinux/src/label.c
@@ -48,6 +48,9 @@ static char *selabel_sub(struct selabel_sub *ptr, const char *src) @@ -43,12 +43,18 @@ static void selabel_subs_fini(struct selabel_sub *ptr)
static char *selabel_sub(struct selabel_sub *ptr, const char *src)
{
char *dst = NULL;
+ int len;
while (ptr) {
if (strncmp(src, ptr->src, ptr->slen) == 0 ) { if (strncmp(src, ptr->src, ptr->slen) == 0 ) {
if (src[ptr->slen] == '/' || if (src[ptr->slen] == '/' ||
src[ptr->slen] == 0) { src[ptr->slen] == 0) {
- if (asprintf(&dst, "%s%s", ptr->dst, &src[ptr->slen]) < 0)
+ if ((src[ptr->slen] == '/') && + if ((src[ptr->slen] == '/') &&
+ (strcmp(ptr->dst, "/") == 0)) + (strcmp(ptr->dst, "/") == 0))
+ ptr->slen++; + len = ptr->slen + 1;
if (asprintf(&dst, "%s%s", ptr->dst, &src[ptr->slen]) < 0) + else
+ len = ptr->slen;
+ if (asprintf(&dst, "%s%s", ptr->dst, &src[len]) < 0)
return NULL; return NULL;
return dst; return dst;
}
diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c
index 5f697f3..9b0d6b0 100644 index 5f697f3..9b0d6b0 100644
--- a/libselinux/src/label_file.c --- a/libselinux/src/label_file.c

View File

@ -10,7 +10,7 @@
Summary: SELinux library and simple utilities Summary: SELinux library and simple utilities
Name: libselinux Name: libselinux
Version: 2.1.13 Version: 2.1.13
Release: 14%{?dist} Release: 15%{?dist}
License: Public Domain License: Public Domain
Group: System Environment/Libraries Group: System Environment/Libraries
Source: %{name}-%{version}.tgz Source: %{name}-%{version}.tgz
@ -241,6 +241,9 @@ rm -rf %{buildroot}
%{ruby_sitearch}/selinux.so %{ruby_sitearch}/selinux.so
%changelog %changelog
* Mon May 6 2013 Dan Walsh <dwalsh@redhat.com> - 2.1.13-15
- Fix patch that Handles substitutions for /
* Wed Apr 17 2013 Dan Walsh <dwalsh@redhat.com> - 2.1.13-14 * Wed Apr 17 2013 Dan Walsh <dwalsh@redhat.com> - 2.1.13-14
- Handle substitutions for / - Handle substitutions for /
- semanage fcontext -a -e / /opt/rh/devtoolset-2/root - semanage fcontext -a -e / /opt/rh/devtoolset-2/root