summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Goldstein <cardoe@cardoe.com>2017-02-02 09:47:35 -0600
committerJoe MacDonald <joe_macdonald@mentor.com>2017-05-02 09:21:35 -0400
commit9ac187d71cf489b42c3897118d9b1110b7cf8538 (patch)
treeafa2411d9a2fea7b5f27da460f6303b0517abc05
parent60ec38e8fa76b7954a84e0498aea483f0c458ffd (diff)
downloadmeta-selinux-9ac187d71cf489b42c3897118d9b1110b7cf8538.tar.gz
libsemanage: remove dependency on ustr
Use the upstream patches to remove the dependency on ustr which no longer builds with new versions of GCC and the author is unresponsive and the site hosting the code is down. Signed-off-by: Doug Goldstein <cardoe@cardoe.com> Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
-rw-r--r--recipes-security/selinux/libsemanage.inc2
-rw-r--r--recipes-security/selinux/libsemanage/0001-libsemanage-simplify-string-utilities-functions.patch115
-rw-r--r--recipes-security/selinux/libsemanage/0002-libsemanage-add-semanage_str_replace-utility-functio.patch164
-rw-r--r--recipes-security/selinux/libsemanage/0003-libsemanage-genhomedircon-drop-ustr-dependency.patch323
-rw-r--r--recipes-security/selinux/libsemanage/0004-libsemanage-remove-ustr-library-from-Makefiles-READM.patch61
-rw-r--r--recipes-security/selinux/libsemanage_2.6.bb4
6 files changed, 668 insertions, 1 deletions
diff --git a/recipes-security/selinux/libsemanage.inc b/recipes-security/selinux/libsemanage.inc
index d952170..504101d 100644
--- a/recipes-security/selinux/libsemanage.inc
+++ b/recipes-security/selinux/libsemanage.inc
@@ -8,7 +8,7 @@ LICENSE = "LGPLv2.1+"
8 8
9inherit lib_package python-dir 9inherit lib_package python-dir
10 10
11DEPENDS += "libsepol libselinux ustr bzip2 python bison-native flex-native swig-native" 11DEPENDS += "libsepol libselinux bzip2 python bison-native flex-native swig-native"
12DEPENDS_append_class-target += "audit" 12DEPENDS_append_class-target += "audit"
13 13
14# For /usr/libexec/selinux/semanage_migrate_store 14# For /usr/libexec/selinux/semanage_migrate_store
diff --git a/recipes-security/selinux/libsemanage/0001-libsemanage-simplify-string-utilities-functions.patch b/recipes-security/selinux/libsemanage/0001-libsemanage-simplify-string-utilities-functions.patch
new file mode 100644
index 0000000..fd478d0
--- /dev/null
+++ b/recipes-security/selinux/libsemanage/0001-libsemanage-simplify-string-utilities-functions.patch
@@ -0,0 +1,115 @@
1From 514a5df959ea0e13db4e87f73c2ac5edcceebd52 Mon Sep 17 00:00:00 2001
2From: Nicolas Iooss <nicolas.iooss@m4x.org>
3Date: Wed, 21 Dec 2016 19:21:01 +0100
4Subject: [PATCH 1/4] libsemanage: simplify string utilities functions
5
6Use string functions from C standard library instead of ustr. This makes
7the code simpler and make utilities.c no longer depend on ustr library.
8
9This changes how semanage_split() behaves when delim is not empty (NULL
10or "") and the input string contains several successive delimiters:
11semanage_split("foo::::bar", ":") returned "bar" and now returns ":bar".
12This would not have any impact in the current code as semanage_split()
13is only called with delim="=" (through semanage_findval(), in
14libsemanage/src/genhomedircon.c), in order to split a "key=value"
15statement.
16
17Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
18(cherry picked from commit a228bb3736c5957d41ad9e01eb1283fc6883a6e5)
19---
20 libsemanage/src/utilities.c | 59 ++++++++++-----------------------------------
21 1 file changed, 13 insertions(+), 46 deletions(-)
22
23diff --git a/libsemanage/src/utilities.c b/libsemanage/src/utilities.c
24index f48ffa4..fa86cc7 100644
25--- a/libsemanage/src/utilities.c
26+++ b/libsemanage/src/utilities.c
27@@ -26,7 +26,6 @@
28 #include <string.h>
29 #include <sys/types.h>
30 #include <assert.h>
31-#include <ustr.h>
32
33 #define TRUE 1
34 #define FALSE 0
35@@ -74,64 +73,32 @@ char *semanage_split_on_space(const char *str)
36 {
37 /* as per the man page, these are the isspace() chars */
38 const char *seps = "\f\n\r\t\v ";
39- size_t slen = strlen(seps);
40- size_t off = 0, rside_len = 0;
41- char *retval = NULL;
42- Ustr *ustr = USTR_NULL, *temp = USTR_NULL;
43+ size_t off = 0;
44
45 if (!str)
46- goto done;
47- if (!(ustr = ustr_dup_cstr(str)))
48- goto done;
49- temp =
50- ustr_split_spn_chrs(ustr, &off, seps, slen, USTR_NULL,
51- USTR_FLAG_SPLIT_DEF);
52- if (!temp)
53- goto done;
54- /* throw away the left hand side */
55- ustr_sc_free(&temp);
56-
57- rside_len = ustr_len(ustr) - off;
58- temp = ustr_dup_subustr(ustr, off + 1, rside_len);
59- if (!temp)
60- goto done;
61- retval = strdup(ustr_cstr(temp));
62- ustr_sc_free(&temp);
63+ return NULL;
64
65- done:
66- ustr_sc_free(&ustr);
67- return retval;
68+ /* skip one token and the spaces before and after it */
69+ off = strspn(str, seps);
70+ off += strcspn(str + off, seps);
71+ off += strspn(str + off, seps);
72+ return strdup(str + off);
73 }
74
75 char *semanage_split(const char *str, const char *delim)
76 {
77- Ustr *ustr = USTR_NULL, *temp = USTR_NULL;
78- size_t off = 0, rside_len = 0;
79- char *retval = NULL;
80+ char *retval;
81
82 if (!str)
83- goto done;
84+ return NULL;
85 if (!delim || !(*delim))
86 return semanage_split_on_space(str);
87- ustr = ustr_dup_cstr(str);
88- temp =
89- ustr_split_cstr(ustr, &off, delim, USTR_NULL, USTR_FLAG_SPLIT_DEF);
90- if (!temp)
91- goto done;
92- /* throw away the left hand side */
93- ustr_sc_free(&temp);
94-
95- rside_len = ustr_len(ustr) - off;
96
97- temp = ustr_dup_subustr(ustr, off + 1, rside_len);
98- if (!temp)
99- goto done;
100- retval = strdup(ustr_cstr(temp));
101- ustr_sc_free(&temp);
102+ retval = strstr(str, delim);
103+ if (retval == NULL)
104+ return NULL;
105
106- done:
107- ustr_sc_free(&ustr);
108- return retval;
109+ return strdup(retval + strlen(delim));
110 }
111
112 int semanage_list_push(semanage_list_t ** list, const char *data)
113--
1142.10.2
115
diff --git a/recipes-security/selinux/libsemanage/0002-libsemanage-add-semanage_str_replace-utility-functio.patch b/recipes-security/selinux/libsemanage/0002-libsemanage-add-semanage_str_replace-utility-functio.patch
new file mode 100644
index 0000000..ed32785
--- /dev/null
+++ b/recipes-security/selinux/libsemanage/0002-libsemanage-add-semanage_str_replace-utility-functio.patch
@@ -0,0 +1,164 @@
1From de8b13baf3773b41367f265e7dd06c013816ba0a Mon Sep 17 00:00:00 2001
2From: Nicolas Iooss <nicolas.iooss@m4x.org>
3Date: Wed, 21 Dec 2016 19:21:02 +0100
4Subject: [PATCH 2/4] libsemanage: add semanage_str_replace() utility function
5
6This function will be used in the next commit.
7
8Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
9(cherry picked from commit 57a3b1b4b0a50a1d14f825d2933339063ced4fec)
10---
11 libsemanage/src/utilities.c | 55 ++++++++++++++++++++++++++++++++++++++
12 libsemanage/src/utilities.h | 10 +++++++
13 libsemanage/tests/test_utilities.c | 34 +++++++++++++++++++++++
14 3 files changed, 99 insertions(+)
15
16diff --git a/libsemanage/src/utilities.c b/libsemanage/src/utilities.c
17index fa86cc7..0d50d99 100644
18--- a/libsemanage/src/utilities.c
19+++ b/libsemanage/src/utilities.c
20@@ -230,6 +230,61 @@ void semanage_rtrim(char *str, char trim_to)
21 }
22 }
23
24+char *semanage_str_replace(const char *search, const char *replace,
25+ const char *src, size_t lim)
26+{
27+ size_t count = 0, slen, rlen, newsize;
28+ char *p, *pres, *result;
29+ const char *psrc;
30+
31+ slen = strlen(search);
32+ rlen = strlen(replace);
33+
34+ /* Do not support empty search strings */
35+ if (slen == 0)
36+ return NULL;
37+
38+ /* Count the occurences of search in src and compute the new size */
39+ for (p = strstr(src, search); p != NULL; p = strstr(p + slen, search)) {
40+ count++;
41+ if (lim && count >= lim)
42+ break;
43+ }
44+ if (!count)
45+ return strdup(src);
46+
47+ /* Allocate the result string */
48+ newsize = strlen(src) + 1 + count * (rlen - slen);
49+ result = malloc(newsize);
50+ if (!result)
51+ return NULL;
52+
53+ /* Fill the result */
54+ psrc = src;
55+ pres = result;
56+ for (p = strstr(src, search); p != NULL; p = strstr(psrc, search)) {
57+ /* Copy the part which has not been modified */
58+ if (p != psrc) {
59+ size_t length = (size_t)(p - psrc);
60+ memcpy(pres, psrc, length);
61+ pres += length;
62+ }
63+ /* Copy the replacement part */
64+ if (rlen != 0) {
65+ memcpy(pres, replace, rlen);
66+ pres += rlen;
67+ }
68+ psrc = p + slen;
69+ count--;
70+ if (!count)
71+ break;
72+ }
73+ /* Copy the last part, after doing a sanity check */
74+ assert(pres + strlen(psrc) + 1 == result + newsize);
75+ strcpy(pres, psrc);
76+ return result;
77+}
78+
79 /* list_addafter_controlmem does *NOT* duplicate the data argument
80 * use at your own risk, I am building a list out of malloc'd memory and
81 * it is only going to get stored into this list, thus when I destroy it
82diff --git a/libsemanage/src/utilities.h b/libsemanage/src/utilities.h
83index 5fa15ef..f2ff31f 100644
84--- a/libsemanage/src/utilities.h
85+++ b/libsemanage/src/utilities.h
86@@ -116,6 +116,16 @@ int semanage_str_count(char *data, char what);
87 void semanage_rtrim(char *str, char trim_to);
88
89 /**
90+ * @param value being searched for
91+ * @param replacement value that replaces found search values
92+ * @param string being searched and replaced on
93+ * @param maximum number of value occurences (zero for unlimited)
94+ * @return newly-allocated string with the replaced values
95+ */
96+char *semanage_str_replace(const char *search, const char *replace,
97+ const char *src, size_t lim);
98+
99+/**
100 * @param data some string
101 * @return modifies the string such that the first whitespace char becomes
102 * '\0', ending the string.
103diff --git a/libsemanage/tests/test_utilities.c b/libsemanage/tests/test_utilities.c
104index 32cc33c..cdfed0c 100644
105--- a/libsemanage/tests/test_utilities.c
106+++ b/libsemanage/tests/test_utilities.c
107@@ -40,6 +40,7 @@ void test_semanage_split(void);
108 void test_semanage_list(void);
109 void test_semanage_str_count(void);
110 void test_semanage_rtrim(void);
111+void test_semanage_str_replace(void);
112 void test_semanage_findval(void);
113 void test_slurp_file_filter(void);
114
115@@ -101,6 +102,10 @@ int semanage_utilities_add_tests(CU_pSuite suite)
116 if (NULL == CU_add_test(suite, "semanage_rtrim", test_semanage_rtrim)) {
117 goto err;
118 }
119+ if (NULL == CU_add_test(suite, "semanage_str_replace",
120+ test_semanage_str_replace)) {
121+ goto err;
122+ }
123 if (NULL == CU_add_test(suite, "semanage_findval",
124 test_semanage_findval)) {
125 goto err;
126@@ -244,6 +249,35 @@ void test_semanage_rtrim(void)
127 CU_ASSERT_STRING_EQUAL(str, "/blah/foo/bar");
128 }
129
130+void test_semanage_str_replace(void)
131+{
132+ const char *test_str = "Hello, I am %{USERNAME} and my id is %{USERID}";
133+ char *str1, *str2;
134+
135+ str1 = semanage_str_replace("%{USERNAME}", "root", test_str, 0);
136+ CU_ASSERT_STRING_EQUAL(str1, "Hello, I am root and my id is %{USERID}");
137+
138+ str2 = semanage_str_replace("%{USERID}", "0", str1, 1);
139+ CU_ASSERT_STRING_EQUAL(str2, "Hello, I am root and my id is 0");
140+ free(str1);
141+ free(str2);
142+
143+ str1 = semanage_str_replace(":(", ";)", "Test :( :) ! :(:(:))(:(", 0);
144+ CU_ASSERT_STRING_EQUAL(str1, "Test ;) :) ! ;);):))(;)");
145+ free(str1);
146+
147+ str1 = semanage_str_replace(":(", ";)", "Test :( :) ! :(:(:))(:(", 3);
148+ CU_ASSERT_STRING_EQUAL(str1, "Test ;) :) ! ;);):))(:(");
149+ free(str1);
150+
151+ str1 = semanage_str_replace("", "empty search string", "test", 0);
152+ CU_ASSERT_EQUAL(str1, NULL);
153+
154+ str1 = semanage_str_replace("a", "", "abracadabra", 0);
155+ CU_ASSERT_STRING_EQUAL(str1, "brcdbr");
156+ free(str1);
157+}
158+
159 void test_semanage_findval(void)
160 {
161 char *tok;
162--
1632.10.2
164
diff --git a/recipes-security/selinux/libsemanage/0003-libsemanage-genhomedircon-drop-ustr-dependency.patch b/recipes-security/selinux/libsemanage/0003-libsemanage-genhomedircon-drop-ustr-dependency.patch
new file mode 100644
index 0000000..fde2349
--- /dev/null
+++ b/recipes-security/selinux/libsemanage/0003-libsemanage-genhomedircon-drop-ustr-dependency.patch
@@ -0,0 +1,323 @@
1From e8dd31df2268013afb1e8dbe5e617b9c4e9e388e Mon Sep 17 00:00:00 2001
2From: Nicolas Iooss <nicolas.iooss@m4x.org>
3Date: Wed, 21 Dec 2016 19:21:03 +0100
4Subject: [PATCH 3/4] libsemanage: genhomedircon: drop ustr dependency
5
6ustr library uses old (pre-C99) "extern inline" semantic. This makes it
7incompatible with recent versions of gcc and clang, which default to
8C99 standard. Distributions have shipped patched versions of this
9library to fix issues (e.g. Gentoo package uses this patch:
10https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-libs/ustr/files/ustr-1.0.4-gcc_5-check.patch?id=7dea6f8820f36bf389e6315044bea7507553bed0
11) but there is no upstream solution to make ustr compatible with C99
12standard.
13
14The git tree of ustr (http://www.and.org/ustr/ustr.git) has not been
15updated since 2008 and the developer of this project did not reply to
16emails.
17
18Therefore update genhomedircon implementation in order to no longer
19rely on ustr library.
20
21Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
22(cherry picked from commit 300b8ad4235688171f2a91e7aeb14d0ee3561c13)
23---
24 libsemanage/src/genhomedircon.c | 154 ++++++++++++++++++++--------------------
25 1 file changed, 77 insertions(+), 77 deletions(-)
26
27diff --git a/libsemanage/src/genhomedircon.c b/libsemanage/src/genhomedircon.c
28index 6991fff..0f84aa3 100644
29--- a/libsemanage/src/genhomedircon.c
30+++ b/libsemanage/src/genhomedircon.c
31@@ -34,9 +34,9 @@
32
33 #include "utilities.h"
34 #include "genhomedircon.h"
35-#include <ustr.h>
36
37 #include <assert.h>
38+#include <ctype.h>
39 #include <limits.h>
40 #include <stdio.h>
41 #include <stdlib.h>
42@@ -239,46 +239,39 @@ static int fcontext_matches(const semanage_fcontext_t *fcontext, void *varg)
43 {
44 const char *oexpr = semanage_fcontext_get_expr(fcontext);
45 fc_match_handle_t *handp = varg;
46- struct Ustr *expr;
47+ char *expr = NULL;
48 regex_t re;
49 int type, retval = -1;
50+ size_t len;
51
52 /* Only match ALL or DIR */
53 type = semanage_fcontext_get_type(fcontext);
54 if (type != SEMANAGE_FCONTEXT_ALL && type != SEMANAGE_FCONTEXT_ALL)
55 return 0;
56
57- /* Convert oexpr into a Ustr and anchor it at the beginning */
58- expr = ustr_dup_cstr("^");
59- if (expr == USTR_NULL)
60- goto done;
61- if (!ustr_add_cstr(&expr, oexpr))
62- goto done;
63-
64- /* Strip off trailing ".+" or ".*" */
65- if (ustr_cmp_suffix_cstr_eq(expr, ".+") ||
66- ustr_cmp_suffix_cstr_eq(expr, ".*")) {
67- if (!ustr_del(&expr, 2))
68- goto done;
69- }
70-
71- /* Strip off trailing "(/.*)?" */
72- if (ustr_cmp_suffix_cstr_eq(expr, "(/.*)?")) {
73- if (!ustr_del(&expr, 6))
74- goto done;
75- }
76-
77- if (ustr_cmp_suffix_cstr_eq(expr, "/")) {
78- if (!ustr_del(&expr, 1))
79- goto done;
80- }
81-
82- /* Append pattern to eat up trailing slashes */
83- if (!ustr_add_cstr(&expr, "/*$"))
84- goto done;
85+ len = strlen(oexpr);
86+ /* Define a macro to strip a literal string from the end of oexpr */
87+#define rstrip_oexpr_len(cstr, cstrlen) \
88+ do { \
89+ if (len >= (cstrlen) && !strncmp(oexpr + len - (cstrlen), (cstr), (cstrlen))) \
90+ len -= (cstrlen); \
91+ } while (0)
92+#define rstrip_oexpr(cstr) rstrip_oexpr_len(cstr, sizeof(cstr) - 1)
93+
94+ rstrip_oexpr(".+");
95+ rstrip_oexpr(".*");
96+ rstrip_oexpr("(/.*)?");
97+ rstrip_oexpr("/");
98+
99+#undef rstrip_oexpr_len
100+#undef rstrip_oexpr
101+
102+ /* Anchor oexpr at the beginning and append pattern to eat up trailing slashes */
103+ if (asprintf(&expr, "^%.*s/*$", (int)len, oexpr) < 0)
104+ return -1;
105
106 /* Check dir against expr */
107- if (regcomp(&re, ustr_cstr(expr), REG_EXTENDED) != 0)
108+ if (regcomp(&re, expr, REG_EXTENDED) != 0)
109 goto done;
110 if (regexec(&re, handp->dir, 0, NULL, 0) == 0)
111 handp->matched = 1;
112@@ -287,7 +280,7 @@ static int fcontext_matches(const semanage_fcontext_t *fcontext, void *varg)
113 retval = 0;
114
115 done:
116- ustr_free(expr);
117+ free(expr);
118
119 return retval;
120 }
121@@ -523,44 +516,50 @@ static semanage_list_t *make_template(genhomedircon_settings_t * s,
122 return template_data;
123 }
124
125-static Ustr *replace_all(const char *str, const replacement_pair_t * repl)
126+static char *replace_all(const char *str, const replacement_pair_t * repl)
127 {
128- Ustr *retval = USTR_NULL;
129+ char *retval, *retval2;
130 int i;
131
132 if (!str || !repl)
133- goto done;
134- if (!(retval = ustr_dup_cstr(str)))
135- goto done;
136+ return NULL;
137
138- for (i = 0; repl[i].search_for; i++) {
139- ustr_replace_cstr(&retval, repl[i].search_for,
140- repl[i].replace_with, 0);
141+ retval = strdup(str);
142+ for (i = 0; retval != NULL && repl[i].search_for; i++) {
143+ retval2 = semanage_str_replace(repl[i].search_for,
144+ repl[i].replace_with, retval, 0);
145+ free(retval);
146+ retval = retval2;
147 }
148- if (ustr_enomem(retval))
149- ustr_sc_free(&retval);
150-
151- done:
152 return retval;
153 }
154
155-static const char * extract_context(Ustr *line)
156+static const char *extract_context(const char *line)
157 {
158- const char whitespace[] = " \t\n";
159- size_t off, len;
160-
161- /* check for trailing whitespace */
162- off = ustr_spn_chrs_rev(line, 0, whitespace, strlen(whitespace));
163-
164- /* find the length of the last field in line */
165- len = ustr_cspn_chrs_rev(line, off, whitespace, strlen(whitespace));
166-
167- if (len == 0)
168+ const char *p = line;
169+ size_t off;
170+
171+ off = strlen(p);
172+ p += off;
173+ /* consider trailing whitespaces */
174+ while (off > 0) {
175+ p--;
176+ off--;
177+ if (!isspace(*p))
178+ break;
179+ }
180+ if (off == 0)
181 return NULL;
182- return ustr_cstr(line) + ustr_len(line) - (len + off);
183+
184+ /* find the last field in line */
185+ while (off > 0 && !isspace(*(p - 1))) {
186+ p--;
187+ off--;
188+ }
189+ return p;
190 }
191
192-static int check_line(genhomedircon_settings_t * s, Ustr *line)
193+static int check_line(genhomedircon_settings_t * s, const char *line)
194 {
195 sepol_context_t *ctx_record = NULL;
196 const char *ctx_str;
197@@ -584,22 +583,22 @@ static int write_replacements(genhomedircon_settings_t * s, FILE * out,
198 const semanage_list_t * tpl,
199 const replacement_pair_t *repl)
200 {
201- Ustr *line = USTR_NULL;
202+ char *line;
203
204 for (; tpl; tpl = tpl->next) {
205 line = replace_all(tpl->data, repl);
206 if (!line)
207 goto fail;
208 if (check_line(s, line) == STATUS_SUCCESS) {
209- if (!ustr_io_putfileline(&line, out))
210+ if (fprintf(out, "%s\n", line) < 0)
211 goto fail;
212 }
213- ustr_sc_free(&line);
214+ free(line);
215 }
216 return STATUS_SUCCESS;
217
218 fail:
219- ustr_sc_free(&line);
220+ free(line);
221 return STATUS_ERR;
222 }
223
224@@ -607,7 +606,7 @@ static int write_contexts(genhomedircon_settings_t *s, FILE *out,
225 semanage_list_t *tpl, const replacement_pair_t *repl,
226 const genhomedircon_user_entry_t *user)
227 {
228- Ustr *line = USTR_NULL;
229+ char *line, *temp;
230 sepol_context_t *context = NULL;
231 char *new_context_str = NULL;
232
233@@ -624,10 +623,10 @@ static int write_contexts(genhomedircon_settings_t *s, FILE *out,
234
235 if (strcmp(old_context_str, CONTEXT_NONE) == 0) {
236 if (check_line(s, line) == STATUS_SUCCESS &&
237- !ustr_io_putfileline(&line, out)) {
238+ fprintf(out, "%s\n", line) < 0) {
239 goto fail;
240 }
241-
242+ free(line);
243 continue;
244 }
245
246@@ -653,25 +652,27 @@ static int write_contexts(genhomedircon_settings_t *s, FILE *out,
247 goto fail;
248 }
249
250- if (!ustr_replace_cstr(&line, old_context_str,
251- new_context_str, 1)) {
252+ temp = semanage_str_replace(old_context_str, new_context_str,
253+ line, 1);
254+ if (!temp) {
255 goto fail;
256 }
257+ free(line);
258+ line = temp;
259
260 if (check_line(s, line) == STATUS_SUCCESS) {
261- if (!ustr_io_putfileline(&line, out)) {
262+ if (fprintf(out, "%s\n", line) < 0)
263 goto fail;
264- }
265 }
266
267- ustr_sc_free(&line);
268+ free(line);
269 sepol_context_free(context);
270 free(new_context_str);
271 }
272
273 return STATUS_SUCCESS;
274 fail:
275- ustr_sc_free(&line);
276+ free(line);
277 sepol_context_free(context);
278 free(new_context_str);
279 return STATUS_ERR;
280@@ -1284,20 +1285,19 @@ static int write_context_file(genhomedircon_settings_t * s, FILE * out)
281 }
282
283 for (h = homedirs; h; h = h->next) {
284- Ustr *temp = ustr_dup_cstr(h->data);
285+ char *temp = NULL;
286
287- if (!temp || !ustr_add_cstr(&temp, "/" FALLBACK_NAME)) {
288- ustr_sc_free(&temp);
289+ if (asprintf(&temp, "%s/%s", h->data, FALLBACK_NAME) < 0) {
290 retval = STATUS_ERR;
291 goto done;
292 }
293
294 free(s->fallback->home);
295- s->fallback->home = (char*) ustr_cstr(temp);
296+ s->fallback->home = temp;
297
298 if (write_home_dir_context(s, out, homedir_context_tpl,
299 s->fallback) != STATUS_SUCCESS) {
300- ustr_sc_free(&temp);
301+ free(temp);
302 s->fallback->home = NULL;
303 retval = STATUS_ERR;
304 goto done;
305@@ -1305,13 +1305,13 @@ static int write_context_file(genhomedircon_settings_t * s, FILE * out)
306 if (write_home_root_context(s, out,
307 homeroot_context_tpl,
308 h->data) != STATUS_SUCCESS) {
309- ustr_sc_free(&temp);
310+ free(temp);
311 s->fallback->home = NULL;
312 retval = STATUS_ERR;
313 goto done;
314 }
315
316- ustr_sc_free(&temp);
317+ free(temp);
318 s->fallback->home = NULL;
319 }
320 }
321--
3222.10.2
323
diff --git a/recipes-security/selinux/libsemanage/0004-libsemanage-remove-ustr-library-from-Makefiles-READM.patch b/recipes-security/selinux/libsemanage/0004-libsemanage-remove-ustr-library-from-Makefiles-READM.patch
new file mode 100644
index 0000000..1800493
--- /dev/null
+++ b/recipes-security/selinux/libsemanage/0004-libsemanage-remove-ustr-library-from-Makefiles-READM.patch
@@ -0,0 +1,61 @@
1From c7e55daa20f5659799aed47b819ad73e03d11e8f Mon Sep 17 00:00:00 2001
2From: Nicolas Iooss <nicolas.iooss@m4x.org>
3Date: Wed, 21 Dec 2016 19:21:04 +0100
4Subject: [PATCH 4/4] libsemanage: remove ustr library from Makefiles, README
5 and pkg-config
6
7This library is no longer used by libsemanage.
8
9Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
10(cherry picked from commit 920ee9ee18024c7714f1121e91854f38fa1eef73)
11
12Tweaked due to conditional audit patch and no README.
13---
14 README | 2 +-
15 libsemanage/src/Makefile | 2 +-
16 libsemanage/src/libsemanage.pc.in | 2 +-
17 libsemanage/tests/Makefile | 2 +-
18 4 files changed, 4 insertions(+), 4 deletions(-)
19
20diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile
21index 68aab72..83daf0f 100644
22--- a/libsemanage/src/Makefile
23+++ b/libsemanage/src/Makefile
24@@ -91,7 +91,7 @@ $(LIBA): $(OBJS)
25 $(RANLIB) $@
26
27 $(LIBSO): $(LOBJS)
28- $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol $(LIBAUDIT) -lselinux -lbz2 -lustr -L$(LIBDIR) -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs
29+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol $(LIBAUDIT) -lselinux -lbz2 -L$(LIBDIR) -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs
30 ln -sf $@ $(TARGET)
31
32 $(LIBPC): $(LIBPC).in ../VERSION
33diff --git a/libsemanage/src/libsemanage.pc.in b/libsemanage/src/libsemanage.pc.in
34index 81e1805..d3eaa06 100644
35--- a/libsemanage/src/libsemanage.pc.in
36+++ b/libsemanage/src/libsemanage.pc.in
37@@ -7,7 +7,7 @@ Name: libsemanage
38 Description: SELinux management library
39 Version: @VERSION@
40 URL: http://userspace.selinuxproject.org/
41-Requires.private: libselinux libsepol ustr
42+Requires.private: libselinux libsepol
43 Libs: -L${libdir} -lsemanage
44 Libs.private: -lbz2
45 Cflags: -I${includedir}
46diff --git a/libsemanage/tests/Makefile b/libsemanage/tests/Makefile
47index 4b81fed..56285b3 100644
48--- a/libsemanage/tests/Makefile
49+++ b/libsemanage/tests/Makefile
50@@ -12,7 +12,7 @@ LIBS = ../src/libsemanage.a ../../libselinux/src/libselinux.a ../../libsepol/src
51 LIBAUDIT = -laudit
52 endif
53
54-LDFLAGS += -lcunit -lustr -lbz2 $(LIBAUDIT)
55+LDFLAGS += -lcunit -lbz2 $(LIBAUDIT)
56 OBJECTS = $(SOURCES:.c=.o)
57
58 all: $(EXECUTABLE)
59--
602.10.2
61
diff --git a/recipes-security/selinux/libsemanage_2.6.bb b/recipes-security/selinux/libsemanage_2.6.bb
index 6361181..5e24c9d 100644
--- a/recipes-security/selinux/libsemanage_2.6.bb
+++ b/recipes-security/selinux/libsemanage_2.6.bb
@@ -15,5 +15,9 @@ SRC_URI += "\
15 file://libsemanage-allow-to-disable-audit-support.patch \ 15 file://libsemanage-allow-to-disable-audit-support.patch \
16 file://libsemanage-disable-expand-check-on-policy-load.patch \ 16 file://libsemanage-disable-expand-check-on-policy-load.patch \
17 file://0001-src-Makefile-fix-includedir-in-libselinux.pc.patch \ 17 file://0001-src-Makefile-fix-includedir-in-libselinux.pc.patch \
18 file://0001-libsemanage-simplify-string-utilities-functions.patch;striplevel=2 \
19 file://0002-libsemanage-add-semanage_str_replace-utility-functio.patch;striplevel=2 \
20 file://0003-libsemanage-genhomedircon-drop-ustr-dependency.patch;striplevel=2 \
21 file://0004-libsemanage-remove-ustr-library-from-Makefiles-READM.patch;striplevel=2 \
18 " 22 "
19FILES_${PN} += "/usr/libexec" 23FILES_${PN} += "/usr/libexec"