command_block.py #2

  • //
  • guest/
  • russell_jackson/
  • sdp/
  • Server/
  • Unix/
  • p4/
  • common/
  • bin/
  • triggers/
  • command_block.py
  • View
  • Commits
  • Open Download .zip Download (988 B)
#!/usr/bin/env python
#==============================================================================
# Copyright and license info is available in the LICENSE file included with
# the Server Deployment Package (SDP), and also available online:
# https://swarm.workshop.perforce.com/projects/perforce-software-sdp/view/main/LICENSE
#------------------------------------------------------------------------------
#
# This is command trigger to allow you to block commands from all but listed users. 
#
# Trigger table entry examples:
# command-block command pre-user-obliterate "/p4/common/bin/triggers/command_block.py %user% %args%"
# command-block command pre-user-(obliterate|protect$) "/p4/common/bin/triggers/command_block.py %user% %args%"

import sys

passusers = [ 'perforce' ]
user=sys.argv[1]

if len(sys.argv) > 2:
  args=sys.argv[2]
  if "-o" in args:
    sys.exit(0)

if user in passusers:
  sys.exit(0)
else:
  print("You are not allowed to run this command.")
  sys.exit(1)
# Change User Description Committed
#4 32426 Russell C. Jackson (Rusty) Claude ai updates.
#3 32388 Russell C. Jackson (Rusty) Updates using Claude.ai to clean up the code, reduce duplication, enhanace security, and use current standards.
#2 27652 Russell C. Jackson (Rusty) Allow other super users to read the protect, but not modify it.
#1 22693 Russell C. Jackson (Rusty) Branched a Unix only version of the SDP.
Removed extra items to create a cleaner tree.
Moved a few items around to make more sense without Windows in the mix.
//guest/perforce_software/sdp/dev/Server/Unix/p4/common/bin/triggers/command_block.py
#4 22318 Russell C. Jackson (Rusty) Corrected comments for trigger file name.
#3 16373 C. Thomas Tyler Routine Merge Down to dev from main using:
p4 merge -b perforce_software-sdp-dev
#2 16029 C. Thomas Tyler Routine merge to dev from main using:
p4 merge -b perforce_software-sdp-dev
#1 12107 C. Thomas Tyler Routine merge down from 'main' to 'dev', resolved with
'p4 resolve -as'.
//guest/perforce_software/sdp/main/Server/Unix/p4/common/bin/triggers/command_block.py
#2 12104 Russell C. Jackson (Rusty) Updated date to 2015
#1 12067 Russell C. Jackson (Rusty) Changed mkdirs.sh to default to 1666 and added comment to replace the broker
 with command triggers.

 Added simple command trigger to block commands in the server.