[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/ricci/ricci ClientInstance.cpp Ricci.cpp ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2007-09-09 01:06:15

Modified files:
	ricci/ricci    : ClientInstance.cpp Ricci.cpp SSLInstance.cpp 
	                 Server.cpp 

Log message:
	Fix a couple of bugs that caused certificates to not be saved and batch queue files to not be written correctly

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/ClientInstance.cpp.diff?cvsroot=cluster&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Ricci.cpp.diff?cvsroot=cluster&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/SSLInstance.cpp.diff?cvsroot=cluster&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/Server.cpp.diff?cvsroot=cluster&r1=1.7&r2=1.8

--- conga/ricci/ricci/ClientInstance.cpp	2007/08/30 17:08:44	1.9
+++ conga/ricci/ricci/ClientInstance.cpp	2007/09/09 01:06:15	1.10
@@ -106,6 +106,7 @@
 		}
 
 		bool authed = _ssl.client_cert_authed();
+		bool was_authed = authed;
 
 		// send hello
 		send(ricci.hello(authed));
@@ -130,15 +131,11 @@
 			XMLObject response = ricci.request(request, authed,
 									save_cert, remove_cert, done);
 
-			if (!authed && save_cert) {
+			if (!was_authed && save_cert)
 				_ssl.save_client_cert();
-				authed = true;
-			}
 
-			if (authed && remove_cert) {
+			if (was_authed && remove_cert)
 				_ssl.remove_client_cert();
-				authed = false;
-			}
 			send(response);
 		}
 		send(XMLObject("bye"));
--- conga/ricci/ricci/Ricci.cpp	2007/08/30 17:07:14	1.26
+++ conga/ricci/ricci/Ricci.cpp	2007/09/09 01:06:15	1.27
@@ -156,6 +156,7 @@
 			success = RRC_SUCCESS;
 			remove_cert = true;
 		}
+		authenticated = false;
 	} else if (function == "list_modules") {
 		// available modules
 		if (!authenticated) {
@@ -290,29 +291,32 @@
 	}
 
 	// create file
-	int fd = open(path_tmp.c_str(), O_RDONLY | O_CREAT | O_EXCL, 0640);
+	int fd = open(path_tmp.c_str(), O_RDWR | O_CREAT | O_EXCL, 0640);
 	if (fd == -1)
 		throw String("unable to create batch file: ") + String(strerror(errno));
 
-	// write file
-	FILE *file = fdopen(fd, "w+");
-	if (!file)
-		throw String("unable to open batch file: ") + String(strerror(errno));
-
 	try {
 		// save request
 		String xml_str(generateXML(_report));
-		if (fwrite(xml_str.c_str(), xml_str.size(), 1, file) != 1) {
-			throw String("unable to write batch request: ")
-					+ String(strerror(errno));
+		while (xml_str.size()) {
+			ssize_t ret = write(fd, xml_str.c_str(), xml_str.size());
+			if (ret < 0) {
+				if (errno == EINTR)
+					continue;
+				throw String("unable to write batch request: ")
+						+ String(strerror(errno));
+			}
+			xml_str = xml_str.substr(ret);
 		}
-		fclose(file);
+
+		close(fd);
+
 		if (rename(path_tmp.c_str(), _path.c_str())) {
 			throw String("failed to rename batch file: ")
 					+ String(strerror(errno));
 		}
 	} catch ( ... ) {
-		fclose(file);
+		close(fd);
 		unlink(path_tmp.c_str());
 		throw;
 	}
--- conga/ricci/ricci/SSLInstance.cpp	2007/08/30 17:07:14	1.9
+++ conga/ricci/ricci/SSLInstance.cpp	2007/09/09 01:06:15	1.10
@@ -450,8 +450,10 @@
 			iter != authorized_certs.end() ;
 			iter++)
 	{
-		if (iter->cert == _cert_pem)
-			unlink(iter->file.c_str());
+		if (iter->cert == _cert_pem) {
+			if (unlink(iter->file.c_str()) != 0)
+				throw String("error removing certificate");
+		}
 	}
 
 	load_client_certs();
@@ -469,6 +471,8 @@
 {
 	want_read = want_write = false;
 
+	int err = errno;
+
 	String e;
 	switch (SSL_get_error(_ssl, value)) {
 		case SSL_ERROR_NONE:
@@ -499,5 +503,5 @@
 			e = "SSL_ERROR_SSL";
 			break;
 	}
-	throw String("SSL_read() error: ") + e;
+	throw String("SSL_read() error: ") + e + ": " + String(strerror(err));
 }
--- conga/ricci/ricci/Server.cpp	2007/08/30 17:07:14	1.7
+++ conga/ricci/ricci/Server.cpp	2007/09/09 01:06:15	1.8
@@ -131,8 +131,8 @@
 		}
 
 		if (poll_data.revents & (POLLERR | POLLHUP | POLLNVAL))
-			throw String("server socket error????");
-	} // while
+			throw String("server socket error");
+	}
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]