added sigbus testcase
[util-vserver.git] / util-vserver / lib_internal / matchlist-initmanually.c
index 111ab42..8fffe73 100644 (file)
@@ -37,8 +37,8 @@
 #include <wrappers.h>
 
 
-extern int     Global_getVerbosity();
-extern bool    Global_doRenew();
+extern int     Global_getVerbosity() PURE CONST;
+extern bool    Global_doRenew() PURE CONST;
 
 static void
 readExcludeListFD(int fd,
@@ -146,7 +146,8 @@ getConfigfileList(char const *vserver,
 }
 
 void
-MatchList_initManually(struct MatchList *list, char const *vserver,
+MatchList_initManually(struct MatchList *list,
+                      struct MatchVserverInfo const *vserver,
                       char const *vdir, char const *exclude_file)
 {
   char                 *buf[2] = { 0,0 };
@@ -156,36 +157,46 @@ MatchList_initManually(struct MatchList *list, char const *vserver,
 
   char                 **expr_files  = 0;
   size_t               expr_count    = 0;
+  size_t               len;
 
-  if (Global_getVerbosity()>3) {
+  assert((vdir==0 && vserver!=0) || (vdir!=0 && vserver==0));
+
+  if (vserver) {
+    vdir = vserver->vdir.d;
+    len  = vserver->vdir.l;
+  }
+  else
+    len  = strlen(vdir);
+  
+  if (Global_getVerbosity()>=1) {
     WRITE_MSG(1, "Initializing exclude-list for ");
-    WRITE_STR(1, vdir);
+    Vwrite(1, vdir, len);
     if (vserver!=0) {
       WRITE_MSG(1, " (");
-      WRITE_STR(1, vserver);
+      WRITE_STR(1, vserver->name);
       WRITE_MSG(1, ")");
     }
     WRITE_MSG(1, "\n");
   }
-  if (vserver && Global_doRenew()) {
-    if (Global_getVerbosity()>4)
+  if (vserver && vserver->use_pkgmgmt && Global_doRenew()) {
+    if (Global_getVerbosity()>=2)
       WRITE_MSG(1, "  Fetching configuration-file list from packagemanagement\n");
-    getConfigfileList(vserver, &fixed_files, &fixed_count, buf+0);
+    getConfigfileList(vserver->name, &fixed_files, &fixed_count, buf+0);
   }
 
   // abuse special values (NULL, empty string) to skip the next step
   if (exclude_file && *exclude_file) {
-    if (Global_getVerbosity()>4) WRITE_MSG(1, "  Reading exclude file\n");
+    if (Global_getVerbosity()>=6) WRITE_MSG(1, "  Reading exclude file\n");
     readExcludeList(exclude_file,
                    &expr_files,  &expr_count,
                    buf+1);
   }
 
-  MatchList_init(list, vdir, fixed_count + expr_count);
+  MatchList_init(list, strdup(vdir), fixed_count + expr_count);
   list->buf       = Emalloc(sizeof(void *) * 3);
   list->buf[0]    = buf[0];
   list->buf[1]    = buf[1];
-  list->buf[2]    = vdir;
+  list->buf[2]    = list->root.d;
   list->buf_count = 3;
 
   MatchList_appendFiles(list, 0,           fixed_files, fixed_count, false);