From mboxrd@z Thu Jan 1 00:00:00 1970 From: kupcevic@sourceware.org Date: 15 Aug 2006 04:15:58 -0000 Subject: [Cluster-devel] conga ./clustermon.spec.in.in ./conga.spec.in. ... Message-ID: <20060815041558.8885.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Changes by: kupcevic at sourceware.org 2006-08-15 04:15:54 Modified files: . : clustermon.spec.in.in conga.spec.in.in ricci/common : Module.cpp ricci/include : Module.h shred_allocator.h ricci/modules/cluster: Makefile main.cpp ricci/modules/log: Makefile main.cpp ricci/modules/rpm: Makefile main.cpp ricci/modules/service: Makefile main.cpp ricci/modules/storage: Makefile main.cpp Removed files: ricci/modules/cluster: modcluster ricci/modules/log: ricci-modlog ricci/modules/rpm: ricci-modrpm ricci/modules/service: ricci-modservice ricci/modules/storage: ricci-modstorage Log message: - remove astray defines in spec files - change buildroot - ricci: remove stderr redirection scripts (.exe files) - reimplement in code Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/clustermon.spec.in.in.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/conga.spec.in.in.diff?cvsroot=cluster&r1=1.28&r2=1.29 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Module.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/Module.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/shred_allocator.h.diff?cvsroot=cluster&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Makefile.diff?cvsroot=cluster&r1=1.12&r2=1.13 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/main.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/modcluster.diff?cvsroot=cluster&r1=1.1&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/log/Makefile.diff?cvsroot=cluster&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/log/main.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/log/ricci-modlog.diff?cvsroot=cluster&r1=1.1&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/rpm/Makefile.diff?cvsroot=cluster&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/rpm/main.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/rpm/ricci-modrpm.diff?cvsroot=cluster&r1=1.2&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/Makefile.diff?cvsroot=cluster&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/main.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ricci-modservice.diff?cvsroot=cluster&r1=1.2&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/Makefile.diff?cvsroot=cluster&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/main.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/ricci-modstorage.diff?cvsroot=cluster&r1=1.2&r2=NONE --- conga/clustermon.spec.in.in 2006/08/09 21:13:21 1.2 +++ conga/clustermon.spec.in.in 2006/08/15 04:15:51 1.3 @@ -10,9 +10,6 @@ ############################################################################### ############################################################################### -%define vers @@VERS@@ -%define rel @@REL@@%{?dist} - %define PEGASUS_PROVIDERS_DIR %{_libdir}/Pegasus/providers @@ -21,8 +18,8 @@ Name: clustermon -Version: %vers -Release: %rel +Version: @@VERS@@ +Release: @@REL@@%{?dist} License: GPL URL: http://sources.redhat.com/cluster/conga @@ -30,8 +27,7 @@ Summary: cluster snmp agent, cim provider and ricci module - source code Source0: %{name}-%{version}.tar.gz -Buildroot: %{_tmppath}/%{name}-%{version}-buildroot - +Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: glibc-devel gcc-c++ libxml2-devel make BuildRequires: openssl-devel dbus-devel pam-devel @@ -92,7 +88,6 @@ %config(noreplace) %{_sysconfdir}/dbus-1/system.d/modcluster.systembus.conf %{_sysconfdir}/rc.d/init.d/modclusterd %{_sbindir}/modcluster - %{_sbindir}/modcluster.exe %{_sbindir}/modclusterd %{_docdir}/modcluster-%{version}/ --- conga/conga.spec.in.in 2006/08/09 21:13:21 1.28 +++ conga/conga.spec.in.in 2006/08/15 04:15:51 1.29 @@ -10,8 +10,6 @@ ############################################################################### ############################################################################### -%define vers @@VERS@@ -%define rel @@REL@@%{?dist} %define include_zope_and_plone @@INCLUDE_ZOPE_AND_PLONE@@ %define zope_archive @@ZOPE_ARCHIVE@@ @@ -30,8 +28,8 @@ Name: conga -Version: %vers -Release: %rel +Version: @@VERS@@ +Release: @@REL@@%{?dist} License: GPL URL: http://sources.redhat.com/cluster/conga @@ -44,7 +42,7 @@ Source2: %{plone_archive_file} Patch2: Plone-2.5_CMFPlone.patch %endif -Buildroot: %{_tmppath}/%{name}-%{version}-buildroot +Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %if "%{include_zope_and_plone}" == yes @@ -247,22 +245,18 @@ %config(noreplace) %{_sysconfdir}/oddjobd.conf.d/ricci-modrpm.oddjob.conf %config(noreplace) %{_sysconfdir}/dbus-1/system.d/ricci-modrpm.systembus.conf %{_sbindir}/ricci-modrpm - %{_sbindir}/ricci-modrpm.exe # modstorage %config(noreplace) %{_sysconfdir}/oddjobd.conf.d/ricci-modstorage.oddjob.conf %config(noreplace) %{_sysconfdir}/dbus-1/system.d/ricci-modstorage.systembus.conf %{_sbindir}/ricci-modstorage - %{_sbindir}/ricci-modstorage.exe # modservice %config(noreplace) %{_sysconfdir}/oddjobd.conf.d/ricci-modservice.oddjob.conf %config(noreplace) %{_sysconfdir}/dbus-1/system.d/ricci-modservice.systembus.conf %{_sbindir}/ricci-modservice - %{_sbindir}/ricci-modservice.exe # modlog %config(noreplace) %{_sysconfdir}/oddjobd.conf.d/ricci-modlog.oddjob.conf %config(noreplace) %{_sysconfdir}/dbus-1/system.d/ricci-modlog.systembus.conf %{_sbindir}/ricci-modlog - %{_sbindir}/ricci-modlog.exe %pre -n ricci /usr/sbin/groupadd -r -f ricci >/dev/null 2>&1 --- conga/ricci/common/Module.cpp 2006/08/10 22:53:07 1.4 +++ conga/ricci/common/Module.cpp 2006/08/15 04:15:52 1.5 @@ -44,8 +44,8 @@ static VarMap list_APIs(const VarMap& args); static VarMap extract_vars(const XMLObject& xml); static void insert_vars(const VarMap& vars, XMLObject& xml); - -static String clean_string(const String& msg); + + @@ -116,7 +116,7 @@ } catch ( String e ) { func_resp_xml.add_child(Variable("success", false).xml()); func_resp_xml.add_child(Variable("error_code", Except::generic_error).xml()); - func_resp_xml.add_child(Variable("error_description", clean_string(e)).xml()); + func_resp_xml.add_child(Variable("error_description", e).xml()); } catch ( APIerror e ) { throw; } catch ( ... ) { @@ -179,15 +179,6 @@ } -String -clean_string(const String& msg) -{ - String ret(msg); - String::size_type i; - while ((i = ret.find_first_of("\"<>")) != ret.npos) - ret[i] = ' '; - return ret; -} @@ -200,16 +191,67 @@ +// ################ ModuleDriver ###################### + -// ################ ModuleDriver ###################### +#include +static void +close_fd(int fd); +static int +__stdin_out_module_driver(Module& module); int -stdin_out_module_driver(Module& module) +stdin_out_module_driver(Module& module, + int argc, + char** argv) +{ + bool display_err = false; + int rv; + while ((rv = getopt(argc, argv, "e")) != EOF) + switch (rv) { + case 'e': + display_err = true; + break; + default: + break; + } + + int old_err; + if (!display_err) { + // redirect stderr to /dev/null + old_err = dup(2); + int devnull = open("/dev/null", O_RDWR); + if (devnull == -1) { + perror("stdin_out_module_driver(): Can't open /dev/null"); + exit(1); + } + dup2(devnull, 2); + close_fd(devnull); + } + + try { + + return __stdin_out_module_driver(module); + + } catch ( ... ) { + if (!display_err) { + // restore stderr + dup2(old_err, 2); + close_fd(old_err); + } + throw; + } +} + + + +int +__stdin_out_module_driver(Module& module) { unsigned int time_beg = time_mil(); String data; @@ -225,8 +267,7 @@ if (ret == 0) { // continue waiting continue; - } - else if (ret == -1) { + } else if (ret == -1) { if (errno == EINTR) continue; else @@ -244,11 +285,14 @@ } try { data.append(buff, ret); + shred(buff, sizeof(buff)); XMLObject request = parseXML(data); XMLObject response = module.process(request); cout << generateXML(response) << endl; return 0; - } catch ( ... ) {} + } catch ( ... ) { + shred(buff, sizeof(buff)); + } continue; } if (poll_data.revents & (POLLERR | POLLHUP | POLLNVAL)) @@ -260,3 +304,15 @@ throw String("invalid input"); } + + + + +void +close_fd(int fd) +{ + int e; + do { + e = close(fd); + } while (e && (errno == EINTR)); +} --- conga/ricci/include/Module.h 2006/08/10 22:53:07 1.2 +++ conga/ricci/include/Module.h 2006/08/15 04:15:53 1.3 @@ -57,7 +57,10 @@ }; // class Module -int stdin_out_module_driver(Module& module); +int +stdin_out_module_driver(Module& module, + int argc, + char** argv); #endif // Module_h --- conga/ricci/include/shred_allocator.h 2006/08/10 22:53:07 1.1 +++ conga/ricci/include/shred_allocator.h 2006/08/15 04:15:53 1.2 @@ -41,13 +41,11 @@ shred(_Tp* __p, size_t n) { size_t size = sizeof(_Tp) / sizeof(char) * n; - if (size && __p) { - // shred memory + if (size && __p) for (char *ptr = (char*) __p; ptr < ((char*) __p) + size; ptr++) *ptr = 'o'; - } } --- conga/ricci/modules/cluster/Makefile 2006/08/09 20:53:22 1.12 +++ conga/ricci/modules/cluster/Makefile 2006/08/15 04:15:53 1.13 @@ -14,7 +14,7 @@ include ${top_srcdir}/make/defines.mk -TARGET = modcluster.exe +TARGET = modcluster OBJECTS = main.o \ ClusterModule.o \ @@ -38,7 +38,6 @@ install: $(INSTALL_DIR) ${sbindir} $(INSTALL_BIN) ${TARGET} ${sbindir} - $(INSTALL_BIN) modcluster ${sbindir} $(INSTALL_DIR) ${sysconfdir}/oddjobd.conf.d $(INSTALL_FILE) d-bus/modcluster.oddjob.conf ${sysconfdir}/oddjobd.conf.d $(INSTALL_DIR) ${sysconfdir}/dbus-1/system.d --- conga/ricci/modules/cluster/main.cpp 2006/08/10 22:53:08 1.3 +++ conga/ricci/modules/cluster/main.cpp 2006/08/15 04:15:53 1.4 @@ -31,7 +31,9 @@ { try { ClusterModule m; - return stdin_out_module_driver(m); + return stdin_out_module_driver(m, + argc, + argv); } catch (String e) { cerr << e << endl; return 1; --- conga/ricci/modules/log/Makefile 2006/06/30 22:26:13 1.4 +++ conga/ricci/modules/log/Makefile 2006/08/15 04:15:53 1.5 @@ -14,7 +14,7 @@ include ${top_srcdir}/make/defines.mk -TARGET = ricci-modlog.exe +TARGET = ricci-modlog OBJECTS = main.o \ LoggingModule.o \ @@ -33,7 +33,6 @@ install: $(INSTALL_DIR) ${sbindir} $(INSTALL_BIN) ${TARGET} ${sbindir} - $(INSTALL_BIN) ricci-modlog ${sbindir} $(INSTALL_DIR) ${sysconfdir}/oddjobd.conf.d $(INSTALL_FILE) d-bus/ricci-modlog.oddjob.conf ${sysconfdir}/oddjobd.conf.d $(INSTALL_DIR) ${sysconfdir}/dbus-1/system.d --- conga/ricci/modules/log/main.cpp 2006/08/10 22:53:08 1.2 +++ conga/ricci/modules/log/main.cpp 2006/08/15 04:15:53 1.3 @@ -31,7 +31,9 @@ { try { LoggingModule m; - return stdin_out_module_driver(m); + return stdin_out_module_driver(m, + argc, + argv); } catch (String e) { cerr << e << endl; return 1; --- conga/ricci/modules/rpm/Makefile 2006/06/30 22:26:13 1.5 +++ conga/ricci/modules/rpm/Makefile 2006/08/15 04:15:53 1.6 @@ -14,7 +14,7 @@ include ${top_srcdir}/make/defines.mk -TARGET = ricci-modrpm.exe +TARGET = ricci-modrpm OBJECTS = main.o \ RpmModule.o \ @@ -34,7 +34,6 @@ install: $(INSTALL_DIR) ${sbindir} $(INSTALL_BIN) ${TARGET} ${sbindir} - $(INSTALL_BIN) ricci-modrpm ${sbindir} $(INSTALL_DIR) ${sysconfdir}/oddjobd.conf.d $(INSTALL_FILE) d-bus/ricci-modrpm.oddjob.conf ${sysconfdir}/oddjobd.conf.d $(INSTALL_DIR) ${sysconfdir}/dbus-1/system.d --- conga/ricci/modules/rpm/main.cpp 2006/08/10 22:53:08 1.3 +++ conga/ricci/modules/rpm/main.cpp 2006/08/15 04:15:53 1.4 @@ -31,7 +31,9 @@ { try { RpmModule m; - return stdin_out_module_driver(m); + return stdin_out_module_driver(m, + argc, + argv); } catch (String e) { cerr << e << endl; return 1; --- conga/ricci/modules/service/Makefile 2006/06/30 22:26:13 1.6 +++ conga/ricci/modules/service/Makefile 2006/08/15 04:15:53 1.7 @@ -14,7 +14,7 @@ include ${top_srcdir}/make/defines.mk -TARGET = ricci-modservice.exe +TARGET = ricci-modservice OBJECTS = main.o \ ServiceManager.o \ @@ -33,7 +33,6 @@ install: $(INSTALL_DIR) ${sbindir} $(INSTALL_BIN) ${TARGET} ${sbindir} - $(INSTALL_BIN) ricci-modservice ${sbindir} $(INSTALL_DIR) ${sysconfdir}/oddjobd.conf.d $(INSTALL_FILE) d-bus/ricci-modservice.oddjob.conf ${sysconfdir}/oddjobd.conf.d $(INSTALL_DIR) ${sysconfdir}/dbus-1/system.d --- conga/ricci/modules/service/main.cpp 2006/08/10 22:53:09 1.3 +++ conga/ricci/modules/service/main.cpp 2006/08/15 04:15:53 1.4 @@ -31,7 +31,9 @@ { try { ServiceModule m; - return stdin_out_module_driver(m); + return stdin_out_module_driver(m, + argc, + argv); } catch (String e) { cerr << e << endl; return 1; --- conga/ricci/modules/storage/Makefile 2006/06/30 22:26:13 1.8 +++ conga/ricci/modules/storage/Makefile 2006/08/15 04:15:54 1.9 @@ -14,7 +14,7 @@ include ${top_srcdir}/make/defines.mk -TARGET = ricci-modstorage.exe +TARGET = ricci-modstorage OBJECTS = main.o \ Props.o \ @@ -62,7 +62,6 @@ install: $(INSTALL_DIR) ${sbindir} $(INSTALL_BIN) ${TARGET} ${sbindir} - $(INSTALL_BIN) ricci-modstorage ${sbindir} $(INSTALL_DIR) ${sysconfdir}/oddjobd.conf.d $(INSTALL_FILE) d-bus/ricci-modstorage.oddjob.conf ${sysconfdir}/oddjobd.conf.d $(INSTALL_DIR) ${sysconfdir}/dbus-1/system.d --- conga/ricci/modules/storage/main.cpp 2006/08/10 22:53:09 1.3 +++ conga/ricci/modules/storage/main.cpp 2006/08/15 04:15:54 1.4 @@ -31,7 +31,9 @@ { try { StorageModule m; - return stdin_out_module_driver(m); + return stdin_out_module_driver(m, + argc, + argv); } catch (String e) { cerr << e << endl; return 1;