[smuxi/experiments/hook_runner_executable_check] Engine: only run hooks that have the executable bit set on Unix
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi/experiments/hook_runner_executable_check] Engine: only run hooks that have the executable bit set on Unix
- Date: Thu, 23 Apr 2015 02:20:05 +0000 (UTC)
commit 3b86d4393e773ce8f7a1ba0dda12103186d9ce1d
Author: Mirco Bauer <meebey meebey net>
Date: Thu Apr 23 04:18:31 2015 +0200
Engine: only run hooks that have the executable bit set on Unix
src/Engine/Hooks/HookRunner.cs | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/src/Engine/Hooks/HookRunner.cs b/src/Engine/Hooks/HookRunner.cs
index d661008..d54bea5 100644
--- a/src/Engine/Hooks/HookRunner.cs
+++ b/src/Engine/Hooks/HookRunner.cs
@@ -23,6 +23,8 @@ using System.Linq;
using System.Text;
using System.Collections.Generic;
using SysDiag = System.Diagnostics;
+using Mono.Unix;
+using Smuxi.Common;
namespace Smuxi.Engine
{
@@ -78,13 +80,25 @@ namespace Smuxi.Engine
return;
}
foreach (var file in Directory.GetFiles(hookPath).OrderBy(x => x)) {
- try {
- File.OpenRead(file).Close();
- } catch (Exception ex) {
+ if (Environment.OSVersion.Platform == PlatformID.Unix) {
+ var unixFile = new UnixFileInfo(file);
+ if ((unixFile.FileAccessPermissions &
+ FileAccessPermissions.UserExecute) !=
+ FileAccessPermissions.UserExecute) {
#if LOG4NET
- Logger.Error("Init(): error opening " + file, ex);
+ Logger.Debug("Init(): skipping non-executable file " + file);
#endif
- continue;
+ continue;
+ }
+ } else {
+ try {
+ File.OpenRead(file).Close();
+ } catch (Exception ex) {
+#if LOG4NET
+ Logger.Error("Init(): error opening " + file, ex);
+#endif
+ continue;
+ }
}
Hooks.Add(file);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]