xsos
xsos copied to clipboard
Hide RHN,yum in main output when Ubuntu/Debian is detected
I tried to code this so I don't think it will break when used for RHEL, but it seems like there a lot of corner cases.
Figured getting an ack that this is a good direction before doing extensive testing. Thanks!
Sorry for the delay. Yes this is a good direction.
If you don't want to source os-release
then you could grep it. Quick pseudocode sketch to give the idea:
[[ -r "$1/etc/os-release" ]] &&
if [[ egrep "ID=\"?(rhel|fedora|centos)" ]]; then
packaging=rpm
elif [[ egrep "ID=\"?(ubuntu|debian)" ]]; then
packaging=deb
fi
I'd worry more about variables colliding than /etc
being used as an attack vector, but perhaps I am not sufficiently paranoid ;)
Oh, "# I don't like blindly sourcing a file -- that provides a vector to screw with this script..." was already present. I don't mind it, nor do I think it's super likely to mess things up.
We've been using my branch internally at Canonical for Ubuntu as part of ScoutPlane tool for months so the basics still work great.
My biggest worry is that I could have broken some RH/N specific bits that I can't test.
Looking at this again, I think the order which xsos determines and displays OS release is wrong now.
It was originally written a long time ago to think of RHEL first, but these days Ubuntu should also be a first-class citizen. We could handle other distros which carry recent sosreport packages like AlmaLinux, Debian, Fedora, Mageia.
I'm inclined to close this PR and re-order/rewrite _CHECK_DISTRO
to be more distro-agnostic, so still implement the idea of this PR plus end up with an even better result. I will have a think.