This wiki is static and therefore read-only as of August 2011. More information here.
Hosted by NexuizNinjaz.com

NexBash

This is a quite recent project. :!: PLEASE BE AWARE that running this could potentially damage your computer :!:. I have no idea how, but I can't say it's 100% safe.
You better contact me before trying anything, really. See the link to the contact page at the bottom of this page.

I made NexBash to extend the possibilities of Nexuiz scripting to those of Bash. Well, sort of, because it's a bit restricted.

How it works

The concept is simple but hacky: a Bash script runs in background while you're playing Nexuiz, and listens to a local port. For every line it gets, it reads it, parses it to find out what the user wanted to call, executes a custom bash script and passes the rest of the line to it as arguments. Then the output of this script is read by the main background script and written in a .cfg file that must be exec'd from Nexuiz.
It's probably simpler with an example... Definitely.
Here's a line from the example.sh script that can be found in the package:

[[ "$*" == "time" ]] && echo "say POSIX time is ^2$(date +%s)"


To call it from Nexuiz, I send a packet to the port I have configured in NexBash, containing this: scrpt example time
NexBash gets the packet, sees the first word, scrpt, meaning Nexuiz wants to call a script. It reads the second word, example, that tells him what script to run. It then runs example.sh with time as only argument. Then, example.sh sees “$*” is “time”, and then outputs the POSIX time (date +%s in Bash).
NexBash writes that output to a cfg file, and all that's left to do is execute that from Nexuiz.

Security concerns

I really have no idea... I don't know how risky it is to run that system... All I can say is that if a server admin on a modded server manages to find your nexbash command, he will be able to run the scripts. I have added a few protections that could have been exploited:

Scripts can only be executed from the script directory. No parent directory, then. Also, only executable files ending with .sh can be run, so there's no way to call /bin/rm for example.

The user and core scripts are stored in the personal Nexuiz data directory ~/.nexuiz/data in a hidden directory. That prevents anyone to write files in it from DarkPlaces, thanks to a protection in its file functions. So a server admin can't use echo and condump to create a .sh file in the scripts directory. Also, it would have to be an executable file. By default, Nexuiz can't make these.

Issues

  • I don't know how to make socat exit after “breaking the pipe”... It will exit on an error on the next signal it gets. This won't hurt anything, but it's an ugly way to quit :-(
  • For long scripts, the waiting loop in Nexuiz can be spammy... The initial return script initially contains a delayed call to itself, so it loops until it is replaced by the actual return script.

Requirements

You will need these to run NexBash:

  • Bash 3 or later
  • Nexuiz 2.4.2 or later

Setup

Just unpack the archive in your data directory. It consists of two directories, nexbash and .nexbash .
Make sure to read nexbash/README, it contains all the instructions.
nexbash_v2.zip --- 2008/12/31

 
user/mrbougo/proj/nexbash.txt · Last modified: 2008/12/31 13:10 by mrbougo
Nexuiz Ninjaz Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
GFDL logoGFDLcontent Unless mentioned on the licensing page, the work on this page is licensed under the GNU Free Documentation License. The author states that the text and images can be used within the restrictions of this license (for example, they can be incorporated into certain free encyclopedias such as Wikipedia).
Kindly hosted by NexuizNinjaz.com