Skip to contentSkip to conversation

Also libsemanage does not seem to work when adding.

DISCUSSION Ivan Gyurdiev 1 participant 1 message Jan 4, 2006 3 messages not in the archive SELinux security module

lore
Share & tools
lore
#3 lore raw
In reply to a message not in the archive
Quoted 7 lines

libsemanage.parse_assert_space: missing whitespace (/etc/selinux/targeted/modules/active/ports.local: 1):
portcon tcp 123456 system_u:object_r:http_port_t:s0
libsemanage.port_parse: could not parse port record
libsemanage.dbase_file_cache: could not cache file database
libsemanage.enter_ro: could not enter read-only section
Segmentation fault

Fix for single ports parser attached - I had only tried ranges.
Not sure what's going on with this segfault - try to reproduce again, and make sure that all rc values are checked before proceeding to the next semanage call.

libsemanage/src/ports_file.c +11 -4
diff -Naurp --exclude man --exclude-from excludes old/libsemanage/src/ports_file.c new/libsemanage/src/ports_file.c
@@ -99,22 +99,29 @@ static int port_parse(
 	if (parse_fetch_int(handle, info, &low, '-') < 0)
 		goto err;
 
-	if (parse_skip_space(handle, info) < 0)
-		goto err;
+	/* If range (-) does not follow immediately, require a space 
+	 * In other words, the space here is optional, but only
+	 * in the ranged case, not in the single port case,
+	 * so do a custom test */
+	if (*(info->ptr) && *(info->ptr) != '-') {
+		if (parse_assert_space(handle, info) < 0)
+			goto err;
+	}
+
 	if (parse_optional_ch(info, '-') != STATUS_NODATA) {
 
 		if (parse_skip_space(handle, info) < 0)
 			goto err;	
 		if (parse_fetch_int(handle, info, &high, ' ') < 0)
 			goto err;
+		if (parse_assert_space(handle, info) < 0)
+			goto err;
 		semanage_port_set_range(port, low, high);
 	}
 	else 
 		semanage_port_set_port(port, low);
 
         /* Port context */
-	if (parse_assert_space(handle, info) < 0)
-		goto err;
 	if (parse_fetch_string(handle, info, &str, ' ') < 0)
 		goto err;
 	if (semanage_context_from_string(handle, str, &con) < 0) {