Просмотр исходного кода

Merge pull request #31 from own3mall/master

Fix Auto-Update - Addresses Permissions Issues on OGP Files
OwN-3m-All 6 месяцев назад
Родитель
Сommit
18cc123f3c
1 измененных файлов с 12 добавлено и 4 удалено
  1. 12 4
      OGP/ogp_agent.pl

+ 12 - 4
OGP/ogp_agent.pl

@@ -178,6 +178,12 @@ if (-e AGENT_LOG_FILE)
 	logger "New log file created";
 	logger "New log file created";
 }
 }
 
 
+# Fix permissions on OGP files
+my $ownerShipAgentResults = take_ownership(AGENT_RUN_DIR);
+my $ownerShipAgentResults2 = take_ownership(AGENT_RUN_DIR . "/ogp_agent.pl");
+my $ogpFilesEntirePath = AGENT_RUN_DIR . "/../bin/ogp_agent";
+my $ownerShipAgentResultsFixesAgain = take_ownership($ogpFilesEntirePath);
+
 logger "User running agent script is: " . USER_RUNNING_SCRIPT;
 logger "User running agent script is: " . USER_RUNNING_SCRIPT;
 
 
 # Clear all screen sessions
 # Clear all screen sessions
@@ -3242,7 +3248,7 @@ sub take_ownership{
 		logger "Running takeown commands on path of $home_path and $windows_home_path";
 		logger "Running takeown commands on path of $home_path and $windows_home_path";
 		
 		
 		#cygwin path handling
 		#cygwin path handling
-		$takeownCommand = 'takeown /U ' . USER_RUNNING_SCRIPT . ' /f "' . $home_path . '" /r >/dev/null 2>&1';
+		$takeownCommand = 'takeown /U ' . USER_RUNNING_SCRIPT . ' /S localhost /f "' . $home_path . '" /r >/dev/null 2>&1';
 		$chmodCommand = 'chmod 775 -R "' . $home_path . '" >/dev/null 2>&1';
 		$chmodCommand = 'chmod 775 -R "' . $home_path . '" >/dev/null 2>&1';
 		if(defined $action && $action eq "str"){
 		if(defined $action && $action eq "str"){
 			$fullCommands .= $takeownCommand . "\n";
 			$fullCommands .= $takeownCommand . "\n";
@@ -3254,7 +3260,7 @@ sub take_ownership{
 		
 		
 		# Windows path handling
 		# Windows path handling
 		if(defined $windows_home_path && $windows_home_path ne ""){
 		if(defined $windows_home_path && $windows_home_path ne ""){
-			$takeownCommand = 'takeown /U ' . USER_RUNNING_SCRIPT . ' /f "' . $windows_home_path . '" /r >/dev/null 2>&1';
+			$takeownCommand = 'takeown /U ' . USER_RUNNING_SCRIPT . ' /S localhost /f "' . $windows_home_path . '" /r >/dev/null 2>&1';
 			$chmodCommand = 'chmod 775 -R "' . $windows_home_path . '" >/dev/null 2>&1';
 			$chmodCommand = 'chmod 775 -R "' . $windows_home_path . '" >/dev/null 2>&1';
 			$icaclsStr = 'icacls "' . $windows_home_path . '" /grant ' . USER_RUNNING_SCRIPT . ':\\(OI\\)\\(CI\\)F /T >/dev/null 2>&1';
 			$icaclsStr = 'icacls "' . $windows_home_path . '" /grant ' . USER_RUNNING_SCRIPT . ':\\(OI\\)\\(CI\\)F /T >/dev/null 2>&1';
 			$icaclsAdminGroupFullPerms = 'icacls "' . $windows_home_path . '" /grant administrators:F /T >/dev/null 2>&1';
 			$icaclsAdminGroupFullPerms = 'icacls "' . $windows_home_path . '" /grant administrators:F /T >/dev/null 2>&1';
@@ -3265,8 +3271,10 @@ sub take_ownership{
 				$fullCommands .= $icaclsStr . "\n";
 				$fullCommands .= $icaclsStr . "\n";
 				$fullCommands .= $icaclsAdminGroupFullPerms . "\n";
 				$fullCommands .= $icaclsAdminGroupFullPerms . "\n";
 			}else{
 			}else{
-				logger "Running icacls command: $icaclsStr";
-				logger "Running icacls admin group command: $icaclsAdminGroupFullPerms";
+				#logger "Running takeown command: $takeownCommand";
+				#logger "Running icacls command: $icaclsStr";
+				#logger "Running icacls admin group command: $icaclsAdminGroupFullPerms";
+				#logger "Running chmod command: $chmodCommand";
 				system($takeownCommand);
 				system($takeownCommand);
 				system($chmodCommand);
 				system($chmodCommand);
 				system($icaclsStr);
 				system($icaclsStr);