WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: TC8.0 ondemand update  (Read 3056 times)

Offline rdebath

  • Newbie
  • *
  • Posts: 13
TC8.0 ondemand update
« on: April 24, 2017, 08:09:37 AM »
I've made some small fixes to the 'ondemand' script so that it actually works from the command line again.

Currently I've uploaded them to github, but there's no history of issues and pulls there.
Should I push the pull request button or should I be looking somewhere else?

https://github.com/tinycorelinux/Core-scripts/compare/master...rdebath:master
--
Robert

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: TC8.0 ondemand update
« Reply #1 on: April 25, 2017, 09:45:10 AM »
Hi Robert,
I'm currently testing your CLI fix. So far it looks promising.

Unrelated to your fix, maybe this would come in handy, too, so one could run ondemand items with sudo:
replace
Code: [Select]
${COMMAND} "$FROMWHERE""$APPNAME"."$TYPE" || exit
with
Code: [Select]
TCUSER="$(cat /etc/sysconfig/tcuser)"
su "$TCUSER" -c "${COMMAND} "$FROMWHERE""$APPNAME"."$TYPE"" || exit
Download a copy and keep it handy: Core book ;)

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: TC8.0 ondemand update
« Reply #2 on: April 25, 2017, 10:12:58 AM »
With your fix, CLI apps ran from within X via ondemand, are now opened on tty (we have been there already).
So I have changed it from this
Code: [Select]
case "$FOUNDDIR" in
""|*/ondemand* ) launchApp "$APPNAME" "$@" ;;
* ) exec "$FOUNDDIR"/"$APPNAME" "$@" ;;
esac
to this
Code: [Select]
case "$FOUNDDIR" in
""|*/ondemand* ) launchApp "$APPNAME" "$@" ;;
* )
if [ "$DISPLAY" ]; then
launchApp "$APPNAME" "$@"
else
exec "$FOUNDDIR"/"$APPNAME" "$@"
fi
;;
esac
Download a copy and keep it handy: Core book ;)

Offline rdebath

  • Newbie
  • *
  • Posts: 13
Re: TC8.0 ondemand update
« Reply #3 on: April 25, 2017, 10:25:56 AM »
Actually I'd be inclined to add something like this at the start of tce and tce-load.

Code: [Select]
[ $(/usr/bin/id -u) -eq 0 ] && {
    TCUSER="$(cat /etc/sysconfig/tcuser)"
    exec /bin/su "$TCUSER" -c "$0" "$@"
}

That way it works from root like most people would expect.

As for checking DISPLAY that's going to fail if you run inside an xterm (aterm).
How about making the test this instead:

Code: [Select]
if [ ! -t 0 ] ; then

If you're running in the GUI your stdin shouldn't be a terminal.
 
(EDIT: Sigh flip that NOT a terminal!)
--
Robert

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: TC8.0 ondemand update
« Reply #4 on: April 25, 2017, 11:56:23 AM »
Actually I'd be inclined to add something like this at the start of tce and tce-load.

Code: [Select]
[ $(/usr/bin/id -u) -eq 0 ] && {
    TCUSER="$(cat /etc/sysconfig/tcuser)"
    exec /bin/su "$TCUSER" -c "$0" "$@"
}

That way it works from root like most people would expect.
Except that Core is in many ways different to what people expect. :p
But yeah, sounds reasonable. However, I wonder what the Devs say.

I don't understand why checking $DISPLAY should fail when tested from xterm. Works here.
But [ ! -t 0 ] seems fine.
Both ways tested in TTY, xterm and WM menu (Openbox).
Download a copy and keep it handy: Core book ;)

Offline rdebath

  • Newbie
  • *
  • Posts: 13
Re: TC8.0 ondemand update
« Reply #5 on: April 25, 2017, 02:18:02 PM »
Quote
I don't understand why checking $DISPLAY should fail when tested from xterm. Works here.

The point is that launchApp will be called and it detaches the program it's trying to run.
Suppose you're like me and realise that the editor that busybox calls vi is a horrible pile of poo. The real vi that you get on VAX Ultrix from 1995 is a better editor than that. It's the sort ...

Enough! So you want to have vim available but it's big and you don't want other configure scripts to see it's dependencies. So you make it an ondemand program, except the first time you run it (and after that if you forget to do "hash -r") it fails stating that the standard input is not a terminal ... because launchApp ran it in the background.

That's the failure.

Quote
Except that Core is in many ways different to what people expect. :p
Well, yes, but it's security weirdness seems to be a sort of lip service to the "You must not run as root" subverted by making almost everything writable by a non-root.  This defeats it both ways, the "root analogue" isn't actually as powerful as root so you still need to sudo, but when you actually need to it comes as a surprise. On the other hand the "tc" user provides almost none of the guarantees that running as a non-root usually would; for example you can delete anything in /dev by 'accident'.

I tend to work both ways, for some machines (including Windows!) working as non-root (non-Administrator) is exactly what I want. On other machines there is only the root user. As the things I'm looking at TinyCore for are the "root only" class I'm not really worried. But in reality it is an issue.
--
Robert