]> git.ipfire.org Git - thirdparty/sarg.git/blob - auth.c
Continue the replacement of the user info and the translation of the error messages
[thirdparty/sarg.git] / auth.c
1 /*
2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
3 * 1998, 2010
4 *
5 * SARG donations:
6 * please look at http://sarg.sourceforge.net/donations.php
7 * Support:
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
9 * ---------------------------------------------------------------------
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
24 *
25 */
26
27 #include "include/conf.h"
28 #include "include/defs.h"
29
30 void htaccess(const struct userinfostruct *uinfo)
31 {
32 char htname[MAXLEN];
33 FILE *fp_auth;
34 int i;
35
36 if(!UserAuthentication)
37 return;
38
39 if (snprintf(htname,sizeof(htname),"%s/%s/.htaccess",dirname,uinfo->filename)>=sizeof(htname)) {
40 debuga(_("File name too long: %s/%s/.htaccess"),dirname,uinfo->filename);
41 exit(1);
42 }
43 if((fp_auth=fopen(htname,"w"))==NULL) {
44 fprintf(stderr, "SARG: (auth) %s: %s - %s\n",text[45],htname,strerror(errno));
45 exit(1);
46 }
47
48 fprintf(fp_auth,"AuthUserFile %s\n",AuthUserFile);
49 if(strchr(AuthName,'\"') == 0)
50 fprintf(fp_auth,"AuthName \"%s\"\n",AuthName);
51 else
52 fprintf(fp_auth,"AuthName %s\n",AuthName);
53 fprintf(fp_auth,"AuthType %s\n",AuthType);
54 fputs("<Limit GET POST>\nRequire ",fp_auth);
55 for (i=0 ; Require[i] ; i++)
56 if (Require[i]=='%' && Require[i+1]=='u') {
57 fputs(uinfo->id,fp_auth);
58 i++;
59 } else {
60 fputc(Require[i],fp_auth);
61 }
62 fputs("\n</LIMIT>\n",fp_auth);
63
64 fclose(fp_auth);
65
66 return;
67 }