]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Fixed debian bug #504749.
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 16 Jul 2009 10:33:55 +0000 (10:33 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 16 Jul 2009 10:33:55 +0000 (10:33 +0000)
documentation/util.txt
include/info.h
util.c

index 28aa1e7fc28877cd01271561a803a65e277812f9..d607295c0eb3bcd2653c9a9716dc023691c87904 100644 (file)
@@ -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.
index 4bea3da67b68b24e6839a907e3c41232348b170f..67bbf6dfc14c6e7754774e271b5d30cd24ae7229 100755 (executable)
@@ -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 c570e4135c0708c8a99b8128fd1b184b1a518ccf..675b6a32b44cedec0534e73632ef655b73b6b405 100644 (file)
--- 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<namelen ; z1++) {
+         for(z1=0; *str != '\t' && z1<namelen ; z1++) {
             name[z1]=*str++;
          }
          name[z1]=0;