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]

Can't start bash after set*id


Hello, All!

I start my pogram (compiled with using cygwin1.dll) as a user 1000 from
"Administrators" group. When my program switches E*ID and RE*ID
to another user 1013 from Users group and then starts a bash (via execv())
with a script in a parameters, bash fails (Process1312, exception
C0000142 at 77FB17A4).
When my program switches E*ID and RE*ID to another user 500 from
Administrators group, bash works perfectly.
Why it may be?
A program behaviour is same and for using LSA module, and for password
authentication with cygwin_logon_user() and
cygwin_set_impersonation_token().

One important detail - after set*id, /usr/bin and /usr/lib disappear under
any switched user, and therefore I mount them in /etc/fstab with "override"
option:
======  /etc/fstab  ========
D:/cygwin / ntfs binary,override,auto
D:/cygwin/bin /usr/bin ntfs binary,override,auto
D:/cygwin/lib /usr/lib ntfs binary,override,auto
======================


Fragment of my testing code:

uid_t userID = 1013;
gid_t groupID = 545;
char *arg_list[] = { "D:/cygwin/bin/bash", "--login", "-c", "{
#!/bin/sh\n/cygdrive/E/writer.exe\n }", NULL };
child_pid = fork();
if(child_pid == 0) {
    setregid (groupID, -1);
    setregid (-1, groupID);
    setreuid(userID, -1);
    setreuid(-1, userID);
    execv(arg_list[0], arg_list);
    exit(0);
}


Here is fragment from strace output for abnormal work after switching to
user 1013 and "Users" group 545 ("bash entering ReadFile loop" and then
"Process 1312, exception C0000142 at 77FB17A4"):

  404     404 [main] bash 1312 child_copy: cygheap - hp 0x2B0 low 0x6120C6E0, high 0x6120EFF4, res 1
  172     576 [main] bash 1312 child_copy: done
  168     744 [main] bash 1312 open_shared: name shared.5, n 5, shared 0x60FC0000 (wanted 0x60FC0000), h 0x358
  106     850 [main] bash 1312 heap_init: heap base 0x680000, heap top 0x680000
   83     933 [main] bash 1312 open_shared: name (null), n 1, shared 0x60FD0000 (wanted 0x60FD0000), h 0x348
   73    1006 [main] bash 1312 user_shared_create: opening user shared for '' at 0x60FD0000
   72    1078 [main] bash 1312 user_shared_create: user shared version 2E710001
   94    1172 [main] bash (1312) open_shared: name (null), n 560, shared 0x60FF0000 (wanted 0x60FF0000), h 0x29C
  299    1471 [main] bash 560 **********************************************
   68    1539 [main] bash 560 Program name: D:\cygwin\bin\bash.exe (pid 560, ppid 992)
   66    1605 [main] bash 560 App version:  1007.1, api: 0.218
   65    1670 [main] bash 560 DLL version:  1007.1, api: 0.218
   65    1735 [main] bash 560 DLL build:    2009-12-07 11:48
   69    1804 [main] bash 560 OS version:   Windows NT-5.0
   64    1868 [main] bash 560 Heap size:    402653184
   64    1932 [main] bash 560 **********************************************
[...]
  210    7423 [main] bash 560 events_init: windows_system_directory 'C:\SBIN\system32\',
windows_system_directory_length 17
  114    7537 [main] bash 560 dll_crt0_0: finished dll_crt0_0 initialization
 1142    8679 [main] bash 560 _cygtls::remove: wait 0xFFFFFFFF
  161    8840 [main] bash 560 _cygtls::remove: removed 0x22CE64 element 0
  166    9006 [main] bash 560 _cygtls::remove: wait 0xFFFFFFFF
   80    9086 [main] bash 560 _cygtls::remove: removed 0x22CE64 element 0
  122    9208 [main] bash 560 _cygtls::remove: wait 0xFFFFFFFF
   74    9282 [main] bash 560 _cygtls::remove: removed 0x22CE64 element 0
  144    9426 [main] bash 560 _cygtls::remove: wait 0xFFFFFFFF
   77    9503 [main] bash 560 _cygtls::remove: removed 0x22CE64 element 0
 1750   11253 [sig] bash 560 wait_sig: entering ReadFile loop, my_readsig 0x32C, my_sendsig 0x324
--- Process 1312, exception C0000142 at 77FB17A4
72834  143553 [proc_waiter] sw 992 pinfo::maybe_set_exit_code_from_windows:
pid 560, exit value - old 0x0, windows 0x0, cygwin 0x8000000


And here is fragment from strace for normal work after switching to user 500
and "Administrators" group 544 ("bash entering ReadFile loop" and then
"_cygwin_istext_for_stdio: fd 0: opened as binary"):


  894     894 [main] bash 164 child_copy: cygheap - hp 0x2B0 low 0x6120C6E0, high 0x6120EFB4, res 1
  167    1061 [main] bash 164 child_copy: done
  165    1226 [main] bash 164 open_shared: name shared.5, n 5, shared 0x60FC0000 (wanted 0x60FC0000), h 0x358
   99    1325 [main] bash 164 heap_init: heap base 0x680000, heap top 0x680000
   81    1406 [main] bash 164 open_shared: name (null), n 1, shared 0x60FD0000 (wanted 0x60FD0000), h 0x348
   70    1476 [main] bash 164 user_shared_create: opening user shared for '' at 0x60FD0000
   69    1545 [main] bash 164 user_shared_create: user shared version 2E710001
   90    1635 [main] bash (164) open_shared: name (null), n 992, shared 0x60FF0000 (wanted 0x60FF0000), h 0x29C
  292    1927 [main] bash 992 **********************************************
   64    1991 [main] bash 992 Program name: D:\cygwin\bin\bash.exe (pid 992, ppid 1400)
   63    2054 [main] bash 992 App version:  1007.1, api: 0.218
  112    2166 [main] bash 992 DLL version:  1007.1, api: 0.218
   65    2231 [main] bash 992 DLL build:    2009-12-07 11:48
   66    2297 [main] bash 992 OS version:   Windows NT-5.0
   61    2358 [main] bash 992 Heap size:    402653184
   63    2421 [main] bash 992 **********************************************
[...]
  190    7913 [main] bash 992 events_init: windows_system_directory 'C:\SBIN\system32\',
windows_system_directory_length 17
  108    8021 [main] bash 992 dll_crt0_0: finished dll_crt0_0 initialization
  500    8521 [main] bash 992 _cygtls::remove: wait 0xFFFFFFFF
  124    8645 [main] bash 992 _cygtls::remove: removed 0x22CE64 element 0
  148    8793 [main] bash 992 _cygtls::remove: wait 0xFFFFFFFF
   74    8867 [main] bash 992 _cygtls::remove: removed 0x22CE64 element 0
  107    8974 [main] bash 992 _cygtls::remove: wait 0xFFFFFFFF
   70    9044 [main] bash 992 _cygtls::remove: removed 0x22CE64 element 0
  139    9183 [main] bash 992 _cygtls::remove: wait 0xFFFFFFFF
   72    9255 [main] bash 992 _cygtls::remove: removed 0x22CE64 element 0
 3563   12818 [main] bash 992 _cygtls::remove: wait 0xFFFFFFFF
  127   12945 [main] bash 992 _cygtls::remove: removed 0x22CE64 element 0
  292   13237 [sig] bash 992 wait_sig: entering ReadFile loop, my_readsig 0x31C, my_sendsig 0x318
  545   13782 [main] bash 992 _cygwin_istext_for_stdio: fd 0: opened as binary
   77   13859 [main] bash 992 _cygwin_istext_for_stdio: fd 1: opened as binary
  117   13976 [main] bash 992 _cygwin_istext_for_stdio: fd 2: opened as binary


Best regards,
Dmitry Sheremetev, Gomel, Belarus


--
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]