Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • kali-tweaks kali-tweaks
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 12
    • Issues 12
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Kali LinuxKali Linux
  • PackagesPackages
  • kali-tweakskali-tweaks
  • Issues
  • #36
Closed
Open
Issue created Oct 27, 2022 by Arnaud Rebillout@arnaudrOwner

Handle gracefully settings that are not functional

Background

As reported in https://bugs.kali.org/view.php?id=8024, kali-tweaks crashed because of a regression in samba, and more precisely the testparms command.

#################################################################################
$ kali-tweaks # followed by selecting Hardening
Traceback (most recent call last):
  File "/usr/bin/kali-tweaks", line 33, in <module>
    sys.exit(load_entry_point('kali-tweaks==2022.4.0', 'console_scripts', 'kali-tweaks')())
  File "/usr/lib/python3/dist-packages/kali_tweaks/__main__.py", line 1108, in main
    do_main_screen()
  File "/usr/lib/python3/dist-packages/kali_tweaks/__main__.py", line 1099, in do_main_screen
    ret = func()
  File "/usr/lib/python3/dist-packages/kali_tweaks/__main__.py", line 870, in do_hardening_screen
    config = SambaSetting().load()
  File "/usr/lib/python3/dist-packages/kali_tweaks/settings/samba.py", line 24, in load
    value = self.get_client_min_protocol()
  File "/usr/lib/python3/dist-packages/kali_tweaks/settings/samba.py", line 45, in get_client_min_protocol
    res = run(cmd)
  File "/usr/lib/python3/dist-packages/kali_tweaks/utils.py", line 121, in run
    return _run(cmd, **kwargs)
  File "/usr/lib/python3/dist-packages/kali_tweaks/utils.py", line 112, in _run
    res = subprocess.run(cmd, capture_output=(not interactive), shell=True, text=True)
  File "/usr/lib/python3.10/subprocess.py", line 503, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "/usr/lib/python3.10/subprocess.py", line 1152, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "/usr/lib/python3.10/subprocess.py", line 2045, in _communicate
    stderr = self._translate_newlines(stderr,
  File "/usr/lib/python3.10/subprocess.py", line 1029, in _translate_newlines
    data = data.decode(encoding, errors)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd6 in position 28: invalid continuation byte
#################################################################################
$ testparm /etc/samba/smb.conf --suppress-prompt
Load smb config files from �R/�U
Error loading services.
#################################################################################

The problem is that testparms got broken by an update of one of its dependencies, libpopt. In turns, it breaks kali-tweaks in a surprising way: testparms outputs garbage on the terminal, and it's invalid UTF-8.

What should kali-tweaks do about that? I don't think that handling this particular error will get us anywhere. But I think that handling unexpected errors in general, and per setting, and disabling a setting that fails, would be a useful improvement. Kali-tweaks could just grey out the setting, output some error message on the terminal (to help users report the issue), and keep going. I prefer kali-tweaks to be functional and missing a setting, rather than crashing miserably.

Way forward

I don't think the code, in its current state, is ready for this improvement. It supposes that every setting is well isolated, and that we can add code that handles unexpected errors in one place. In the current state of thing, I'm afraid I would have to copy/paste this code for every setting.

So, let's keep that in mind, and as kali-tweaks internals mature and improve, finally we'll get there.

Assignee
Assign to
Time tracking