Skip to content

Commit 382c2b5

Browse files
stephensmalleypcmoore
authored andcommitted
scripts/selinux/mdp: fix initial SID handling
commit e3e0b58 ("selinux: remove unused initial SIDs and improve handling") broke scripts/selinux/mdp since the unused initial SID names were removed and the corresponding generation of policy initial SID definitions by mdp was not updated accordingly. Fix it. With latest upstream checkpolicy it is no longer necessary to include the SID context definitions for the unused initial SIDs but retain them for compatibility with older checkpolicy. Fixes: e3e0b58 ("selinux: remove unused initial SIDs and improve handling") Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent c8e2226 commit 382c2b5

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

scripts/selinux/mdp/mdp.c

+18-5
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,14 @@ int main(int argc, char *argv[])
6767

6868
initial_sid_to_string_len = sizeof(initial_sid_to_string) / sizeof (char *);
6969
/* print out the sids */
70-
for (i = 1; i < initial_sid_to_string_len; i++)
71-
fprintf(fout, "sid %s\n", initial_sid_to_string[i]);
70+
for (i = 1; i < initial_sid_to_string_len; i++) {
71+
const char *name = initial_sid_to_string[i];
72+
73+
if (name)
74+
fprintf(fout, "sid %s\n", name);
75+
else
76+
fprintf(fout, "sid unused%d\n", i);
77+
}
7278
fprintf(fout, "\n");
7379

7480
/* print out the class permissions */
@@ -126,9 +132,16 @@ int main(int argc, char *argv[])
126132
#define OBJUSERROLETYPE "user_u:object_r:base_t"
127133

128134
/* default sids */
129-
for (i = 1; i < initial_sid_to_string_len; i++)
130-
fprintf(fout, "sid %s " SUBJUSERROLETYPE "%s\n",
131-
initial_sid_to_string[i], mls ? ":" SYSTEMLOW : "");
135+
for (i = 1; i < initial_sid_to_string_len; i++) {
136+
const char *name = initial_sid_to_string[i];
137+
138+
if (name)
139+
fprintf(fout, "sid %s ", name);
140+
else
141+
fprintf(fout, "sid unused%d\n", i);
142+
fprintf(fout, SUBJUSERROLETYPE "%s\n",
143+
mls ? ":" SYSTEMLOW : "");
144+
}
132145
fprintf(fout, "\n");
133146

134147
#define FS_USE(behavior, fstype) \

0 commit comments

Comments
 (0)