Recently I've been hacking around on GNU screen. I've fixed a few bugs and added a few new features. One of the earliest features I added was the ability to source every file in a directory. One of the later additions was to add simple conditionals to the dotfile, via the new if primitive.
Today I had an epiphany moment. Rather than adding either of these two features I should have altered the behaviour in the far simpler manner.
If we allow ~/.tscreenrc to be an executable we immediately gain lots of things for free.
Consider this ~/.tscreenrc file:
#!/bin/sh
for i in ~/.tscreen/*; do
if [ -e $i ];
echo "source $i"
fi
done
That gives us the effect of a "source directory/" primitive. Similarly I can do complex tests without the need for an if primitive if I were to write this:
#!/bin/sh # common config cat ~/.tscreenrc.common # per host config? file=~/.tscreenrc.$(hostname --fqdn) if [ -e "$file" ]; then cat $file fi # if we have lynx define an alias for it + map it to a key if [ -x /usr/bin/lynx ]; then cat <<EOF # Surf the web with <Ctrl-a f> alias web screen -F -t web /usr/bin/lynx bind w web EOF fi
So as of v0.4.7 tscreen allows you to have your configuration file be:
- A normal file:
In which case it is parsed as you'd expect.
- An executable file:
In which case it is executed and the output is parsed.
The code change is trivial, just an extra stat call and the use of popen vs. fopen, but the payoff is significant.
ObFilm: Léon
I hope that there's a way for the system administrator to turn this feature off, globally, and that distros make this the default.
or:
think of:
Joe: Whilst it is true that the script can do anything the user can it already is disabled by default.
For this to start happening you need to explicitly change your ~/.tscreenrc file to be executable. By default this shouldn't be the case.
Des: No I'd not considered that, but it does make sense.
Anonymous: Yes, yes they should!
Fortunately I use screen less than I should, I would not allow screen on my systems unless you contained the scripting LUA seeming an obvious way. Some may create considerable state to their screen sessions, and may like the power without the security risk of your proposal.
I cannot understand how this is a security issue.
Consider the facts:
Now if you're in a situation where somebody other than yourself can change permissions/contents of files inside your home directory then you've already lost.
If nobody but you may change the permissions/content then there is no security hole at all.
So .. lua? Great idea. Love to see it in screen. But that's not a replacement, and in this context a distraction. If you believe I've introduced a security hole please do explain it to me explicitly!