Skip to contentSkip to conversation

conga/ricci/ricci Auth.cpp Auth.h ClientInstan ...

Cluster-devel [email protected] 1 participant 1 message Aug 30, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-08-30 17:07:16

Modified files:
ricci/ricci : Auth.cpp Auth.h ClientInstance.cpp
ClientInstance.h DBusController.cpp DBusController.h Makefile QueueLocker.cpp QueueLocker.h RebootModule.cpp RebootModule.h Ricci.cpp Ricci.h RicciWorker.cpp RicciWorker.h SSLInstance.cpp SSLInstance.h Server.cpp Server.h dbus_test.cpp main.cpp ricci_defines.h

Log message:
- cleanup for readability and maintainability
- fix a handful of minor problems

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Auth.cpp.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Auth.h.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/ClientInstance.cpp.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/ClientInstance.h.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/DBusController.cpp.diff?cvsroot=cluster&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/DBusController.h.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Makefile.diff?cvsroot=cluster&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/QueueLocker.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/QueueLocker.h.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/RebootModule.cpp.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/RebootModule.h.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Ricci.cpp.diff?cvsroot=cluster&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Ricci.h.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/RicciWorker.cpp.diff?cvsroot=cluster&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/RicciWorker.h.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/SSLInstance.cpp.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/SSLInstance.h.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Server.cpp.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Server.h.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/dbus_test.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/main.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/ricci_defines.h.diff?cvsroot=cluster&r1=1.8&r2=1.9

