3 * $Id: authenticate.cc,v 1.14 2001/01/05 09:51:36 adrian Exp $
5 * DEBUG: section 29 Authenticator
6 * AUTHOR: Duane Wessels
8 * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
9 * ----------------------------------------------------------
11 * Squid is the result of efforts by numerous individuals from the
12 * Internet community. Development is led by Duane Wessels of the
13 * National Laboratory for Applied Network Research and funded by the
14 * National Science Foundation. Squid is Copyrighted (C) 1998 by
15 * the Regents of the University of California. Please see the
16 * COPYRIGHT file for full details. Squid incorporates software
17 * developed and/or copyrighted by other sources. Please see the
18 * CREDITS file for full details.
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
40 acl_proxy_auth_user
*auth_user
;
42 } authenticateStateData
;
44 static HLPCB authenticateHandleReply
;
45 static void authenticateStateFree(authenticateStateData
* r
);
46 static helper
*authenticators
= NULL
;
49 authenticateHandleReply(void *data
, char *reply
)
51 authenticateStateData
*r
= data
;
54 debug(29, 5) ("authenticateHandleReply: {%s}\n", reply
? reply
: "<NULL>");
56 if ((t
= strchr(reply
, ' ')))
61 valid
= cbdataValid(r
->data
);
62 cbdataUnlock(r
->data
);
64 r
->handler(r
->data
, reply
);
65 authenticateStateFree(r
);
69 authenticateStateFree(authenticateStateData
* r
)
75 authenticateStats(StoreEntry
* sentry
)
77 storeAppendPrintf(sentry
, "Authenticator Statistics:\n");
78 helperStats(sentry
, authenticators
);
81 CBDATA_TYPE(authenticateStateData
);
83 /**** PUBLIC FUNCTIONS ****/
87 authenticateStart(acl_proxy_auth_user
* auth_user
, RH
* handler
, void *data
)
89 authenticateStateData
*r
= NULL
;
93 debug(29, 5) ("authenticateStart: '%s:%s'\n", hashKeyStr(&auth_user
->hash
),
95 if (Config
.Program
.authenticate
== NULL
) {
99 r
= CBDATA_ALLOC(authenticateStateData
, NULL
);
100 r
->handler
= handler
;
103 r
->auth_user
= auth_user
;
104 snprintf(buf
, 8192, "%s %s\n", hashKeyStr(&r
->auth_user
->hash
),
105 r
->auth_user
->passwd
);
106 helperSubmit(authenticators
, buf
, authenticateHandleReply
, r
);
110 authenticateInit(void)
113 if (!Config
.Program
.authenticate
)
115 if (authenticators
== NULL
)
116 authenticators
= helperCreate("authenticator");
117 authenticators
->cmdline
= Config
.Program
.authenticate
;
118 authenticators
->n_to_start
= Config
.authenticateChildren
;
119 authenticators
->ipc_type
= IPC_TCP_SOCKET
;
120 helperOpenServers(authenticators
);
122 cachemgrRegister("authenticator",
123 "User Authenticator Stats",
124 authenticateStats
, 0, 1);
127 CBDATA_INIT_TYPE(authenticateStateData
);
131 authenticateShutdown(void)
135 helperShutdown(authenticators
);
138 helperFree(authenticators
);
139 authenticators
= NULL
;