Browse Source

coroparse: Don't allow sections within uidgid

Unify behavior with uidgid files and solve problem with incorrect prefix
if subsections were used.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse 9 months ago
parent
commit
a14311a5a4
1 changed files with 8 additions and 2 deletions
  1. 8 2
      exec/coroparse.c

+ 8 - 2
exec/coroparse.c

@@ -1028,7 +1028,7 @@ static int main_config_parser_cb(const char *path,
 			add_as_string = 0;
 			break;
 		case MAIN_CP_CB_DATA_STATE_UIDGID:
-			if (strcmp(key, "uid") == 0) {
+			if (strcmp(path, "uidgid.uid") == 0) {
 				uid = uid_determine(value);
 				if (uid == -1) {
 					*error_string = error_string_response;
@@ -1040,7 +1040,7 @@ static int main_config_parser_cb(const char *path,
 					goto icmap_set_error;
 				}
 				add_as_string = 0;
-			} else if (strcmp(key, "gid") == 0) {
+			} else if (strcmp(path, "uidgid.gid") == 0) {
 				gid = gid_determine(value);
 				if (gid == -1) {
 					*error_string = error_string_response;
@@ -1219,6 +1219,12 @@ static int main_config_parser_cb(const char *path,
 		if (strcmp(path, "resources.process.memory_used") == 0) {
 			*state = MAIN_CP_CB_DATA_STATE_RESOURCES_PROCESS_MEMUSED;
 		}
+
+		if (*state == MAIN_CP_CB_DATA_STATE_UIDGID && strcmp(path, "uidgid") != 0) {
+			*error_string = "Subsections are not allowed within uidgid section";
+
+			return (0);
+		};
 		break;
 	case PARSER_CB_SECTION_END:
 		switch (*state) {