#!/bin/sh # # update-files # John Simpson 2006-02-15 # # reads incoming data and saves it to one of a set of known filenames # then runs additional commands based on which file was received # # 2007-01-26 jms1 - adding auth.cdb to the mix # # 2008-04-16 jms1 - changing license from "GPLv2 only" to "GPL v2 or v3". # no code changes. # ############################################################################### # # Copyright (C) 2006,2007,2008 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 or version 3 of the # license, at your option. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ############################################################################### PATH="/usr/bin:/bin:/usr/local/bin" # if variable not set, $file will contain an empty string file=${SSH_ORIGINAL_COMMAND:-} # these files are all handled by: # - writing to a temp file # - chmod to make world readable # - rename to the real name if [ "$file" = "validrcptto.cdb" \ -o "$file" = "rcpthosts" \ -o "$file" = "morercpthosts.cdb" \ -o "$file" = "auth.cdb" \ -o "$file" = "smtproutes" ] then logger -t update-files "$TCPREMOTEIP updating $file" echo Saving incoming data to $file.new cat > $file.new echo Setting permissions chmod 644 $file.new echo Renaming $file.new to $file mv $file.new $file exit 0 fi # unknown command - either it's a bug or a security violation # either way, it needs to be logged logger -t update-files "$TCPREMOTEIP sent invalid command '$file'" echo Invalid command, this incident has been reported exit 1