libselinux: avoid logs in get_ordered_context_list() without policy
PATCH 1/1 libselinux: avoid logs in get_ordered_context_list() without policy
If no policy has been loaded yet and thus the current context is still "kernel" avoid logging failures in get_ordered_context_list(), like:
get_ordered_context_list: error in processing configuration file /etc/selinux/debian/contexts/users/root
get_ordered_context_list: error in processing configuration file /etc/selinux/debian/contexts/default_contexts
Since get_context_user() needs a valid context, because it tries to split it into its parts, jump right to the failsafe.
--- libselinux/src/get_context_list.c | 6 ++++++ 1 file changed, 6 insertions(+)
libselinux/src/get_context_list.c +6 -0
@@ -427,6 +427,12 @@ int get_ordered_context_list(const char *user, fromcon = backup_fromcon; } +if (strcmp (fromcon,"kernel" ) ==0 ) +/* get_context_user() needs a valid context, avoid +* unnecessary log messages if no policy has been loaded +* yet. */ + goto failsafe; +/* Determine the ordering to apply from the optional per-user config and from the global config. */ fname_len =strlen (user_contexts_path) +strlen (user) +2 ;
Signature · 1 line
2.43.0
Quoted 9 lines · Christian Göttsche
If no policy has been loaded yet and thus the current context is still "kernel" avoid logging failures in
get_ordered_context_list(), like:
get_ordered_context_list: error in processing configuration file/etc/selinux/debian/contexts/users/root
get_ordered_context_list: error in processing configuration file/etc/selinux/debian/contexts/default_contextsSince
get_context_user()needs a valid context, because it tries to split it into its parts, jump right to the failsafe.
Needs a sign-off.
Thanks,
Jim
Quoted 25 lines
--- libselinux/src/get_context_list.c | 6 ++++++ 1 file changed, 6 insertions(+)libselinux/src/get_context_list.c +6
-1@@ -427,6 +427,12 @@ int get_ordered_context_list(const char *user, fromcon = backup_fromcon; } +if (strcmp (fromcon,"kernel" ) ==0 ) +/* get_context_user() needs a valid context, avoid +* unnecessary log messages if no policy has been loaded +* yet. */ + goto failsafe; +/* Determine the ordering to apply from the optional per-user config and from the global config. */ fname_len =strlen (user_contexts_path) +strlen (user) +2 ; --2.43.0