[condor: 19/31] Range of work. Includes first stab at BOSCO.
Brian Bockelman
bbockelm at fedoraproject.org
Fri Mar 8 01:21:13 UTC 2013
commit da2fd33ba439b5d322f734e8c4350674b95d90b0
Author: Brian Bockelman <bbockelm at cse.unl.edu>
Date: Tue Oct 30 20:48:29 2012 -0500
Range of work. Includes first stab at BOSCO.
...ser-s-condor_config-last-rather-than-firs.patch | 14 +-
condor.spec | 88 ++++-
condor_host_alias_patch.txt | 386 ++++++++++++++++++++
dprintf_syslog.patch | 324 ++++++++++++++++
4 files changed, 795 insertions(+), 17 deletions(-)
---
diff --git a/0001-Apply-the-user-s-condor_config-last-rather-than-firs.patch b/0001-Apply-the-user-s-condor_config-last-rather-than-firs.patch
index 46ecc9a..2fcf042 100644
--- a/0001-Apply-the-user-s-condor_config-last-rather-than-firs.patch
+++ b/0001-Apply-the-user-s-condor_config-last-rather-than-firs.patch
@@ -85,19 +85,19 @@ index fc760fa..72ad7b8 100644
- // 1) $HOME/.condor/condor_config
- struct passwd *pw = getpwuid( geteuid() );
- if ( !can_switch_ids() && pw && pw->pw_dir ) {
-- sprintf( locations[0], "%s/.%s/%s", pw->pw_dir, myDistro->Get(),
+- formatstr( locations[0], "%s/.%s/%s", pw->pw_dir, myDistro->Get(),
- file_name );
- }
// 2) /etc/condor/condor_config
-- locations[1].sprintf( "/etc/%s/%s", myDistro->Get(), file_name );
-+ locations[0].sprintf( "/etc/%s/%s", myDistro->Get(), file_name );
+- locations[1].formatstr( "/etc/%s/%s", myDistro->Get(), file_name );
++ locations[0].formatstr( "/etc/%s/%s", myDistro->Get(), file_name );
// 3) /usr/local/etc/condor_config (FreeBSD)
-- locations[2].sprintf( "/usr/local/etc/%s", file_name );
-+ locations[1].sprintf( "/usr/local/etc/%s", file_name );
+- locations[2].formatstr( "/usr/local/etc/%s", file_name );
++ locations[1].formatstr( "/usr/local/etc/%s", file_name );
if (tilde) {
// 4) ~condor/condor_config
-- locations[3].sprintf( "%s/%s", tilde, file_name );
-+ locations[2].sprintf( "%s/%s", tilde, file_name );
+- locations[3].formatstr( "%s/%s", tilde, file_name );
++ locations[2].formatstr( "%s/%s", tilde, file_name );
}
int ctr;
diff --git a/condor.spec b/condor.spec
index e214ee3..e6a4045 100644
--- a/condor.spec
+++ b/condor.spec
@@ -38,12 +38,17 @@
%define git_build 1
# If building with git tarball, Fedora requests us to record the rev. Use:
# git log -1 --pretty=format:'%h'
-%define git_rev ecc9193
+%define git_rev b714b0e
+
+%if ! (0%{?fedora} > 12 || 0%{?rhel} > 5)
+%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
+%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
+%endif
Summary: Condor: High Throughput Computing
Name: condor
-Version: 7.9.1
-%define condor_base_release 0.11
+Version: 7.9.2
+%define condor_base_release 0.2
%if %git_build
%define condor_release %condor_base_release.%{git_rev}.git
%else
@@ -113,14 +118,17 @@ Patch2: hcc_config.patch
Patch3: wso2-axis2.patch
Patch4: condor_pid_namespaces_v7.patch
Patch5: condor-gahp.patch
-Patch6: cgahp_scaling.patch
-Patch7: condor-1605-v2.patch
+#Patch6: cgahp_scaling.patch
+Patch7: condor-1605-v3.patch
+#Patch7: condor_host_alias_patch.txt
Patch8: lcmaps_env_in_init_script.patch
# See gt3158
Patch9: 0001-Apply-the-user-s-condor_config-last-rather-than-firs.patch
Patch11: condor_oom_v3.patch
# From ZKM
-Patch12: zkm-782.patch
+#Patch12: zkm-782.patch
+# Add syslog support to dprintf.
+Patch12: dprintf_syslog.patch
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
@@ -388,6 +396,23 @@ The cream_gahp enables the Condor grid universe to communicate with a remote
CREAM server.
%endif
+#######################
+%package bosco
+Summary: BOSCO, a Condor overlay system for managing jobs at remote clusters
+Url: http://bosco.opensciencegrid.org
+Group: Applications/System
+Requires: %name = %version-%release
+
+%description bosco
+BOSCO allows a locally-installed Condor to submit jobs to remote clusters,
+using SSH as a transit mechanism. It is designed for cases where the remote
+cluster is using a different batch system such as PBS, SGE, LSF, or another
+Condor system.
+
+BOSCO provides an overlay system so the remote clusters appear to be a Condor
+cluster. This allows the user to run their workflows using Condor tools across
+multiple clusters.
+
%pre
getent group condor >/dev/null || groupadd -r condor
getent passwd condor >/dev/null || \
@@ -410,11 +435,12 @@ exit 0
%patch3 -p0
%patch4 -p1
%patch5 -p1
-%patch6 -p1
+#%patch6 -p1
%patch7 -p1
%patch9 -p1
#%patch10 -p1
%patch11 -p1
+#%patch12 -p1
%patch12 -p1
%if %systemd
@@ -689,6 +715,14 @@ rm -rf %{buildroot}%{_datadir}/condor/libcondorapi.a
rm %{buildroot}%{_libexecdir}/condor/condor_schedd.init
+# Install BOSCO
+mkdir -p %{buildroot}%{python_sitelib}
+mv %{buildroot}%{_libexecdir}/condor/campus_factory/python-lib/GlideinWMS %{buildroot}%{python_sitelib}
+mv %{buildroot}%{_libexecdir}/condor/campus_factory/python-lib/campus_factory %{buildroot}%{python_sitelib}
+mv %{buildroot}%{_libexecdir}/condor/campus_factory/share/condor/condor_config.factory %{buildroot}%{_sysconfdir}/condor/config.d/60-campus_factory.config
+mv %{buildroot}%{_libexecdir}/condor/campus_factory/etc/campus_factory.conf %{buildroot}%{_sysconfdir}/condor/
+mv %{buildroot}%{_libexecdir}/condor/campus_factory/share %{buildroot}%{_datadir}/condor/campus_factory
+
%clean
rm -rf %{buildroot}
@@ -719,7 +753,7 @@ rm -rf %{buildroot}
#%_datadir/condor/Condor.pm
%_datadir/condor/scimark2lib.jar
%dir %_sysconfdir/condor/config.d/
-%_sysconfdir/condor/config.d/00personal_condor.config
+%config(noreplace) %_sysconfdir/condor/config.d/00personal_condor.config
%_sysconfdir/condor/condor_ssh_to_job_sshd_config_template
%dir %_libexecdir/condor/
%_libexecdir/condor/condor_chirp
@@ -885,7 +919,7 @@ rm -rf %{buildroot}
%dir %_var/run/condor
%endif
-%_libexecdir/condor/condor_defrag
+%_libexecdir/condor/accountant_log_fixer
%_datadir/condor/libcondorapi.so
%_libexecdir/condor/interactive.sub
@@ -902,7 +936,7 @@ rm -rf %{buildroot}
%files qmf
%defattr(-,root,root,-)
%doc LICENSE-2.0.txt NOTICE.txt
-%_sysconfdir/condor/config.d/60condor-qmf.config
+%config(noreplace) %_sysconfdir/condor/config.d/60condor-qmf.config
%dir %_libdir/condor/plugins
%_libdir/condor/plugins/MgmtCollectorPlugin-plugin.so
%_libdir/condor/plugins/MgmtMasterPlugin-plugin.so
@@ -1060,6 +1094,25 @@ rm -rf %{buildroot}
%_sbindir/cream_gahp
%endif
+%files bosco
+%defattr(-,root,root,-)
+%config(noreplace) %_sysconfdir/condor/campus_factory.conf
+%config(noreplace) %_sysconfdir/condor/config.d/60-campus_factory.config
+%_libexecdir/condor/shellselector
+%_libexecdir/condor/campus_factory
+%_sbindir/bosco_install
+%_sbindir/campus_factory
+%_sbindir/condor_ft-gahp
+%_sbindir/runfactory
+%_bindir/bosco_cluster
+%_bindir/bosco_ssh_start
+%_bindir/bosco_start
+%_bindir/bosco_stop
+%_bindir/bosco_uninstall
+%_datadir/condor/campus_factory
+%{python_sitelib}/GlideinWMS
+%{python_sitelib}/campus_factory
+
%if %systemd
%post
if [ $1 -eq 1 ] ; then
@@ -1113,6 +1166,21 @@ fi
%endif
%changelog
+* Tue Oct 30 2012 Brian Bockelman <bbockelm at cse.unl.edu> - 7.9.2-0.2.b714b0e.git
+- Re-up to the latest master.
+- Add support for syslog.
+
+* Thu Oct 11 2012 Brian Bockelman <bbockelm at cse.unl.edu> - 7.9.1-0.14.b135441.git
+- Re-up to the latest master.
+- Split out a separate package for BOSCO.
+
+* Tue Sep 25 2012 Brian Bockelman <bbockelm at cse.unl.edu> - 7.9.1-0.13.c7df613.git
+- Rebuild to re-enable blahp.
+
+* Mon Sep 24 2012 Brian Bockelman <bbockelm at cse.unl.edu> - 7.9.1-0.12.c7df613.git
+- Update to capture the latest security fixes.
+- CGAHP scalability fixes have been upstreamed.
+
* Wed Aug 15 2012 Brian Bockelman <bbockelm at cse.unl.edu> - 7.9.1-0.11.ecc9193.git
- Fixes to the JobRouter configuration.
diff --git a/condor_host_alias_patch.txt b/condor_host_alias_patch.txt
new file mode 100644
index 0000000..b14ac5d
--- /dev/null
+++ b/condor_host_alias_patch.txt
@@ -0,0 +1,386 @@
+commit 29f16f3edf7e2346c9677554e735e4abfe61c779
+Author: Dan Bradley <dan at hep.wisc.edu>
+Date: Tue Sep 18 16:43:14 2012 -0500
+
+ Allow GSI hostname check to work when client is connecting to a CNAME. #1605
+
+ The CNAME (alias) specified by the client must be stored in the
+ connection address (sinful string) so that it can be used when
+ verifying that the server's DN matches.
+
+diff --git a/src/condor_daemon_client/daemon.cpp b/src/condor_daemon_client/daemon.cpp
+index 59da24b..ebc19f4 100644
+--- a/src/condor_daemon_client/daemon.cpp
++++ b/src/condor_daemon_client/daemon.cpp
+@@ -55,6 +55,7 @@ Daemon::common_init() {
+ _is_configured = true;
+ _addr = NULL;
+ _name = NULL;
++ _alias = NULL;
+ _pool = NULL;
+ _version = NULL;
+ _platform = NULL;
+@@ -200,6 +201,7 @@ Daemon::deepCopy( const Daemon © )
+ // which is exactly what we want everywhere in this method.
+
+ New_name( strnewp(copy._name) );
++ New_alias( strnewp(copy._alias) );
+ New_hostname( strnewp(copy._hostname) );
+ New_full_hostname( strnewp(copy._full_hostname) );
+ New_addr( strnewp(copy._addr) );
+@@ -256,6 +258,7 @@ Daemon::~Daemon()
+ dprintf( D_HOSTNAME, " --- End of Daemon object info ---\n" );
+ }
+ if( _name ) delete [] _name;
++ if( _alias ) delete [] _alias;
+ if( _pool ) delete [] _pool;
+ if( _addr ) delete [] _addr;
+ if( _error ) delete [] _error;
+@@ -1109,9 +1112,12 @@ Daemon::getDaemonInfo( AdTypes adtype, bool query_collector )
+ } else return false;
+ buf = generate_sinful(hostaddr.to_ip_string().Value(), _port);
+ dprintf( D_HOSTNAME, "Found IP address and port %s\n", buf.c_str() );
+- New_addr( strnewp(buf.c_str()) );
+ if (fqdn.Length() > 0)
+ New_full_hostname(strnewp(fqdn.Value()));
++ if( host ) {
++ New_alias( strnewp(host) );
++ }
++ New_addr( strnewp(buf.c_str()) );
+ }
+
+ if (host) free( host );
+@@ -1134,9 +1140,10 @@ Daemon::getDaemonInfo( AdTypes adtype, bool query_collector )
+ newError( CA_LOCATE_FAILED, err_msg.c_str() );
+ return false;
+ }
+- // if it worked, we've not got the proper values for the
++ // if it worked, we've now got the proper values for the
+ // name (and the full hostname, since that's just the
+ // "host part" of the "name"...
++ New_alias( strnewp(get_host_part( _name )) );
+ New_name( tmp );
+ dprintf( D_HOSTNAME, "Using \"%s\" for name in Daemon object\n",
+ tmp );
+@@ -1475,8 +1482,11 @@ Daemon::findCmDaemon( const char* cm_name )
+ sinful.setHost(saddr.to_ip_string().Value());
+ dprintf( D_HOSTNAME, "Found IP address and port %s\n",
+ sinful.getSinful() ? sinful.getSinful() : "NULL" );
+- New_addr( strnewp( sinful.getSinful() ) );
+ New_full_hostname(strnewp(fqdn.Value()));
++ if( host ) {
++ New_alias( strnewp(host) );
++ }
++ New_addr( strnewp( sinful.getSinful() ) );
+ }
+
+ // If the pool was set, we want to use _name for that, too.
+@@ -1991,8 +2001,31 @@ Daemon::New_addr( char* str )
+ // This address explicitly specifies that UDP is not supported
+ m_has_udp_command_port = false;
+ }
++ if( !sinful.getAlias() && _alias ) {
++ size_t len = strlen(_alias);
++ // If _alias is not equivalent to the canonical hostname,
++ // then stash it in the sinful address. This is important
++ // in cases where we later verify that the certificate
++ // presented by the host we are connecting to matches
++ // the hostname we requested.
++ if( !_full_hostname || (strcmp(_alias,_full_hostname)!=0 && (strncmp(_alias,_full_hostname,len)!=0 || _full_hostname[len]!='.')) )
++ {
++ sinful.setAlias(_alias);
++ delete [] _addr;
++ _addr = strnewp( sinful.getSinful() );
++ }
++ }
+ }
+
++ if( _addr ) {
++ dprintf( D_HOSTNAME, "Daemon client (%s) address determined: "
++ "name: \"%s\", pool: \"%s\", alias: \"%s\", addr: \"%s\"\n",
++ daemonString(_type),
++ _name ? _name : "NULL",
++ _pool ? _pool : "NULL",
++ _alias ? _alias : "NULL",
++ _addr ? _addr : "NULL" );
++ }
+ return;
+ }
+
+@@ -2027,6 +2060,15 @@ Daemon::New_name( char* str )
+ return str;
+ }
+
++const char*
++Daemon::New_alias( char *str )
++{
++ if( _alias ) {
++ delete [] _alias;
++ }
++ _alias = str;
++ return str;
++}
+
+ char*
+ Daemon::New_pool( char* str )
+diff --git a/src/condor_daemon_client/daemon.h b/src/condor_daemon_client/daemon.h
+index 57fcd8a..8f0e99b 100644
+--- a/src/condor_daemon_client/daemon.h
++++ b/src/condor_daemon_client/daemon.h
+@@ -527,6 +527,7 @@ protected:
+ char* _hostname;
+ char* _full_hostname;
+ char* _addr;
++ char* _alias;
+ bool m_has_udp_command_port;
+ char* _version;
+ char* _platform;
+@@ -700,6 +701,7 @@ protected:
+ char* New_platform( char* );
+ void New_addr( char* );
+ char* New_pool( char* );
++ const char* New_alias( char* );
+
+ /**
+ Set a string so we know what command we're inside for use
+diff --git a/src/condor_includes/condor_attributes.h b/src/condor_includes/condor_attributes.h
+index 3dc1b87..5c0df6d 100644
+--- a/src/condor_includes/condor_attributes.h
++++ b/src/condor_includes/condor_attributes.h
+@@ -901,6 +901,7 @@ extern const char ATTR_SEC_AUTHENTICATED_USER [];
+ #define ATTR_RETRY "Retry"
+ #define ATTR_SSH_KEYGEN_ARGS "SSHKeyGenArgs"
+ #define ATTR_SOCK "sock"
++#define ATTR_ALIAS "alias"
+ #define ATTR_JOB_AD_INFORMATION_ATTRS "JobAdInformationAttrs"
+
+ #define ATTR_LAST_NEGOTIATION_CYCLE_TIME "LastNegotiationCycleTime"
+diff --git a/src/condor_includes/sock.h b/src/condor_includes/sock.h
+index ca1b1c8..55f808e 100644
+--- a/src/condor_includes/sock.h
++++ b/src/condor_includes/sock.h
+@@ -279,7 +279,7 @@ public:
+ int get_port();
+
+ /// sinful address of mypoint() in the form of "<a.b.c.d:pppp>"
+- char * get_sinful();
++ char const * get_sinful();
+
+ /// Sinful address for access from outside of our private network.
+ /// This takes into account TCP_FORWARDING_HOST.
+@@ -507,10 +507,10 @@ private:
+ char _sinful_peer_buf[SINFUL_STRING_BUF_SIZE];
+
+ // Buffer to hold the sinful address of ourself
+- char _sinful_self_buf[SINFUL_STRING_BUF_SIZE];
++ std::string _sinful_self_buf;
+
+ // Buffer to hold the public sinful address of ourself
+- char _sinful_public_buf[SINFUL_STRING_BUF_SIZE];
++ std::string _sinful_public_buf;
+
+ // struct to hold state info for do_connect() method
+ struct connect_state_struct {
+diff --git a/src/condor_io/cedar_no_ckpt.cpp b/src/condor_io/cedar_no_ckpt.cpp
+index 34df44f..8aaff8b 100644
+--- a/src/condor_io/cedar_no_ckpt.cpp
++++ b/src/condor_io/cedar_no_ckpt.cpp
+@@ -877,12 +877,16 @@ ReliSock::do_shared_port_local_connect( char const *shared_port_id, bool nonbloc
+ // to be the standard network interface, because localhost
+ // typically does not happen to be allowed in the authorization policy
+ const bool use_standard_interface = true;
++ std::string orig_connect_addr = get_connect_addr() ? get_connect_addr() : "";
+ if( !connect_socketpair(sock_to_pass,use_standard_interface) ) {
+ dprintf(D_ALWAYS,
+ "Failed to connect to loopback socket, so failing to connect via local shared port access to %s.\n",
+ peer_description());
+ return 0;
+ }
++ // restore the original connect address, which got overwritten
++ // in connect_socketpair()
++ set_connect_addr(orig_connect_addr.c_str());
+
+ char const *request_by = "";
+ if( !shared_port_client.PassSocket(&sock_to_pass,shared_port_id,request_by) ) {
+@@ -938,10 +942,16 @@ Sock::get_sinful_public()
+ addr = addrs.front();
+ }
+ addr.set_port(get_port());
+- strncpy(_sinful_public_buf, addr.to_sinful().Value(),
+- SINFUL_STRING_BUF_SIZE);
+- _sinful_public_buf[SINFUL_STRING_BUF_SIZE-1] = '\0';
+- return _sinful_public_buf;
++ _sinful_public_buf = addr.to_sinful().Value();
++
++ std::string alias;
++ if( param(alias,"HOST_ALIAS") ) {
++ Sinful s(_sinful_public_buf.c_str());
++ s.setAlias(alias.c_str());
++ _sinful_public_buf = s.getSinful();
++ }
++
++ return _sinful_public_buf.c_str();
+ }
+
+ return get_sinful();
+diff --git a/src/condor_io/condor_auth_x509.cpp b/src/condor_io/condor_auth_x509.cpp
+index ad04ddc..98368bf 100644
+--- a/src/condor_io/condor_auth_x509.cpp
++++ b/src/condor_io/condor_auth_x509.cpp
+@@ -31,6 +31,7 @@
+ #include "globus_utils.h"
+ #include "condor_gssapi_openssl.h"
+ #include "ipv6_hostname.h"
++#include "condor_sinful.h"
+
+ #if defined(HAVE_EXT_VOMS)
+ extern "C" {
+@@ -873,6 +874,18 @@ bool Condor_Auth_X509::CheckServerName(char const *fqh,char const *ip,ReliSock *
+ OM_uint32 major_status = 0;
+ OM_uint32 minor_status = 0;
+
++ char const *connect_addr = sock->get_connect_addr();
++ std::string alias_buf;
++ if( connect_addr ) {
++ Sinful s(connect_addr);
++ char const *alias = s.getAlias();
++ if( alias ) {
++ dprintf(D_FULLDEBUG,"GSI host check: using host alias %s for %s %s\n",alias,fqh,sock->peer_ip_str());
++ alias_buf = alias;
++ fqh = alias_buf.c_str();
++ }
++ }
++
+ formatstr(connect_name,"%s/%s",fqh,sock->peer_ip_str());
+
+ gss_connect_name_buf.value = strdup(connect_name.c_str());
+@@ -902,11 +915,11 @@ bool Condor_Auth_X509::CheckServerName(char const *fqh,char const *ip,ReliSock *
+
+ if( !name_equal ) {
+ std::string msg;
+- formatstr(msg,"We are trying to connect to a daemon with certificate DN (%s), but the host name in the certificate does not match any DNS name associated with the host to which we are connecting (host name is '%s', IP is '%s', Condor connection address is '%s'). Check that DNS is correctly configured. If you wish to use a daemon certificate that does not match the daemon's host name, make GSI_SKIP_HOST_CHECK_CERT_REGEX match the DN, or disable all host name checks by setting GSI_SKIP_HOST_CHECK=true or by defining GSI_DAEMON_NAME.\n",
++ formatstr(msg,"We are trying to connect to a daemon with certificate DN (%s), but the host name in the certificate does not match any DNS name associated with the host to which we are connecting (host name is '%s', IP is '%s', Condor connection address is '%s'). Check that DNS is correctly configured. If the certificate is for a DNS alias, configure HOST_ALIAS in the daemon's configuration. If you wish to use a daemon certificate that does not match the daemon's host name, make GSI_SKIP_HOST_CHECK_CERT_REGEX match the DN, or disable all host name checks by setting GSI_SKIP_HOST_CHECK=true or by defining GSI_DAEMON_NAME.\n",
+ server_dn,
+ fqh,
+ ip,
+- sock->peer_description() );
++ connect_addr ? connect_addr : sock->peer_description() );
+ errstack->push("GSI", GSI_ERR_DNS_CHECK_ERROR, msg.c_str());
+ }
+ return name_equal != 0;
+diff --git a/src/condor_io/shared_port_endpoint.cpp b/src/condor_io/shared_port_endpoint.cpp
+index 18e141c..a26a49f 100644
+--- a/src/condor_io/shared_port_endpoint.cpp
++++ b/src/condor_io/shared_port_endpoint.cpp
+@@ -809,6 +809,10 @@ SharedPortEndpoint::GetMyLocalAddress()
+ sinful.setPort("0");
+ sinful.setHost(my_ip_string());
+ sinful.setSharedPortID( m_local_id.Value() );
++ std::string alias;
++ if( param(alias,"HOST_ALIAS") ) {
++ sinful.setAlias(alias.c_str());
++ }
+ m_local_addr = sinful.getSinful();
+ }
+ return m_local_addr.Value();
+diff --git a/src/condor_io/sock.cpp b/src/condor_io/sock.cpp
+index c4dcb0b..934b189 100644
+--- a/src/condor_io/sock.cpp
++++ b/src/condor_io/sock.cpp
+@@ -35,6 +35,7 @@
+ #include "authentication.h"
+ #include "condor_sockfunc.h"
+ #include "condor_ipv6.h"
++#include "condor_config.h"
+
+ #ifdef HAVE_EXT_OPENSSL
+ #include "condor_crypt_blowfish.h"
+@@ -1806,8 +1807,8 @@ Sock::addr_changed()
+ // either the peer's address or our address change, zap them all
+ _my_ip_buf[0] = '\0';
+ _peer_ip_buf[0] = '\0';
+- _sinful_self_buf[0] = '\0';
+- _sinful_public_buf[0] = '\0';
++ _sinful_self_buf.clear();
++ _sinful_public_buf.clear();
+ _sinful_peer_buf[0] = '\0';
+ }
+
+@@ -1983,18 +1984,25 @@ Sock::my_ip_str()
+ return _my_ip_buf;
+ }
+
+-char *
++char const *
+ Sock::get_sinful()
+-{
+- if( !_sinful_self_buf[0] ) {
++{
++ if( _sinful_self_buf.empty() ) {
+ condor_sockaddr addr;
+ int ret = condor_getsockname_ex(_sock, addr);
+ if (ret == 0) {
+- MyString sinful_self = addr.to_sinful();
+- strcpy(_sinful_self_buf, sinful_self.Value());
+- }
++ _sinful_self_buf = addr.to_sinful();
++
++ std::string alias;
++ if( param(alias,"HOST_ALIAS") ) {
++ Sinful s(_sinful_self_buf.c_str());
++ s.setAlias(alias.c_str());
++ _sinful_self_buf = s.getSinful();
++ }
++
++ }
+ }
+- return _sinful_self_buf;
++ return _sinful_self_buf.c_str();
+ }
+
+ char *
+diff --git a/src/condor_utils/condor_sinful.cpp b/src/condor_utils/condor_sinful.cpp
+index 9eab941..5bd1532 100644
+--- a/src/condor_utils/condor_sinful.cpp
++++ b/src/condor_utils/condor_sinful.cpp
+@@ -292,6 +292,18 @@ Sinful::getSharedPortID() const
+ }
+
+ void
++Sinful::setAlias(char const *alias)
++{
++ setParam(ATTR_ALIAS,alias);
++}
++
++char const *
++Sinful::getAlias() const
++{
++ return getParam(ATTR_ALIAS);
++}
++
++void
+ Sinful::setPrivateAddr(char const *addr)
+ {
+ setParam("PrivAddr",addr);
+diff --git a/src/condor_utils/condor_sinful.h b/src/condor_utils/condor_sinful.h
+index 5198b9f..8d8307c 100644
+--- a/src/condor_utils/condor_sinful.h
++++ b/src/condor_utils/condor_sinful.h
+@@ -69,6 +69,9 @@ class Sinful {
+ // id of SharedPortEndpoint (i.e. basename of named socket)
+ char const *getSharedPortID() const;
+ void setSharedPortID(char const *contact);
++ // hostname alias
++ char const *getAlias() const;
++ void setAlias(char const *alias);
+ // is the noUDP flag set in this address?
+ bool noUDP() const;
+ void setNoUDP(bool flag);
+@@ -91,6 +94,7 @@ class Sinful {
+ std::string m_sinful; // the sinful string "<host:port?params>"
+ std::string m_host;
+ std::string m_port;
++ std::string m_alias;
+ std::map<std::string,std::string> m_params; // key value pairs from params
+ bool m_valid;
+
diff --git a/dprintf_syslog.patch b/dprintf_syslog.patch
new file mode 100644
index 0000000..c567266
--- /dev/null
+++ b/dprintf_syslog.patch
@@ -0,0 +1,324 @@
+From cf86dbaf75f4c81e406036b6695c717cf4fd1331 Mon Sep 17 00:00:00 2001
+From: Brian Bockelman <bbockelm at cse.unl.edu>
+Date: Wed, 24 Oct 2012 20:28:09 -0500
+Subject: [PATCH 1/3] First attempt at syslog code for dprintf.
+
+---
+ src/condor_includes/dprintf_internal.h | 11 ++++-
+ src/condor_utils/dprintf_setup.cpp | 16 ++++++
+ src/condor_utils/dprintf_syslog.cpp | 19 +++++++
+ src/condor_utils/dprintf_syslog.h | 82 ++++++++++++++++++++++++++++++++
+ 4 files changed, 127 insertions(+), 1 deletions(-)
+ create mode 100644 src/condor_utils/dprintf_syslog.cpp
+ create mode 100644 src/condor_utils/dprintf_syslog.h
+
+diff --git a/src/condor_includes/dprintf_internal.h b/src/condor_includes/dprintf_internal.h
+index c26a886..b0ecf48 100644
+--- a/src/condor_includes/dprintf_internal.h
++++ b/src/condor_includes/dprintf_internal.h
+@@ -17,6 +17,9 @@
+ *
+ ***************************************************************/
+
++#ifndef __dprintf_internal_h_
++#define __dprintf_internal_h_
++
+ // This #define doesn't actually do anything. This value needs to be
+ // defined before any system header files are included in the source file
+ // to have any effect.
+@@ -27,6 +30,7 @@ typedef _Longlong int64_t;
+ #else
+ #include <stdint.h>
+ #endif
++#include <ctime>
+
+ struct DebugFileInfo;
+
+@@ -37,7 +41,8 @@ enum DebugOutput
+ FILE_OUT,
+ STD_OUT,
+ STD_ERR,
+- OUTPUT_DEBUG_STR
++ OUTPUT_DEBUG_STR,
++ SYSLOG
+ };
+
+ /* future
+@@ -70,6 +75,7 @@ struct DebugFileInfo
+ bool want_truncate;
+ bool accepts_all;
+ bool dont_panic;
++ void *userData;
+ DebugFileInfo() :
+ outputTarget(FILE_OUT),
+ debugFP(0),
+@@ -79,6 +85,7 @@ struct DebugFileInfo
+ want_truncate(false),
+ accepts_all(false),
+ dont_panic(false),
++ userData(NULL),
+ dprintfFunc(NULL)
+ {}
+ DebugFileInfo(const DebugFileInfo &dfi) : outputTarget(dfi.outputTarget), debugFP(NULL), choice(dfi.choice),
+@@ -115,3 +122,5 @@ void _dprintf_global_func(int cat_and_flags, int hdr_flags, time_t clock_now, st
+ void dprintf_to_outdbgstr(int cat_and_flags, int hdr_flags, time_t clock_now, struct tm *tm, const char* message, DebugFileInfo* dbgInfo);
+ #endif
+
++#endif
++
+diff --git a/src/condor_utils/dprintf_setup.cpp b/src/condor_utils/dprintf_setup.cpp
+index 440ef98..b1ccd3a 100644
+--- a/src/condor_utils/dprintf_setup.cpp
++++ b/src/condor_utils/dprintf_setup.cpp
+@@ -24,6 +24,7 @@
+ #include "condor_sys_types.h"
+ #include "condor_debug.h"
+ #include "dprintf_internal.h"
++#include "dprintf_syslog.h"
+ #include "condor_constants.h"
+
+ #if HAVE_BACKTRACE
+@@ -134,6 +135,13 @@ void dprintf_set_outputs(const struct dprintf_output_settings *p_info, int c_inf
+ it->dprintfFunc = dprintf_to_outdbgstr;
+ }
+ #endif
++ else if (logPath == "SYSLOG")
++ {
++ // Intention is to eventually user-selected
++ it->dprintfFunc = DprintfSyslog::Log;
++ it->outputTarget = SYSLOG;
++ it->userData = static_cast<void*>(DprintfSyslogFactory::NewLog(LOG_DAEMON));
++ }
+ else
+ {
+ it->outputTarget = FILE_OUT;
+@@ -211,6 +219,14 @@ void dprintf_set_outputs(const struct dprintf_output_settings *p_info, int c_inf
+
+ if(debugLogsOld)
+ {
++
++ for (it = debugLogsOld->begin(); it != debugLogsOld->end(); it++)
++ {
++ if ((it->outputTarget == SYSLOG) && (it->userData))
++ {
++ delete static_cast<DprintfSyslog*>(it->userData);
++ }
++ }
+ delete debugLogsOld;
+ }
+
+diff --git a/src/condor_utils/dprintf_syslog.cpp b/src/condor_utils/dprintf_syslog.cpp
+new file mode 100644
+index 0000000..d0189f8
+--- /dev/null
++++ b/src/condor_utils/dprintf_syslog.cpp
+@@ -0,0 +1,19 @@
++
++#include "condor_common.h"
++#include "condor_debug.h"
++#include "dprintf_syslog.h"
++
++DprintfSyslogFactory * DprintfSyslogFactory::m_singleton = NULL;
++
++void
++DprintfSyslog::Log(const char * message)
++{
++ syslog(LOG_INFO, "%s", message);
++}
++
++DprintfSyslog::~DprintfSyslog()
++{
++ DprintfSyslogFactory &factory = DprintfSyslogFactory::getInstance();
++ factory.DecCount();
++}
++
+diff --git a/src/condor_utils/dprintf_syslog.h b/src/condor_utils/dprintf_syslog.h
+new file mode 100644
+index 0000000..a10d42d
+--- /dev/null
++++ b/src/condor_utils/dprintf_syslog.h
+@@ -0,0 +1,82 @@
++
++#include "dprintf_internal.h"
++#include <syslog.h>
++
++class DprintfSyslogFactory;
++
++class DprintfSyslog
++{
++ friend class DprintfSyslogFactory;
++
++public:
++ static void Log(int, int, time_t, struct tm*, const char * message, DebugFileInfo* info)
++ {
++ if (!info || !info->userData)
++ {
++ return;
++ }
++ DprintfSyslog * logger = static_cast<DprintfSyslog*>(info->userData);
++ logger->Log(message);
++ }
++
++ ~DprintfSyslog();
++
++protected:
++ DprintfSyslog() {}
++
++private:
++ void Log(const char *);
++};
++
++class DprintfSyslogFactory
++{
++ friend class DprintfSyslog;
++
++public:
++ static DprintfSyslog *NewLog(int facility)
++ {
++ DprintfSyslogFactory & factory = getInstance();
++ return factory.NewDprintfSyslog(facility);
++ }
++
++protected:
++ void DecCount()
++ {
++ m_count--;
++ if (m_count == 0)
++ {
++ closelog();
++ }
++ }
++
++ static DprintfSyslogFactory & getInstance()
++ {
++ if (!m_singleton)
++ {
++ m_singleton = new DprintfSyslogFactory();
++ }
++ return *m_singleton;
++ }
++
++private:
++ DprintfSyslog * NewDprintfSyslog(int facility)
++ {
++ DprintfSyslog * logger = new DprintfSyslog();
++ if (!logger) return NULL;
++ if (m_count == 0)
++ {
++ openlog("condor", LOG_PID|LOG_NDELAY, facility);
++ }
++ m_count++;
++ return logger;
++ }
++
++ DprintfSyslogFactory() :
++ m_count(0)
++ {
++ }
++
++ static DprintfSyslogFactory *m_singleton;
++
++ unsigned int m_count;
++};
+--
+1.7.4.1
+
+
+From 5b17f58b41722735bf1a7da34c728bfe3114479b Mon Sep 17 00:00:00 2001
+From: Brian Bockelman <bbockelm at cse.unl.edu>
+Date: Wed, 24 Oct 2012 20:46:52 -0500
+Subject: [PATCH 2/3] Don't provide an ident - it defaults to the binary name, which is more useful anyway.
+
+---
+ src/condor_utils/dprintf_syslog.h | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/src/condor_utils/dprintf_syslog.h b/src/condor_utils/dprintf_syslog.h
+index a10d42d..364a228 100644
+--- a/src/condor_utils/dprintf_syslog.h
++++ b/src/condor_utils/dprintf_syslog.h
+@@ -65,7 +65,7 @@ private:
+ if (!logger) return NULL;
+ if (m_count == 0)
+ {
+- openlog("condor", LOG_PID|LOG_NDELAY, facility);
++ openlog(NULL, LOG_PID|LOG_NDELAY, facility);
+ }
+ m_count++;
+ return logger;
+--
+1.7.4.1
+
+
+From d082fcc410b3729241dbe82912f526d51a96a2f5 Mon Sep 17 00:00:00 2001
+From: Brian Bockelman <bbockelm at cse.unl.edu>
+Date: Tue, 30 Oct 2012 18:15:21 -0500
+Subject: [PATCH 3/3] Prevent dprintf_syslog from compiling on Windows.
+
+---
+ src/condor_utils/CMakeLists.txt | 4 +++-
+ src/condor_utils/dprintf_setup.cpp | 7 ++++++-
+ 2 files changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/src/condor_utils/CMakeLists.txt b/src/condor_utils/CMakeLists.txt
+index 7ce1fd6..7de76fb 100644
+--- a/src/condor_utils/CMakeLists.txt
++++ b/src/condor_utils/CMakeLists.txt
+@@ -84,10 +84,12 @@ endif()
+ ##################################################
+ # condorapi & tests
+
+-condor_selective_glob("my_username.*;condor_event.*;file_sql.*;misc_utils.*;user_log_header.*;write_user_log*;read_user_log*;iso_dates.*;file_lock.*;format_time.*;utc_time.*;stat_wrapper*;log_rotate.*;dprintf*;sig_install.*;basename.*;mkargv.*;except.*;strupr.*;lock_file.*;rotate_file.*;strcasestr.*;strnewp.*;condor_environ.*;setsyscalls.*;passwd_cache.*;uids.c*;chomp.*;subsystem_info.*;my_subsystem.*;distribution.*;my_distribution.*;get_random_num.*;libcondorapi_stubs.*;seteuid.*;setegid.*;condor_open.*;classad_merge.*;condor_attributes.*;simple_arg.*;compat_classad.*;compat_classad_util.*;classad_oldnew.*;condor_snutils.*;stringSpace.*;string_list.*;stl_string_utils.*;MyString.*;condor_xml_classads.*;directory*;param_functions.*;filename_tools_cpp.*;filename_tools.*;stat_info.*;${SAFE_OPEN_SRC}" ApiSrcs)
++condor_selective_glob("my_username.*;condor_event.*;file_sql.*;misc_utils.*;user_log_header.*;write_user_log*;read_user_log*;iso_dates.*;file_lock.*;format_time.*;utc_time.*;stat_wrapper*;log_rotate.*;dprintf.cpp;dprintf_c*;dprintf_setup.cpp;sig_install.*;basename.*;mkargv.*;except.*;strupr.*;lock_file.*;rotate_file.*;strcasestr.*;strnewp.*;condor_environ.*;setsyscalls.*;passwd_cache.*;uids.c*;chomp.*;subsystem_info.*;my_subsystem.*;distribution.*;my_distribution.*;get_random_num.*;libcondorapi_stubs.*;seteuid.*;setegid.*;condor_open.*;classad_merge.*;condor_attributes.*;simple_arg.*;compat_classad.*;compat_classad_util.*;classad_oldnew.*;condor_snutils.*;stringSpace.*;string_list.*;stl_string_utils.*;MyString.*;condor_xml_classads.*;directory*;param_functions.*;filename_tools_cpp.*;filename_tools.*;stat_info.*;${SAFE_OPEN_SRC}" ApiSrcs)
+ if(WINDOWS)
+ condor_selective_glob("directory.WINDOWS.*;directory_util.*;dynuser.WINDOWS.*;lock_file.WINDOWS.*;lsa_mgr.*;my_dynuser.*;ntsysinfo.WINDOWS.*;posix.WINDOWS.*;stat.WINDOWS.*;store_cred.*;token_cache.WINDOWS.*;truncate.WINDOWS.*" ApiSrcs)
+ set_property( TARGET utils_genparams PROPERTY FOLDER "libraries" )
++else()
++ condor_selective_glob("dprintf_syslog*" ApiSrcs)
+ endif()
+
+ condor_static_lib( condorapi "${ApiSrcs}" )
+diff --git a/src/condor_utils/dprintf_setup.cpp b/src/condor_utils/dprintf_setup.cpp
+index b1ccd3a..b5938e2 100644
+--- a/src/condor_utils/dprintf_setup.cpp
++++ b/src/condor_utils/dprintf_setup.cpp
+@@ -24,7 +24,9 @@
+ #include "condor_sys_types.h"
+ #include "condor_debug.h"
+ #include "dprintf_internal.h"
++#if !defined(WIN32)
+ #include "dprintf_syslog.h"
++#endif
+ #include "condor_constants.h"
+
+ #if HAVE_BACKTRACE
+@@ -134,7 +136,7 @@ void dprintf_set_outputs(const struct dprintf_output_settings *p_info, int c_inf
+ it->outputTarget = OUTPUT_DEBUG_STR;
+ it->dprintfFunc = dprintf_to_outdbgstr;
+ }
+-#endif
++#else
+ else if (logPath == "SYSLOG")
+ {
+ // Intention is to eventually user-selected
+@@ -142,6 +144,7 @@ void dprintf_set_outputs(const struct dprintf_output_settings *p_info, int c_inf
+ it->outputTarget = SYSLOG;
+ it->userData = static_cast<void*>(DprintfSyslogFactory::NewLog(LOG_DAEMON));
+ }
++#endif
+ else
+ {
+ it->outputTarget = FILE_OUT;
+@@ -224,7 +227,9 @@ void dprintf_set_outputs(const struct dprintf_output_settings *p_info, int c_inf
+ {
+ if ((it->outputTarget == SYSLOG) && (it->userData))
+ {
++#if !defined(WIN32)
+ delete static_cast<DprintfSyslog*>(it->userData);
++#endif
+ }
+ }
+ delete debugLogsOld;
+--
+1.7.4.1
+
More information about the scm-commits
mailing list