server: Make sure that CreateFile overwrites existing file attributes. Take 2.
Dmitry Timoshkov
dmitry at codeweavers.com
Thu Mar 31 02:59:27 CDT 2011
---
dlls/advapi32/tests/security.c | 1 -
dlls/ntdll/tests/file.c | 10 +---------
server/fd.c | 5 ++++-
server/main.c | 7 +++++++
4 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 7040add..e15d02f 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -935,7 +935,6 @@ cleanup:
rc = GetFileAttributes(file);
rc &= ~FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
-todo_wine
ok(rc == (FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY),
"expected FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY got %#x\n", rc);
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index ac4ff19..602f835 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -1617,15 +1617,7 @@ static void test_NtCreateFile(void)
ret = GetFileAttributesW(path);
ret &= ~FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
- /* FIXME: leave only 'else' case below once Wine is fixed */
- if (ret != td[i].attrib_out)
- {
- todo_wine
- ok(ret == td[i].attrib_out, "%d: expected %#x got %#x\n", i, td[i].attrib_out, ret);
- SetFileAttributesW(path, td[i].attrib_out);
- }
- else
- ok(ret == td[i].attrib_out, "%d: expected %#x got %#x\n", i, td[i].attrib_out, ret);
+ ok(ret == td[i].attrib_out, "%d: expected %#x got %#x\n", i, td[i].attrib_out, ret);
CloseHandle(handle);
}
diff --git a/server/fd.c b/server/fd.c
index e0ec708..0fc5060 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -329,6 +329,7 @@ static const struct object_ops file_lock_ops =
#define FILE_POS_T_MAX (~(file_pos_t)0)
static file_pos_t max_unix_offset = OFF_T_MAX;
+mode_t FILE_umask = 0;
#define DUMP_LONG_LONG(val) do { \
if (sizeof(val) > sizeof(unsigned long) && (val) > ~0UL) \
@@ -1780,7 +1781,6 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
closed_fd->unix_fd = fd->unix_fd;
closed_fd->unlink[0] = 0;
fstat( fd->unix_fd, &st );
- *mode = st.st_mode;
/* only bother with an inode for normal files and directories */
if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode))
@@ -1829,6 +1829,8 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
return NULL;
}
ftruncate( fd->unix_fd, 0 );
+ fchmod( fd->unix_fd, *mode & (~FILE_umask) );
+ fstat( fd->unix_fd, &st );
}
}
else /* special file */
@@ -1846,6 +1848,7 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
free( closed_fd );
fd->cacheable = 1;
}
+ *mode = st.st_mode;
return fd;
error:
diff --git a/server/main.c b/server/main.c
index 2d841e8..77010db 100644
--- a/server/main.c
+++ b/server/main.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
+#include <sys/stat.h>
#include <unistd.h>
#ifdef HAVE_GETOPT_H
# include <getopt.h>
@@ -127,9 +128,15 @@ static void sigterm_handler( int signum )
int main( int argc, char *argv[] )
{
+ extern mode_t FILE_umask;
+
setvbuf( stderr, NULL, _IOLBF, 0 );
parse_args( argc, argv );
+ /* retrieve current umask */
+ FILE_umask = umask( 0777 );
+ umask( FILE_umask );
+
/* setup temporary handlers before the real signal initialization is done */
signal( SIGPIPE, SIG_IGN );
signal( SIGHUP, sigterm_handler );
--
1.7.4.1
More information about the wine-patches
mailing list