Message ID | 20200617234344.392695-1-alex.hung@canonical.com |
---|---|
State | Rejected |
Headers | show |
Series | live-image: ask for sudo permissions instead of exiting | expand |
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
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 --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 #
Signed-off-by: Alex Hung <alex.hung@canonical.com> --- live-image/fwts-frontend-text | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)