From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 0E11C13835C for ; Sun, 7 Feb 2021 03:20:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0AE28E0870; Sun, 7 Feb 2021 03:20:09 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E6A30E0870 for ; Sun, 7 Feb 2021 03:20:08 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BD1BD3415DA for ; Sun, 7 Feb 2021 03:20:07 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 85DAA4C3 for ; Sun, 7 Feb 2021 03:20:04 +0000 (UTC) From: "Jason Zaman" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Jason Zaman" Message-ID: <1612644851.607c61b089898d26c00af42a887cd1f24372be4d.perfinion@gentoo> Subject: [gentoo-commits] proj/hardened-refpolicy:master commit in: support/ X-VCS-Repository: proj/hardened-refpolicy X-VCS-Files: support/genhomedircon.py X-VCS-Directories: support/ X-VCS-Committer: perfinion X-VCS-Committer-Name: Jason Zaman X-VCS-Revision: 607c61b089898d26c00af42a887cd1f24372be4d X-VCS-Branch: master Date: Sun, 7 Feb 2021 03:20:04 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: c70c20c6-3a8a-4925-83a9-647290c292e3 X-Archives-Hash: ef2c577db84d20a6ea5a04b982b0531b commit: 607c61b089898d26c00af42a887cd1f24372be4d Author: Christian Göttsche googlemail com> AuthorDate: Sun Jan 31 20:50:25 2021 +0000 Commit: Jason Zaman gentoo org> CommitDate: Sat Feb 6 20:54:11 2021 +0000 URL: https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=607c61b0 genhomedircon: misc pylint cleanup support/genhomedircon.py:297:5: R1714: Consider merging these comparisons with "in" to "o in ('--type', '-t')" (consider-using-in) support/genhomedircon.py:299:5: R1714: Consider merging these comparisons with "in" to "o in ('--nopasswd', '-n')" (consider-using-in) support/genhomedircon.py:301:5: R1714: Consider merging these comparisons with "in" to "o in ('--dir', '-d')" (consider-using-in) support/genhomedircon.py:238:2: R1705: Unnecessary "else" after "return" (no-else-return) support/genhomedircon.py:207:11: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) support/genhomedircon.py:146:2: R1705: Unnecessary "else" after "return" (no-else-return) support/genhomedircon.py:144:1: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements) Signed-off-by: Christian Göttsche googlemail.com> Signed-off-by: Jason Zaman gentoo.org> support/genhomedircon.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/support/genhomedircon.py b/support/genhomedircon.py index 0490f724..e4475f5c 100644 --- a/support/genhomedircon.py +++ b/support/genhomedircon.py @@ -143,10 +143,9 @@ class selinuxConfig: def getHomeRootContext(self, homedir): rc=getstatusoutput("grep HOME_ROOT %s | sed -e \"s|^HOME_ROOT|%s|\"" % ( self.getHomeDirTemplate(), homedir)) - if rc[0] == 0: - return rc[1]+"\n" - else: - errorExit("sed error " + rc[1]) + if rc[0] != 0: + errorExit("sed error (" + str(rc[0]) + "): " + rc[1]) + return rc[1]+"\n" def getUsersFile(self): return self.selinuxdir+self.setype+"/users/local.users" @@ -211,7 +210,7 @@ class selinuxConfig: users = self.getUsers() ret="" # Fill in HOME and ROLE for users that are defined - for u in users.keys(): + for u in users: ret += self.getHomeDirContext (u, users[u]["home"], users[u]["role"], users[u]["name"], users[u]["uid"]) return ret+"\n" @@ -244,8 +243,7 @@ class selinuxConfig: break if exists == 1: return 1 - else: - return 0 + return 0 def getHomeDirs(self): @@ -301,11 +299,11 @@ try: 'nopasswd', 'dir=']) for o,a in gopts: - if o == '--type' or o == "-t": + if o in ('--type', '-t'): setype=a - if o == '--nopasswd' or o == "-n": + if o in ('--nopasswd', '-n'): usepwd=0 - if o == '--dir' or o == "-d": + if o in ('--dir', '-d'): directory=a if o == '--help': usage()