Check for root and bail out if the user is root.

Submitted by Peter J. Philipp on Aug. 19, 2017, 2:07 p.m.

Details

Message ID 20170819140726.9080-1-freifunk@centroid.eu
State Accepted
Headers show

Commit Message

Peter J. Philipp Aug. 19, 2017, 2:07 p.m.
Signed-off-by: Peter J. Philipp <freifunk@centroid.eu>
---
 buildscript | 6 ++++++
 1 file changed, 6 insertions(+)

Patch hide | download patch | download mbox

diff --git a/buildscript b/buildscript
index f6d6297..01da2eb 100755
--- a/buildscript
+++ b/buildscript
@@ -373,6 +373,12 @@  buildall() {
     done
 }
 
+
+if [ "$(/usr/bin/id -u)" -eq 0 ]; then
+	echo "don't run buildscript as root"
+	exit 1
+fi
+
 if [ "$1" != "selectbsp" -a "$1" != "selectcommunity" ]; then
     if [ ! -h selected_bsp ]; then
         echo "Please select a Board-Support-Package using:"

Comments

Tim Niemeyer Aug. 19, 2017, 2:13 p.m.
Hi

Schaut gut aus. Danke.

Am Samstag, den 19.08.2017, 16:07 +0200 schrieb Peter J. Philipp:
> Signed-off-by: Peter J. Philipp <freifunk@centroid.eu>
> ---
>  buildscript | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/buildscript b/buildscript
> index f6d6297..01da2eb 100755
> --- a/buildscript
> +++ b/buildscript
> @@ -373,6 +373,12 @@ buildall() {
>      done
>  }
>  
> +
Beim applien vllt diese überflüssige Leerstelle entfernen.

Reviewed-by: Tim Niemeyer <tim@tn-x.org>

Tim

> +if [ "$(/usr/bin/id -u)" -eq 0 ]; then
> +	echo "don't run buildscript as root"
> +	exit 1
> +fi
> +
>  if [ "$1" != "selectbsp" -a "$1" != "selectcommunity" ]; then
>      if [ ! -h selected_bsp ]; then
>          echo "Please select a Board-Support-Package using:"
> -- 
> 2.14.1.145.gb3622a4ee
>
Tim Niemeyer Aug. 20, 2017, 12:29 p.m.
Hi

Und applied.

Danke

Am Samstag, den 19.08.2017, 16:13 +0200 schrieb Tim Niemeyer:
> Hi
> 
> Schaut gut aus. Danke.
> 
> Am Samstag, den 19.08.2017, 16:07 +0200 schrieb Peter J. Philipp:
> > Signed-off-by: Peter J. Philipp <freifunk@centroid.eu>
> > ---
> >  buildscript | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/buildscript b/buildscript
> > index f6d6297..01da2eb 100755
> > --- a/buildscript
> > +++ b/buildscript
> > @@ -373,6 +373,12 @@ buildall() {
> >      done
> >  }
> >  
> > +
> 
> Beim applien vllt diese überflüssige Leerstelle entfernen.
> 
> Reviewed-by: Tim Niemeyer <tim@tn-x.org>
> 
> Tim
> 
> > +if [ "$(/usr/bin/id -u)" -eq 0 ]; then
> > +	echo "don't run buildscript as root"
> > +	exit 1
> > +fi
> > +
> >  if [ "$1" != "selectbsp" -a "$1" != "selectcommunity" ]; then
> >      if [ ! -h selected_bsp ]; then
> >          echo "Please select a Board-Support-Package using:"
> > -- 
> > 2.14.1.145.gb3622a4ee
> > 
> 
>