SCAutolib 3.2.2__py3-none-any.whl → 3.3.3__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 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 (OSVersion, CardType, UserType)
15
+ from SCAutolib.enums import (CardType, UserType)
16
16
  from SCAutolib.utils import (_check_selinux, _gen_private_key,
17
- _get_os_version, _install_packages,
18
- _check_packages, dump_to_json, ca_factory)
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,13 +159,21 @@ 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
- run("dnf -y copr enable jjelen/vsmartcard")
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
165
170
  for u in self.lib_conf["users"]]):
166
171
  packages += self._general_steps_for_ipa()
167
172
 
173
+ # In RHEL-10 we need one extra policy for the pcsc-lite to work
174
+ if isDistro(['rhel', 'centos'], version='10'):
175
+ packages += ["sssd-polkit-rules"]
176
+
168
177
  # Check for installed packages
169
178
  missing = _check_packages(packages)
170
179
  if install_missing and missing:
@@ -175,13 +184,15 @@ class Controller:
175
184
  logger.critical(msg)
176
185
  raise exceptions.SCAutolibException(msg)
177
186
 
178
- os_version = _get_os_version()
179
187
  if graphical:
180
- if os_version != OSVersion.Fedora:
188
+ if not isDistro('fedora'):
181
189
  run(['dnf', 'groupinstall', 'Server with GUI', '-y',
182
190
  '--allowerasing'])
191
+ run(['pip', 'install', 'python-uinput'])
183
192
  else:
184
- run(['dnf', 'install', 'gdm', '-y'])
193
+ # Fedora doesn't have server with GUI group so installed gdm
194
+ # manually and also python3-uinput should be installed from RPM
195
+ run(['dnf', 'install', 'gdm', 'python3-uinput', '-y'])
185
196
  # disable subscription message
186
197
  run(['systemctl', '--global', 'mask',
187
198
  'org.gnome.SettingsDaemon.Subscription.target'])
@@ -190,12 +201,14 @@ class Controller:
190
201
  self.dconf_file.save()
191
202
  run('dconf update')
192
203
 
193
- if os_version != OSVersion.Fedora:
204
+ if not isDistro('fedora'):
194
205
  run(['dnf', 'groupinstall', "Smart Card Support", '-y',
195
206
  '--allowerasing'])
196
207
  logger.debug("Smart Card Support group in installed.")
197
208
  else:
198
- run(['dnf', 'install', 'opensc', 'pcsc-lite-ccid', '-y'])
209
+ # Fedora requires rsyslog as well
210
+ run(['dnf', 'install', 'opensc', 'pcsc-lite-ccid', 'rsyslog', '-y'])
211
+ run(['systemctl', 'start', 'rsyslog'])
199
212
 
200
213
  self.sssd_conf.create()
201
214
  self.sssd_conf.save()
@@ -207,13 +220,6 @@ class Controller:
207
220
  dump_to_json(user.User(username="root",
208
221
  password=self.lib_conf["root_passwd"]))
209
222
 
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
223
  def setup_local_ca(self, force: bool = False):
218
224
  """
219
225
  Setup local CA based on configuration from the configuration file. All
@@ -534,13 +540,12 @@ class Controller:
534
540
 
535
541
  :return: name of the IPA client package for current Linux
536
542
  """
537
- os_version = _get_os_version()
538
- if os_version not in (OSVersion.RHEL_9, OSVersion.CentOS_9):
543
+ if isDistro(['rhel', 'centos'], version='8'):
539
544
  run("dnf module enable -y idm:DL1")
540
545
  run("dnf install @idm:DL1 -y")
541
546
  logger.debug("idm:DL1 module is installed")
542
547
 
543
- if os_version == OSVersion.Fedora:
548
+ if isDistro('fedora'):
544
549
  return ["freeipa-client"]
545
550
  else:
546
551
  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
- RHEL_9 = 2
10
- RHEL_8 = 3
11
- CentOS_8 = 4
12
- CentOS_9 = 5
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.enums import OSVersion
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
- os_version = _get_os_version()
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.2.2
3
+ Version: 3.3.3
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=x7BEg-FQKNmGKrj6Xu_JqGvY1QScicWEr5Kq00lrZDk,23059
4
- SCAutolib/enums.py,sha256=3t3N2RRjZeZW2EMhNf1kk5S-FgarabBEo1qLlf6uIzE,638
3
+ SCAutolib/controller.py,sha256=-SvoDp3qWRfpdoZmRl9MpKUvv1h4cwRKGAQLFxnoB2M,23384
4
+ SCAutolib/enums.py,sha256=UviyFPIw6MPkJl-BwWd4eTtr47BRr_KMsDlHF-ErGcU,677
5
5
  SCAutolib/exceptions.py,sha256=-Jsj80CXOSXQacCI46PYXEIh6-tdHSOw3FE4itE_e5w,857
6
- SCAutolib/utils.py,sha256=4BdttTsNzZtletfeoIuIERrdd5BNiJGlcHa1mOFIuSY,8026
6
+ SCAutolib/isDistro.py,sha256=nAbxa9q0LIWmxmwlZeKXd22M3s9_E6FbD9G5j5coLsY,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=Rx8QawyXxpqulPGm1l9RKxE1o6cuTrYvZMw0EUR6aYY,23066
12
- SCAutolib/models/gui.py,sha256=v_OHpcnqy8mp03eVzGstlOu2vuzZv-fk2jwJMg_ewEo,16378
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=eBQJu9AY7LG4OsHRxinUjUeQOIxSu_MksWPKfqZswYo,236
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.2.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
23
- SCAutolib-3.2.2.dist-info/METADATA,sha256=4LiG0ITAAPI_0Uvbz-Em6OMm1f6brnA2tDXlMRFFAZM,2313
24
- SCAutolib-3.2.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
25
- SCAutolib-3.2.2.dist-info/entry_points.txt,sha256=SyEBTEHEsfYmYZ4L3mQ_RUkW_PRTEWurYgITxGkFLe4,54
26
- SCAutolib-3.2.2.dist-info/top_level.txt,sha256=z2XZ0S23vykXV_dZYNlLcgcSERgBDIWxmNsiiQBL-wQ,10
27
- SCAutolib-3.2.2.dist-info/RECORD,,
24
+ SCAutolib-3.3.3.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
25
+ SCAutolib-3.3.3.dist-info/METADATA,sha256=AnDOB83TI5EVhRjsOCS_cEGmVVoDXOjM6z-8_ZKE56s,2343
26
+ SCAutolib-3.3.3.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
27
+ SCAutolib-3.3.3.dist-info/entry_points.txt,sha256=SyEBTEHEsfYmYZ4L3mQ_RUkW_PRTEWurYgITxGkFLe4,54
28
+ SCAutolib-3.3.3.dist-info/top_level.txt,sha256=z2XZ0S23vykXV_dZYNlLcgcSERgBDIWxmNsiiQBL-wQ,10
29
+ SCAutolib-3.3.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (71.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
File without changes