Loading...
Searching...
No Matches
XrdAccAuthFile Class Reference

`#include <XrdAccAuthFile.hh>`

Inheritance diagram for XrdAccAuthFile:
Collaboration diagram for XrdAccAuthFile:

## Public Member Functions

| XrdAccAuthFile (XrdSysError *erp)
| ~XrdAccAuthFile ()
int | Changed (const char *dbpath)
int | Close ()
char | getID (char **id)
int | getPP (char **path, char **priv, bool &istmplt)
char | getRec (char **recname)
int | Open (XrdSysError &eroute, const char *path=0)
Public Member Functions inherited from XrdAccAuthDB
| XrdAccAuthDB ()
virtual | ~XrdAccAuthDB ()

## Detailed Description

Definition at line 44 of file XrdAccAuthFile.hh.

## Constructor & Destructor Documentation

## XrdAccAuthFile()

XrdAccAuthFile::XrdAccAuthFile | ( | XrdSysError * | erp | ) |

Definition at line 54 of file XrdAccAuthFile.cc.

{
// Set starting values
//
authfn = 0;
flags = Noflags;
modtime = 0;
Eroute = erp;
// Setup for an error in the first record
//
strcpy(path_buff, "start of file");
}

## ~XrdAccAuthFile()

XrdAccAuthFile::~XrdAccAuthFile | ( |  | ) |

Definition at line 73 of file XrdAccAuthFile.cc.

{
// If the file is open, close it
//
if (flags &isOpen) Close();
// Free the authfn string
//
if (authfn) free(authfn);
}
XrdAccAuthFile::Close
int Close()
Definition XrdAccAuthFile.cc:117

References Close().

Here is the call graph for this function:

## Member Function Documentation

## Changed()

int XrdAccAuthFile::Changed | ( | const char * | dbpath | ) |

virtual

Implements XrdAccAuthDB.

Definition at line 89 of file XrdAccAuthFile.cc.

{
struct stat statbuff;
// If no file here, indicate nothing changed
//
if (!authfn || !*authfn) return 0;
// If file paths differ, indicate that something has changed
//
if (dbfn && strcmp(dbfn, authfn)) return 1;
// Get the modification timestamp for this file
//
if (stat(authfn, &statbuff))
{Eroute->Emsg("AuthFile", errno, "find", authfn);
return 0;
}
// Indicate whether or not the file has changed
//
return (modtime < statbuff.st_mtime);
}
stat
#define stat(a, b)
Definition XrdPosix.hh:101

References stat.

## Close()

int XrdAccAuthFile::Close | ( |  | ) |

virtual

Implements XrdAccAuthDB.

Definition at line 117 of file XrdAccAuthFile.cc.

{
// Return is the file is not open
//
if (!(flags & isOpen)) return 1;
// Close the stream
//
DBfile.Close();
// Unlock the protecting mutex
//
DBcontext.UnLock();
// Indicate file is no longer open
//
flags = (DBflags)(flags & ~isOpen);
// Return indicator of whether we had any errors
//
if (flags & dbError) return 0;
return 1;
}

Referenced by ~XrdAccAuthFile().

Here is the caller graph for this function:

## getID()

char XrdAccAuthFile::getID | ( | char ** | id | ) |

virtual

Implements XrdAccAuthDB.

Definition at line 145 of file XrdAccAuthFile.cc.

{
char *pp, idcode[2] = {0,0};
// If a record has not been read, return end of record (i.e., 0)
//
if (!(flags & inRec)) return 0;
// Read the next word from the record (if none, simulate end of record)
//
if (!(pp = DBfile.GetWord()))
{flags = (DBflags)(flags & ~inRec);
return 0;
}
// Id's are of the form 'c', but historically they were 'c:' so we accept a
// two character specification but only validate the first to be backward
// compatible.
//
if (strlen(pp) > 2 || !index("ghoru", *pp))
{Eroute->Emsg("AuthFile", "Invalid ID sprecifier -", pp);
flags = (DBflags)(flags | dbError);
return 0;
}
idcode[0] = *pp;
// Now get the actual id associated with it
//
if (!(pp = DBfile.GetWord()))
{flags = (DBflags)(flags & ~inRec);
Eroute->Emsg("AuthFile", "ID value missing after", idcode);
flags = (DBflags)(flags | dbError);
return 0;
}
// Copy the value since the stream buffer might get overlaid.
//
Copy(path_buff, pp, sizeof(path_buff)-1);
// Return result
//
*id = path_buff;
return idcode[0];
}

## getPP()

int XrdAccAuthFile::getPP | ( | char ** | path,
|  | char ** | priv,
|  | bool & | istmplt )

