broker_must_be_super.pl #1

  • //
  • p4-hms/
  • dev/
  • p4/
  • common/
  • site/
  • hms/
  • dlp/
  • broker_must_be_super.pl
  • View
  • Commits
  • Open Download .zip Download (2 KB)
#!/usr/bin/perl

#------------------------------------------------------------------------------
# Must Be Super
#
# This broker filter script overrides P4D default behaviour, requiring that
# the user running the specified command must have 'super' access, as reported
# by 'p4 protects -m -u <user>'.  This is for scenarios where the P4D default
# is too insecure.  For example, this can be used to require that the 'p4 groups'
# command, which by default can be run as any logged in user, is restricted to
# super users (as the mere names of groups is inherently sensitive info).
#
# Enable in the broker config file like this example for the 'p4 groups' and
# 'p4 users' commands.
#
# command: ^groups|users$
# {
#    action  = filter;
#    checkauth = true;
#    execute = /p4/common/site/hms/scripts/broker_must_be_super.pl;
# }

use strict;

my $User;
my $Cmd;
my $AccessLevel;
my $AccessLevelCmd;
my $BotUser = "bot_dlp";

while (<STDIN>) {
   if (/^user: /) {
      $User = $_;
      chomp $User;
      $User =~ s/^user: //;
   }
   if (/^command: /) {
      $Cmd = $_;
      chomp $Cmd;
      $Cmd =~ s/^command: //;
   }
}

if ( ! $Cmd ) {
   print "action: REJECT\n";
   print "message: \"Data Leakage Protection: Internal Error, could not determine Cmd.\"\n";
   exit (0);
}

if ( ! $User ) {
   print "action: REJECT\n";
   print "message: \"Data Leakage Protection: Internal Error, could not determine User.\"\n";
   exit (0);
}

$AccessLevelCmd = "$ENV{P4BIN} -E P4TRUST=$ENV{P4TRUST} -E P4TICKETS=$ENV{P4TICKETS} -p $ENV{P4MASTERPORT} -u $BotUser protects -m -u $User";
$AccessLevel=`$AccessLevelCmd`;
chomp $AccessLevel;

if ($AccessLevel eq "super") {
   print "action: PASS\n";
   exit (0);
}

print "action: REJECT\n";
print "message: \"Data Leakage Protection: The command 'p4 $Cmd' requires super access on this server. Your access level is $AccessLevel. Checked with: $AccessLevelCmd\"\n";
exit (0);
# Change User Description Committed
#1 33516 C. Thomas Tyler Consistency pass: fix absolute URLs, p4ms->hms renames, script/doc typos and bugs

- Convert absolute workshop.perforce.com URLs to relative paths in dlp/ReadMe.md
- Fix case-mismatch link to HMS_Product_Roadmap.md in README.md
- Rename reset_p4ms.sh -> reset_hms.sh and p4broker_p4ms_test -> p4broker_hms_test
- Fix .sh-suffix bugs: bin/hms calling global_replica_status.sh (should be no ext),
  and matching SEE ALSO / doc references for sdp_sync and global_replica_status
- Add missing scripts (gtu, hrun, irun, global_replica_status) to gen_script_man_pages.sh
- Add stub scripts: nj_help.sh, broker_njob.pl, broker_mkproj.pl, broker_jr.pl
- Remove dangling absolute symlinks HostCM/p4 and HostCM/p4d (cruft)
- Rename test/b -> test/broker_ctl.sh for clarity
- Fix real bugs: broker_imply-u.pl broken regex match, gen_dlp_broker_cfg.sh and
  gen_nj_broker_cfg.sh copy-pasted Version-file existence check, garbled comment
  in broker_must_be_owner.pl, unclosed quote in tools/gsr.sh usage(), missing 'h'
  in HMS_SystemComponents.md broker command example (^ms$ -> ^hms$)
- Fix broken sed command and incomplete sentence in HMS_Install_Notes.md and
  SDP_and_HMS_Update_Process.md
- Fix broken markdown table in HMS_Product_Roadmap.md
- Fix unclosed parenthesis, missing verb, and FKA Swarm mislabel in
  HMSDeploymentPlanning.adoc
- Standardize //streams/main/... naming in HostCM/ReadMe.md
- Numerous typo fixes across README.md, HMS_SystemComponents.md,
  SDP_and_HMS_Update_Process.md, HMS_TightShipManagement.adoc,
  HMSDeploymentPlanning.adoc, HostCM/ReadMe.md, and various scripts

Co-authored-by: Copilot <[email protected]>