]> code.ossystems Code Review - openembedded-core.git/commitdiff
sstatesig: Add descriptive error message to getpwuid/getgrgid "uid/gid not found...
authorTomasz Dziendzielski <tomasz.dziendzielski@gmail.com>
Mon, 1 Feb 2021 00:32:56 +0000 (01:32 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 3 Feb 2021 21:42:44 +0000 (21:42 +0000)
If path is not owned by any user installed on target it gives
insufficient error "getpwuid(): uid not found" which may be misleading.
This exception occurs if uid/gid of path was not found in PSEUDO_PASSWD
files, which simply means the path is owned by host user and there is
host user contamination.

Add more information to the exception message to make it easier for user
to debug.

[YOCTO #14031]

Signed-off-by: Tomasz Dziendzielski <tomasz.dziendzielski@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oe/sstatesig.py

index adfe2e403bcfb3a1ac1f1a123f7bdb93e7287e13..84999ee94d4217f9faa572a37991449e7d11f6c0 100644 (file)
@@ -552,9 +552,11 @@ def OEOuthashBasic(path, sigfile, task, d):
                     try:
                         update_hash(" %10s" % pwd.getpwuid(s.st_uid).pw_name)
                         update_hash(" %10s" % grp.getgrgid(s.st_gid).gr_name)
-                    except KeyError:
+                    except KeyError as e:
                         bb.warn("KeyError in %s" % path)
-                        raise
+                        msg = ("KeyError: %s\nPath %s is owned by uid %d, gid %d, which doesn't match "
+                            "any user/group on target. This may be due to host contamination." % (e, path, s.st_uid, s.st_gid))
+                        raise Exception(msg).with_traceback(e.__traceback__)
 
                 if include_timestamps:
                     update_hash(" %10d" % s.st_mtime)