Explorar el Código

dpkg-deb: Check and warn on duplicate conffiles

Closes: #131633
Guillem Jover hace 17 años
padre
commit
6257d864d6
Se han modificado 2 ficheros con 28 adiciones y 0 borrados
  1. 1 0
      debian/changelog
  2. 27 0
      dpkg-deb/build.c

+ 1 - 0
debian/changelog

@@ -5,6 +5,7 @@ dpkg (1.15.5) UNRELEASED; urgency=low
   * Update list of binaries dpkg checks on the PATH.
   * Update list of binaries dpkg checks on the PATH.
     - Remove install-info, now a wrapper that will disappear soonish.
     - Remove install-info, now a wrapper that will disappear soonish.
     - Add programs used by dpkg itself: sh, rm, find, tar and dpkg-deb.
     - Add programs used by dpkg itself: sh, rm, find, tar and dpkg-deb.
+  * Check and warn on duplicate conffiles in dpkg-deb. Closes: #131633
 
 
   [ Raphaël Hertzog ]
   [ Raphaël Hertzog ]
   * Add versioned dependency on base-files (>= 5.0.0) to dpkg-dev to ensure
   * Add versioned dependency on base-files (>= 5.0.0) to dpkg-dev to ensure

+ 27 - 0
dpkg-deb/build.c

@@ -115,6 +115,18 @@ file_info_new(const char *filename)
   return fi;
   return fi;
 }
 }
 
 
+static struct file_info *
+file_info_find_name(struct file_info *list, const char *filename)
+{
+  struct file_info *node;
+
+  for (node = list; node; node = node->next)
+    if (strcmp(node->fn, filename) == 0)
+      return node;
+
+  return NULL;
+}
+
 /*
 /*
  * Read the next filename from a filedescriptor and create a file_info struct
  * Read the next filename from a filedescriptor and create a file_info struct
  * for it. If there is nothing to read return NULL.
  * for it. If there is nothing to read return NULL.
@@ -341,6 +353,9 @@ void do_build(const char *const *argv) {
     strcpy(controlfile, directory);
     strcpy(controlfile, directory);
     strcat(controlfile, "/" BUILDCONTROLDIR "/" CONFFILESFILE);
     strcat(controlfile, "/" BUILDCONTROLDIR "/" CONFFILESFILE);
     if ((cf= fopen(controlfile,"r"))) {
     if ((cf= fopen(controlfile,"r"))) {
+      struct file_info *conffiles_head = NULL;
+      struct file_info *conffiles_tail = NULL;
+
       while (fgets(conffilename,MAXCONFFILENAME+1,cf)) {
       while (fgets(conffilename,MAXCONFFILENAME+1,cf)) {
         n= strlen(conffilename);
         n= strlen(conffilename);
         if (!n) ohshite(_("empty string from fgets reading conffiles"));
         if (!n) ohshite(_("empty string from fgets reading conffiles"));
@@ -367,7 +382,19 @@ void do_build(const char *const *argv) {
           warning(_("conffile '%s' is not a plain file"), conffilename);
           warning(_("conffile '%s' is not a plain file"), conffilename);
           warns++;
           warns++;
         }
         }
+
+        if (file_info_find_name(conffiles_head, conffilename))
+          warning(_("conffile name '%s' is duplicated"), conffilename);
+        else {
+          struct file_info *conffile;
+
+          conffile = file_info_new(conffilename);
+          add_to_filist(&conffiles_head, &conffiles_tail, conffile);
+        }
       }
       }
+
+      free_filist(conffiles_head);
+
       if (ferror(cf)) ohshite(_("error reading conffiles file"));
       if (ferror(cf)) ohshite(_("error reading conffiles file"));
       fclose(cf);
       fclose(cf);
     } else if (errno != ENOENT) {
     } else if (errno != ENOENT) {