libsemanage: genhomedircon: do not leak shells list

If get_home_dirs() was called without usepasswd we would generate the
entire shell list, but would never use that list.  We would then not
free that list when we returned the homedir_list.  Instead, do not
create the list of shells until after we know it will be used.

Signed-off-by: Eric Paris <[email protected]>
diff --git a/libsemanage/src/genhomedircon.c b/libsemanage/src/genhomedircon.c
index 26f6dd8..95c8c3b 100644
--- a/libsemanage/src/genhomedircon.c
+++ b/libsemanage/src/genhomedircon.c
@@ -289,9 +289,6 @@
 	struct stat buf;
 	int retval;
 
-	shells = get_shell_list();
-	assert(shells);
-
 	path = semanage_findval(PATH_ETC_USERADD, "HOME", "=");
 	if (path && *path) {
 		if (semanage_list_push(&homedir_list, path))
@@ -324,6 +321,9 @@
 	if (!(s->usepasswd))
 		return homedir_list;
 
+	shells = get_shell_list();
+	assert(shells);
+
 	path = semanage_findval(PATH_ETC_LOGIN_DEFS, "UID_MIN", NULL);
 	if (path && *path) {
 		temp = atoi(path);