From f5259eead333d3e5f57c2619f200219973fffa30 Mon Sep 17 00:00:00 2001 From: Derek Carter Date: Fri, 29 Jun 2012 20:05:23 -0400 Subject: [PATCH 1/3] file when UID or GID doesn't exist --- library/file | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/library/file b/library/file index 892696dd156..71e01c53b06 100755 --- a/library/file +++ b/library/file @@ -184,8 +184,16 @@ def user_and_group(filename): st = os.stat(filename) uid = st.st_uid gid = st.st_gid - user = pwd.getpwuid(uid)[0] - group = grp.getgrgid(gid)[0] + try: + user = pwd.getpwuid(uid)[0] + except KeyError: + #print('unknown user') + user = 'UID' + str(uid) + try: + group = grp.getgrgid(gid)[0] + except KeyError: + #print('unknown group') + group = 'GID' + str(gid) return (user, group) def set_context_if_different(path, context, changed): From c532a1c97868329e51ebcf2a0c65a0950b7c9b5a Mon Sep 17 00:00:00 2001 From: Derek Carter Date: Fri, 29 Jun 2012 21:38:31 -0400 Subject: [PATCH 2/3] removed print from debug code of file module --- library/file | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/file b/library/file index 71e01c53b06..337fa15c007 100755 --- a/library/file +++ b/library/file @@ -187,12 +187,10 @@ def user_and_group(filename): try: user = pwd.getpwuid(uid)[0] except KeyError: - #print('unknown user') user = 'UID' + str(uid) try: group = grp.getgrgid(gid)[0] except KeyError: - #print('unknown group') group = 'GID' + str(gid) return (user, group) From aff0403a0e746f7b61b5b59121b9e479b5a34bd4 Mon Sep 17 00:00:00 2001 From: Derek Carter Date: Sun, 1 Jul 2012 17:38:17 -0400 Subject: [PATCH 3/3] remove UID/GID from output --- library/file | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/file b/library/file index 337fa15c007..2575c57c39a 100755 --- a/library/file +++ b/library/file @@ -187,11 +187,11 @@ def user_and_group(filename): try: user = pwd.getpwuid(uid)[0] except KeyError: - user = 'UID' + str(uid) + user = str(uid) try: group = grp.getgrgid(gid)[0] except KeyError: - group = 'GID' + str(gid) + group = str(gid) return (user, group) def set_context_if_different(path, context, changed):