XRootD
XrdSecsssCon.cc
Go to the documentation of this file.
1 /******************************************************************************/
2 /* */
3 /* X r d S e c s s s C o n . c c */
4 /* */
5 /* (c) 2020 by the Board of Trustees of the Leland Stanford, Jr., University */
6 /* All Rights Reserved */
7 /* Produced by Andrew Hanushevsky for Stanford University under contract */
8 /* DE-AC02-76-SFO0515 with the Department of Energy */
9 /* */
10 /* This file is part of the XRootD software suite. */
11 /* */
12 /* XRootD is free software: you can redistribute it and/or modify it under */
13 /* the terms of the GNU Lesser General Public License as published by the */
14 /* Free Software Foundation, either version 3 of the License, or (at your */
15 /* option) any later version. */
16 /* */
17 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
18 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
20 /* License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
24 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
25 /* */
26 /* The copyright holder's institutional names and contributor's names may not */
27 /* be used to endorse or promote products derived from this software without */
28 /* specific prior written permission of the institution or contributor. */
29 /******************************************************************************/
30 
31 #include <string>
32 #include <set>
33 
37 
38 using namespace XrdSecsssMap;
39 
40 /******************************************************************************/
41 /* C o n t a c t */
42 /******************************************************************************/
43 
44 bool XrdSecsssCon::Contact(const std::string &lgnid, const std::string &hostID)
45 {
46  EntityMap::iterator it;
47  char *colon, lid[256];
48  size_t n;
49 
50 // Don't bother we are not tracking contacts
51 //
52  if (this != conTrack) return false;
53 
54 // Extract out the loginid
55 //
56  n = hostID.find('@');
57  if (n == std::string::npos || n < 1 || n >= sizeof(lid)) return false;
58  strncpy(lid, hostID.c_str(), n);
59  lid[n] = 0;
60  if ((colon = index(lid, ':')))
61  {if (colon == lid) return false;
62  *colon = 0;
63  }
64 
65 // Find the id in the registry
66 //
67  sssMutex.Lock();
68  it = Registry.find(lid);
69  if (it == Registry.end()) {sssMutex.UnLock(); return false;}
70 
71 // Add this contact to the set of contacts
72 //
73  it->second->AddContact(hostID);
74  sssMutex.UnLock();
75  return true;
76 }
bool Contact(const std::string &lgnid, const std::string &hostID)
Definition: XrdSecsssCon.cc:44
XrdSysMutex sssMutex
Definition: XrdSecsssID.cc:62
XrdSecsssCon * conTrack
Definition: XrdSecsssID.cc:64
EntityMap Registry
Definition: XrdSecsssID.cc:68