Changeset 484 for scripts/usr/local


Ignore:
Timestamp:
Nov 16, 2023, 2:47:20 PM (12 months ago)
Author:
alloc
Message:

Scripts: Command execution monitor fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • scripts/usr/local/lib/7dtd/monitor-log.sh

    r482 r484  
    9292        local cmd="$1"
    9393        local name="$2"
    94        
    95         echo "$(timestamp): Player \"$name\" executed \"$cmd\"" >> $COMMANDLOG
     94        local clientInfo="$3"
     95       
     96        echo "$(timestamp): Player \"$name\" executed \"$cmd\" (client $clientInfo)" >> $COMMANDLOG
    9697
    9798        for H in $(getHooksFor remoteCommand $INSTANCE); do
     99                $H $INSTANCE "$cmd" "$name"
     100        done
     101}
     102
     103handleRemoteCommandDenied() {
     104        local cmd="$1"
     105        local name="$2"
     106        local clientInfo="$3"
     107       
     108        echo "$(timestamp): Denied \"$name\" to exec command \"$cmd\" (client $clientInfo)" >> $COMMANDLOG
     109
     110        for H in $(getHooksFor remoteCommandDenied $INSTANCE); do
    98111                $H $INSTANCE "$cmd" "$name"
    99112        done
     
    180193                #Executing command ".*" from client ".*"$
    181194                elif [ -n "$(echo "$line" | grep '^Executing command '.*' from client')" ]; then
    182                         cmd=$(expr "$line" : "Executing command '\(.*\)' from client .*$")
    183                         nick=$(expr "$line" : "Executing command '.*' from client \(.*\)$")
    184                         handleRemoteCommand "$cmd" "$nick"
    185                         unset cmd nick
     195                        cmd=$(expr "$line" : "Executing command '\(.*\)' from client EntityID=.*, PltfmId='.*', CrossId='.*', OwnerID='.*', PlayerName='.*', ClientNumber='.*'$")
     196                        clientInfo=$(expr "$line" : "Executing command '.*' from client \(.*\)$")
     197                        playerName=$(expr "$line" : "Executing command '.*' from client EntityID=.*, PltfmId='.*', CrossId='.*', OwnerID='.*', PlayerName='\(.*\)', ClientNumber='.*'$")
     198                        handleRemoteCommand "$cmd" "$playerName" "$clientInfo"
     199                        unset cmd playerName clientInfo
     200                #Denying command ".*" from client ".*"$
     201                elif [ -n "$(echo "$line" | grep '^Denying command '.*' from client')" ]; then
     202                        cmd=$(expr "$line" : "Denying command '\(.*\)' from client EntityID=.*, PltfmId='.*', CrossId='.*', OwnerID='.*', PlayerName='.*', ClientNumber='.*'$")
     203                        clientInfo=$(expr "$line" : "Denying command '.*' from client \(.*\)$")
     204                        playerName=$(expr "$line" : "Denying command '.*' from client EntityID=.*, PltfmId='.*', CrossId='.*', OwnerID='.*', PlayerName='\(.*\)', ClientNumber='.*'$")
     205                        handleRemoteCommandDenied "$cmd" "$playerName" "$clientInfo"
     206                        unset cmd playerName clientInfo
    186207                #Executing command ".*" by Telnet from .*$
    187208                elif [ -n "$(echo "$line" | grep '^Executing command '.*' by Telnet from ')" ]; then
Note: See TracChangeset for help on using the changeset viewer.