Skip to contentSkip to conversation

sstatesig: Improve debug output if getpwuid() fails

PATCH New Richard Purdie 1 participant 1 message Jan 14, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sstatesig: Improve debug output if getpwuid() fails

If getpwduid fails, we don't see which file it failed on which is key information to aid debugging. Print this information when exceptions are raised.

---
 meta/lib/oe/sstatesig.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
meta/lib/oe/sstatesig.py +6 -2
index 0e17ad6f5b7..4325b66a9ee 100644
@@ -541,8 +541,12 @@ def OEOuthashBasic(path, sigfile, task, d):
                     add_perm(stat.S_IXOTH, 'x')
 
                 if include_owners:
-                    update_hash(" %10s" % pwd.getpwuid(s.st_uid).pw_name)
-                    update_hash(" %10s" % grp.getgrgid(s.st_gid).gr_name)
+                    try:
+                        update_hash(" %10s" % pwd.getpwuid(s.st_uid).pw_name)
+                        update_hash(" %10s" % grp.getgrgid(s.st_gid).gr_name)
+                    except KeyError:
+                        bb.warn("KeyError in %s" % path)
+                        raise
 
                 update_hash(" ")
                 if stat.S_ISBLK(s.st_mode) or stat.S_ISCHR(s.st_mode):
Signature · 1 line
2.20.1