[Libguestfs] [PATCH 2/2] customize: allow editing symlinked files

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


Resolve also symlinks when checking whether a path passed to --edit is a
file: the file editing code supports symlinks anyway (properly changes
the target file, instead of overwrite the symlink with a real file), so
it is safe to allow this operation in customize/builder.
---
 customize/customize_run.ml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/customize/customize_run.ml b/customize/customize_run.ml
index 054ee53..ed3c818 100644
--- a/customize/customize_run.ml
+++ b/customize/customize_run.ml
@@ -201,7 +201,7 @@ exec >>%s 2>&1
       if not (g#exists path) then
         error (f_"%s does not exist in the guest") path;
 
-      if not (g#is_file path) then
+      if not (g#is_file ~followsymlinks:true path) then
         error (f_"%s is not a regular file in the guest") path;
 
       Perl_edit.edit_file g#ocaml_handle path expr
-- 
2.1.0




More information about the Libguestfs mailing list