This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mktemp() fails on Wine 1.9.3 + Cygwin 2.5.0-0.2


Hi John,

This looks like a bug in wineserver.

Cygwin strace log show an access error soon after fhandler_base::open()

  [main] mktemp 111 fhandler_base::open:
(\??\C:\cygwin\tmp\tmp.kAEScb0yvo, 0x108A02)
  [main] mktemp 111 __set_errno: int aclsort32(int, int,
aclent_t*):1403 setting errno 22
  [main] mktemp 111 __set_errno: void* set_posix_access(mode_t, uid_t,
gid_t, aclent_t*, int, security_descriptor&, bool):269 setting errno
13

fhandler_base::open() is forwarded to NtCreateFile, but Wine
+relay,+server log show that NtCreateFile seems fine (please ignore
the difference of random file name):

0009:Call ntdll.NtCreateFile(0060c7d4,c0100000,0060c7e8,0060c7e0,00000000,00000080,00000007,00000002,00004020,00000000,00000000)
ret=6103a45d
0009:trace:ntdll:FILE_CreateFile handle=0x60c7d4 access=c0100000
name=L"\\??\\C:\\cygwin\\tmp\\tmp.BM21HIw0vU" objattr=00000042
root=(nil) sec=(nil) io=0x60c7e0 alloc_size=(nil) attr=00000080
sharing=00000007 disp=2 options=00004020 ea=(nil).0x00000000
0009:trace:file:wine_nt_to_unix_file_name
L"\\??\\C:\\cygwin\\tmp\\tmp.BM21HIw0vU" ->
"/media/workspace/wine-cygwin-1028/dosdevices/c:/cygwin/tmp/tmp.BM21HIw0vU"
0009: create_file( access=c0100000, sharing=00000007, create=2,
options=00004020, attrs=00000080,
objattr={rootdir=0000,attributes=00000042,sd={},name=L""},
filename="/media/workspace/wine-cygwin-1028/dosdevices/c:/cygwin/tmp/tmp.BM21HIw0vU"
)
0009: create_file() = 0 { handle=00f4 }
0009:Ret  ntdll.NtCreateFile() retval=00000000 ret=6103a45d

(looks identity to the good version of log, so I won't paste the good
version here)

In this case, comparing +relay,+server log between good case and bad
case doesn't expose enough information, so we might need to compare
Linux strace log from good case and bad case:

[pid 11724] write(2, 0xb7584000, 2440009: create_file(
access=c0100000, sharing=00000007, create=2, options=00004020,
attrs=00000080,
objattr={rootdir=0000,attributes=00000042,sd={},name=L""},
filename="/media/workspace/wine-cygwin-1028/dosdevices/c:/cygwin/tmp/tmp.2kmv323jLu"
)
 <unfinished ...>
[pid 11732] close(9 <unfinished ...>
[pid 11724] <... write resumed> )       = 244
[pid 11732] <... close resumed> )       = 0
[pid 11724] open(0xa3a0e90, O_RDONLY|O_NONBLOCK|O_LARGEFILE) = 107
[pid 11724] fstat64(107, {...})         = 0
[pid 11724] fgetxattr(107, 0x80a30e8, 0xbfe5dcec, 65536) = 314
[pid 11724] close(107)                  = 0
[pid 11724] open(0xa3a0e40,
O_RDWR|O_CREAT|O_EXCL|O_NONBLOCK|O_LARGEFILE, 0555 <unfinished ...>

By comparing to the good case, i found the above open syscall should
open the file as 0666 mode.

Related code below:

https://github.com/wine-compholio/wine-patched/blob/master/server/file.c#L408

226     if (sd)
227     {
228         const SID *owner = sd_get_owner( sd );
229         if (!owner)
230             owner = token_get_user( current->process->token );
231         mode = sd_to_mode( sd, owner );
232     }
233     else if (options & FILE_DIRECTORY_FILE)
234         mode = (attrs & FILE_ATTRIBUTE_READONLY) ? 0555 : 0777;
235     else
236         mode = (attrs & FILE_ATTRIBUTE_READONLY) ? 0444 : 0666;


I need to do more research in order to write test and figure out the
right way to fix this bug, my current guess is Wine's sd/token
emulation is not completed yet, which cause unexpected behavior.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]