Przeglądaj źródła

Feature/correct group perms (#48)

* Security Changes

* Additional Security - Run Game Servers in Limited User Account

* Apply New Group Right Away

* Apply Proper Permissions to FTP User

* Fix for Home Dirs Under OGP Agent User

* No Return Sudo Command Function

* Fix Group Perms

* Recursive
OwN-3m-All 3 lat temu
rodzic
commit
effb76497f
1 zmienionych plików z 28 dodań i 0 usunięć
  1. 28 0
      ogp_agent.pl

+ 28 - 0
ogp_agent.pl

@@ -2126,8 +2126,11 @@ sub set_path_ownership
 	# Set owner and perms on it recursivelly as well
 	my $chownCommand = "chown -Rf $owner_uid:$group_uid '$path'";
 	my $chmodCommand = "chmod -Rf ug+rwx '$path'";
+	my $groupCommand = "chmod -Rf g+s '$path'";
 	sudo_exec_without_decrypt($chownCommand);
 	sudo_exec_without_decrypt($chmodCommand);
+	sudo_exec_without_decrypt($groupCommand);
+	
 	
 	# Remove perms for other users
 	$chmodCommand = "chmod -Rf o-rwx '$path'";
@@ -3088,6 +3091,31 @@ sub sudo_exec_without_decrypt
 	return -1;
 }
 
+sub sudo_exec_without_decrypt_no_return
+{
+	my ($sudo_exec, $as_user) = @_;
+	$sudo_exec =~ s/('+)/'"$1"'/g;
+	if( !defined($as_user) )
+	{
+		$as_user = "root";
+	}
+	
+	my $command = "echo '$SUDOPASSWD'|sudo -kS -p \"<prompt>\" su -c '$sudo_exec' $as_user 2>&1";
+	my @cmdret = qx($command);
+	$cmdret[0] =~ s/^<prompt>//g if defined $cmdret[0];
+	chomp(@cmdret);
+	
+	my $ret = pop(@cmdret);
+	chomp($ret);
+	
+	if ("X$ret" eq "X0")
+	{
+		return "1;".encode_list(@cmdret);
+	}
+	
+	return -1;
+}
+
 sub secure_path
 {
 	chomp(@_);