Skip to contentSkip to conversation

policycoretuils: sestatus belongs to bin not sbin

PATCH Superseded bauen1 3 participants 6 messages Feb 13, 2021 – Feb 21, 2021 SELinux security module

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

bauen1

author
#0 lore raw

PATCH 1/1 policycoretuils: sestatus belongs to bin not sbin

It is quite useful even to non-privileged users and doesn't require any privileges to work, except for maybe -v.

---

Only tested by running make DESTDIR="$PWD" install and checking that sestatus ends up at /usr/bin/sestatus

 policycoreutils/sestatus/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
policycoreutils/sestatus/Makefile +3 -3
index 8c4f45f8..ac113814 100644
@@ -1,7 +1,7 @@
 # Installation directories.
 LINGUAS ?= ru
 PREFIX ?= /usr
-SBINDIR ?= $(PREFIX)/sbin
+BINDIR ?= $(PREFIX)/bin
 MANDIR = $(PREFIX)/share/man
 ETCDIR ?= /etc
 
@@ -16,8 +16,8 @@ sestatus: sestatus.o
 install: all
 	[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
 	[ -d $(DESTDIR)$(MANDIR)/man5 ] || mkdir -p $(DESTDIR)$(MANDIR)/man5
-	-mkdir -p $(DESTDIR)$(SBINDIR)
-	install -m 755 sestatus $(DESTDIR)$(SBINDIR)
+	-mkdir -p $(DESTDIR)$(BINDIR)
+	install -m 755 sestatus $(DESTDIR)$(BINDIR)
 	install -m 644 sestatus.8 $(DESTDIR)$(MANDIR)/man8
 	install -m 644 sestatus.conf.5 $(DESTDIR)$(MANDIR)/man5
 	for lang in $(LINGUAS) ; do \
Signature · 1 line
2.30.0
#1 lore raw
Quoted 5 lines · On Sat, Feb 13, 2021 at 9:44 PM bauen1 <[email protected]> wrote:

It is quite useful even to non-privileged users and doesn't require any privileges to work, except for maybe -v.

I agree with the reasoning, but changing the location of an existing
tool has the potential to break software which depends on the precise
location of sestatus (like
https://github.com/openstack/cookbook-openstack-dashboard/blob/86127240974041b456086b5fff6f8f525c9cf555/spec/spec_helper.rb#L82
and https://github.com/rapid7/metasploit-framework/blob/4a380771d3a18011af153e47e1d08a4a83feb452/lib/msf/core/post/linux/kernel.rb#L276
and https://github.com/RedHatInsights/insights-core/blob/6fd58aeab11232a62ea97ba576220abca808c660/insights/specs/default.py#L815
and ...).

On the other hand, if you have a clear use-case of non-privileged users refusing to add /usr/sbin to their $PATH but willing to use sestatus, and that supporting this use-case seems more important than not breaking programs which rely on sestatus being in /usr/sbin, this patch will be acceptable. Do you know of such a use-case?

(By the way, there is a misspelling in the patch subject: you wrote "policycoretuils" instead of "policycoreutils")

Thanks,
Nicolas

Quoted 35 lines

---

Only tested by running make DESTDIR="$PWD" install and checking that sestatus ends up at /usr/bin/sestatus

 policycoreutils/sestatus/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
policycoreutils/sestatus/Makefile +3 -4
index 8c4f45f8..ac113814 100644
@@ -1,7 +1,7 @@
 # Installation directories.
 LINGUAS ?= ru
 PREFIX ?= /usr
-SBINDIR ?= $(PREFIX)/sbin
+BINDIR ?= $(PREFIX)/bin
 MANDIR = $(PREFIX)/share/man
 ETCDIR ?= /etc
 
@@ -16,8 +16,8 @@ sestatus: sestatus.o
 install: all
        [ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
        [ -d $(DESTDIR)$(MANDIR)/man5 ] || mkdir -p $(DESTDIR)$(MANDIR)/man5
-       -mkdir -p $(DESTDIR)$(SBINDIR)
-       install -m 755 sestatus $(DESTDIR)$(SBINDIR)
+       -mkdir -p $(DESTDIR)$(BINDIR)
+       install -m 755 sestatus $(DESTDIR)$(BINDIR)
        install -m 644 sestatus.8 $(DESTDIR)$(MANDIR)/man8
        install -m 644 sestatus.conf.5 $(DESTDIR)$(MANDIR)/man5
        for lang in $(LINGUAS) ; do \
--

2.30.0

author
#2 lore raw
Quoted 7 lines · Nicolas Iooss
Quoted 5 lines · On Sat, Feb 13, 2021 at 9:44 PM bauen1 <[email protected]> wrote:

It is quite useful even to non-privileged users and doesn't require any privileges to work, except for maybe -v.

Quoted 7 lines

I agree with the reasoning, but changing the location of an existing
tool has the potential to break software which depends on the precise
location of sestatus (like
https://github.com/openstack/cookbook-openstack-dashboard/blob/86127240974041b456086b5fff6f8f525c9cf555/spec/spec_helper.rb#L82
and https://github.com/rapid7/metasploit-framework/blob/4a380771d3a18011af153e47e1d08a4a83feb452/lib/msf/core/post/linux/kernel.rb#L276
and https://github.com/RedHatInsights/insights-core/blob/6fd58aeab11232a62ea97ba576220abca808c660/insights/specs/default.py#L815
and ...).

While I personally believe those shouldn't have been hard-coded in the first place, that is a good argument. Would it be acceptable, if a symlink is added to /usr/sbin/sestatus to link to /usr/bin/sestatus (or the other way) ?

Quoted 5 lines

On the other hand, if you have a clear use-case of non-privileged users refusing to add /usr/sbin to their $PATH but willing to use sestatus, and that supporting this use-case seems more important than not breaking programs which rely on sestatus being in /usr/sbin, this patch will be acceptable. Do you know of such a use-case?

My use case is logging in as my normal user account and checking if SELinux is properly working.
I'm not sure _why_ I should have to add sbin to $PATH to access a tool that works properly for non-privileged users, not that I couldn't do that.

IIRC I did once (~2 years ago) have /sbin, /usr/sbin in $PATH, but then I end up with a lot of tools in tab-complete that I can't actually use (properly) and I don't like that.

Quoted 2 lines

(By the way, there is a misspelling in the patch subject: you wrote "policycoretuils" instead of "policycoreutils")

Thanks, I'll fix that if necessary.

Signature · 2 lines
bauen1
https://dn42.bauen1.xyz/
#3 lore raw
In reply to Nicolas Iooss
Quoted 15 lines · Nicolas Iooss
Quoted 5 lines · On Sat, Feb 13, 2021 at 9:44 PM bauen1 <[email protected]> wrote:

It is quite useful even to non-privileged users and doesn't require any privileges to work, except for maybe -v.

I agree with the reasoning, but changing the location of an existing
tool has the potential to break software which depends on the precise
location of sestatus (like
https://github.com/openstack/cookbook-openstack-dashboard/blob/86127240974041b456086b5fff6f8f525c9cf555/spec/spec_helper.rb#L82
and https://github.com/rapid7/metasploit-framework/blob/4a380771d3a18011af153e47e1d08a4a83feb452/lib/msf/core/post/linux/kernel.rb#L276
and https://github.com/RedHatInsights/insights-core/blob/6fd58aeab11232a62ea97ba576220abca808c660/insights/specs/default.py#L815
and ...).

Quoted 9 lines

On the other hand, if you have a clear use-case of non-privileged users refusing to add /usr/sbin to their $PATH but willing to use sestatus, and that supporting this use-case seems more important than not breaking programs which rely on sestatus being in /usr/sbin, this patch will be acceptable. Do you know of such a use-case?

(By the way, there is a misspelling in the patch subject: you wrote "policycoretuils" instead of "policycoreutils")

Could a symlink /usr/bin/sestatus -> ../sbin/sestatus solve this?

Quoted 38 lines

Thanks,
Nicolas

Quoted 35 lines

---

Only tested by running make DESTDIR="$PWD" install and checking that sestatus ends up at /usr/bin/sestatus

 policycoreutils/sestatus/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
policycoreutils/sestatus/Makefile +3 -4
index 8c4f45f8..ac113814 100644
@@ -1,7 +1,7 @@
 # Installation directories.
 LINGUAS ?= ru
 PREFIX ?= /usr
-SBINDIR ?= $(PREFIX)/sbin
+BINDIR ?= $(PREFIX)/bin
 MANDIR = $(PREFIX)/share/man
 ETCDIR ?= /etc
 
@@ -16,8 +16,8 @@ sestatus: sestatus.o
 install: all
        [ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
        [ -d $(DESTDIR)$(MANDIR)/man5 ] || mkdir -p $(DESTDIR)$(MANDIR)/man5
-       -mkdir -p $(DESTDIR)$(SBINDIR)
-       install -m 755 sestatus $(DESTDIR)$(SBINDIR)
+       -mkdir -p $(DESTDIR)$(BINDIR)
+       install -m 755 sestatus $(DESTDIR)$(BINDIR)
        install -m 644 sestatus.8 $(DESTDIR)$(MANDIR)/man8
        install -m 644 sestatus.conf.5 $(DESTDIR)$(MANDIR)/man5
        for lang in $(LINGUAS) ; do \
--

2.30.0

author
#4 lore raw

PATCH v2 1/1 policycoreutils: sestatus belongs to bin not sbin

In reply to Nicolas Iooss

It is quite useful even to non-privileged users and doesn't require any privileges to work, except for maybe -v.

Some tools hard code the old path, so a compatibility symlink is also created.

---
 policycoreutils/sestatus/Makefile | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
policycoreutils/sestatus/Makefile +7 -1
index 8c4f45f8..e108f96f 100644
@@ -1,6 +1,7 @@
 # Installation directories.
 LINGUAS ?= ru
 PREFIX ?= /usr
+BINDIR ?= $(PREFIX)/bin
 SBINDIR ?= $(PREFIX)/sbin
 MANDIR = $(PREFIX)/share/man
 ETCDIR ?= /etc
@@ -16,8 +17,13 @@ sestatus: sestatus.o
 install: all
 	[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
 	[ -d $(DESTDIR)$(MANDIR)/man5 ] || mkdir -p $(DESTDIR)$(MANDIR)/man5
+	-mkdir -p $(DESTDIR)$(BINDIR)
 	-mkdir -p $(DESTDIR)$(SBINDIR)
-	install -m 755 sestatus $(DESTDIR)$(SBINDIR)
+	# Some tools hardcode /usr/sbin/sestatus ; add a compatibility symlink
+	# install will overwrite a symlink, so create the symlink before calling
+	# install to allow distributions with BINDIR == SBINDIR
+	ln -s ../bin/sestatus $(DESTDIR)$(SBINDIR)
+	install -m 755 sestatus $(DESTDIR)$(BINDIR)
 	install -m 644 sestatus.8 $(DESTDIR)$(MANDIR)/man8
 	install -m 644 sestatus.conf.5 $(DESTDIR)$(MANDIR)/man5
 	for lang in $(LINGUAS) ; do \
Signature · 1 line
2.30.1
#5 lore raw

Re: [PATCH v2] policycoreutils: sestatus belongs to bin not sbin

Quoted 25 lines · On Thu, Feb 18, 2021 at 7:33 PM bauen1 <[email protected]> wrote:

It is quite useful even to non-privileged users and doesn't require any privileges to work, except for maybe -v.

Some tools hard code the old path, so a compatibility symlink is also created.

---
 policycoreutils/sestatus/Makefile | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
policycoreutils/sestatus/Makefile +1 -0
index 8c4f45f8..e108f96f 100644
@@ -1,6 +1,7 @@
 # Installation directories.
 LINGUAS ?= ru
 PREFIX ?= /usr
+BINDIR ?= $(PREFIX)/bin
 SBINDIR ?= $(PREFIX)/sbin
 MANDIR = $(PREFIX)/share/man
 ETCDIR ?= /etc

policycoreutils/sestatus/Makefile sestatus: sestatus.o · line 25

Quoted 10 lines
policycoreutils/sestatus/Makefile +5 -1
@@ -16,8 +17,13 @@ sestatus: sestatus.o
 install: all
        [ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
        [ -d $(DESTDIR)$(MANDIR)/man5 ] || mkdir -p $(DESTDIR)$(MANDIR)/man5
+       -mkdir -p $(DESTDIR)$(BINDIR)
        -mkdir -p $(DESTDIR)$(SBINDIR)
-       install -m 755 sestatus $(DESTDIR)$(SBINDIR)
+       # Some tools hardcode /usr/sbin/sestatus ; add a compatibility symlink
+       # install will overwrite a symlink, so create the symlink before calling
+       # install to allow distributions with BINDIR == SBINDIR
+       ln -s ../bin/sestatus $(DESTDIR)$(SBINDIR)

This assumes that $(BINDIR) == $(SBINDIR)/../bin, which is likely to be true but which would break if not. Moreover, not using "-f" breaks running "make install" twice:

ln -s ../bin/sestatus /my-DESTDIR/usr/sbin
ln: failed to create symbolic link '/my-DESTDIR/usr/sbin/sestatus': File exists

To fix both these issues, you can add --relative and -f like other Makefiles in the project:

ln -sf --relative $(DESTDIR)$(BINDIR)/sestatus $(DESTDIR)$(SBINDIR)

Doing this seems to work fine on my test system. Could you please send a v3 with this?

By the way I confirm that this v2 addresses the previous comments I made on the first version of this patch, thanks!
Nicolas