[OE-core] [PATCH] Avoid crashing if getgrnam() cannont find a group by the given name

Cody P Schafer dev at codyps.com
Sat Oct 25 16:10:43 UTC 2014


Without this, we get (on systems without a 'mail' group):

	ERROR: Error executing a python function in /home/x/g/poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers_3.16.bb:

	The stack trace of python calls that resulted in this exception/failure was:
	File: 'fixup_perms', lineno: 231, function: <module>
	     0227:                    each_file = os.path.join(root, f)
	     0228:                    fix_perms(each_file, fs_perms_table[dir].fmode, fs_perms_table[dir].fuid, fs_perms_table[dir].fgid, dir)
	     0229:
	     0230:
	 *** 0231:fixup_perms(d)
	     0232:
	File: 'fixup_perms', lineno: 173, function: fixup_perms
	     0169:                if len(lsplit) != 8 and not (len(lsplit) == 3 and lsplit[1].lower() == "link"):
	     0170:                    msg = "Fixup perms: %s invalid line: %s" % (conf, line)
	     0171:                    package_qa_handle_error("perm-line", msg, d)
	     0172:                    continue
	 *** 0173:                entry = fs_perms_entry(d.expand(line))
	     0174:                if entry and entry.path:
	     0175:                    fs_perms_table[entry.path] = entry
	     0176:            f.close()
	     0177:
	File: 'fixup_perms', lineno: 32, function: __init__
	  File "fixup_perms", line 32, in __init__

	File: 'fixup_perms', lineno: 44, function: _setdir
	  File "fixup_perms", line 44, in _setdir

	File: 'fixup_perms', lineno: 75, function: _procgid
	  File "fixup_perms", line 75, in _procgid

	Exception: KeyError: 'getgrnam(): name not found: mail'

	ERROR: Function failed: fixup_perms
	ERROR: Logfile of failure stored in: /home/x/obj/y/tmp/work/i586-poky-linux/linux-libc-headers/3.16-r0/temp/log.do_package.15841
	ERROR: Task 400 (/home/x/g/poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers_3.16.bb, do_package) failed with exit code '1'

Signed-off-by: Cody P Schafer <dev at codyps.com>
---
 meta/classes/package.bbclass | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 2aec3e6..d7c970b 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -568,7 +568,10 @@ python fixup_perms () {
             elif gid.isdigit():
                 return int(gid)
             else:
-                return grp.getgrnam(gid).gr_gid
+                try:
+                    return grp.getgrnam(gid).gr_gid
+                except Exception:
+                   return -1
 
         # Use for debugging the entries
         def __str__(self):
-- 
2.0.4




More information about the Openembedded-core mailing list