Skip to content

systemctl location#1278

Merged
TheRealFalcon merged 4 commits into
canonical:mainfrom
rjschwei:sysctlLoc
Mar 1, 2022
Merged

systemctl location#1278
TheRealFalcon merged 4 commits into
canonical:mainfrom
rjschwei:sysctlLoc

Conversation

@rjschwei
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

@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.

4 participants