Message ID | 20230805070650.197744-1-wanghuizhao1@huawei.com (mailing list archive) |
---|---|
State | Accepted |
Commit | ca76a8813e9a |
Delegated to: | Petr Lautrbach |
Headers | show |
Series | restorecond: compatible with the use of EUID | expand |
Huizhao Wang <wanghuizhao1@huawei.com> writes: > The `EUID` does not exist in some shell environments. To ensure compatibility, > use `id -u` instead of `EUID` when `EUID` does not exist. > > Signed-off-by: Huizhao Wang <wanghuizhao1@huawei.com> Acked-by: Petr Lautrbach <lautrbach@redhat.com> > --- > restorecond/restorecond.init | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/restorecond/restorecond.init b/restorecond/restorecond.init > index c1cbb247..4e71a2c6 100644 > --- a/restorecond/restorecond.init > +++ b/restorecond/restorecond.init > @@ -29,7 +29,11 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin > [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || exit 7 > > # Check that we are root ... so non-root users stop here > -test $EUID = 0 || exit 4 > +if [ $EUID ]; then > + test $EUID = 0 || exit 4 > +else > + test `id -u` = 0 || exit 4 > +fi > > test -x /usr/sbin/restorecond || exit 5 > test -f /etc/selinux/restorecond.conf || exit 6 > -- > 2.12.3
On Tue, Oct 31, 2023 at 1:04 PM Petr Lautrbach <lautrbach@redhat.com> wrote: > > Huizhao Wang <wanghuizhao1@huawei.com> writes: > > > The `EUID` does not exist in some shell environments. To ensure compatibility, > > use `id -u` instead of `EUID` when `EUID` does not exist. > > > > Signed-off-by: Huizhao Wang <wanghuizhao1@huawei.com> > > Acked-by: Petr Lautrbach <lautrbach@redhat.com> > Merged. Thanks, Jim > > --- > > restorecond/restorecond.init | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/restorecond/restorecond.init b/restorecond/restorecond.init > > index c1cbb247..4e71a2c6 100644 > > --- a/restorecond/restorecond.init > > +++ b/restorecond/restorecond.init > > @@ -29,7 +29,11 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin > > [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || exit 7 > > > > # Check that we are root ... so non-root users stop here > > -test $EUID = 0 || exit 4 > > +if [ $EUID ]; then > > + test $EUID = 0 || exit 4 > > +else > > + test `id -u` = 0 || exit 4 > > +fi > > > > test -x /usr/sbin/restorecond || exit 5 > > test -f /etc/selinux/restorecond.conf || exit 6 > > -- > > 2.12.3 >
diff --git a/restorecond/restorecond.init b/restorecond/restorecond.init index c1cbb247..4e71a2c6 100644 --- a/restorecond/restorecond.init +++ b/restorecond/restorecond.init @@ -29,7 +29,11 @@ PATH=/sbin:/bin:/usr/bin:/usr/sbin [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || exit 7 # Check that we are root ... so non-root users stop here -test $EUID = 0 || exit 4 +if [ $EUID ]; then + test $EUID = 0 || exit 4 +else + test `id -u` = 0 || exit 4 +fi test -x /usr/sbin/restorecond || exit 5 test -f /etc/selinux/restorecond.conf || exit 6
The `EUID` does not exist in some shell environments. To ensure compatibility, use `id -u` instead of `EUID` when `EUID` does not exist. Signed-off-by: Huizhao Wang <wanghuizhao1@huawei.com> --- restorecond/restorecond.init | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)