From: Frédéric Marchal Date: Thu, 16 Jul 2009 10:33:55 +0000 (+0000) Subject: Fixed debian bug #504749. X-Git-Tag: v2_2_6~56 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a4aabea6e5c2063e9446a4040a5467cb2a86d3b7;p=thirdparty%2Fsarg.git Fixed debian bug #504749. --- diff --git a/documentation/util.txt b/documentation/util.txt index 28aa1e7..d607295 100644 --- a/documentation/util.txt +++ b/documentation/util.txt @@ -694,9 +694,14 @@ the function returns NULL. /*! \fn void read_usertab(const char *UserTabFile) -Read the content fo the \a UserTabFile and store it for further use with get_usertab_name(). +Read the content of the \a UserTabFile and store it for further use with get_usertab_name(). The file contains the IP address or ID of the user then some spaces and the real name of the user. + +Any trailing space or tabulation is removed from the real name. The user ID or IP cannot contain +a space or a tabulation but it may contain any other character, including the colon that was +forbidden in the past. That change was made to allow IPv6 addresses. + The file may contain comments if the line starts with a #. \param UserTabFile The name of the file to read. If it is empty, the function does nothing. diff --git a/include/info.h b/include/info.h index 4bea3da..67bbf6d 100755 --- a/include/info.h +++ b/include/info.h @@ -1,3 +1,3 @@ -#define VERSION "2.2.5 Jul-09-2009" +#define VERSION "2.2.5 Jul-16-2009" #define PGM "sarg" #define URL "http://sarg.sourceforge.net" diff --git a/util.c b/util.c index c570e41..675b6a3 100644 --- a/util.c +++ b/util.c @@ -1400,6 +1400,7 @@ void read_usertab(const char *UserTabFile) char bufy[MAXLEN]; int z2; int z1; + int i; if (UserTabFile[0] != '\0') { if(debug) { @@ -1416,12 +1417,11 @@ void read_usertab(const char *UserTabFile) fprintf(stderr, "SARG ERROR: %s",text[87]); exit(1); } - strcpy(userfile,":"); + strcpy(userfile,"\t"); z2=1; while(fgets(buf,sizeof(buf),fp_usr)!=NULL) { if (buf[0]=='#') continue; - buf[strlen(buf)-1]='\0'; - if(strstr(buf,"\r") != 0) buf[strlen(buf)-1]='\0'; + for (i=strlen(buf)-1 ; i>=0 && (unsigned char)buf[i]<=' ' ; i--) buf[i]=0; if (getword_multisep(bufy,sizeof(bufy),buf,' ')<0) { printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",UserTabFile); exit(1); @@ -1432,10 +1432,10 @@ void read_usertab(const char *UserTabFile) } for(z1=0; bufy[z1]; z1++) userfile[z2++]=bufy[z1]; - userfile[z2++]='|'; + userfile[z2++]='\n'; for(z1=0; buf[z1]; z1++) userfile[z2++]=buf[z1]; - userfile[z2++]=':'; + userfile[z2++]='\t'; } userfile[z2]=0; fclose(fp_usr); @@ -1452,14 +1452,14 @@ void get_usertab_name(const char *user,char *name,int namelen) strncpy(name,user,namelen); name[namelen]=0; } else { - sprintf(warea,":%s|",user); + sprintf(warea,"\t%s\n",user); if((str=(char *) strstr(userfile,warea)) == (char *) NULL ) { strncpy(name,user,namelen); name[namelen]=0; } else { - str=strchr(str+1,'|'); + str=strchr(str+1,'\n'); str++; - for(z1=0; *str != ':' && z1