diff mbox series

live-image: ask for sudo permissions instead of exiting

Message ID 20200617234344.392695-1-alex.hung@canonical.com
State Rejected
Headers show
Series live-image: ask for sudo permissions instead of exiting | expand

Commit Message

Alex Hung June 17, 2020, 11:43 p.m. UTC
Signed-off-by: Alex Hung <alex.hung@canonical.com>
---
 live-image/fwts-frontend-text | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Colin Ian King June 18, 2020, 11:19 a.m. UTC | #1
On 18/06/2020 00:43, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>  live-image/fwts-frontend-text | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/live-image/fwts-frontend-text b/live-image/fwts-frontend-text
> index 7fe4533f..4c397438 100755
> --- a/live-image/fwts-frontend-text
> +++ b/live-image/fwts-frontend-text
> @@ -31,7 +31,8 @@ FWTS_TIME=`date +%H%M`
>  #
>  if [ $EUID -ne 0 ]; then
>  	echo "`basename $0`: must be executed with sudo"
> -	exit 1
> +	SELF="$(readlink -f "${BASH_SOURCE[0]}")"
> +	exec sudo -- "$BASH" -- "$SELF" "$@"
>  fi
>  
>  #
> 
How does this work for distros that don't support sudo?

Colin
Alex Hung June 18, 2020, 5:54 p.m. UTC | #2
On Thu, Jun 18, 2020 at 5:19 AM Colin Ian King <colin.king@canonical.com>
wrote:

> On 18/06/2020 00:43, Alex Hung wrote:
> > Signed-off-by: Alex Hung <alex.hung@canonical.com>
> > ---
> >  live-image/fwts-frontend-text | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/live-image/fwts-frontend-text
> b/live-image/fwts-frontend-text
> > index 7fe4533f..4c397438 100755
> > --- a/live-image/fwts-frontend-text
> > +++ b/live-image/fwts-frontend-text
> > @@ -31,7 +31,8 @@ FWTS_TIME=`date +%H%M`
> >  #
> >  if [ $EUID -ne 0 ]; then
> >       echo "`basename $0`: must be executed with sudo"
> > -     exit 1
> > +     SELF="$(readlink -f "${BASH_SOURCE[0]}")"
> > +     exec sudo -- "$BASH" -- "$SELF" "$@"
> >  fi
> >
> >  #
> >
> How does this work for distros that don't support sudo?
>

A good point. Let's drop this patch.

>
> Colin
>
diff mbox series

Patch

diff --git a/live-image/fwts-frontend-text b/live-image/fwts-frontend-text
index 7fe4533f..4c397438 100755
--- a/live-image/fwts-frontend-text
+++ b/live-image/fwts-frontend-text
@@ -31,7 +31,8 @@  FWTS_TIME=`date +%H%M`
 #
 if [ $EUID -ne 0 ]; then
 	echo "`basename $0`: must be executed with sudo"
-	exit 1
+	SELF="$(readlink -f "${BASH_SOURCE[0]}")"
+	exec sudo -- "$BASH" -- "$SELF" "$@"
 fi
 
 #