Message ID | 20190321020218.5154-9-tytso@mit.edu |
---|---|
State | Accepted, archived |
Headers | show |
Series | [1/9] e2scrub: check to make sure lvm2 is installed | expand |
On Wed, Mar 20, 2019 at 10:02:18PM -0400, Theodore Ts'o wrote: > Signed-off-by: Theodore Ts'o <tytso@mit.edu> Oops, yeah, I forgot this. :/ Looks ok, Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> --D > --- > scrub/e2scrub.in | 5 +++++ > scrub/e2scrub_all.in | 5 +++++ > 2 files changed, 10 insertions(+) > > diff --git a/scrub/e2scrub.in b/scrub/e2scrub.in > index 301574968..666d6485a 100644 > --- a/scrub/e2scrub.in > +++ b/scrub/e2scrub.in > @@ -25,6 +25,11 @@ > > PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin > > +if (( $EUID != 0 )); then > + echo "e2scrub must be run as root" > + exit 1 > +fi > + > snap_size_mb=256 > fstrim=0 > reap=0 > diff --git a/scrub/e2scrub_all.in b/scrub/e2scrub_all.in > index cad232987..a02ffe226 100644 > --- a/scrub/e2scrub_all.in > +++ b/scrub/e2scrub_all.in > @@ -20,6 +20,11 @@ > > PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin > > +if (( $EUID != 0 )); then > + echo "e2scrub_all must be run as root" > + exit 1 > +fi > + > scrub_all=0 > snap_size_mb=256 > reap=0 > -- > 2.19.1 >
On Wed, Mar 20, 2019 at 10:02:18PM -0400, Theodore Ts'o wrote: > Signed-off-by: Theodore Ts'o <tytso@mit.edu> > --- > scrub/e2scrub.in | 5 +++++ > scrub/e2scrub_all.in | 5 +++++ > 2 files changed, 10 insertions(+) > > diff --git a/scrub/e2scrub.in b/scrub/e2scrub.in > index 301574968..666d6485a 100644 > --- a/scrub/e2scrub.in > +++ b/scrub/e2scrub.in > @@ -25,6 +25,11 @@ > > PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin > > +if (( $EUID != 0 )); then EUID is bashism and might not be available in a different shell. But I am sure we're using a lot of those and we have "#!/bin/bash". It's just somehting to consider, because I am not sure if we say anywhere that those scripts will require bash. Personally I do not care too much, but I am using bash exclusively :) -Lukas > + echo "e2scrub must be run as root" > + exit 1 > +fi > + > snap_size_mb=256 > fstrim=0 > reap=0 > diff --git a/scrub/e2scrub_all.in b/scrub/e2scrub_all.in > index cad232987..a02ffe226 100644 > --- a/scrub/e2scrub_all.in > +++ b/scrub/e2scrub_all.in > @@ -20,6 +20,11 @@ > > PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin > > +if (( $EUID != 0 )); then > + echo "e2scrub_all must be run as root" > + exit 1 > +fi > + > scrub_all=0 > snap_size_mb=256 > reap=0 > -- > 2.19.1 >
On Thu, Mar 21, 2019 at 12:36:38PM +0100, Lukas Czerner wrote: > > EUID is bashism and might not be available in a different shell. But I > am sure we're using a lot of those and we have "#!/bin/bash". > > It's just somehting to consider, because I am not sure if we say > anywhere that those scripts will require bash. Personally I do not care > too much, but I am using bash exclusively :) Bash is considered "essential" by Debian so it's guaranteed to be installed. So I haven't really considered it high priority to try to make it work on dash or pdksh or mksh or some other nitpicky POSIX.2 shell. I assume that the right place to state this is in the RPM spec file (it isn't not needed for debian/control since bash is an essential package). Shrug; I'd accept clean patches that allowed the use of a strict POSIX.2-only shell, especially if there were distributions who cared about this. But I find it hard to get excited about it, personally. :-) - Ted
diff --git a/scrub/e2scrub.in b/scrub/e2scrub.in index 301574968..666d6485a 100644 --- a/scrub/e2scrub.in +++ b/scrub/e2scrub.in @@ -25,6 +25,11 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +if (( $EUID != 0 )); then + echo "e2scrub must be run as root" + exit 1 +fi + snap_size_mb=256 fstrim=0 reap=0 diff --git a/scrub/e2scrub_all.in b/scrub/e2scrub_all.in index cad232987..a02ffe226 100644 --- a/scrub/e2scrub_all.in +++ b/scrub/e2scrub_all.in @@ -20,6 +20,11 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +if (( $EUID != 0 )); then + echo "e2scrub_all must be run as root" + exit 1 +fi + scrub_all=0 snap_size_mb=256 reap=0
Signed-off-by: Theodore Ts'o <tytso@mit.edu> --- scrub/e2scrub.in | 5 +++++ scrub/e2scrub_all.in | 5 +++++ 2 files changed, 10 insertions(+)