XRootD
Loading...
Searching...
No Matches
XrdAccAudit.cc
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d A c c A u d i t . c c */
4/* */
5/* (c) 2003 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 <cstdio>
32#include <cstdlib>
33
34#include "XrdAcc/XrdAccAudit.hh"
35#include "XrdSys/XrdSysError.hh"
36
37/******************************************************************************/
38/* C o n s t r u c t o r */
39/******************************************************************************/
40
42{
43
44// Set default
45//
46 auditops = audit_none;
47 mDest = erp;
48}
49
50/******************************************************************************/
51/* D e n y */
52/******************************************************************************/
53
54void XrdAccAudit::Deny(const char *opname,
55 const char *tident,
56 const char *atype,
57 const char *id,
58 const char *host,
59 const char *path)
60{if (auditops & audit_deny)
61 {char buff[2048];
62 snprintf(buff, sizeof(buff)-1, "%s deny %s %s@%s %s %s",
63 (tident ? tident : ""), atype, id, host, opname, path);
64 buff[sizeof(buff)-1] = '\0';
65 mDest->Emsg("Audit", buff);
66 }
67}
68
69/******************************************************************************/
70/* G r a n t */
71/******************************************************************************/
72
73void XrdAccAudit::Grant(const char *opname,
74 const char *tident,
75 const char *atype,
76 const char *id,
77 const char *host,
78 const char *path)
79{if (auditops & audit_deny)
80 {char buff[2048];
81 snprintf(buff, sizeof(buff)-1, "%s grant %s %s@%s %s %s",
82 (tident ? tident : ""), atype, id, host, opname, path);
83 buff[sizeof(buff)-1] = '\0';
84 mDest->Emsg("Audit", buff);
85 }
86}
87
88/******************************************************************************/
89/* A u d i t O b j e c t G e n e r a t o r */
90/******************************************************************************/
91
93{
94static XrdAccAudit AuditObject(erp);
95
96// Simply return the default audit object
97//
98 return &AuditObject;
99}
XrdAccAudit * XrdAccAuditObject(XrdSysError *erp)
@ audit_none
@ audit_deny
#define tident
XrdAccAudit(XrdSysError *erp)
virtual void Deny(const char *opname, const char *tident, const char *atype, const char *id, const char *host, const char *path)
virtual void Grant(const char *opname, const char *tident, const char *atype, const char *id, const char *host, const char *path)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)