XRootD
Loading...
Searching...
No Matches
XrdSecProtocolunix Class Reference
+ Inheritance diagram for XrdSecProtocolunix:
+ Collaboration diagram for XrdSecProtocolunix:

Public Member Functions

 XrdSecProtocolunix (const char *hname, XrdNetAddrInfo &endPoint)
 
int Authenticate (XrdSecCredentials *cred, XrdSecParameters **parms, XrdOucErrInfo *einfo=0)
 
void Delete ()
 Delete the protocol object. DO NOT use C++ delete() on this object.
 
XrdSecCredentialsgetCredentials (XrdSecParameters *parm=0, XrdOucErrInfo *einfo=0)
 
- Public Member Functions inherited from XrdSecProtocol
 XrdSecProtocol (const char *pName)
 Constructor.
 
virtual int Decrypt (const char *inbuff, int inlen, XrdSecBuffer **outbuff)
 
virtual int Encrypt (const char *inbuff, int inlen, XrdSecBuffer **outbuff)
 
virtual int getKey (char *buff=0, int size=0)
 
virtual bool needTLS ()
 Check if this protocol requires TLS to properly function.
 
virtual int setKey (char *buff, int size)
 
virtual int Sign (const char *inbuff, int inlen, XrdSecBuffer **outbuff)
 
virtual int Verify (const char *inbuff, int inlen, const char *sigbuff, int siglen)
 

Friends

class XrdSecProtocolDummy
 

Additional Inherited Members

- Public Attributes inherited from XrdSecProtocol
XrdSecEntity Entity
 
- Protected Member Functions inherited from XrdSecProtocol
virtual ~XrdSecProtocol ()
 Destructor (prevents use of direct delete).
 

Detailed Description

Definition at line 51 of file XrdSecProtocolunix.cc.

Constructor & Destructor Documentation

◆ XrdSecProtocolunix()

XrdSecProtocolunix::XrdSecProtocolunix ( const char * hname,
XrdNetAddrInfo & endPoint )
inline

Definition at line 64 of file XrdSecProtocolunix.cc.

65 : XrdSecProtocol("unix")
66 {Entity.host = strdup(hname);
67 Entity.name = (char *)"?";
68 epAddr = endPoint;
69 Entity.addrInfo = &epAddr;
70 credBuff = 0;
71 }
XrdSecEntity Entity
XrdSecProtocol(const char *pName)
Constructor.

References XrdSecProtocol::XrdSecProtocol(), and XrdSecProtocol::Entity.

+ Here is the call graph for this function:

Member Function Documentation

◆ Authenticate()

int XrdSecProtocolunix::Authenticate ( XrdSecCredentials * cred,
XrdSecParameters ** parms,
XrdOucErrInfo * einfo = 0 )
virtual

Authenticate a client.

Parameters
credCredentials supplied by the client.
parmsPlace where the address of additional authentication data is to be placed for another autrhentication handshake.
einfoThe error information object where error messages should be placed. The messages are returned to the client. Should einfo be null, messages should be written to stderr.
Returns
> 0 -> parms present (more authentication needed) = 0 -> Entity present (authentication suceeded) < 0 -> einfo present (error has occurred)

Implements XrdSecProtocol.

Definition at line 127 of file XrdSecProtocolunix.cc.

130{
131 char *bp, *ep;
132
133// Check if we have any credentials or if no credentials really needed.
134// In either case, use host name as client name
135//
136 if (cred->size <= int(4) || !cred->buffer)
137 {strncpy(Entity.prot, "host", sizeof(Entity.prot));
138 Entity.name = (char *)"?";
139 return 0;
140 }
141
142// Check if this is our protocol
143//
144 if (strcmp(cred->buffer, "unix"))
145 {char msg[256];
146 snprintf(msg, sizeof(msg),
147 "Secunix: Authentication protocol id mismatch (unix != %.4s).",
148 cred->buffer);
149 if (erp) erp->setErrInfo(EINVAL, msg);
150 else std::cerr <<msg <<std::endl;
151 return -1;
152 }
153
154// Skip over the protocol ID and copy the buffer
155//
156 bp = credBuff = strdup((cred->buffer)+5);
157 ep = bp + strlen(bp);
158
159// Extract out username
160//
161 while(*bp && *bp == ' ') bp++;
162 Entity.name = bp;
163 while(*bp && *bp != ' ') bp++;
164 *bp++ = '\0';
165
166// Extract out the group name
167//
168 if (bp >= ep) return 0;
169 while(*bp && *bp == ' ') bp++;
170 Entity.grps = bp;
171
172// All done
173//
174 return 0;
175}
char * buffer
Pointer to the buffer.
int size
Size of the buffer or length of data in the buffer.

References XrdSecBuffer::buffer, XrdSecProtocol::Entity, XrdOucErrInfo::setErrInfo(), and XrdSecBuffer::size.

+ Here is the call graph for this function:

◆ Delete()

void XrdSecProtocolunix::Delete ( )
inlinevirtual

Delete the protocol object. DO NOT use C++ delete() on this object.

Implements XrdSecProtocol.

Definition at line 73 of file XrdSecProtocolunix.cc.

73{delete this;}

◆ getCredentials()

XrdSecCredentials * XrdSecProtocolunix::getCredentials ( XrdSecParameters * parm = 0,
XrdOucErrInfo * einfo = 0 )
virtual

Generate client credentials to be used in the authentication process.

Parameters
parmPointer to the information returned by the server either in the initial login response or the authmore response.
einfoThe error information object where error messages should be placed. The messages are returned to the client. Should einfo be null, messages should be written to stderr.
Returns
Success: Pointer to credentials to sent to the server. The caller is responsible for deleting the object. Failure: Null pointer with einfo, if supplied, containing the reason for the failure.

Implements XrdSecProtocol.

Definition at line 93 of file XrdSecProtocolunix.cc.

95{
96 char Buff[512], *Bp;
97 int Blen, n;
98
99// Set protocol ID in the buffer
100//
101 strcpy(Buff, "unix"); Bp = Buff + 5;
102
103// Get the username
104//
105 if (XrdOucUtils::UserName(geteuid(), Bp, 256)) strcpy(Bp, "*");
106 Bp += strlen(Bp); Blen = (Bp - Buff) + 1;
107
108// Get the group name
109//
110 if ((n = XrdOucUtils::GroupName(getegid(), Bp+1, sizeof(Buff)-Blen)))
111 {*Bp = ' '; Blen += (n+1);}
112
113// Return the credentials
114//
115 Bp = (char *)malloc(Blen);
116 memcpy(Bp, Buff, Blen);
117 return new XrdSecCredentials(Bp, Blen);
118}
XrdSecBuffer XrdSecCredentials
static int UserName(uid_t uID, char *uName, int uNsz)
static int GroupName(gid_t gID, char *gName, int gNsz)

References XrdOucUtils::GroupName(), and XrdOucUtils::UserName().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ XrdSecProtocolDummy

friend class XrdSecProtocolDummy
friend

Definition at line 54 of file XrdSecProtocolunix.cc.

References XrdSecProtocolDummy.

Referenced by XrdSecProtocolDummy.


The documentation for this class was generated from the following file: