]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ident/AclIdent.cc
2 * DEBUG: section 28 Access Control
3 * AUTHOR: Duane Wessels
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
32 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
39 #include "acl/FilledChecklist.h"
40 #include "acl/RegexData.h"
41 #include "acl/UserData.h"
42 #include "client_side.h"
43 #include "comm/Connection.h"
45 #include "ident/AclIdent.h"
46 #include "ident/Ident.h"
53 ACLIdent::ACLIdent(ACLData
<char const *> *newData
, char const *newType
) : data (newData
), type_ (newType
) {}
55 ACLIdent::ACLIdent (ACLIdent
const &old
) : data (old
.data
->clone()), type_ (old
.type_
)
59 ACLIdent::operator= (ACLIdent
const &rhs
)
61 data
= rhs
.data
->clone();
67 ACLIdent::typeString() const
76 debugs(28, 3, HERE
<< "current is null. Creating");
77 data
= new ACLUserData
;
84 ACLIdent::match(ACLChecklist
*cl
)
86 ACLFilledChecklist
*checklist
= Filled(cl
);
87 if (checklist
->rfc931
[0]) {
88 return data
->match(checklist
->rfc931
);
89 } else if (checklist
->conn() != NULL
&& checklist
->conn()->clientConnection
!= NULL
&& checklist
->conn()->clientConnection
->rfc931
[0]) {
90 return data
->match(checklist
->conn()->clientConnection
->rfc931
);
91 } else if (checklist
->conn() != NULL
&& Comm::IsConnOpen(checklist
->conn()->clientConnection
)) {
92 if (checklist
->goAsync(IdentLookup::Instance())) {
93 debugs(28, 3, "switching to ident lookup state");
96 // else fall through to ACCESS_DUNNO failure below
98 debugs(28, DBG_IMPORTANT
, HERE
<< "Can't start ident lookup. No client connection" );
99 // fall through to ACCESS_DUNNO failure below
102 checklist
->markFinished(ACCESS_DUNNO
, "cannot start ident lookup");
107 ACLIdent::dump() const
113 ACLIdent::empty () const
115 return data
->empty();
119 ACLIdent::clone() const
121 return new ACLIdent(*this);
124 IdentLookup
IdentLookup::instance_
;
127 IdentLookup::Instance()
133 IdentLookup::checkForAsync(ACLChecklist
*cl
)const
135 ACLFilledChecklist
*checklist
= Filled(cl
);
136 const ConnStateData
*conn
= checklist
->conn();
137 // check that ACLIdent::match() tested this lookup precondition
138 assert(conn
&& Comm::IsConnOpen(conn
->clientConnection
));
139 debugs(28, 3, HERE
<< "Doing ident lookup" );
140 Ident::Start(checklist
->conn()->clientConnection
, LookupDone
, checklist
);
144 IdentLookup::LookupDone(const char *ident
, void *data
)
146 ACLFilledChecklist
*checklist
= Filled(static_cast<ACLChecklist
*>(data
));
149 xstrncpy(checklist
->rfc931
, ident
, USER_IDENT_SZ
);
151 xstrncpy(checklist
->rfc931
, dash_str
, USER_IDENT_SZ
);
155 * Cache the ident result in the connection, to avoid redoing ident lookup
156 * over and over on persistent connections
158 if (checklist
->conn() != NULL
&& checklist
->conn()->clientConnection
!= NULL
&& !checklist
->conn()->clientConnection
->rfc931
[0])
159 xstrncpy(checklist
->conn()->clientConnection
->rfc931
, checklist
->rfc931
, USER_IDENT_SZ
);
161 checklist
->resumeNonBlockingCheck(IdentLookup::Instance());
164 #endif /* USE_IDENT */