]>
git.ipfire.org Git - thirdparty/sarg.git/blob - auth.c
2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
6 * please look at http://sarg.sourceforge.net/donations.php
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
9 * ---------------------------------------------------------------------
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.
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.
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.
27 #include "include/conf.h"
28 #include "include/defs.h"
30 void htaccess(const struct userinfostruct
*uinfo
)
38 if(!UserAuthentication
)
41 if (snprintf(htname
,sizeof(htname
),"%s/%s/.htaccess",outdirname
,uinfo
->filename
)>=sizeof(htname
)) {
42 debuga(_("Path too long: "));
43 debuga_more("%s/%s/.htaccess\n",outdirname
,uinfo
->filename
);
46 if((fp_auth
=fopen(htname
,"w"))==NULL
) {
47 debuga(_("Cannot open file \"%s\": %s\n"),htname
,strerror(errno
));
51 if ((fp_in
=fopen(AuthUserTemplateFile
,"r"))==NULL
) {
52 debuga(_("Cannot open file \"%s\": %s\n"),AuthUserTemplateFile
,strerror(errno
));
56 while((nread
=fread(line
,1,sizeof(line
),fp_in
))!=0) {
57 for (i
=0 ; i
<nread
; i
++)
58 if (line
[i
]=='%' && i
+2<nread
&& line
[i
+1]=='u' && !isalpha(line
[i
+2])) {
59 fputs(uinfo
->id
,fp_auth
);
62 fputc(line
[i
],fp_auth
);
65 if (fclose(fp_auth
)==EOF
) {
66 debuga(_("Write error in \"%s\": %s\n"),htname
,strerror(errno
));
69 if (fclose(fp_in
)==EOF
) {
70 debuga(_("Read error in \"%s\": %s\n"),AuthUserTemplateFile
,strerror(errno
));