ソースを参照

Fix for Locking Files Post Steam

own3mall 9 年 前
コミット
44eaa9f301
1 ファイル変更29 行追加20 行削除
  1. 29 20
      ogp_agent.pl

+ 29 - 20
ogp_agent.pl

@@ -2553,31 +2553,40 @@ sub secure_path
 sub secure_path_without_decrypt
 sub secure_path_without_decrypt
 {   
 {   
 	my ($action, $file_path, $returnType) = @_;
 	my ($action, $file_path, $returnType) = @_;
+	my $checkIfFileExists = 1;
 	
 	
-	if( -e $file_path )
+	if(defined $returnType && $returnType eq "str"){
+		$checkIfFileExists = 0;
+	}
+	
+	if($checkIfFileExists){
+		if(! -e $file_path){
+			return -1;
+		}
+	}
+	
+	my $uid = `id -u`;
+	chomp $uid;
+	my $gid = `id -g`;
+	chomp $gid;
+	$file_path =~ s/('+)/'\"$1\"'/g;
+	if($action eq "chattr+i")
 	{
 	{
-		my $uid = `id -u`;
-		chomp $uid;
-		my $gid = `id -g`;
-		chomp $gid;
-		$file_path =~ s/('+)/'\"$1\"'/g;
-		if($action eq "chattr+i")
-		{
-			if(defined $returnType && $returnType eq "str"){
-				return 'chown -Rf '.$uid.':'.$gid.' \''.$file_path.'\' && chattr -Rf +i \''.$file_path.'\'';
-			}else{
-				return sudo_exec_without_decrypt('chown -Rf '.$uid.':'.$gid.' \''.$file_path.'\' && chattr -Rf +i \''.$file_path.'\'');
-			}
+		if(defined $returnType && $returnType eq "str"){
+			return 'chown -Rf '.$uid.':'.$gid.' \''.$file_path.'\' && chattr -Rf +i \''.$file_path.'\'';
+		}else{
+			return sudo_exec_without_decrypt('chown -Rf '.$uid.':'.$gid.' \''.$file_path.'\' && chattr -Rf +i \''.$file_path.'\'');
 		}
 		}
-		elsif($action eq "chattr-i")
-		{
-			if(defined $returnType && $returnType eq "str"){
-				return 'chattr -Rf -i \''.$file_path.'\' && chown -Rf '.$uid.':'.$gid.' \''.$file_path.'\'';
-			}else{
-				return sudo_exec_without_decrypt('chattr -Rf -i \''.$file_path.'\' && chown -Rf '.$uid.':'.$gid.' \''.$file_path.'\'');
-			}
+	}
+	elsif($action eq "chattr-i")
+	{
+		if(defined $returnType && $returnType eq "str"){
+			return 'chattr -Rf -i \''.$file_path.'\' && chown -Rf '.$uid.':'.$gid.' \''.$file_path.'\'';
+		}else{
+			return sudo_exec_without_decrypt('chattr -Rf -i \''.$file_path.'\' && chown -Rf '.$uid.':'.$gid.' \''.$file_path.'\'');
 		}
 		}
 	}
 	}
+	
 	return -1;
 	return -1;
 }
 }