[dpm-xrootd] Fix build with xrootd 4
Alejandro Alvarez
aalvarez at fedoraproject.org
Wed Jul 9 12:44:45 UTC 2014
commit aba8f07a7845a5e3faa407db4ae144c7128a73cd
Author: Alejandro Alvarez Ayllon <aalvarez at cern.ch>
Date: Wed Jul 9 14:35:56 2014 +0200
Fix build with xrootd 4
dpm-xrootd-xrootd4.patch | 439 ++++++++++++++++++++++++++++++++++++++++++++++
dpm-xrootd.spec | 16 ++-
2 files changed, 451 insertions(+), 4 deletions(-)
---
diff --git a/dpm-xrootd-xrootd4.patch b/dpm-xrootd-xrootd4.patch
new file mode 100644
index 0000000..a06cdd1
--- /dev/null
+++ b/dpm-xrootd-xrootd4.patch
@@ -0,0 +1,439 @@
+Index: dpm-xrootd/trunk/include/XrdDPM/XrdDPMFinder.hh
+===================================================================
+--- dpm-xrootd/trunk/include/XrdDPM/XrdDPMFinder.hh (revision 9675)
++++ dpm-xrootd/trunk/include/XrdDPM/XrdDPMFinder.hh (revision 10610)
+@@ -18,4 +18,5 @@
+ #include <XrdOuc/XrdOucErrInfo.hh>
+ #include <XrdAcc/XrdAccAuthorize.hh>
++#include <XrdNet/XrdNetAddr.hh>
+
+ #include <sys/types.h>
+@@ -39,5 +40,5 @@
+ unsigned short xrd_server_port;
+ bool mkpath_bool;
+- std::vector<sockaddr_storage> mmReqHosts;
++ std::vector<XrdNetAddr> mmReqHosts;
+
+ time_t reqput_lifetime;
+@@ -138,5 +139,4 @@
+ bool IsMetaManagerDiscover(XrdOucEnv *Info, int flags,
+ const char *path, const char *user);
+- XrdOucString SockaddrToIP(const sockaddr *sa);
+
+ void DpmAdded(const char *path, int Pend=0);
+Index: dpm-xrootd/trunk/src/XrdDPMRedirAcc.cc
+===================================================================
+--- dpm-xrootd/trunk/src/XrdDPMRedirAcc.cc (revision 8037)
++++ dpm-xrootd/trunk/src/XrdDPMRedirAcc.cc (revision 10610)
+@@ -19,7 +19,5 @@
+ // globals
+
+-#if XrdVNUMBER >= 30300
+ XrdVERSIONINFO(XrdAccAuthorizeObject,XrdDPMRedirAcc)
+-#endif
+
+ namespace DpmRedirAcc {
+Index: dpm-xrootd/trunk/src/XrdDPMFinderConfig.cc
+===================================================================
+--- dpm-xrootd/trunk/src/XrdDPMFinderConfig.cc (revision 9675)
++++ dpm-xrootd/trunk/src/XrdDPMFinderConfig.cc (revision 10610)
+@@ -9,4 +9,6 @@
+ #include <XrdOuc/XrdOucStream.hh>
+ #include <XrdOuc/XrdOuca2x.hh>
++#include <XrdNet/XrdNetAddr.hh>
++#include <XrdNet/XrdNetUtils.hh>
+
+ #include <sys/types.h>
+@@ -14,6 +16,4 @@
+ #include <fcntl.h>
+ #include <string.h>
+-#include <sys/socket.h>
+-#include <netdb.h>
+ #include <stdio.h>
+
+@@ -373,27 +373,12 @@
+ for(itr=reqhost.begin();itr!=reqhost.end();++itr) {
+ const char *host = SafeCStr(*itr);
+- addrinfo hints;
+- addrinfo *ai, *aitop;
+- int gaierrno;
+- memset (&hints, 0, sizeof(hints));
+- hints.ai_family = AF_UNSPEC;
+- hints.ai_socktype = SOCK_STREAM;
+- gaierrno = getaddrinfo(host, 0, &hints, &aitop);
+- if (gaierrno != 0) {
+- Say.Emsg("Config","Could not resolve "
+- "mmreqhost hostname",host);
+- NoGo |= 1;
+- } else {
+- sockaddr_storage ss;
+- for(ai=aitop;ai;ai=ai->ai_next) {
+- if (ai->ai_family != AF_INET &&
+- ai->ai_family != AF_INET6)
+- continue;
+- memset(&ss,0,sizeof(ss));
+- memcpy(&ss,ai->ai_addr,ai->ai_addrlen);
+- Opts.mmReqHosts.push_back(ss);
+- }
+- freeaddrinfo(aitop);
+- }
++ XrdNetAddr *nap = 0;
++ int num = 0;
++ XrdNetUtils::GetAddrs(host, &nap, num, XrdNetUtils::allIPMap,
++ XrdNetUtils::NoPortRaw);
++ for(int i=0;i<num;++i) {
++ Opts.mmReqHosts.push_back(nap[i]);
++ }
++ delete[] nap;
+ }
+
+@@ -594,14 +579,11 @@
+ TRACEX("fixed ID authz = No");
+ }
+- for(std::vector<sockaddr_storage>::const_iterator itr=
++ for(std::vector<XrdNetAddr>::iterator itr=
+ Opts.mmReqHosts.begin();
+ itr!=Opts.mmReqHosts.end();++itr) {
+- union {
+- sockaddr_storage ss;
+- sockaddr sa;
+- } u;
+- u.ss = *itr;
+- TRACEX("mmReqHost = "
+- << SockaddrToIP(&u.sa));
++ char ipbuff[512];
++ itr->Format(ipbuff, sizeof(ipbuff), XrdNetAddr::fmtAddr,
++ XrdNetAddr::noPort);
++ TRACEX("mmReqHost = " << XrdOucString(ipbuff));
+ }
+ if (enableCms) {
+Index: dpm-xrootd/trunk/src/XrdDPMDiskAcc.cc
+===================================================================
+--- dpm-xrootd/trunk/src/XrdDPMDiskAcc.cc (revision 8063)
++++ dpm-xrootd/trunk/src/XrdDPMDiskAcc.cc (revision 10610)
+@@ -16,7 +16,5 @@
+ #include <vector>
+
+-#if XrdVNUMBER >= 30300
+ XrdVERSIONINFO(XrdAccAuthorizeObject,XrdDPMDiskAcc)
+-#endif
+
+ /******************************************************************************/
+Index: dpm-xrootd/trunk/src/XrdDPMOss.cc
+===================================================================
+--- dpm-xrootd/trunk/src/XrdDPMOss.cc (revision 9879)
++++ dpm-xrootd/trunk/src/XrdDPMOss.cc (revision 10610)
+@@ -31,7 +31,5 @@
+ #include <dmlite/cpp/poolmanager.h>
+
+-#if XrdVNUMBER >= 30300
+ XrdVERSIONINFO(XrdOssGetStorageSystem,XrdDPMOss)
+-#endif
+
+ /******************************************************************************/
+Index: dpm-xrootd/trunk/src/XrdDPMFinder.cc
+===================================================================
+--- dpm-xrootd/trunk/src/XrdDPMFinder.cc (revision 9909)
++++ dpm-xrootd/trunk/src/XrdDPMFinder.cc (revision 10610)
+@@ -12,19 +12,12 @@
+ #include <XrdSfs/XrdSfsInterface.hh>
+ #include <XrdSys/XrdSysPlugin.hh>
+-#include <XrdSys/XrdSysDNS.hh>
++#include <XrdNet/XrdNetAddr.hh>
++#include <XrdNet/XrdNetUtils.hh>
+ #include <XrdSys/XrdSysPthread.hh>
+-#include <Xrd/XrdLink.hh>
+-#include <Xrd/XrdLinkMatch.hh>
+ #include <XrdVersion.hh>
+-
+-#if XrdVNUMBER < 30300
+-#include <XrdCms/XrdCmsFinder.hh>
+-#endif
+
+ #include <sys/time.h>
+ #include <sys/select.h>
+ #include <sys/stat.h>
+-#include <arpa/inet.h>
+-#include <netinet/in.h>
+ #include <fcntl.h>
+ #include <string.h>
+@@ -36,11 +29,7 @@
+ #include <dmlite/cpp/poolmanager.h>
+
+-#define XPROTO "xroot"
+-
+ // globals
+
+-#if XrdVNUMBER >= 30300
+-XrdVERSIONINFO(XrdCmsClient,XrdDPMFinder)
+-#endif
++XrdVERSIONINFO(XrdCmsGetClient,XrdDPMFinder)
+
+ namespace DpmFinder {
+@@ -424,5 +413,4 @@
+ DEBUG(dbgstr);
+
+- // XPROTO
+ r_Location = si.getPoolManager()->whereToWrite(SafeCStr(spath));
+
+@@ -466,5 +454,4 @@
+ DEBUG(dbgstr);
+
+- // XPROTO
+ r_Location = si.getPoolManager()->whereToRead(SafeCStr(spath));
+
+@@ -563,15 +550,4 @@
+ Say.addTable(ETab);
+ XrdDmCommonInit();
+-}
+-
+-XrdOucString XrdDPMFinder::SockaddrToIP(const sockaddr *sa) {
+- char buf[INET6_ADDRSTRLEN+2];
+- XrdOucString ip;
+-
+- if (!sa) return ip;
+- if (XrdSysDNS::IPFormat(sa, buf, sizeof(buf), 0))
+- ip = buf;
+-
+- return ip;
+ }
+
+@@ -894,5 +870,4 @@
+ const char *p;
+ XrdOucString item, tried;
+- struct addrinfo hints, *aitop, *ai;
+ int from;
+
+@@ -937,36 +912,36 @@
+ std::map<std::string, int> hmap;
+ p = SafeCStr(req.Host());
+- memset(&hints, 0, sizeof(hints));
+- hints.ai_family = PF_UNSPEC;
+- hints.ai_socktype = SOCK_STREAM;
+- if (!getaddrinfo(p, 0, &hints, &aitop)) {
+- char hbuf[NI_MAXHOST];
+- for(ai=aitop; ai; ai=ai->ai_next) {
+- if (!getnameinfo(ai->ai_addr,ai->ai_addrlen,
+- hbuf,sizeof(hbuf),0,0,NI_NUMERICHOST)) {
+- hmap[hbuf] = 1;
+- }
+- }
+- freeaddrinfo(aitop);
+- }
++ XrdNetAddr *nap = 0;
++ int num = 0;
++ XrdNetUtils::GetAddrs(p, &nap, num, XrdNetUtils::allIPMap,
++ XrdNetUtils::NoPortRaw);
++ for(int i=0;i<num;++i) {
++ char ipbuff[512];
++ nap[i].Format(ipbuff, sizeof(ipbuff), XrdNetAddr::fmtAddr,
++ XrdNetAddr::noPort);
++ hmap[ipbuff] = 1;
++ }
++ delete[] nap;
++ nap = 0; num = 0;
+
+ from = 0;
+ while ((from = tried.tokenize(item, from, ',')) != STR_NPOS) {
+- memset(&hints, 0, sizeof(hints));
+- hints.ai_family = PF_UNSPEC;
+- hints.ai_socktype = SOCK_STREAM;
+- bool found = 0;
+ p = SafeCStr(item);
+ if (*p == '+') { continue; }
+- if (!getaddrinfo(p, 0, &hints, &aitop)) {
+- char hbuf[NI_MAXHOST];
+- for(ai=aitop; ai && !found; ai=ai->ai_next) {
+- if (!getnameinfo(ai->ai_addr,ai->ai_addrlen,
+- hbuf,sizeof(hbuf),0,0,NI_NUMERICHOST)) {
+- if (hmap.count(hbuf)) { found = 1; }
+- }
++ XrdNetUtils::GetAddrs(p, &nap, num,
++ XrdNetUtils::allIPMap, XrdNetUtils::NoPortRaw);
++ for(int i=0;i<num;++i) {
++ char ipbuff[512];
++ nap[i].Format(ipbuff, sizeof(ipbuff),
++ XrdNetAddr::fmtAddr,
++ XrdNetAddr::noPort);
++ if (hmap.count(ipbuff)) {
++ found = 1;
++ break;
+ }
+- freeaddrinfo(aitop);
+- }
++ }
++ delete[] nap;
++ nap = 0; num = 0;
++ if (found) { break; }
+ }
+ }
+@@ -1111,5 +1086,5 @@
+ if (!(flags & SFS_O_STAT))
+ return 0;
+- if (!Info || !Info->Get("oss.lcl"))
++ if (!Info)
+ return 0;
+ if (!path || !*path)
+@@ -1117,100 +1092,28 @@
+ if (!user || !*user)
+ return 0;
+-
+- XrdLinkMatch match;
+- {
+- XrdOucString searchStr(user);
+- searchStr += "*";
+- match.Set(SafeCStr(searchStr));
+- DEBUG("Link match: " << searchStr);
+- }
+- XrdLink *linkp;
+- XrdOucString hn;
+- int curr = -1, nmatch = 0;
+- union {
+- sockaddr_storage ss;
+- sockaddr_in sin;
+- sockaddr_in6 sin6;
+- sockaddr sa;
+- } u_naddr,u_itr;
+-
+- memset(&u_naddr, 0, sizeof(u_naddr));
+-
+- // must not exit this loop early, it will leave list locked
+- //
+- while((linkp = XrdLink::Find(curr, &match))) {
+- if (!strcmp(linkp->ID, user)) {
+- hn = linkp->Host(&u_naddr.sa);
+- ++nmatch;
+- }
+- }
+-
+- if (nmatch != 1) {
+- DEBUG("Found " << nmatch << " link matches");
++ const XrdSecEntity *secEntity = Info->secEnv();
++ if (!secEntity)
+ return 0;
+- }
++ XrdNetAddrInfo *ni = secEntity->addrInfo;
++ if (!ni)
++ return 0;
+
+ bool hfound=0;
+- std::vector<sockaddr_storage>::const_iterator itr;
+-
+- in_addr *targ = &u_naddr.sin.sin_addr;
+- in6_addr *targ6 = &u_naddr.sin6.sin6_addr;
+-
+- for(itr=Opts.mmReqHosts.begin();
+- itr!=Opts.mmReqHosts.end();++itr) {
+-
+- u_itr.ss = *itr;
+-
+- in_addr *in = &u_itr.sin.sin_addr;
+- in6_addr *in6 = &u_itr.sin6.sin6_addr;
+-
+- if (itr->ss_family == AF_INET) {
+- if (u_naddr.ss.ss_family == AF_INET6) {
+- if (IN6_IS_ADDR_V4MAPPED(targ6) &&
+- !memcmp(in, &targ6->s6_addr[12], 4)) {
+- hfound=1;
+- break;
+- }
+- if (ntohl(in->s_addr) == INADDR_LOOPBACK &&
+- IN6_IS_ADDR_LOOPBACK(targ6)) {
+- hfound=1;
+- break;
+- }
+- }
+- if (u_naddr.ss.ss_family == AF_INET) {
+- if (!memcmp(in, targ, sizeof(in_addr))) {
+- hfound=1;
+- break;
+- }
+- }
+- }
+- if (itr->ss_family == AF_INET6) {
+- if (u_naddr.ss.ss_family == AF_INET) {
+- if (IN6_IS_ADDR_V4MAPPED(in6) &&
+- !memcmp(&in6->s6_addr[12], targ, 4)) {
+- hfound=1;
+- break;
+- }
+- if (IN6_IS_ADDR_LOOPBACK(in6) &&
+- ntohl(targ->s_addr) == INADDR_LOOPBACK) {
+- hfound=1;
+- break;
+- }
+- }
+- if (u_naddr.ss.ss_family == AF_INET6) {
+- if (!memcmp(in6, targ6,
+- sizeof(in6_addr))) {
+- hfound=1;
+- break;
+- }
+- }
++ std::vector<XrdNetAddr>::const_iterator itr;
++
++ for(itr=Opts.mmReqHosts.begin(); itr!=Opts.mmReqHosts.end();++itr) {
++ if (ni->Same(&(*itr))) {
++ hfound=1;
++ break;
+ }
+ }
+
+ if (!hfound) {
++ char ipbuff[512];
++ ni->Format(ipbuff, sizeof(ipbuff), XrdNetAddr::fmtAddr,
++ XrdNetAddr::noPort);
+ XrdOucString err =
+ "Possible meta-manager discovery request from host "
+- + hn + " " + SockaddrToIP(&u_naddr.sa)
+- + " (not listed in dpm.mmreqhost)";
++ + XrdOucString(ipbuff) + " (not listed in dpm.mmreqhost)";
+ Say.Emsg("IsMetaManagerDiscover", SafeCStr(err));
+ return 0;
+@@ -1231,11 +1134,6 @@
+ XrdOss *theSS) // Storage System I/F
+ {
+-#if XrdVNUMBER < 30300
+- XrdCmsClient *cmsFinder = (XrdCmsClient *)new
+- XrdCmsFinderTRG(Logger,XrdCms::IsTarget,myPort);
+-#else
+ XrdCmsClient *cmsFinder = XrdCms::GetDefaultClient(Logger,
+ XrdCms::IsTarget,myPort);
+-#endif
+
+ XrdDPMFinder *inst = new XrdDPMFinder(cmsFinder,Logger,opMode,myPort);
+Index: dpm-xrootd/trunk/src/XrdDPMCommon.cc
+===================================================================
+--- dpm-xrootd/trunk/src/XrdDPMCommon.cc (revision 9686)
++++ dpm-xrootd/trunk/src/XrdDPMCommon.cc (revision 10610)
+@@ -10,5 +10,5 @@
+ #include <XrdDPM/XrdDPMCommon.hh>
+ #include <XrdSys/XrdSysError.hh>
+-#include <XrdSys/XrdSysDNS.hh>
++#include <XrdNet/XrdNetUtils.hh>
+ #include <XrdSys/XrdSysPthread.hh>
+ #include <XrdDPM/XrdDPMTrace.hh>
+@@ -571,8 +571,8 @@
+ void InitLocalHostNameList(std::vector<XrdOucString> &names) {
+ char *localhostname;
+- char *errtxt=0;
++ const char *errtxt=0;
+
+ names.clear();
+- localhostname = XrdSysDNS::getHostName(0, &errtxt);
++ localhostname = XrdNetUtils::MyHostName((char*)0, &errtxt);
+
+ if (localhostname && !errtxt && strlen(localhostname))
+
+ all:
+Index: dpm-xrootd/trunk/CMakeLists.txt
+===================================================================
+--- dpm-xrootd/trunk/CMakeLists.txt (revision 9988)
++++ dpm-xrootd/trunk/CMakeLists.txt (revision 10610)
+@@ -21,5 +21,5 @@
+ add_definitions( -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 )
+ # For extra warnings
+-add_definitions( -Wall -Wextra -pedantic -Wno-unused -Wno-long-long )
++add_definitions( -Wall -Wextra -Wno-unused -Wno-long-long )
+
+ # Lib suffix
diff --git a/dpm-xrootd.spec b/dpm-xrootd.spec
index 0dbba95..cf39429 100644
--- a/dpm-xrootd.spec
+++ b/dpm-xrootd.spec
@@ -1,7 +1,7 @@
Name: dpm-xrootd
Summary: XROOT interface to the Disk Pool Manager (DPM)
Version: 3.3.5
-Release: 2%{?dist}
+Release: 4%{?dist}
License: GPLv3
Group: Applications/Internet
URL: http://svnweb.cern.ch/trac/lcgdm
@@ -10,19 +10,20 @@ URL: http://svnweb.cern.ch/trac/lcgdm
# svn export http://svn.cern.ch/guest/lcgdm/dpm-xrootd/tags/dpm-xrootd_3_3_5 dpm-xrootd-3.3.5
# tar -czvf dpm-xrootd-3.3.5.tar.gz dpm-xrootd-3.3.5
Source0: %{name}-%{version}.tar.gz
+Patch0: %{name}-xrootd4.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: cmake
BuildRequires: dmlite-devel >= 0.6.2
BuildRequires: openssl-devel
-BuildRequires: xrootd-server-devel >= 1:3.3
+BuildRequires: xrootd-server-devel >= 1:4.0
Requires(preun): chkconfig
Requires(preun): initscripts
Requires(post): chkconfig
Requires(postun): initscripts
-Requires: xrootd-server >= 1:3.3
-Requires: xrootd-client >= 1:3.3
+Requires: xrootd-server >= 1:4.0
+Requires: xrootd-client >= 1:4.0
# The requirement on dmlite-libs is added because of incompatibility between 0.6.1 and 0.6.2
Requires: dmlite-libs >= 0.6.2
Provides: DPM-xrootd = %{version}-%{release}
@@ -43,6 +44,7 @@ DPM XROOT interface.
%prep
%setup -q -n %{name}-%{version}
+%patch0 -p2
%build
%cmake . -DCMAKE_INSTALL_PREFIX=/
@@ -97,6 +99,12 @@ fi
%{_libdir}/libXrdDPMRedirAcc.so
%changelog
+* Wed Jul 09 2014 Alejandro Alvarez <aalvarez at cern.ch> - 3.3.5-4
+- Patch for building against xrootd4
+
+* Fri Jul 04 2014 Alejandro Alvarez <aalvarez at cern.ch> - 3.3.5-3
+- Rebuild for new release of xrootd
+
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 3.3.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
More information about the scm-commits
mailing list