Browse Source

Fixed legacy console commands (lcon)

lcon sends commands to the server directly, through screen, to the game server without using any rcon protocol.
It used to call "system" to send the command to screen, which runs as the agent user but, since the game servers are started as their own user, the screen socket can not be reached as the agent user, therefore the agent now sends the screen command as the appropriate user.
DieFeM 3 years ago
parent
commit
92feac342c
1 changed files with 5 additions and 2 deletions
  1. 5 2
      ogp_agent.pl

+ 5 - 2
ogp_agent.pl

@@ -1503,9 +1503,12 @@ sub send_rcon_command
 	if ($control_protocol eq "lcon")
 	{
 		my $screen_id = create_screen_id(SCREEN_TYPE_HOME, $home_id);
-		system('screen -S '.$screen_id.' -p 0 -X stuff "'.$rconCommand.'$(printf \\\\r)"');
+		my $as_user = find_user_by_screen_id($screen_id);
+		my $ScreenCommand = 'screen -S '.$screen_id.' -p 0 -X stuff "'.$rconCommand.'$(printf \\\\r)"';
 		logger "Sending legacy console command to ".$screen_id.": \n$rconCommand \n .";
-		if ($? == -1)
+		my $ret = sudo_exec_without_decrypt($ScreenCommand, $as_user);	
+		my ($retval, $enc_out) = split(/;/, $ret, 2);
+		if($retval == 1)
 		{
 			my(@modedlines) = "$rconCommand";
 			my $encoded_content = encode_list(@modedlines);