From 5e46bb8647877acf8c7ff8253921c90ee50f3cdc Mon Sep 17 00:00:00 2001 From: Dan Walsh Date: Mon, 12 Dec 2011 15:03:21 -0500 Subject: [PATCH] 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 Acked-by: Dan Walsh --- libsemanage/src/genhomedircon.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libsemanage/src/genhomedircon.c b/libsemanage/src/genhomedircon.c index ff8403d5..d2646aee 100644 --- a/libsemanage/src/genhomedircon.c +++ b/libsemanage/src/genhomedircon.c @@ -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);