[Openvas-commits] r6576 - in trunk/openvas-libraries: . base
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Jan 28 13:54:05 CET 2010
Author: felix
Date: 2010-01-28 13:54:00 +0100 (Thu, 28 Jan 2010)
New Revision: 6576
Modified:
trunk/openvas-libraries/ChangeLog
trunk/openvas-libraries/base/drop_privileges.c
trunk/openvas-libraries/base/drop_privileges.h
Log:
* base/drop_privileges.c (drop_privileges): Prevent error-pile-up.
* base/drop_priviliges.h: Define return value for error-pile-up
programming mistake.
Modified: trunk/openvas-libraries/ChangeLog
===================================================================
--- trunk/openvas-libraries/ChangeLog 2010-01-28 12:28:43 UTC (rev 6575)
+++ trunk/openvas-libraries/ChangeLog 2010-01-28 12:54:00 UTC (rev 6576)
@@ -1,5 +1,12 @@
2010-01-28 Felix Wolfsteller <felix.wolfsteller at intevation.de>
+ * base/drop_privileges.c (drop_privileges): Prevent error-pile-up.
+
+ * base/drop_priviliges.h: Define return value for error-pile-up
+ programming mistake.
+
+2010-01-28 Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
Added module for basic support for privilege dropping.
* base/drop_privileges.c, base/drop_privileges.h: New module
Modified: trunk/openvas-libraries/base/drop_privileges.c
===================================================================
--- trunk/openvas-libraries/base/drop_privileges.c 2010-01-28 12:28:43 UTC (rev 6575)
+++ trunk/openvas-libraries/base/drop_privileges.c 2010-01-28 12:54:00 UTC (rev 6576)
@@ -68,7 +68,8 @@
*
* @param[in] username The user to become. Its safe to pass "NULL", in which
* case it will default to "nobody".
- * @param[out] error Return location for errors.
+ * @param[out] error Return location for errors or NULL if not interested
+ * in errors.
*
* @return OPENVAS_DROP_PRIVILEGES_OK in case of success. Sets \param error
* otherwise and returns the error code.
@@ -77,6 +78,10 @@
drop_privileges (gchar* username, GError** error)
{
struct passwd * user_pw = NULL;
+
+ g_return_val_if_fail (*error == NULL,
+ OPENVAS_DROP_PRIVILEGES_ERROR_ALREADY_SET);
+
if (username == NULL)
username = "nobody";
Modified: trunk/openvas-libraries/base/drop_privileges.h
===================================================================
--- trunk/openvas-libraries/base/drop_privileges.h 2010-01-28 12:28:43 UTC (rev 6575)
+++ trunk/openvas-libraries/base/drop_privileges.h 2010-01-28 12:54:00 UTC (rev 6576)
@@ -34,7 +34,9 @@
*/
#define OPENVAS_DROP_PRIVILEGES g_quark_from_static_string ("openvas-drop-privileges-error-quark")
-// Various error codes
+/* Definitions of the return codes. */
+#define OPENVAS_DROP_PRIVILEGES_ERROR_ALREADY_SET -1
+
#define OPENVAS_DROP_PRIVILEGES_OK 0
#define OPENVAS_DROP_PRIVILEGES_FAIL_NOT_ROOT 1
#define OPENVAS_DROP_PRIVILEGES_FAIL_UNKNOWN_USER 2
More information about the Openvas-commits
mailing list