ricci/ricci/Auth.cpp +89 -95
@@ -1,5 +1,5 @@
 /*
-  Copyright Red Hat, Inc. 2005
+  Copyright Red Hat, Inc. 2005-2007
 
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
@@ -13,7 +13,7 @@
 
   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to the
-  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge,
   MA 02139, USA.
 */
 /*
@@ -25,121 +25,115 @@
 #include "Mutex.h"
 #include <sasl/sasl.h>
 
+static int
+sasl_getopts_callback(	void* context,
+						const char *plugin_name,
+						const char *option,
+						const char **result,
+						unsigned int *len);
 
 
+static Mutex mutex; // global sasl_lib protection mutex
+static bool inited = false; // sasl_lib initialized?
 
-static int 
-sasl_getopts_callback(void*         context, 
-		     const char*   plugin_name,
-		     const char*   option, 
-		     const char**  result, 
-		     unsigned int* len);
-
-
-static Mutex mutex;          // global sasl_lib protection mutex
-static bool inited = false;  // sasl_lib initialized?
-const static 
+const static
 sasl_callback_t callbacks[] = {
-  {SASL_CB_GETOPT, (int (*)()) sasl_getopts_callback, NULL}, 
-  {SASL_CB_LIST_END, NULL, NULL},
+	{ SASL_CB_GETOPT,	(int (*)()) sasl_getopts_callback,	NULL },
+	{ SASL_CB_LIST_END,	NULL,								NULL },
 };
 
-
-
 Auth::Auth()
 {
-  if (!initialize_auth_system())
-    throw String("Failed to initialize authentication engine");
+	if (!initialize_auth_system())
+		throw String("Failed to initialize authentication engine");
 }
 
 Auth::~Auth()
 {}
 
 
-bool 
+bool
 Auth::authenticate(const String& passwd) const
 {
-  MutexLocker l(mutex);
-  
-  sasl_conn_t *conn = 0;
-  try {
-    bool success = false;
-    
-    int ret = sasl_server_new("ricci", // servicename
-			      NULL,    // hostname
-			      NULL,    // realm
-			      NULL,    // local ip:port
-			      NULL,    // remote ip:port
-			      callbacks, 
-			      0,       // connection flags
-			      &conn);
-    if (ret != SASL_OK)
-      throw String("authentication engine error");
-    
-    ret = sasl_checkpass(conn, 
-			 "root", 4, 
-			 passwd.c_str(), passwd.size());
-    if (ret == SASL_OK)
-      success = true;
-    else
-      if (ret != SASL_BADAUTH)
-	throw String("authentication engine error");
-    
-    sasl_dispose(&conn); conn = 0;
-    return success;
-  } catch ( ... ) {
-    if (conn) {
-      sasl_dispose(&conn);
-      conn = 0;
-    }
-    throw;
-  }
-}
-
+	MutexLocker l(mutex);
+	sasl_conn_t *conn = NULL;
 
+	try {
+		bool success = false;
+		int ret = sasl_server_new("ricci", // servicename
+					NULL,		// hostname
+					NULL,		// realm
+					NULL,		// local ip:port
+					NULL,		// remote ip:port
+					callbacks,
+					0,			// connection flags
+					&conn);
+
+		if (ret != SASL_OK)
+			throw String("authentication engine error");
+
+		ret = sasl_checkpass(conn, "root", 4, passwd.c_str(), passwd.size());
+		if (ret == SASL_OK)
+			success = true;
+		else {
+			if (ret != SASL_BADAUTH)
+				throw String("authentication engine error");
+		}
+
+		sasl_dispose(&conn);
+		conn = NULL;
+		return success;
+	} catch ( ... ) {
+		if (conn) {
+			sasl_dispose(&conn);
+			conn = NULL;
+		}
+		throw;
+	}
+}
 
 bool
 Auth::initialize_auth_system()
 {
-  MutexLocker l(mutex);
-  
-  if (!inited) {
-    int ret = sasl_server_init(callbacks, "ricci");
-    inited = (ret == SASL_OK);
-  }
-  return inited;
+	MutexLocker l(mutex);
+
+	if (!inited) {
+		int ret = sasl_server_init(callbacks, "ricci");
+		inited = (ret == SASL_OK);
+	}
+	return inited;
 }
 
-int 
-sasl_getopts_callback(void*         context, 
-		      const char*   plugin_name,
-		      const char*   option, 
-		      const char**  result, 
-		      unsigned * len)
+int
+sasl_getopts_callback(	void *context,
+						const char *plugin_name,
+						const char *option,
+						const char **result,
+						unsigned *len)
 {
-  try {
-    static const char authd_option[]         = "pwcheck_method";
-    static const char authd_result[]         = "saslauthd";
-    
-    static const char authd_version_option[] = "saslauthd_version";
-    static const char authd_version_result[] = "2";
-    
-    
-    if (result) {
-      *result = 0;
-      if (strcmp(option, authd_option) == 0)
-	*result = authd_result;
-      else if (strcmp(option, authd_version_option) == 0)
-	*result = authd_version_result;
-      else {
-	// modify more options we'd like to use
-      }
-    }
-    if (len)
-      *len = 0;
-    
-    return SASL_OK;
-  } catch ( ... ) {
-    return SASL_FAIL;
-  }
+
+	try {
+		static const char authd_option[] = "pwcheck_method";
+		static const char authd_result[] = "saslauthd";
+		static const char authd_version_option[] = "saslauthd_version";
+		static const char authd_version_result[] = "2";
+
+		if (result) {
+			*result = 0;
+			if (!strcmp(option, authd_option))
+				*result = authd_result;
+			else if (!strcmp(option, authd_version_option))
+				*result = authd_version_result;
+			else {
+				// modify more options we'd like to use
+			}
+		}
+
+		if (len)
+			*len = 0;
+
+		return SASL_OK;
+	} catch ( ... ) {
+		return SASL_FAIL;
+	}
 }
ricci/ricci/Auth.h +10 -15
@@ -1,5 +1,5 @@
 /*
-  Copyright Red Hat, Inc. 2005
+  Copyright Red Hat, Inc. 2005-2007
 
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
@@ -13,7 +13,7 @@
 
   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to the
-  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge,
   MA 02139, USA.
 */
 /*
@@ -29,20 +29,15 @@
 
 // thread safe
 
-
 class Auth
 {
- public:
-  Auth();
-  virtual ~Auth();
-  
-  bool authenticate(const String& passwd) const;
-  
-  
-  static bool initialize_auth_system();  // to be called at start-up (not required)
-  
-  
-};
+	public:
+		Auth();
+		virtual ~Auth();
+		bool authenticate(const String& passwd) const;
 
+		// to be called at start-up (not required)
+		static bool initialize_auth_system();
+};
 
-#endif  // Auth_h
+#endif // Auth_h
ricci/ricci/ClientInstance.cpp +173 -165

379 lines not on this page · raw message

ricci/ricci/ClientInstance.h +20 -31

68 lines not on this page · raw message

ricci/ricci/DBusController.cpp +124 -129

303 lines not on this page · raw message

ricci/ricci/DBusController.h +11 -18
@@ -1,5 +1,5 @@
 /*
-  Copyright Red Hat, Inc. 2005
+  Copyright Red Hat, Inc. 2005-2007
 
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
@@ -13,7 +13,7 @@
 
   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to the
-  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge,
   MA 02139, USA.
 */
 /*
@@ -27,28 +27,21 @@
 #include "XML.h"
 #include "String.h"
 
-
 // thread safe
 
 // currently: requests, waiting for response, are serialized per PROCESS
 // FIXME: d-bus supports processing of multiple messages at the same time
 
-
 class DBusController
 {
- public:
-  DBusController();
-  virtual ~DBusController();
-  
-  String process(const String& message,
-		      const String& module_name);
-  
-  std::list<String> modules(); // available modules
-  
- private:
-  std::map<String, String> _mod_map;
-  
-};
+	public:
+		DBusController();
+		virtual ~DBusController();
+		String process(const String& message, const String& module_name);
+		std::list<String> modules(); // available modules
 
+	private:
+		std::map<String, String> _mod_map;
+};
 
-#endif  // DBusController_h
+#endif // DBusController_h
ricci/ricci/Makefile +14 -28

88 lines not on this page · raw message

ricci/ricci/QueueLocker.cpp +46 -39

105 lines not on this page · raw message

ricci/ricci/QueueLocker.h +6 -6
@@ -1,5 +1,5 @@
 /*
-  Copyright Red Hat, Inc. 2005
+  Copyright Red Hat, Inc. 2005-2007
 
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
@@ -13,7 +13,7 @@
 
   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to the
-  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge,
   MA 02139, USA.
 */
 /*
@@ -29,10 +29,10 @@
 
 class QueueLocker : public MutexLocker
 {
-public:
-  QueueLocker();
-  virtual ~QueueLocker();
+	public:
+		QueueLocker();
+		virtual ~QueueLocker();
 };
 
 
-#endif  // QueueLocker_h
+#endif // QueueLocker_h
ricci/ricci/RebootModule.cpp +21 -26

90 lines not on this page · raw message

ricci/ricci/RebootModule.h +11 -14
@@ -1,5 +1,5 @@
 /*
-  Copyright Red Hat, Inc. 2006
+  Copyright Red Hat, Inc. 2006-2007
 
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
@@ -13,7 +13,7 @@
 
   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to the
-  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge,
   MA 02139, USA.
 */
 /*
@@ -30,18 +30,15 @@
 
 class RebootModule : public Module
 {
- public:
-  RebootModule(DBusController& dbus);
-  virtual ~RebootModule();
-  
-  virtual XMLObject process(const XMLObject& request);
-  
-  bool block();
-  
- private:
-  DBusController& _dbus;
-  
+	public:
+		RebootModule(DBusController& dbus);
+		virtual ~RebootModule();
+		virtual XMLObject process(const XMLObject& request);
+		bool block();
+
+	private:
+		DBusController& _dbus;
 };
 
 
-#endif  // RebootModule_h
+#endif // RebootModule_h
ricci/ricci/Ricci.cpp +377 -391

853 lines not on this page · raw message

ricci/ricci/Ricci.h +55 -73

149 lines not on this page · raw message

ricci/ricci/RicciWorker.cpp +315 -291

581 lines not on this page · raw message

ricci/ricci/RicciWorker.h +65 -78

143 lines not on this page · raw message

ricci/ricci/SSLInstance.cpp +393 -366

759 lines not on this page · raw message

ricci/ricci/SSLInstance.h +32 -35

67 lines not on this page · raw message

ricci/ricci/Server.cpp +78 -80

158 lines not on this page · raw message

ricci/ricci/Server.h +12 -15

Lines of this file are not shown. View the raw message.

ricci/ricci/dbus_test.cpp +15 -15

Lines of this file are not shown. View the raw message.

ricci/ricci/main.cpp +90 -50

140 lines not on this page · raw message

ricci/ricci/ricci_defines.h +12 -14

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.