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

Fixed Directory Creation if Doesn't Exist

own3mall 7 лет назад
Родитель
Сommit
afbc9b06ee
1 измененных файлов с 8 добавлено и 3 удалено
  1. 8 3
      ogp_agent.pl

+ 8 - 3
ogp_agent.pl

@@ -1961,15 +1961,20 @@ sub check_b4_chdir
 	{
 		logger "$path does not exist yet. Trying to create it...";
 
-		if (!mkpath($path))
+		eval { mkpath($path); 1 } or logger "Error creating $path with Perl mkpath command. Errno: $! - Trying again with sudo...";
+
+		if (!-e $path)
+		{
+			sudo_exec_without_decrypt('mkdir -p ' . $path);
+		}
+		
+		if (!-e $path)
 		{
-			logger "Error creating $path . Errno: $!";
 			return -1;
 		}
 		
 		# Set perms on it as well
 		sudo_exec_without_decrypt('chown -Rf '.$uid.':'.$gid.' \''.$path.'\'');
-		
 	}
 	else
 	{