[Openvas-commits] r3462 - in trunk/openvas-client: . nessus

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon May 25 09:47:46 CEST 2009


Author: felix
Date: 2009-05-25 09:47:46 +0200 (Mon, 25 May 2009)
New Revision: 3462

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/nessus/context.c
Log:
Replaced context_delete_dir with the newer file_utils_rmdir_rf at the
price of possibly less detailed error messages.

* nessus/context.c (context_delete_directory): Removed.

* nessus/context.c (context_delete): Updated call, show error message if
failed.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-05-25 07:10:09 UTC (rev 3461)
+++ trunk/openvas-client/ChangeLog	2009-05-25 07:47:46 UTC (rev 3462)
@@ -1,5 +1,15 @@
 2009-05-20  Felix Wolfsteller <felix.wolfsteller at intevation.de>
 
+	Replaced context_delete_dir with the newer file_utils_rmdir_rf at the
+	price of possibly less detailed error messages.
+
+	* nessus/context.c (context_delete_directory): Removed.
+
+	* nessus/context.c (context_delete): Updated call, show error message if
+	failed.
+
+2009-05-20  Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
 	* nessus/context.c (check_is_dir, check_is_file, check_exists):
 	Cosmetics, reformatting.
 

Modified: trunk/openvas-client/nessus/context.c
===================================================================
--- trunk/openvas-client/nessus/context.c	2009-05-25 07:10:09 UTC (rev 3461)
+++ trunk/openvas-client/nessus/context.c	2009-05-25 07:47:46 UTC (rev 3462)
@@ -727,44 +727,14 @@
   return context;
 }
 
+
 /**
- * @brief Deletes a directory and (recursively) all its content.
- * @TODO In the long run use function from file_utils module
+ * @brief Removes a Context and its children, including the representation on
+ * @brief disc.
+ * 
+ * @param context The context to remove.
  */
 void
-context_delete_directory (const char* dir)
-{
-  DIR *odir;
-  struct dirent *dirent;
-
-  if((odir = opendir(dir)))
-  {
-    while((dirent = readdir(odir)))
-    {
-      const char *file = dirent->d_name;
-      char *path;
-
-      if(!strcmp(file, ".") || !strcmp(file, ".."))
-	continue;
-
-      path = g_build_filename(dir, file, NULL);
-
-      if(check_is_dir(path))
-	context_delete_directory(path);
-      else
-	if(unlink(path))
-	  show_error_and_wait (_("File %s couldn't be deleted: %s."),
-                               path, strerror(errno));
-      g_free(path);
-    }
-    closedir(odir);
-    if(rmdir(dir))
-      show_error_and_wait(_("Directory %s couldn't be deleted: %s."),
-	    dir, strerror(errno));
-  }
-}
-
-void
 context_delete (struct context *context)
 {
   while(context->children)
@@ -775,7 +745,8 @@
   context_reset_plugins (context);
   arg_free_all (context->dependencies);
   context->dependencies = NULL;
-  context_delete_directory (context->dir);
+  if (file_utils_rmdir_rf (context->dir) == -1)
+    show_error (_("Error removing files or directories\n(possible cause of error: '%s')"), strerror(errno));
   if (context->signer_fp_certificates)
     g_hash_table_destroy (context->signer_fp_certificates);
   if (context->map_target_sshlogin)



More information about the Openvas-commits mailing list