1

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.

duhaime
  • 25,611
  • 17
  • 169
  • 224

1 Answers1

3

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

Itamar Haber
  • 47,336
  • 7
  • 91
  • 117
  • Thanks @ItamarHaber, this is interesting but I'm worried I haven't explained my situation clearly--I'm needing to run a shell command from the server process, not from an outside process. I believe the shell command must be run from the process running the server (or a process spawned by that process) to update the AFS token for that process. – duhaime Nov 13 '17 at 21:11
  • Ok, so that afaik that is impossible short of modifying the Redis source code. – Itamar Haber Nov 14 '17 at 01:21