libsemanage: Fallback_user_level can be NULL if you are not using MLS

If you build a distribution without MLS turned on, libsemanage will
crash if given a user without a level.  This patch allows users
without levels to be passed in.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
This commit is contained in:
Dan Walsh 2011-12-12 15:03:21 -05:00 committed by Eric Paris
parent b39e8cab3c
commit 5e46bb8647
1 changed files with 5 additions and 2 deletions

View File

@ -717,9 +717,12 @@ static int set_fallback_user(genhomedircon_settings_t *s, const char *user,
{
char *fallback_user = strdup(user);
char *fallback_user_prefix = strdup(prefix);
char *fallback_user_level = strdup(level);
char *fallback_user_level = NULL;
if (level)
fallback_user_level = strdup(level);
if (fallback_user == NULL || fallback_user_prefix == NULL || fallback_user_level == NULL) {
if (fallback_user == NULL || fallback_user_prefix == NULL ||
(fallback_user_level == NULL && level != NULL)) {
free(fallback_user);
free(fallback_user_prefix);
free(fallback_user_level);