From: "Erich E. Hoover" Subject: [PATCH 2/5] server: Create directories with the specified security attributes. Message-Id: Date: Thu, 1 Nov 2012 22:43:02 -0600 This patch sets the appropriate attributes for directories when security attributes are specified on the directory, which is needed to ensure that PlayReady's user-specific cache directory is created with the correct permissions (770) instead of global permissions (777). From 18a5066591591c6924fc0cb12d838c31d5097263 Mon Sep 17 00:00:00 2001 From: Erich Hoover Date: Thu, 1 Nov 2012 22:26:26 -0600 Subject: server: Create directories with the specified security attributes. --- server/fd.c | 2 +- server/file.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/server/fd.c b/server/fd.c index f3e42bd..248f15a 100644 --- a/server/fd.c +++ b/server/fd.c @@ -1765,7 +1765,7 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode, /* create the directory if needed */ if ((options & FILE_DIRECTORY_FILE) && (flags & O_CREAT)) { - if (mkdir( name, 0777 ) == -1) + if (mkdir( name, *mode ) == -1) { if (errno != EEXIST || (flags & O_EXCL)) { diff --git a/server/file.c b/server/file.c index 02a1e37..3a8c964 100644 --- a/server/file.c +++ b/server/file.c @@ -219,7 +219,12 @@ static struct object *create_file( struct fd *root, const char *nameptr, data_si mode = sd_to_mode( sd, owner ); } else - mode = (attrs & FILE_ATTRIBUTE_READONLY) ? 0444 : 0666; + { + if (options & FILE_NON_DIRECTORY_FILE) + mode = (attrs & FILE_ATTRIBUTE_READONLY) ? 0444 : 0666; + else + mode = (attrs & FILE_ATTRIBUTE_READONLY) ? 0555 : 0777; + } if (len >= 4 && (!strcasecmp( name + len - 4, ".exe" ) || !strcasecmp( name + len - 4, ".com" ))) -- 1.7.9.5