[oe-commits] [bitbake] 02/02: utils: lockfile: Fix infinite loop

git at git.openembedded.org git at git.openembedded.org
Tue Sep 25 14:18:00 UTC 2018


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository bitbake.

commit c1c4f042942780d3f72fb44ffd71b6c59498aef4
Author: Ioan-Adrian Ratiu <adrian.ratiu at ni.com>
AuthorDate: Tue Sep 25 15:34:19 2018 +0300

    utils: lockfile: Fix infinite loop
    
    A nasty corner case leads to a hang when utils.lockfile is called from
    oe-core's package-manager:deploy_dir_lock (in turn called from
    rootfs:_create further up the call stack) with "name" owned by root
    and the user running bitbake has no write access.
    
    Because this code runs under pseudo, the UID and EUID of the bitbake
    worker process are 0, so the os.access(dirname, os.W_OK) returns True
    i.e. it thinks the path is writable when in fact it's not writable.
    
    Only later when trying to open the file an Exception it thrown because
    the OS prohibits writing, but the Exception is ignored and the open is
    retried leading to an infinite loop.
    
    So this fix is to not ignore the "Permission Denied" exception.
    
    An alternative fix would be to replace the os.access() call with an
    try: open() except() at the beginning of the function.
    
    Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu at ni.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/utils.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 56894f1..73b6cb4 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -497,7 +497,11 @@ def lockfile(name, shared=False, retry=True, block=False):
                 if statinfo.st_ino == statinfo2.st_ino:
                     return lf
             lf.close()
-        except Exception:
+        except OSError as e:
+            if e.errno == errno.EACCES:
+                logger.error("Unable to acquire lock '%s', %s",
+                             e.strerror, name)
+                sys.exit(1)
             try:
                 lf.close()
             except Exception:

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list