File: 10-open-mode.patch

package info (click to toggle)
dx 1%3A4.4.4-19
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 56,128 kB
  • sloc: ansic: 365,481; cpp: 156,584; sh: 10,872; java: 10,641; makefile: 2,294; javascript: 837; awk: 444; yacc: 327
file content (37 lines) | stat: -rw-r--r-- 1,714 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From: James Westby <james.westby@canonical.com>
Subject: Add mode argument to open() calls with O_CREAT.

diff -urNad dx-4.4.4~/src/exec/libdx/fileio.c dx-4.4.4/src/exec/libdx/fileio.c
--- dx-4.4.4~/src/exec/libdx/fileio.c	2006-01-05 22:55:47.000000000 +0000
+++ dx-4.4.4/src/exec/libdx/fileio.c	2009-01-17 17:06:51.000000000 +0000
@@ -263,7 +263,7 @@
 	case 2:/* read/write */
 		fd = open(name, O_RDWR);
 		if (fd < 0) {
-			fd = open(name, O_WRONLY | O_CREAT);
+			fd = open(name, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
 			if (fd < 0) {
 				DXSetError(ERROR_DATA_INVALID, 
 				"can't open/create file '%s'", name);
diff -urNad dx-4.4.4~/src/exec/libdx/plock.c dx-4.4.4/src/exec/libdx/plock.c
--- dx-4.4.4~/src/exec/libdx/plock.c	2002-07-17 05:48:18.000000000 +0100
+++ dx-4.4.4/src/exec/libdx/plock.c	2009-01-17 17:06:51.000000000 +0000
@@ -37,7 +37,8 @@
 
 #define SEM_FLAGS  	 (IPC_CREAT | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
 #define SHM_FLAGS  	 (IPC_CREAT | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
-#define OPEN_FLAGS 	 (O_CREAT | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
+#define OPEN_FLAGS 	 (O_CREAT)
+#define OPEN_MODE  (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
 #define IS_MINE(a)	 (locks->_owner[a] == getpid())
 #define SET_OWNER(a)	 (locks->_owner[a] = getpid())
 #define CLEAR_OWNER(a)	 (locks->_owner[a] = 0)
@@ -268,7 +269,7 @@
 
     if (stat(LOCKFILE, &statbuf))
     {
-        int fd = open(LOCKFILE, OPEN_FLAGS);
+        int fd = open(LOCKFILE, OPEN_FLAGS, OPEN_MODE);
 	if (fd < 0)
 	{
 	    fprintf(stderr, "initLocks: error accessing locks shared block: open\n");