[PATCH 1/2] customize: check for file existence with --edit (RHBZ#1275806)
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
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
On Mon, Nov 09, 2015 at 06:36:16PM +0100, Pino Toscano wrote:
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
ACK series. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
participants (2)
-
Pino Toscano -
Richard W.M. Jones