diff options
author | Ioan-Adrian Ratiu <adrian.ratiu@ni.com> | 2018-09-25 15:34:19 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-09-25 23:16:21 +0100 |
commit | 9d0cad1ae12bfa9a72b295948f00343e53df3032 (patch) | |
tree | d2bd2908fca523ce603172300b42f78d0cb8c6fe /bitbake/lib/bb/utils.py | |
parent | 364c4c7d3fc049f2b734a6a235758a75af364ce0 (diff) | |
download | poky-9d0cad1ae12bfa9a72b295948f00343e53df3032.tar.gz |
bitbake: 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.
(Bitbake rev: 0cb64d0f85b41b2fa764baf6ff7ea1b13f95004e)
Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 56894f130f..73b6cb423b 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -497,7 +497,11 @@ def lockfile(name, shared=False, retry=True, block=False): | |||
497 | if statinfo.st_ino == statinfo2.st_ino: | 497 | if statinfo.st_ino == statinfo2.st_ino: |
498 | return lf | 498 | return lf |
499 | lf.close() | 499 | lf.close() |
500 | except Exception: | 500 | except OSError as e: |
501 | if e.errno == errno.EACCES: | ||
502 | logger.error("Unable to acquire lock '%s', %s", | ||
503 | e.strerror, name) | ||
504 | sys.exit(1) | ||
501 | try: | 505 | try: |
502 | lf.close() | 506 | lf.close() |
503 | except Exception: | 507 | except Exception: |