SCAutolib 3.2.2__py3-none-any.whl → 3.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- SCAutolib/controller.py +20 -19
- SCAutolib/enums.py +7 -5
- SCAutolib/isDistro.py +50 -0
- SCAutolib/models/file.py +7 -1
- SCAutolib/models/gui.py +2 -4
- SCAutolib/templates/sssd.conf-10 +18 -0
- SCAutolib/utils.py +0 -23
- {SCAutolib-3.2.2.dist-info → SCAutolib-3.3.2.dist-info}/METADATA +2 -1
- {SCAutolib-3.2.2.dist-info → SCAutolib-3.3.2.dist-info}/RECORD +14 -12
- /SCAutolib/templates/{sssd.conf → sssd.conf-8or9} +0 -0
- {SCAutolib-3.2.2.dist-info → SCAutolib-3.3.2.dist-info}/LICENSE +0 -0
- {SCAutolib-3.2.2.dist-info → SCAutolib-3.3.2.dist-info}/WHEEL +0 -0
- {SCAutolib-3.2.2.dist-info → SCAutolib-3.3.2.dist-info}/entry_points.txt +0 -0
- {SCAutolib-3.2.2.dist-info → SCAutolib-3.3.2.dist-info}/top_level.txt +0 -0
SCAutolib/controller.py
CHANGED
|
@@ -12,10 +12,11 @@ from SCAutolib import (logger, run, LIB_DIR, LIB_BACKUP, LIB_DUMP,
|
|
|
12
12
|
from SCAutolib.models import CA, file, user, card, authselect as auth
|
|
13
13
|
from SCAutolib.models.file import File, OpensslCnf
|
|
14
14
|
from SCAutolib.models.CA import BaseCA
|
|
15
|
-
from SCAutolib.enums import (
|
|
15
|
+
from SCAutolib.enums import (CardType, UserType)
|
|
16
16
|
from SCAutolib.utils import (_check_selinux, _gen_private_key,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
_install_packages, _check_packages,
|
|
18
|
+
dump_to_json, ca_factory)
|
|
19
|
+
from SCAutolib.isDistro import isDistro
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
class Controller:
|
|
@@ -158,7 +159,11 @@ class Controller:
|
|
|
158
159
|
for c in self.lib_conf["cards"]):
|
|
159
160
|
packages += ["pcsc-lite-ccid", "pcsc-lite", "virt_cacard",
|
|
160
161
|
"vpcd", "softhsm"]
|
|
161
|
-
|
|
162
|
+
extra_args = ""
|
|
163
|
+
if isDistro(['rhel', 'centos'], version='10'):
|
|
164
|
+
# TODO: use better approach later
|
|
165
|
+
extra_args = " centos-stream-10-x86_64"
|
|
166
|
+
run("dnf -y copr enable jjelen/vsmartcard{0}".format(extra_args))
|
|
162
167
|
|
|
163
168
|
# Add IPA packages if needed
|
|
164
169
|
if any([u["user_type"] != UserType.local
|
|
@@ -175,13 +180,15 @@ class Controller:
|
|
|
175
180
|
logger.critical(msg)
|
|
176
181
|
raise exceptions.SCAutolibException(msg)
|
|
177
182
|
|
|
178
|
-
os_version = _get_os_version()
|
|
179
183
|
if graphical:
|
|
180
|
-
if
|
|
184
|
+
if not isDistro('fedora'):
|
|
181
185
|
run(['dnf', 'groupinstall', 'Server with GUI', '-y',
|
|
182
186
|
'--allowerasing'])
|
|
187
|
+
run(['pip', 'install', 'python-uinput'])
|
|
183
188
|
else:
|
|
184
|
-
|
|
189
|
+
# Fedora doesn't have server with GUI group so installed gdm
|
|
190
|
+
# manually and also python3-uinput should be installed from RPM
|
|
191
|
+
run(['dnf', 'install', 'gdm', 'python3-uinput', '-y'])
|
|
185
192
|
# disable subscription message
|
|
186
193
|
run(['systemctl', '--global', 'mask',
|
|
187
194
|
'org.gnome.SettingsDaemon.Subscription.target'])
|
|
@@ -190,12 +197,14 @@ class Controller:
|
|
|
190
197
|
self.dconf_file.save()
|
|
191
198
|
run('dconf update')
|
|
192
199
|
|
|
193
|
-
if
|
|
200
|
+
if not isDistro('fedora'):
|
|
194
201
|
run(['dnf', 'groupinstall', "Smart Card Support", '-y',
|
|
195
202
|
'--allowerasing'])
|
|
196
203
|
logger.debug("Smart Card Support group in installed.")
|
|
197
204
|
else:
|
|
198
|
-
|
|
205
|
+
# Fedora requires rsyslog as well
|
|
206
|
+
run(['dnf', 'install', 'opensc', 'pcsc-lite-ccid', 'rsyslog', '-y'])
|
|
207
|
+
run(['systemctl', 'start', 'rsyslog'])
|
|
199
208
|
|
|
200
209
|
self.sssd_conf.create()
|
|
201
210
|
self.sssd_conf.save()
|
|
@@ -207,13 +216,6 @@ class Controller:
|
|
|
207
216
|
dump_to_json(user.User(username="root",
|
|
208
217
|
password=self.lib_conf["root_passwd"]))
|
|
209
218
|
|
|
210
|
-
# Fedora requires python3-uinput from RPM and rsyslog
|
|
211
|
-
if os_version == OSVersion.Fedora:
|
|
212
|
-
run(['dnf', 'install', 'python3-uinput', 'rsyslog', '-y'])
|
|
213
|
-
run(['systemctl', 'start', 'rsyslog'])
|
|
214
|
-
else:
|
|
215
|
-
run(['pip', 'install', 'python-uinput'])
|
|
216
|
-
|
|
217
219
|
def setup_local_ca(self, force: bool = False):
|
|
218
220
|
"""
|
|
219
221
|
Setup local CA based on configuration from the configuration file. All
|
|
@@ -534,13 +536,12 @@ class Controller:
|
|
|
534
536
|
|
|
535
537
|
:return: name of the IPA client package for current Linux
|
|
536
538
|
"""
|
|
537
|
-
|
|
538
|
-
if os_version not in (OSVersion.RHEL_9, OSVersion.CentOS_9):
|
|
539
|
+
if isDistro(['rhel', 'centos'], version='8'):
|
|
539
540
|
run("dnf module enable -y idm:DL1")
|
|
540
541
|
run("dnf install @idm:DL1 -y")
|
|
541
542
|
logger.debug("idm:DL1 module is installed")
|
|
542
543
|
|
|
543
|
-
if
|
|
544
|
+
if isDistro('fedora'):
|
|
544
545
|
return ["freeipa-client"]
|
|
545
546
|
else:
|
|
546
547
|
return ["ipa-client"]
|
SCAutolib/enums.py
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
from enum import Enum, auto
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
class OSVersion(Enum):
|
|
4
|
+
class OSVersion(int, Enum):
|
|
5
5
|
"""
|
|
6
6
|
Enumeration for Linux versions. Used for more convenient checks.
|
|
7
7
|
"""
|
|
8
8
|
Fedora = 1
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
RHEL_8 = 2
|
|
10
|
+
RHEL_9 = 3
|
|
11
|
+
RHEL_10 = 4
|
|
12
|
+
CentOS_8 = 5
|
|
13
|
+
CentOS_9 = 6
|
|
14
|
+
CentOS_10 = 7
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
class CardType(str, Enum):
|
SCAutolib/isDistro.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module provides a function (isDistro) that helps us identify the os
|
|
3
|
+
of the system and configure the system accordingly.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import distro
|
|
7
|
+
from typing import Union
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def isDistro(oses: Union[str, list], version: str = None) -> bool:
|
|
11
|
+
cur_id = distro.id().lower()
|
|
12
|
+
cur_name = distro.name().lower()
|
|
13
|
+
|
|
14
|
+
if isinstance(oses, str):
|
|
15
|
+
results = (oses in cur_id) or (oses in cur_name)
|
|
16
|
+
else:
|
|
17
|
+
results = False
|
|
18
|
+
for item in oses:
|
|
19
|
+
if not isinstance(item, str):
|
|
20
|
+
continue
|
|
21
|
+
item = item.lower()
|
|
22
|
+
results = results or (item in cur_id) or (item in cur_name)
|
|
23
|
+
|
|
24
|
+
if results is False:
|
|
25
|
+
return False
|
|
26
|
+
|
|
27
|
+
if version:
|
|
28
|
+
cur_major = int(distro.major_version())
|
|
29
|
+
cur_minor = int(distro.minor_version()) if distro.minor_version() else 0
|
|
30
|
+
|
|
31
|
+
if version[0] in ('<', '=', '>'):
|
|
32
|
+
if version[1] == '=':
|
|
33
|
+
op = version[:2]
|
|
34
|
+
version = version[2:]
|
|
35
|
+
else:
|
|
36
|
+
op = version[0] if version[0] != '=' else '=='
|
|
37
|
+
version = version[1:]
|
|
38
|
+
else:
|
|
39
|
+
op = '=='
|
|
40
|
+
|
|
41
|
+
parts = version.split('.')
|
|
42
|
+
major = int(parts[0])
|
|
43
|
+
minor = int(parts[1]) if len(parts) > 1 else None
|
|
44
|
+
|
|
45
|
+
if major == cur_major and minor:
|
|
46
|
+
return eval("{0} {1} {2}".format(cur_minor, op, minor))
|
|
47
|
+
else:
|
|
48
|
+
return eval("{0} {1} {2}".format(cur_major, op, major))
|
|
49
|
+
|
|
50
|
+
return True
|
SCAutolib/models/file.py
CHANGED
|
@@ -26,6 +26,7 @@ import json
|
|
|
26
26
|
|
|
27
27
|
from SCAutolib import logger, TEMPLATES_DIR, LIB_BACKUP, LIB_DUMP_CONFS, run
|
|
28
28
|
from SCAutolib.exceptions import SCAutolibException
|
|
29
|
+
from SCAutolib.isDistro import isDistro
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
class File:
|
|
@@ -277,7 +278,6 @@ class SSSDConf(File):
|
|
|
277
278
|
runtimes.
|
|
278
279
|
"""
|
|
279
280
|
__instance = None
|
|
280
|
-
_template = Path(TEMPLATES_DIR, "sssd.conf")
|
|
281
281
|
_conf_file = Path("/etc/sssd/sssd.conf")
|
|
282
282
|
_backup_original = None
|
|
283
283
|
_backup_default = LIB_BACKUP.joinpath('default-sssd.conf')
|
|
@@ -298,6 +298,12 @@ class SSSDConf(File):
|
|
|
298
298
|
return
|
|
299
299
|
self.__initialized = True
|
|
300
300
|
|
|
301
|
+
if isDistro(['rhel', 'centos'], version='<=9') \
|
|
302
|
+
or isDistro(['fedora'], version='<39'):
|
|
303
|
+
self._template = TEMPLATES_DIR.joinpath("sssd.conf-8or9")
|
|
304
|
+
else:
|
|
305
|
+
self._template = TEMPLATES_DIR.joinpath("sssd.conf-10")
|
|
306
|
+
|
|
301
307
|
# _default_parser object stores default content of config file
|
|
302
308
|
self._default_parser = ConfigParser()
|
|
303
309
|
# avoid problems with inserting some 'specific' values
|
SCAutolib/models/gui.py
CHANGED
|
@@ -12,8 +12,7 @@ import uinput
|
|
|
12
12
|
import logging
|
|
13
13
|
|
|
14
14
|
from SCAutolib import run, logger
|
|
15
|
-
from SCAutolib.
|
|
16
|
-
from SCAutolib.utils import _get_os_version
|
|
15
|
+
from SCAutolib.isDistro import isDistro
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
class HTMLFileHandler(logging.FileHandler):
|
|
@@ -487,8 +486,7 @@ class GUI:
|
|
|
487
486
|
else:
|
|
488
487
|
func_str = 'assert_no_text'
|
|
489
488
|
|
|
490
|
-
|
|
491
|
-
if os_version == OSVersion.Fedora:
|
|
489
|
+
if isDistro('fedora'):
|
|
492
490
|
check_str = 'tosearch'
|
|
493
491
|
else:
|
|
494
492
|
check_str = 'Activities'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[sssd]
|
|
2
|
+
debug_level = 9
|
|
3
|
+
services = nss, pam, ssh, sudo
|
|
4
|
+
domains = shadowutils
|
|
5
|
+
certificate_verification = no_ocsp
|
|
6
|
+
|
|
7
|
+
[nss]
|
|
8
|
+
debug_level = 9
|
|
9
|
+
|
|
10
|
+
[pam]
|
|
11
|
+
debug_level = 9
|
|
12
|
+
pam_cert_auth = True
|
|
13
|
+
|
|
14
|
+
[domain/shadowutils]
|
|
15
|
+
debug_level = 9
|
|
16
|
+
id_provider = proxy
|
|
17
|
+
proxy_lib_name = files
|
|
18
|
+
local_auth_policy = only
|
SCAutolib/utils.py
CHANGED
|
@@ -10,7 +10,6 @@ from pathlib import Path
|
|
|
10
10
|
|
|
11
11
|
from SCAutolib import (run, logger, TEMPLATES_DIR, LIB_DUMP_USERS, LIB_DUMP_CAS,
|
|
12
12
|
LIB_DUMP_CARDS)
|
|
13
|
-
from SCAutolib.enums import OSVersion
|
|
14
13
|
from SCAutolib.exceptions import SCAutolibException
|
|
15
14
|
from SCAutolib.models.CA import LocalCA, BaseCA, CustomCA, IPAServerCA
|
|
16
15
|
from SCAutolib.models.card import Card
|
|
@@ -58,28 +57,6 @@ def _gen_private_key(key_path: Path):
|
|
|
58
57
|
encryption_algorithm=serialization.NoEncryption()))
|
|
59
58
|
|
|
60
59
|
|
|
61
|
-
def _get_os_version():
|
|
62
|
-
"""
|
|
63
|
-
Find Linux version. Available version: RHEL 8, RHEL 9, Fedora.
|
|
64
|
-
:return: Enum with OS version
|
|
65
|
-
"""
|
|
66
|
-
with open('/etc/redhat-release', "r") as f:
|
|
67
|
-
cnt = f.read()
|
|
68
|
-
|
|
69
|
-
if "Red Hat Enterprise Linux release 9" in cnt:
|
|
70
|
-
return OSVersion.RHEL_9
|
|
71
|
-
elif "Red Hat Enterprise Linux release 8" in cnt:
|
|
72
|
-
return OSVersion.RHEL_8
|
|
73
|
-
elif "Fedora" in cnt:
|
|
74
|
-
return OSVersion.Fedora
|
|
75
|
-
elif "CentOS Stream release 8" in cnt:
|
|
76
|
-
return OSVersion.CentOS_8
|
|
77
|
-
elif "CentOS Stream release 9" in cnt:
|
|
78
|
-
return OSVersion.CentOS_9
|
|
79
|
-
else:
|
|
80
|
-
raise SCAutolibException("OS is not detected.")
|
|
81
|
-
|
|
82
|
-
|
|
83
60
|
def _install_packages(packages):
|
|
84
61
|
"""
|
|
85
62
|
Install given packages and log package version
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: SCAutolib
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.3.2
|
|
4
4
|
Summary: Python library for automation tests of smart cards using virtualization.
|
|
5
5
|
Home-page: https://github.com/redhat-qe-security/SCAutolib
|
|
6
6
|
Author: Pavel Yadlouski
|
|
@@ -25,6 +25,7 @@ Requires-Dist: pytest >=7
|
|
|
25
25
|
Requires-Dist: schema >=0.7
|
|
26
26
|
Requires-Dist: python-freeipa >=1.0
|
|
27
27
|
Requires-Dist: pexpect >=4
|
|
28
|
+
Requires-Dist: distro >=1.5.0
|
|
28
29
|
Provides-Extra: graphical
|
|
29
30
|
Requires-Dist: opencv-python ; extra == 'graphical'
|
|
30
31
|
Requires-Dist: pandas ; extra == 'graphical'
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
SCAutolib/__init__.py,sha256=nC78DtNE09z1s-LglB2K_-iquLONQAOfg2qbK_6ay9g,5490
|
|
2
2
|
SCAutolib/cli_commands.py,sha256=5G6JSGskB0igROUufRQ8xpKwoOv6tfzhWDo6o6nI-Ao,5888
|
|
3
|
-
SCAutolib/controller.py,sha256=
|
|
4
|
-
SCAutolib/enums.py,sha256=
|
|
3
|
+
SCAutolib/controller.py,sha256=HTkG_d9g9CuObBPjagyJSoES-Tero8PsvySAeWthy3k,23210
|
|
4
|
+
SCAutolib/enums.py,sha256=UviyFPIw6MPkJl-BwWd4eTtr47BRr_KMsDlHF-ErGcU,677
|
|
5
5
|
SCAutolib/exceptions.py,sha256=-Jsj80CXOSXQacCI46PYXEIh6-tdHSOw3FE4itE_e5w,857
|
|
6
|
-
SCAutolib/
|
|
6
|
+
SCAutolib/isDistro.py,sha256=vYSmjtIEEh0N-qF9c9xtTtvYSCRWi5yP2mlTQBvOgBk,1460
|
|
7
|
+
SCAutolib/utils.py,sha256=dArD7_gVa9WA8N4GlP4PwfOaK_mm_HkwA-Z7dxM7IGY,7326
|
|
7
8
|
SCAutolib/models/CA.py,sha256=vWXZNxUlula854MwcbVNSU1Eiy07bSH1dBr7Y2Zz20A,29633
|
|
8
9
|
SCAutolib/models/__init__.py,sha256=8NZySkDbAn2sktD1L3__Y37kY9kEXM2o4TnN3hiIsfk,48
|
|
9
10
|
SCAutolib/models/authselect.py,sha256=PqRcxB9RSAWmGSF1Z8u1YrE7OLrD9oj-sCzGJEAWHa8,3443
|
|
10
11
|
SCAutolib/models/card.py,sha256=QhGn5hbdZaaEuH9T1jZNNwKTopTApJfQcjP5iSKP5Kk,16149
|
|
11
|
-
SCAutolib/models/file.py,sha256=
|
|
12
|
-
SCAutolib/models/gui.py,sha256=
|
|
12
|
+
SCAutolib/models/file.py,sha256=MCAyiB8rd9CEHgcjTaVRJBbv2i5Ig7M3uTWcosiS5hc,23323
|
|
13
|
+
SCAutolib/models/gui.py,sha256=BIIHPXOiSDgBm3GIN8jFucQQHO-XeicGjVhECeTuEBk,16285
|
|
13
14
|
SCAutolib/models/log.py,sha256=6EoiehIIJjCXZqbT_X3eQyKWCS-_yZ5RdJcX5HVTJXI,1499
|
|
14
15
|
SCAutolib/models/user.py,sha256=VK4chlS7izTYiwmVuYjl_cknOe00FFbCbiQOfMOoZU4,6390
|
|
15
16
|
SCAutolib/templates/ca.cnf,sha256=9oqUZUSy_lEtNLDViD8SwgJl1ZKCI1-DMri1feF6vjQ,1047
|
|
16
17
|
SCAutolib/templates/gnome_disable_welcome,sha256=POtfU_SrgKGn4RmgLrFtg0K3MTetSFAmUo9HWidi5W0,60
|
|
17
18
|
SCAutolib/templates/softhsm2.conf,sha256=WAlZpRSLzssZ0-dnUZcz2pig9RGIJD0oQg_t5B1X3Fo,108
|
|
18
|
-
SCAutolib/templates/sssd.conf,sha256=
|
|
19
|
+
SCAutolib/templates/sssd.conf-10,sha256=qwgNOBTy7j9GKpXD9vDUPH5h1-qkDm8C8sGzGbUnq9U,284
|
|
20
|
+
SCAutolib/templates/sssd.conf-8or9,sha256=eBQJu9AY7LG4OsHRxinUjUeQOIxSu_MksWPKfqZswYo,236
|
|
19
21
|
SCAutolib/templates/user.cnf,sha256=pyyJhxFdOVlFqoVGVwjomOq-W4wEt3YWfRGZEXprwto,452
|
|
20
22
|
SCAutolib/templates/virt_cacard.service,sha256=31NrSKUspYIKNOVhL4Usc62CImlu3heNZprJ8sdw11Y,299
|
|
21
23
|
SCAutolib/templates/virtcacard.cil,sha256=TwxknjxnTtDK_KR3-MbKcLM0VrB76JVSlY-j84VaNZY,167
|
|
22
|
-
SCAutolib-3.
|
|
23
|
-
SCAutolib-3.
|
|
24
|
-
SCAutolib-3.
|
|
25
|
-
SCAutolib-3.
|
|
26
|
-
SCAutolib-3.
|
|
27
|
-
SCAutolib-3.
|
|
24
|
+
SCAutolib-3.3.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
25
|
+
SCAutolib-3.3.2.dist-info/METADATA,sha256=2_nuaZphJacyzbEkC6byGhWjtvp3n8pvTxUQi1A5GZo,2343
|
|
26
|
+
SCAutolib-3.3.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
27
|
+
SCAutolib-3.3.2.dist-info/entry_points.txt,sha256=SyEBTEHEsfYmYZ4L3mQ_RUkW_PRTEWurYgITxGkFLe4,54
|
|
28
|
+
SCAutolib-3.3.2.dist-info/top_level.txt,sha256=z2XZ0S23vykXV_dZYNlLcgcSERgBDIWxmNsiiQBL-wQ,10
|
|
29
|
+
SCAutolib-3.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|