[bitbake-devel] [PATCH] lib/bb/utils: prevent movefile from changing dest dir permissions

Peter Kjellerstedt peter.kjellerstedt at axis.com
Tue Apr 10 14:44:51 UTC 2018


From: Mattias Hansson <mattias.hansson at axis.com>

Prevent movefile from falsely setting the source file's owner and
permissions on the destination directory instead of the destination
file when moving between devices.

This bug caused the last file moved into a directory to dictate the
directory's owner and permissions.

Signed-off-by: Mattias Hansson <mattias.hansson at axis.com>
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt at axis.com>
---
 bitbake/lib/bb/utils.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 8b739d7849..378e699e0c 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -807,8 +807,8 @@ def movefile(src, dest, newmtime = None, sstat = None):
                 return None # failure
         try:
             if didcopy:
-                os.lchown(dest, sstat[stat.ST_UID], sstat[stat.ST_GID])
-                os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown
+                os.lchown(destpath, sstat[stat.ST_UID], sstat[stat.ST_GID])
+                os.chmod(destpath, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown
                 os.unlink(src)
         except Exception as e:
             print("movefile: Failed to chown/chmod/unlink", dest, e)
-- 
2.12.0




More information about the bitbake-devel mailing list