ktsuss - revision to gksu script

General talk about packaging procedures and packages.
Post Reply
User avatar
pwatk
Posts: 474
Joined: 14. Mar 2010, 23:56
Location: United Kingdom

ktsuss - revision to gksu script

Post by pwatk »

This is my gksu script that I used to use with slackware:

Code: Select all

#!/bin/sh

# /usr/bin/gksu

PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
CMD="$@"
BIN="$1"

if [ -x "`type -path ktsuss`" ]; then
  KTSUSS="`type -path ktsuss` -u root"
else
  echo "$(basename $0): \`ktsuss' command not found"
  exit 1
fi

if [ "$UID" = "0" ]; then
  KTSUSS=""
fi

if [ -x "`type -path $BIN`" ]; then
  eval $KTSUSS $CMD
else
  echo "$(basename $0): \`$BIN' command not found"
  exit 1
fi
I would like to see it included in the next ktsuss package as it is (without trying to cause offense) a little bit more robust than the current script and it will work with pcmanfm (if the option to 'open as root' isn't patched out that is).

Thanks
Image
Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

Re: ktsuss - revision to gksu script

Post by Shador »

If variables are quoted properly I don't mind. Currently it would fail for such stuff: "gksu ls '/space/in here/'"
From my ccache wrapper script:

Code: Select all

exec "$targetcc" "$@"
That's where I learned it the hard way, when audacity failed because of properly quoted spaces in their command lines.
Image
User avatar
pwatk
Posts: 474
Joined: 14. Mar 2010, 23:56
Location: United Kingdom

Re: ktsuss - revision to gksu script

Post by pwatk »

I think that was actually part of the reason behind me making this script. Eval solves most of the problems (including pcmanfm) but I agree this might be better:

Code: Select all

...
  eval "$KTSUSS" "$CMD"
...
That said, my script isn't really geared towards launching commands outside of the system path so the script would exit with an error if you ran gksu ~/silly dir name/script.sh for example.

On the other hand, the current script bombs if you run it as root... spot the deliberate mistake:

Code: Select all

#!/bin/sh

export PATH="${PATH}:/sbin:/usr/sbin"

if [ "$(id -u)" = "0" ]; then
	KTSUSS=""
else
	KTSUSS=/usr/bin/ktsuss
fi
$KTSUSS -u root "$@"
Image
User avatar
gapan
Salix Wizard
Posts: 6349
Joined: 6. Jun 2009, 17:40

Re: ktsuss - revision to gksu script

Post by gapan »

Ouch. Is that our ktsuss script? It sucks. :D

Thanks, I'll take a look.
Image
Image
User avatar
gapan
Salix Wizard
Posts: 6349
Joined: 6. Jun 2009, 17:40

Re: ktsuss - revision to gksu script

Post by gapan »

Updated packages are in the repositories. Thanks pwatk.
Image
Image
User avatar
pwatk
Posts: 474
Joined: 14. Mar 2010, 23:56
Location: United Kingdom

Re: ktsuss - revision to gksu script

Post by pwatk »

gapan wrote:Ouch. Is that our ktsuss script? It sucks. :D

Thanks, I'll take a look.
Well I didn't want to put it quite like that :D
gapan wrote:Updated packages are in the repositories. Thanks pwatk.
It's nice to be able to contribute.

Shador got me thinking though, maybe it would be useful to be able to launch commands outside the system path. If I get sometime I might try to add that in.
Image
Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

Re: ktsuss - revision to gksu script

Post by Shador »

pwatk wrote:Shador got me thinking though, maybe it would be useful to be able to launch commands outside the system path. If I get sometime I might try to add that in.
Can't you already? At least this one worked (with the freshly installed ktsuss package):

Code: Select all

gksu /home/shador/bin/argouml.sh
If it's about supporting ~ and possibly other expansion, I don't think that's feasible. You have to expect that it's expanded as root (in fact I sometimes use that behaviour intentionally), so we we shouldn't change that.
Image
User avatar
pwatk
Posts: 474
Joined: 14. Mar 2010, 23:56
Location: United Kingdom

Re: ktsuss - revision to gksu script

Post by pwatk »

So it does, I thought it would bomb out.. cool, thanks :D

Edit: I'm a fool, of course it would work, I'm already providing the path :oops:
Image
Post Reply