private FileNamePatternAndFormat GetFileNamePatternAndFormat() { var pattern = default(string); var format = default(ZippedToolFormat); if (_settings.OSPlatform == TorSharpOSPlatform.Windows) { pattern = @"tor-win32-(?<Version>[\d\.]+)\.zip$"; format = ZippedToolFormat.Zip; } else if (_settings.OSPlatform == TorSharpOSPlatform.Linux) { if (_settings.Architecture == TorSharpArchitecture.X86) { pattern = @"tor-browser-linux32-(?<Version>[\d\.]+)_en-US\.tar\.xz$"; format = ZippedToolFormat.TarXz; } else if (_settings.Architecture == TorSharpArchitecture.X64) { pattern = @"tor-browser-linux64-(?<Version>[\d\.]+)_en-US\.tar\.xz$"; format = ZippedToolFormat.TarXz; } } if (pattern == null) { _settings.RejectRuntime($"fetch Tor from {BaseUrl.AbsoluteUri}"); } return(new FileNamePatternAndFormat(pattern, format)); }
public static void MakeExecutable(TorSharpSettings settings, string path) { if (settings.OSPlatform == TorSharpOSPlatform.Windows) { return; } else if (settings.OSPlatform == TorSharpOSPlatform.Linux) { // We shell out here since invoking "stat" is non-trivial. We should invoke "chmod" but we would need // to know the initial permissions to perform an additive "+x" change which "stat" could tell us. Let's // just keep things simple. using (var process = new Process()) { process.StartInfo.FileName = "chmod"; process.StartInfo.Arguments = $"+x \"{path}\""; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.CreateNoWindow = true; process.StartInfo.UseShellExecute = false; var output = new StringBuilder(); var outputLock = new object(); process.OutputDataReceived += GetOutputHandler(output, outputLock); process.ErrorDataReceived += GetOutputHandler(output, outputLock); process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); if (process.ExitCode != 0) { throw new TorSharpException( $"Failed making file '{path}' executable with 'chmod'. Exit code: {process.ExitCode}. " + $"Output: {Environment.NewLine}{output}"); } } } else { settings.RejectRuntime("make a file executable"); } }
private void Reject(Uri baseUrl) { _settings.RejectRuntime($"fetch Privoxy from {baseUrl.AbsoluteUri}"); }