virtual

Implements XrdAccAuthDB.

Definition at line 194 of file XrdAccAuthFile.cc.

{
// char *pp, *bp;
char *pp;
// If a record has not been read, return end of record (i.e., 0)
//
if (!(flags & inRec)) return 0;
// read the next word from the record (if none, simulate end of record)
//
if (!(pp = DBfile.GetWord()))
{flags = (DBflags)(flags & ~inRec);
return 0;
}
// Check of objectid specification
//
istmplt = false;
*path = path_buff;
if (*pp == '\\')
{if (*(pp+1)) pp++;
else {Eroute->Emsg("AuthFile", "Object ID missing after '\\'");
*path = 0;
flags = (DBflags)(flags | dbError);
}
} else if (*pp != '/') istmplt = true;
// Copy the value since the stream buffer might get overlaid.
//
// bp = Copy(path_buff, pp, sizeof(path_buff)-1);
if (path) Copy(path_buff, pp, sizeof(path_buff)-1);
// Check if this is really a path or a template
//
if (istmplt) {*priv = (char *)0; return 1;}
// Verify that the path ends correctly (normally we would force a slash to
// appear at the end but that prevents caps on files. So, we commented the
// code out until we decide that maybe we really need to do this, sigh.
//
// bp--;
// if (*bp != '/') {bp++; *bp = '/'; bp++; *bp = '\0';}
// Get the next word which should be the privilege string
//
if (!(pp = DBfile.GetWord()))
{flags = (DBflags)(flags & ~inRec);
Eroute->Emsg("AuthFile", "Privileges missing after", path_buff);
flags = (DBflags)(flags | dbError);
*priv = (char *)0;
return 0;
}
// All done here
//
*priv = pp;
return 1;
}

## getRec()

char XrdAccAuthFile::getRec | ( | char ** | recname | ) |

virtual

Implements XrdAccAuthDB.

Definition at line 258 of file XrdAccAuthFile.cc.

{
char *pp;
int idok;
// Do this until we get a vlaid record
//
while(1)
{
// If we arer still in the middle of a record, flush it
//
if (flags & inRec) while(DBfile.GetWord()) {}
else flags = (DBflags)(flags | inRec);
// Get the next word, the record type
//
if (!(pp = DBfile.GetWord()))
{*recname = (char *)0; return '\0';}
// Verify the id-type
//
idok = 0;
if (strlen(pp) == 1)
switch(*pp)
{case 'g':
case 'h':
case 's':
case 'n':
case 'o':
case 'r':
case 't':
case 'u':
case 'x':
case '=': idok = 1;
break;
default: break;
}
// Check if the record type was valid
//
if (!idok) {Eroute->Emsg("AuthFile", "Invalid id type -", pp);
flags = (DBflags)(flags | dbError);
continue;
}
rectype = *pp;
// Get the record name. It must exist
//
if (!(pp = DBfile.GetWord()))
{Eroute->Emsg("AuthFile","Record name is missing after",path_buff);
flags = (DBflags)(flags | dbError);
continue;
}
// Copy the record name
//
Copy(recname_buff, pp, sizeof(recname_buff));
*recname = recname_buff;
return rectype;
}
return '\0'; // Keep the compiler happy :-)
}

## Open()

int XrdAccAuthFile::Open | ( | XrdSysError & | eroute,
|  | const char * | path = 0 )

virtual

Implements XrdAccAuthDB.

Definition at line 325 of file XrdAccAuthFile.cc.

{
struct stat statbuff;
int authFD;
// Enter the DB context (serialize use of this database)
//
DBcontext.Lock();
Eroute = &eroute;
// Use whichever path is the more recent
//
if (path)
{if (authfn) free(authfn); authfn = strdup(path);}
if( !authfn || !*authfn) return Bail(0, "Authorization file not specified.");
// Get the modification timestamp for this file
//
if (stat(authfn, &statbuff)) return Bail(errno, "find", authfn);
// Try to open the authorization file.
//
if ( (authFD = open(authfn, O_RDONLY, 0)) < 0)
return Bail(errno,"open authorization file",authfn);
// Copy in all the relevant information
//
modtime = statbuff.st_mtime;
flags = isOpen;
DBfile.SetEroute(Eroute);
DBfile.Tabs(0);
// Attach the file to the stream
//
if (DBfile.Attach(authFD))
return Bail(DBfile.LastError(), "initialize stream for", authfn);
return 1;
}
open
#define open
Definition XrdPosix.hh:76

References open, and stat.

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

- XrdAccAuthFile.hh
- XrdAccAuthFile.cc