auth.c (sarg-2.3.11) | : | auth.c (sarg-2.4.0) | ||
---|---|---|---|---|
/* | /* | |||
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net | * SARG Squid Analysis Report Generator http://sarg.sourceforge.net | |||
* 1998, 2013 | * 1998, 2015 | |||
* | * | |||
* SARG donations: | * SARG donations: | |||
* please look at http://sarg.sourceforge.net/donations.php | * please look at http://sarg.sourceforge.net/donations.php | |||
* Support: | * Support: | |||
* http://sourceforge.net/projects/sarg/forums/forum/363374 | * http://sourceforge.net/projects/sarg/forums/forum/363374 | |||
* --------------------------------------------------------------------- | * --------------------------------------------------------------------- | |||
* | * | |||
* This program is free software; you can redistribute it and/or modify | * This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 2 of the License, or | * the Free Software Foundation; either version 2 of the License, or | |||
skipping to change at line 38 | skipping to change at line 38 | |||
#include "include/defs.h" | #include "include/defs.h" | |||
void htaccess(const struct userinfostruct *uinfo) | void htaccess(const struct userinfostruct *uinfo) | |||
{ | { | |||
char htname[MAXLEN]; | char htname[MAXLEN]; | |||
char line[MAXLEN]; | char line[MAXLEN]; | |||
FILE *fp_in; | FILE *fp_in; | |||
FILE *fp_auth; | FILE *fp_auth; | |||
size_t i,nread; | size_t i,nread; | |||
if(!UserAuthentication) | if (!UserAuthentication) | |||
return; | return; | |||
if (snprintf(htname,sizeof(htname),"%s/%s/.htaccess",outdirname,uinfo->fi lename)>=sizeof(htname)) { | if (snprintf(htname,sizeof(htname),"%s/%s/.htaccess",outdirname,uinfo->fi lename)>=sizeof(htname)) { | |||
debuga(_("Path too long: ")); | debuga(__FILE__,__LINE__,_("Path too long: ")); | |||
debuga_more("%s/%s/.htaccess\n",outdirname,uinfo->filename); | debuga_more("%s/%s/.htaccess\n",outdirname,uinfo->filename); | |||
exit(EXIT_FAILURE); | exit(EXIT_FAILURE); | |||
} | } | |||
if((fp_auth=fopen(htname,"w"))==NULL) { | if ((fp_auth=fopen(htname,"w"))==NULL) { | |||
debugapos("auth",_("Cannot open file \"%s\": %s\n"),htname,strerr | debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),htnam | |||
or(errno)); | e,strerror(errno)); | |||
exit(EXIT_FAILURE); | exit(EXIT_FAILURE); | |||
} | } | |||
if ((fp_in=fopen(AuthUserTemplateFile,"r"))==NULL) { | if ((fp_in=fopen(AuthUserTemplateFile,"r"))==NULL) { | |||
debugapos("auth",_("Cannot open file \"%s\": %s\n"),AuthUserTempl ateFile,strerror(errno)); | debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),AuthU serTemplateFile,strerror(errno)); | |||
exit(EXIT_FAILURE); | exit(EXIT_FAILURE); | |||
} | } | |||
while((nread=fread(line,1,sizeof(line),fp_in))!=0) { | while((nread=fread(line,1,sizeof(line),fp_in))!=0) { | |||
for (i=0 ; i<nread ; i++) | for (i=0 ; i<nread ; i++) | |||
if (line[i]=='%' && i+2<nread && line[i+1]=='u' && !isalp ha(line[i+2])) { | if (line[i]=='%' && i+2<nread && line[i+1]=='u' && !isalp ha(line[i+2])) { | |||
fputs(uinfo->id,fp_auth); | fputs(uinfo->id,fp_auth); | |||
i++; | i++; | |||
} else { | } else { | |||
fputc(line[i],fp_auth); | fputc(line[i],fp_auth); | |||
} | } | |||
} | } | |||
fclose(fp_auth); | if (fclose(fp_auth)==EOF) { | |||
fclose(fp_in); | debuga(__FILE__,__LINE__,_("Write error in \"%s\": %s\n"),htname, | |||
strerror(errno)); | ||||
exit(EXIT_FAILURE); | ||||
} | ||||
if (fclose(fp_in)==EOF) { | ||||
debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),AuthUser | ||||
TemplateFile,strerror(errno)); | ||||
exit(EXIT_FAILURE); | ||||
} | ||||
return; | return; | |||
} | } | |||
End of changes. 6 change blocks. | ||||
9 lines changed or deleted | 17 lines changed or added |