comparison common/portpath.c @ 1070:f110a3f6e387

(issue114) Fine tune ACL propagation using mkdir_p the ACL of the parent directories would propagate to all subdirectories and objects in the directory. Now we only use ACL propagation in the last directory to make sure that files we might create in that directory inherit the correct (resitricted) ACL
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 10 Sep 2014 16:41:36 +0200
parents 66f6361fba1b
children fd7d04bb37cb
comparison
equal deleted inserted replaced
1069:709a7633a2c6 1070:f110a3f6e387
6 * See LICENSE.txt for details. 6 * See LICENSE.txt for details.
7 */ 7 */
8 #include "portpath.h" 8 #include "portpath.h"
9 #include "strhelp.h" 9 #include "strhelp.h"
10 #include "util.h" 10 #include "util.h"
11 #include "logging.h"
11 12
12 #include <libgen.h> 13 #include <libgen.h>
13 #include <limits.h> 14 #include <limits.h>
14 #include <stdio.h> 15 #include <stdio.h>
15 #include <stdlib.h> 16 #include <stdlib.h>
37 return path; 38 return path;
38 #endif 39 #endif
39 } 40 }
40 41
41 bool 42 bool
42 port_mkdir(const char *path) 43 port_mkdir(const char *path, bool propagate_acl)
43 { 44 {
44 #ifndef _WIN32 45 #ifndef _WIN32
46 if (propagate_acl)
47 {
48 DEBUGPRINTF("WARNING: ACL propagation only has an effect on Windows.\n");
49 }
45 return mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0; 50 return mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0;
46 #else 51 #else
47 wchar_t *wchar_path = utf8_to_wchar(path, strlen(path)); 52 wchar_t *wchar_path = utf8_to_wchar(path, strlen(path));
48 bool ret; 53 bool ret;
49 54
50 if (!wchar_path) 55 if (!wchar_path)
51 { 56 {
52 return false; 57 return false;
53 } 58 }
54 ret = create_restricted_directory (wchar_path); 59 ret = create_restricted_directory (wchar_path, propagate_acl);
55 xfree (wchar_path); 60 xfree (wchar_path);
56 return ret; 61 return ret;
57 #endif 62 #endif
58 } 63 }
59 64
88 else 93 else
89 return false; 94 return false;
90 } 95 }
91 96
92 bool 97 bool
93 port_mkdir_p(const char *path) 98 port_mkdir_p(const char *path, bool propagate_acl)
94 { 99 {
95 char *parent_path, 100 char *parent_path,
96 *p; 101 *p;
97 if (!path) { 102 if (!path) {
98 return false; 103 return false;
111 return false; 116 return false;
112 } 117 }
113 *p = '\0'; 118 *p = '\0';
114 if (!port_isdir(parent_path)) 119 if (!port_isdir(parent_path))
115 { 120 {
116 port_mkdir_p(parent_path); 121 port_mkdir_p(parent_path, false);
117 } 122 }
118 return port_mkdir(path); 123 return port_mkdir(path, propagate_acl);
119 } 124 }
120 125
121 bool 126 bool
122 port_isdir(const char *path) 127 port_isdir(const char *path)
123 { 128 {

http://wald.intevation.org/projects/trustbridge/