From 0757c107eb8f44333404fcf715d50e80c618b388 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Fri, 2 Oct 2009 11:39:59 +0100
Subject: [PATCH] TryOSFromDisk: only check actual os scripts for +x

Currently all checked files in the loop are os scripts, so nothing will
change, but in the future we only want the +x bit on actual os scripts,
not necessarily all files.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Olivier Tharan <olive@google.com>
---
 lib/backend.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/backend.py b/lib/backend.py
index d263d1373..d3a4a54e1 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -1706,14 +1706,16 @@ def _TryOSFromDisk(name, base_dir=None):
       return False, ("File '%s' under path '%s' is missing (%s)" %
                      (name, os_dir, _ErrnoOrStr(err)))
 
-    if stat.S_IMODE(st.st_mode) & stat.S_IXUSR != stat.S_IXUSR:
-      return False, ("File '%s' under path '%s' is not executable" %
-                     (name, os_dir))
-
     if not stat.S_ISREG(stat.S_IFMT(st.st_mode)):
       return False, ("File '%s' under path '%s' is not a regular file" %
                      (name, os_dir))
 
+    if name in constants.OS_SCRIPTS:
+      if stat.S_IMODE(st.st_mode) & stat.S_IXUSR != stat.S_IXUSR:
+        return False, ("File '%s' under path '%s' is not executable" %
+                       (name, os_dir))
+
+
   os_obj = objects.OS(name=name, path=os_dir,
                       create_script=os_files[constants.OS_SCRIPT_CREATE],
                       export_script=os_files[constants.OS_SCRIPT_EXPORT],
-- 
GitLab