[oe-commits] [bitbake] branch master updated: utils: lockfile: Fix infinite loop

git at git.openembedded.org git at git.openembedded.org
Tue Sep 25 22:17:33 UTC 2018


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

rpurdie pushed a commit to branch master
in repository bitbake.

The following commit(s) were added to refs/heads/master by this push:
     new 0cb64d0  utils: lockfile: Fix infinite loop
0cb64d0 is described below

commit 0cb64d0f85b41b2fa764baf6ff7ea1b13f95004e
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