Gentoo Archives: gentoo-commits

From: Jason Zaman <perfinion@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/hardened-refpolicy:master commit in: support/
Date: Sun, 07 Feb 2021 03:20:10
Message-Id: 1612644851.607c61b089898d26c00af42a887cd1f24372be4d.perfinion@gentoo
1 commit: 607c61b089898d26c00af42a887cd1f24372be4d
2 Author: Christian Göttsche <cgzones <AT> googlemail <DOT> com>
3 AuthorDate: Sun Jan 31 20:50:25 2021 +0000
4 Commit: Jason Zaman <perfinion <AT> gentoo <DOT> org>
5 CommitDate: Sat Feb 6 20:54:11 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=607c61b0
7
8 genhomedircon: misc pylint cleanup
9
10 support/genhomedircon.py:297:5: R1714: Consider merging these comparisons with "in" to "o in ('--type', '-t')" (consider-using-in)
11 support/genhomedircon.py:299:5: R1714: Consider merging these comparisons with "in" to "o in ('--nopasswd', '-n')" (consider-using-in)
12 support/genhomedircon.py:301:5: R1714: Consider merging these comparisons with "in" to "o in ('--dir', '-d')" (consider-using-in)
13 support/genhomedircon.py:238:2: R1705: Unnecessary "else" after "return" (no-else-return)
14 support/genhomedircon.py:207:11: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
15 support/genhomedircon.py:146:2: R1705: Unnecessary "else" after "return" (no-else-return)
16 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)
17
18 Signed-off-by: Christian Göttsche <cgzones <AT> googlemail.com>
19 Signed-off-by: Jason Zaman <perfinion <AT> gentoo.org>
20
21 support/genhomedircon.py | 18 ++++++++----------
22 1 file changed, 8 insertions(+), 10 deletions(-)
23
24 diff --git a/support/genhomedircon.py b/support/genhomedircon.py
25 index 0490f724..e4475f5c 100644
26 --- a/support/genhomedircon.py
27 +++ b/support/genhomedircon.py
28 @@ -143,10 +143,9 @@ class selinuxConfig:
29
30 def getHomeRootContext(self, homedir):
31 rc=getstatusoutput("grep HOME_ROOT %s | sed -e \"s|^HOME_ROOT|%s|\"" % ( self.getHomeDirTemplate(), homedir))
32 - if rc[0] == 0:
33 - return rc[1]+"\n"
34 - else:
35 - errorExit("sed error " + rc[1])
36 + if rc[0] != 0:
37 + errorExit("sed error (" + str(rc[0]) + "): " + rc[1])
38 + return rc[1]+"\n"
39
40 def getUsersFile(self):
41 return self.selinuxdir+self.setype+"/users/local.users"
42 @@ -211,7 +210,7 @@ class selinuxConfig:
43 users = self.getUsers()
44 ret=""
45 # Fill in HOME and ROLE for users that are defined
46 - for u in users.keys():
47 + for u in users:
48 ret += self.getHomeDirContext (u, users[u]["home"], users[u]["role"], users[u]["name"], users[u]["uid"])
49 return ret+"\n"
50
51 @@ -244,8 +243,7 @@ class selinuxConfig:
52 break
53 if exists == 1:
54 return 1
55 - else:
56 - return 0
57 + return 0
58
59
60 def getHomeDirs(self):
61 @@ -301,11 +299,11 @@ try:
62 'nopasswd',
63 'dir='])
64 for o,a in gopts:
65 - if o == '--type' or o == "-t":
66 + if o in ('--type', '-t'):
67 setype=a
68 - if o == '--nopasswd' or o == "-n":
69 + if o in ('--nopasswd', '-n'):
70 usepwd=0
71 - if o == '--dir' or o == "-d":
72 + if o in ('--dir', '-d'):
73 directory=a
74 if o == '--help':
75 usage()