[Openvas-commits] r3214 - in trunk/openvas-config-manager: . src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Apr 29 11:18:44 CEST 2009
Author: mwiegand
Date: 2009-04-29 11:18:44 +0200 (Wed, 29 Apr 2009)
New Revision: 3214
Modified:
trunk/openvas-config-manager/ChangeLog
trunk/openvas-config-manager/src/openvascd.c
Log:
* src/openvascd.c: Housekeeping commit. (openvas_config_list_users,
openvas_config_list_all_prefs) Narrow down variable scopes. Make sure
all used memory is freed. Make sure variables are initialized with a
sane value. Improved flow.
* ChangeLog: Fixed typos.
Modified: trunk/openvas-config-manager/ChangeLog
===================================================================
--- trunk/openvas-config-manager/ChangeLog 2009-04-29 07:28:30 UTC (rev 3213)
+++ trunk/openvas-config-manager/ChangeLog 2009-04-29 09:18:44 UTC (rev 3214)
@@ -1,16 +1,25 @@
2009-04-29 Michael Wiegand <michael.wiegand at intevation.de>
+ * src/openvascd.c: Housekeeping commit. (openvas_config_list_users,
+ openvas_config_list_all_prefs) Narrow down variable scopes. Make sure
+ all used memory is freed. Make sure variables are initialized with a
+ sane value. Improved flow.
+
+ * ChangeLog: Fixed typos.
+
+2009-04-29 Michael Wiegand <michael.wiegand at intevation.de>
+
Added preliminary support for adding users. This functionality is
currently not exposed pending the implementation of XML parsing.
- * src/opevasd.c: Added include for glib/gstdio.h since it is necessary
+ * src/openvascd.c: Added include for glib/gstdio.h since it is necessary
for glib file operations, added include for gcrypt.h since it is
necessary for message digest calculation. (openvas_config_list_users)
Added TODO for non-password users. (openvas_config_add_user) New. This
function will add a new user to the OpenVAS installation. (digest_hex)
New. Convenience function to get the hexadecimal representation of a
message digest. (get_password_hashes) New. This function generates a
- pair of hashes for the authentification process implemented by openvasd.
+ pair of hashes for the authentication process implemented by openvasd.
2009-04-24 Michael Wiegand <michael.wiegand at intevation.de>
Modified: trunk/openvas-config-manager/src/openvascd.c
===================================================================
--- trunk/openvas-config-manager/src/openvascd.c 2009-04-29 07:28:30 UTC (rev 3213)
+++ trunk/openvas-config-manager/src/openvascd.c 2009-04-29 09:18:44 UTC (rev 3214)
@@ -361,41 +361,45 @@
GSList *
openvas_config_list_users (const gchar * directory)
{
- GError *error;
- GDir *users_dir;
- const gchar *entry_name;
GSList *users = NULL;
if (g_file_test (directory, G_FILE_TEST_EXISTS) &&
g_file_test (directory, G_FILE_TEST_IS_DIR))
{
- g_debug ("%s exist and is a directory.", directory);
+ const gchar *entry_name = NULL;
+ GError *error = NULL;
+ GDir *users_dir = NULL;
+
users_dir = g_dir_open (directory, 0, &error);
if (users_dir == NULL)
{
g_debug (error->message);
- return NULL;
+ g_error_free (error);
}
- while ((entry_name = g_dir_read_name (users_dir)))
+ else
{
- gchar *user_hash_filename = g_build_filename (directory, entry_name,
- "auth", "hash", NULL);
- g_debug ("Checking for user_hash_filename (%s)...", user_hash_filename);
- if (g_file_test (user_hash_filename, G_FILE_TEST_EXISTS))
+ while ((entry_name = g_dir_read_name (users_dir)))
{
- users = g_slist_append (users, g_strdup(entry_name));
+ gchar *user_hash_filename = g_build_filename (directory, entry_name,
+ "auth", "hash", NULL);
+ if (g_file_test (user_hash_filename, G_FILE_TEST_EXISTS))
+ {
+ users = g_slist_append (users, g_strdup(entry_name));
+ }
+ g_free (user_hash_filename);
+ // TODO: Even if "auth/hash" does not exist, try to look for an
+ // alternative authentication mechanism before discarding the entry.
}
- g_free (user_hash_filename);
+ g_dir_close (users_dir);
}
- g_dir_close (users_dir);
+
+ return users;
}
else
{
g_debug ("Could not find %s!", directory);
return NULL;
}
-
- return users;
}
/**
@@ -412,7 +416,7 @@
GHashTable *
openvas_config_list_all_prefs (const gchar * config_file)
{
- GError *error;
+ GError *error = NULL;
GKeyFile *config_key_file = g_key_file_new ();
gchar **config_keys = NULL;
@@ -432,11 +436,14 @@
}
g_strfreev (config_keys);
g_key_file_free (config_key_file);
+ g_error_free (error);
return prefs;
}
else
{
g_debug ("%s", error->message);
+ g_key_file_free (config_key_file);
+ g_error_free (error);
return NULL;
}
}
@@ -564,6 +571,7 @@
g_file_test (user_dir_name, G_FILE_TEST_IS_DIR))
{
g_debug ("User %s already exists!", name);
+ g_free (user_dir_name);
return FALSE;
}
else
@@ -601,8 +609,13 @@
g_chmod (user_hash_file_name, 0600);
g_free (hashes_out);
+ g_free (user_auth_dir_name);
+ g_free (user_rules_dir_name);
+ g_free (user_hash_file_name);
+ g_error_free (error);
g_debug ("User %s created successfully!", name);
+ g_free (user_dir_name);
return TRUE;
}
}
More information about the Openvas-commits
mailing list