[Libguestfs] [PATCH 1/2] customize: check for file existence with --edit (RHBZ#1275806)

Pino Toscano ptoscano at redhat.com
Mon Nov 9 17:36:15 UTC 2015


Check that a path provided to --edit exists already; while the is_file
call later will fail for non-existing files, with an explicit check a
better error message can be provided.
---
 customize/customize_run.ml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/customize/customize_run.ml b/customize/customize_run.ml
index ff7bd0d..054ee53 100644
--- a/customize/customize_run.ml
+++ b/customize/customize_run.ml
@@ -198,6 +198,9 @@ exec >>%s 2>&1
     | `Edit (path, expr) ->
       message (f_"Editing: %s") path;
 
+      if not (g#exists path) then
+        error (f_"%s does not exist in the guest") path;
+
       if not (g#is_file path) then
         error (f_"%s is not a regular file in the guest") path;
 
-- 
2.1.0




More information about the Libguestfs mailing list