Skip to contentSkip to conversation

Do not set execute permission on qemu-dm log file

PATCH In review Daniel Kiper 2 participants 3 messages Mar 26, 2010 – Apr 7, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Do not set execute permission on qemu-dm log file

Hi,

Patch for xen-3.4-testing/xen-unstable which do not allow to set execute permission on qemu-dm log file.

# HG changeset patch
# User [email protected]
# Date 1269611494 -3600
# Node ID 12a8db7dfdc2e589bce509069cb2ff1951bf68d5 # Parent 5b43b64a40f92b59e765c874289ed5af4d4155fe Do not set execute permission on qemu-dm log file.

tools/python/xen/xend/image.py +1 -1
diff -r 5b43b64a40f9 -r 12a8db7dfdc2 tools/python/xen/xend/image.py
@@ -411,7 +411,7 @@ class ImageHandler:
                 os.rename(self.logfile, self.logfile + ".1")
 
         null = os.open("/dev/null", os.O_RDONLY)
-        logfd = os.open(self.logfile, logfile_mode)
+        logfd = os.open(self.logfile, logfile_mode, 0666)
         
         sys.stderr.flush()
         contract = osdep.prefork("%s:%d" %

# HG changeset patch
# User [email protected]
# Date 1269611880 -3600
# Node ID c51208d7795fbfd6e198b63db5373aae0c9c5743 # Parent 21d7095162da9976dad39ab1473cacd37959e070 Do not set execute permission on qemu-dm log file.

tools/python/xen/xend/image.py +1 -1
diff -r 21d7095162da -r c51208d7795f tools/python/xen/xend/image.py
@@ -435,7 +435,7 @@ class ImageHandler:
                 os.rename(self.logfile, self.logfile + ".1")
 
         null = os.open("/dev/null", os.O_RDONLY)
-        logfd = os.open(self.logfile, logfile_mode)
+        logfd = os.open(self.logfile, logfile_mode, 0666)
         
         sys.stderr.flush()
         contract = osdep.prefork("%s:%d" %

Daniel

# HG changeset patch
# User [email protected]
# Date 1269611494 -3600
# Node ID 12a8db7dfdc2e589bce509069cb2ff1951bf68d5 # Parent 5b43b64a40f92b59e765c874289ed5af4d4155fe Do not set execute permission on qemu-dm log file.

tools/python/xen/xend/image.py +1 -1
diff -r 5b43b64a40f9 -r 12a8db7dfdc2 tools/python/xen/xend/image.py
@@ -411,7 +411,7 @@ class ImageHandler:
                 os.rename(self.logfile, self.logfile + ".1")
 
         null = os.open("/dev/null", os.O_RDONLY)
-        logfd = os.open(self.logfile, logfile_mode)
+        logfd = os.open(self.logfile, logfile_mode, 0666)
         
         sys.stderr.flush()
         contract = osdep.prefork("%s:%d" %

# HG changeset patch
# User [email protected]
# Date 1269611880 -3600
# Node ID c51208d7795fbfd6e198b63db5373aae0c9c5743 # Parent 21d7095162da9976dad39ab1473cacd37959e070 Do not set execute permission on qemu-dm log file.

tools/python/xen/xend/image.py +1 -1
diff -r 21d7095162da -r c51208d7795f tools/python/xen/xend/image.py
@@ -435,7 +435,7 @@ class ImageHandler:
                 os.rename(self.logfile, self.logfile + ".1")
 
         null = os.open("/dev/null", os.O_RDONLY)
-        logfd = os.open(self.logfile, logfile_mode)
+        logfd = os.open(self.logfile, logfile_mode, 0666)
         
         sys.stderr.flush()
         contract = osdep.prefork("%s:%d" %

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Acked-by on v1 1/1
#1 lore raw

Daniel Kiper writes ("[Xen-devel] [PATCH] Do not set execute permission on qemu-dm log file"):

Quoted 2 lines

Patch for xen-3.4-testing/xen-unstable which do not allow to set execute permission on qemu-dm log file.

You might want to grep the rest of the code for similar uses of os.open. The choice of 0777 as the default mode is ... surprising.

IMO this should be backported to 3.4 and to the 4.0 tree (but only after the 4.0 release).

Ian.

#2 lore raw

Hi,

Quoted 2 lines

You might want to grep the rest of the code
for similar uses of os.open.

Fast search: grep -r os\\.open . | grep -v O_RDONLY | wc -l
Occurences: 32 (one of them is invalid)

For the first sight it looks not bed because most of the opens with !O_RDONLY are for files on sysfs/proc filesystem. However I think it should be verified (it is a piece of cake).

Additionally, I think that also C code should be checked, however it require a bit more work.

If you are interested in that I could do that.

Quoted 1 line

The choice of 0777 as the default mode is ... surprising.

man 2 open:
"mode must be specified when O_CREAT is in the flags, and is ignored otherwise"

I think that:

os.open(pathname, flags) is
int open(const char *pathname, int flags) and

os.open(pathname, flags, mode) is
int open(const char *pathname, int flags, mode_t mode)

fcntl.h:
extern int open (__const char *__file, int __oflag, ...)
Here is reply ^^^

If flags/__oflag contains O_CREAT and two argument open is used then invalid mode is taken from the stack and then modified by umask.

If I am wrong please correct me.

Daniel Kiper