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

systemctl location #1278

Merged
merged 4 commits into from Mar 1, 2022
Merged

systemctl location #1278

merged 4 commits into from Mar 1, 2022

Conversation

rjschwei
Copy link
Contributor

Proposed Commit Message

It is reasonable to expect that "systemctl" is found in one of the locations in the PATH

  • Using the '/bin' prefix is very distribution specific. A number of
    distributions are moving all executables from '/' to '/usr'.
systemctl may bot be in `/bin`

Additional Context

Test Steps

cloud-init on a distribution where systmctl is in /usr/bin produces an error
Command: ['/bin/systemctl', 'show', '-p', 'UserspaceTimestampMonotonic']
[ 37.366919] cloud-init[882]: Exit code: -
[ 37.369468] cloud-init[882]: Reason: [Errno 2] No such file or directory:

Checklist:

  • [ x] My code follows the process laid out in the documentation
  • [x ] I have updated or added any unit tests accordingly
  • I have updated or added any documentation accordingly

…cations

in the PATH
  + Using the '/bin' prefix is very distribution specific. A number of
    distributions are moving all executables from '/' to '/usr'.
@Conan-Kudo
Copy link
Contributor

Is anyone actually doing this in a way where /bin isn't a symlink to /usr/bin? Fedora, openSUSE, and Ubuntu all have a persistent symlink for this...

@rjschwei
Copy link
Contributor Author

Is anyone actually doing this in a way where /bin isn't a symlink to /usr/bin? Fedora, openSUSE, and Ubuntu all have a persistent symlink for this...

See the error message posted, I really don't make this stuff up.

In any event it is reasonable to assume that systemctl will be on the path and if we don't want to make that assumption then we should be using subp.which() everywhere rather than assuming the executable lives in /bin or there exists a symlink

Copy link
Collaborator

@smoser smoser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the intent. hard coded paths are nonsense.

Copy link
Member

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@TheRealFalcon TheRealFalcon merged commit 3642ed7 into canonical:main Mar 1, 2022
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.

None yet

4 participants