Commit Graph

13 Commits

Author SHA1 Message Date
Christian Göttsche 627a453910 genhomedircon: improve error messages for min uid search
Only grep if the files exist.
grep returns 1 on no match, check against 1 instead of 256.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2021-01-31 21:53:33 +01:00
Christian Göttsche 27e3099f40 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 <cgzones@googlemail.com>
2021-01-31 21:53:33 +01:00
Christian Göttsche 9e48ce1f2e genhomedircon: generate file contexts for %{USERNAME} and %{USERID}
Generate substituted file contexts for templated paths containing
%{USERNAME} or %{USERID}, like semodules' genhomedircon.

Example:
  /run/user/%{USERID}  -d  gen_context(system_u:object_r:user_runtime_t,s0)
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2021-01-31 21:53:33 +01:00
Christian Göttsche cf8f7bbea7 genhomedircon: drop unused functions
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2021-01-31 21:50:21 +01:00
Christian Göttsche 806a0d12f8 genhomedircon: require match for home directory name
Use regular expression '/[^/]+' instead of '/[^/]*', like semodule's
genhomedircon.
Generates file contexts like '/home/[^/]+/dead\.letter'

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2021-01-31 21:50:18 +01:00
Christian Göttsche 577373f0db genhomedircon: drop backwards compatibility section
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2021-01-31 21:50:11 +01:00
Christian Göttsche cdfd85c35b Correct some misspellings
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2020-06-05 15:38:43 +02:00
Chris PeBenito a229fb0e39 genhomedircon: Drop Python 2 compatibility code.
Python 2 is end-of-life.

Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
2020-05-13 16:12:53 -04:00
Chris PeBenito 0bfd1387ac Remove incorrect usages of "is" operator from Python scripts.
Closes #128

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-11-23 10:12:53 -05:00
Chris PeBenito 0af99256c6 genhomedircon.py: Fix top-level exception handling.
Fixes errors like this:

Traceback (most recent call last):
  File "support/genhomedircon.py", line 490, in <module>
    errorExit("Options Error " + error)
TypeError: Can't convert 'GetoptError' object to str implicitly

Signed-off-by: Chris PeBenito <Christopher.PeBenito@microsoft.com>
2019-03-15 09:41:49 -04:00
Adam Duskett 6c9cc47e6c fix regex escape sequence error.
python3.6 will error out with the message "invalid escape sequence"
in genhomedircon.py.  This patch fixes these errors by turning the string
in the into a raw string.
2017-10-10 18:00:30 -04:00
cgzones 33fd9ae139 fix travis and genhomedircon 2017-03-18 18:38:20 +01:00
cgzones 82b0a6d4d5 convert build scripts to python3 2017-03-15 02:09:20 +01:00