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

[system] List env_var names #3794

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pafernanr
Copy link
Contributor

This code gets the environment Names (without values) and saves them to environment_varnames.

Inspired by: #3792
Resolves: #3792

Signed-off-by: Pablo Fernández Rodríguez [email protected]

Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines

  • [ x] Is the commit message split over multiple lines and hard-wrapped at 72 characters?
  • [ x] Is the subject and message clear and concise?
  • [ x] Does the subject start with [plugin_name] if submitting a plugin patch or a [section_name] if part of the core sosreport code?
  • [ x] Does the commit contain a Signed-off-by: First Lastname [email protected]?
  • [x ] Are any related Issues or existing PRs properly referenced via a Closes (Issue) or Resolved (PR) line?
  • [ x] Are all passwords or private data gathered by this PR obfuscated?

Signed-off-by: Pablo Fernández Rodríguez <[email protected]>
Copy link

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/sosreport-sos-3794
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

@TurboTurtle
Copy link
Member

Should this instead go into the top-level environment file? We'd have to pull it out of plugin code (easy enough to add it to the report-level env var collection method), but it feels odd having a schism between "the environment file has env vars in it, and sos_commands/system/environment_varnames has just the names, including those already in environment".

@pafernanr
Copy link
Contributor Author

That makes much sense, It can be very confusing to put the environment_vars in two different places. The logic can be easily moved to collect_env_vars and could be something similar to:

    def collect_env_vars(self):
        env = ""
        var_names = list(os.environ.keys())
        var_names.sort()
        for name in var_names:
            if self.env_vars and name in self.env_vars:
                env += f"{name}={os.environ.get(name)}\n"
            else:   
                env += f"{name}=ValueNotCollected\n"
        self.archive.add_string(env, 'environment')
  • I think the point is: How to format the output and make it comprehensible; IMO it should let us know which values are "collected" or "not collected", and also show if collected values are "None". Example output:
BASH_FUNC_which%%=ValueNotCollected
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus
HISTCONTROL=ValueNotCollected
HISTSIZE=ValueNotCollected
...
HTTP_PROXY=
CUSTOM_EMPTY_VAR=ValueNotCollected
...

** Note that HTTP_PROXY is a "collected empty var" while CUSTOM_EMPTY_VAR is a "uncollected empty var".

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