Search code examples
rediskerberosopenafs

Run shell command from within redis server process


I am running a Redis server on a RHEL system that requires processes to update their AFS authentication tokens every 24 hours.

In the client-side code that posts data to the database, I can update the AFS token by calling a shell command every N POST requests (e.g. echo PASSWORD | kinit && aklog.

I would like to achieve something similar in the server process, but am not sure how to do so. Are there any "post-receive-data" callback style hooks that one can use to run a shell command from within a Redis server process? I would be very grateful for any advice others can offer on this question.


Solution

  • No - the Redis server isn't designed for that and is not intended for this purpose. If you really insist on using an event from the Redis server to trigger a shell command, you could hack by:

    • Trailing the server's log file and looking for an event generated by a client's call to EVAL with a script that invokes the redis.log Lua function.
    • Running a loop with a basic local Redis client (e.g. redis-cli) that BRPOPs from a queue, does the work and repeats
    • Code something to act as a sort of daemon that uses Redis' PubSub receive messages over a channel to trigger the shell commands
    • and so forth...

    Note: WRT to "Redis server isn't designed for that" - if you do find some loophole that allows you to do what you're looking for, please report it as a severe security issue. In that sense, you may want to read http://antirez.com/news/96