/*
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
- * 1998, 2012
+ * 1998, 2015
*
* SARG donations:
* please look at http://sarg.sourceforge.net/donations.php
static void ip2name_execconfig(const char *name,const char *param)
{
int len;
-
+
len=strlen(param);
if (len>=sizeof(ExecCmd)) {
- debuga(_("Command to execute to resolve the IP addresses is too long (maximum is %d bytes)\n"),(int)sizeof(ExecCmd));
+ debuga(__FILE__,__LINE__,_("Command to execute to resolve the IP addresses is too long (maximum is %d bytes)\n"),(int)sizeof(ExecCmd));
exit(EXIT_FAILURE);
}
strcpy(ExecCmd,param);
FILE *cmd_in;
char buffer[512];
size_t nread;
-
+
if (ExecCmd[0]=='\0') {
- debuga(_("No command to run to resolve an IP address. Please configure it in sarg.conf\n"));
+ debuga(__FILE__,__LINE__,_("No command to run to resolve an IP address. Please configure it in sarg.conf\n"));
exit(EXIT_FAILURE);
}
-
+
j=0;
len=strlen(ip);
for (i=0 ; i<sizeof(ExecCmd) && ExecCmd[i] ; i++) {
if (ExecCmd[i]=='%' && strncmp(ExecCmd+i+1,"IP",2)==0) {
if (j+len>=sizeof(cmd)) {
- debuga(_("IP address \"%s\" too long for the command to run\n"),ip);
+ debuga(__FILE__,__LINE__,_("IP address \"%s\" too long for the command to run\n"),ip);
return(INRC_Error);
}
strcpy(cmd+j,ip);
i+=2;
} else {
if (j>=sizeof(cmd)) {
- debuga(_("IP address \"%.*s\" too long for the command to run\n"),ip_len,ip);
+ debuga(__FILE__,__LINE__,_("IP address \"%s\" too long for the command to run\n"),ip);
return(INRC_Error);
}
cmd[j++]=ExecCmd[i];
}
}
cmd[j]='\0';
-
+
cmd_in=popen(cmd,"r");
if (!cmd_in) {
- debuga(_("Cannot run command %s\n"),cmd);
+ debuga(__FILE__,__LINE__,_("Cannot run command %s\n"),cmd);
exit(EXIT_FAILURE);
}
-
+
nread=fread(buffer,1,sizeof(buffer),cmd_in);
-
+
if (pclose(cmd_in)==-1) {
- debuga(_("Command failed: %s\n"),cmd);
+ debuga(__FILE__,__LINE__,_("Command failed: %s\n"),cmd);
exit(EXIT_FAILURE);
}
if (nread==0) return(INRC_NotFound);
-
+
safe_strcpy(ip,buffer,ip_len);
return(INRC_Found);
}