[elbe-devel] [PATCH v2 2/5] efilesystem: Fix copy_filelist copying none existing file

Torben Hohn torben.hohn at linutronix.de
Wed Aug 19 11:53:39 CEST 2020


On Mon, Aug 17, 2020 at 09:49:17AM -0400, Olivier Dion wrote:
> Some files that are passed to copy_filelist() might not exist on the
> source file system.  One such example IIRC was /etc/sysctl.conf that
> was a broken symlink to something like /etc/sysctl.d/*.conf

maybe the other way round ?

i have here:

--------------------------------------------
/etc/sysctl.d:
total 16
-rw-r--r-- 1 root root 552 Apr 14  2019 30-lxc-inotify.conf
-rw-r--r-- 1 root root 462 Jan  4  2015 30-postgresql-shm.conf
lrwxrwxrwx 1 root root  14 Apr 27 19:02 99-sysctl.conf -> ../sysctl.conf
-rw-r--r-- 1 root root 324 May 31  2018 protect-links.conf
-rw-r--r-- 1 root root 639 Jan 31  2010 README.sysctl
--------------------------------------------

anyways... it seems ok to me, that /etc/sysctl.conf does not exist.
because it look like sysctl only looks into /etc/sysctl.d

however, if one creates /etc/sysctl.conf afterwards, then it should work
out of the box.

So... we really want to copy the broken symlink.



> 
> Thus, ignore broken symlinks and emit a warning when trying to copy a
> regular file that doesn't exist.

errm... this comment is misleading.
You actually create the broken symlink. Dont you ?

> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>
> ---
>  elbepack/efilesystem.py | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
> index ef697c46..18b592a4 100644
> --- a/elbepack/efilesystem.py
> +++ b/elbepack/efilesystem.py
> @@ -56,6 +56,10 @@ def copy_filelist(src, file_lst, dst):
>  
>              tgt = src.readlink(f)
>  
> +            if not src.lexists(tgt):
> +                dst.symlink(tgt, f, allow_exists=True)
> +                continue
> +
>              # If the target is not yet in the destination RFS, we need
>              # to defer the copy of the symlink after the target is
>              # resolved.  Thus, we recusively call copy_filelist
> @@ -78,8 +82,12 @@ def copy_filelist(src, file_lst, dst):
>              dst.chown(f, st.st_uid, st.st_gid)
>  
>          else:
> -            system('cp -a --reflink=auto "%s" "%s"' % (src.realpath(f),
> -                                                       dst.realpath(f)))
> +            try:
> +                system('cp -a --reflink=auto "%s" "%s"' % (src.realpath(f),
> +                                                           dst.realpath(f)))
> +            except CommandError as E:
> +                logging.warning("Error while copying from %s to %s of file %s - %s",
> +                                src.path, dst.path, f, E)
>  
>      # update utime which will change after a file has been copied into
>      # the directory
> -- 
> 2.28.0
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner


More information about the elbe-devel mailing list