Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Extend diagnostic information's #1318

Merged
merged 1 commit into from
Oct 6, 2022
Merged

feat: Extend diagnostic information's #1318

merged 1 commit into from
Oct 6, 2022

Conversation

buhtz
Copy link
Member

@buhtz buhtz commented Oct 3, 2022

Extend diagnostic information's

  1. Python executable path.
  2. Rsync environment variables.
  3. Modified username replacement to replace users homepath and not only its username.
  4. PEP8 etc

About 1: Related to #1316 where the path to systems python interpreter was "hacked" via "pyenv". This info will catch situations like that.

About 2: Related to #1247. Rsync 3.2.4 do use a different way of argument protection. The situation is complex and the environment variables RSYNC_OLD_ARGS and RSYNC_PROTECT_ARGS to influence that.

About 3: The replacement is done on the whole JSON-like string and not on specific elements. To prevent replacement of technical informations (e.g. about "rsync") when a user do use a technical login name (e.g. "rsync") now we search for the users homepath and not only is username.

About 4: Replaced use of os.path with high-level API pathlib.Path. Also reduced "cyclomatic complexity" (was 15) of get_diagnostics() with moving one code part into its own private method.

The output no looks like this

    "backintime": {
        "name": "Back In Time",
        "version": "1.3.2",
        "latest-config-version": 6,
        "local-config-file": "/home/UsernameReplaced/.config/backintime/config",
        "local-config-file-found": true,
        "global-config-file": "/etc/backintime/config",
        "global-config-file-found": false,
        "distribution-package": "/home/UsernameReplaced/ownCloud/my.work/bit/backintime",
        "started-from": "/home/UsernameReplaced/ownCloud/my.work/bit/backintime/common",
        "running-as-root": false,
        "user-callback": "/home/UsernameReplaced/.config/backintime/user-callback",
        "git-branch": "improve_diagnostics",
        "git-hash": "eb59d0aedf9b383a0fef646928490701641aeaa8"
    },
    "host-setup": {
        "platform": "Linux-5.10.0-18-amd64-x86_64-with-glibc2.31",
        "system": "Linux #1 SMP Debian 5.10.140-1 (2022-09-02)",
        "os-release": "Debian GNU/Linux 11 (bullseye)",
        "display-system": "tty",
        "locale": "de_DE, UTF-8",
        "PATH": "/home/UsernameReplaced/.local/bin:/home/UsernameReplaced/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games",
        "RSYNC_OLD_ARGS": "(not set)",
        "RSYNC_PROTECT_ARGS": "(not set)"
    },
    "python-setup": {
        "python": "3.9.2 default Feb 28 2021 17:03:44 CPython GCC 10.2.1 20210110",
        "python-executable": "/usr/bin/python3",
        "python-executable-symlink": true,
        "python-executable-resolved": "/usr/bin/python3.9",
        "sys.path": [
            "/home/UsernameReplaced/ownCloud/my.work/bit/backintime/qt/plugins",
            "/home/UsernameReplaced/ownCloud/my.work/bit/backintime/common/plugins",
            "/home/UsernameReplaced/ownCloud/my.work/bit/backintime/plugins",
            "/home/UsernameReplaced/ownCloud/my.work/bit/backintime/common",
            "/usr/lib/python39.zip",
            "/usr/lib/python3.9",
            "/usr/lib/python3.9/lib-dynload",
            "/usr/local/lib/python3.9/dist-packages",
            "/usr/lib/python3/dist-packages",
            "/usr/lib/python3.9/dist-packages"
        ],
        "qt": "PyQt 5.15.2 / Qt 5.15.2"
    },
    "external-programs": {
        "rsync": "3.2.3",
        "ssh": "OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n  15 Mar 2022",
        "sshfs": "3.7.1",
        "encfs": "1.9.5",
        "shell": "/bin/bash",
        "shell-version": "GNU bash, Version 5.1.4(1)-release (x86_64-pc-linux-gnu)"
    }
}

1. Python executable path.
2. Rsync environment variables.
3. Modified username replacement to replace users homepath and not only
   its username.

About 1: Related to #1316 where the path to systems python interpreter
was "hacked" via "pyenv". This info will catch situations like that.

About 2: Related to #1247. Rsync 3.2.4 do use a different way of
argument protection. The situation is complex and the environment
variables RSYNC_OLD_ARGS and RSYNC_PROTECT_ARGS to influence that.

About 3: The replacement is done on the whole JSON-like string and not
on specific elements. To prevent replacement of technical informations
(e.g. about "rsync") when a user do use a technical login name (e.g.
"rsync") now we search for the users homepath and not only is username.
@aryoda
Copy link
Contributor

aryoda commented Oct 3, 2022

Thanks for implementing it tout de suite!

This way we can see now if the distro python was bypassed...

@emtiu emtiu merged commit 964dc11 into bit-team:master Oct 6, 2022
@buhtz buhtz deleted the improve_diagnostics branch October 7, 2022 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants