Re: setup-1.7 defaults to Just me
On Apr 15 21:55, Brian Dessent wrote: Corinna Vinschen wrote: I just found that, regardless of my privileges, setup-1.7 defaults to install for just me instead of all users while the standard setup defaults to all users. Why does that happen? This is very odd. Setup's is_admin() was returning 0 despite the user belonging to the administrators group, and debugging revealed that the cause was the following: // Get the group token information UCHAR token_info[1024]; PTOKEN_GROUPS groups = (PTOKEN_GROUPS) token_info; DWORD token_info_len = sizeof (token_info); status = GetTokenInformation (token, TokenGroups, token_info, token_info_len, token_info_len); CloseHandle (token); if (!status) return 0; For whatever reason, GetTokenInformation was failing and returning ERROR_NOACCESS when passed a 1024 byte buffer. I changed the code to first call it with NULL to get the desired size, and that seems to have satisfied it. I cannot explain why it would object to a 1024 byte buffer, maybe you have some idea. Not really, no. 1024 bytes should be big enough in most cases. Did you look for the desired size which now gets returned by the NULL call? I'll install an updated setup-1.7.exe in a moment. Thanks, Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat
Re: setup-1.7 defaults to Just me
Corinna Vinschen wrote: Not really, no. 1024 bytes should be big enough in most cases. Did you look for the desired size which now gets returned by the NULL call? Yes, it was in the neighborhood of 230 bytes or so. It wasn't that the buffer was too small, and I would have expected ERROR_INSUFFICIENT_BUFFER anyway in that case. It was just something about the buffer that it didn't like. Brian
Re: setup-1.7 defaults to Just me
On Apr 16 02:12, Brian Dessent wrote: Corinna Vinschen wrote: Not really, no. 1024 bytes should be big enough in most cases. Did you look for the desired size which now gets returned by the NULL call? Yes, it was in the neighborhood of 230 bytes or so. It wasn't that the buffer was too small, and I would have expected ERROR_INSUFFICIENT_BUFFER anyway in that case. It was just something about the buffer that it didn't like. Alignment? Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat
Re: setup-1.7 defaults to Just me
On Apr 16 11:28, Corinna Vinschen wrote: On Apr 16 02:12, Brian Dessent wrote: Corinna Vinschen wrote: Not really, no. 1024 bytes should be big enough in most cases. Did you look for the desired size which now gets returned by the NULL call? Yes, it was in the neighborhood of 230 bytes or so. It wasn't that the buffer was too small, and I would have expected ERROR_INSUFFICIENT_BUFFER anyway in that case. It was just something about the buffer that it didn't like. Alignment? I mean, token_info was an UCHAR array, so it's not aligned while the token_group information might require a 4 or 8 byte alignment which you now get by chance. Probably you'd be better off not using `char buf[size]' but PTOKEN_GROUPS groups = (PTOKEN_GROUPS) alloca (size); instead because alloca always aligns sufficiently. What sounds strange here is that MSDN does not state anything about alignment requirements for the GetTokenInformation call. However, it also didn't say anything about alignment requirements of ZwQueryDirectoryFile but it failed on W2K for that reason nevertheless. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat
Re: setup-1.7 defaults to Just me
On Apr 16 02:45, Brian Dessent wrote: Corinna Vinschen wrote: Alignment? Perhaps. Do you know if gcc aligns VLAs higher than their natural alignment? The nonworking code was just UCHAR foo[1024] whereas the working was char buf[size], which I cribbed from grp.cc:internal_getgroups(). Maybe such a dynamic stack allocation like `char buf[size]' uses an alloca-like function under the hood which also always aligns sufficently for all datatypes. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat
Re: setup-1.7 defaults to Just me
Corinna Vinschen wrote: Alignment? Perhaps. Do you know if gcc aligns VLAs higher than their natural alignment? The nonworking code was just UCHAR foo[1024] whereas the working was char buf[size], which I cribbed from grp.cc:internal_getgroups(). Brian
Re: setup-1.7 defaults to Just me
On Apr 16 02:49, Brian Dessent wrote: Don't you love discovering these little pearls of joy inside the Win32 API? They're like little rays of sunshine. No wait, the opposite. Big rays of moonshine? ;) Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat
Re: setup-1.7 defaults to Just me
Corinna Vinschen wrote: I mean, token_info was an UCHAR array, so it's not aligned while the token_group information might require a 4 or 8 byte alignment which you now get by chance. Probably you'd be better off not using `char buf[size]' but PTOKEN_GROUPS groups = (PTOKEN_GROUPS) alloca (size); Interesting: #include stdio.h #include malloc.h int main (int argc, char **argv) { char vla[argc * 250]; char *alloca_array = (char *) alloca (argc * 250); char normal_array[1024]; printf (alignof(vla) = %d\n, __alignof__ (vla)); printf (alignof(alloca_array) = %d\n, __alignof__ (alloca_array)); printf (alignof(normal_array) = %d\n, __alignof__ (normal_array)); return 0; } Returns: alignof(vla) = 1 alignof(alloca_array) = 4 alignof(normal_array) = 1 So, perhaps this is working now by accident? for the GetTokenInformation call. However, it also didn't say anything about alignment requirements of ZwQueryDirectoryFile but it failed on W2K for that reason nevertheless. Don't you love discovering these little pearls of joy inside the Win32 API? They're like little rays of sunshine. No wait, the opposite. Brian
Re: setup-1.7 defaults to Just me
On Apr 16 02:45, Brian Dessent wrote: Corinna Vinschen wrote: Alignment? Perhaps. Do you know if gcc aligns VLAs higher than their natural alignment? The nonworking code was just UCHAR foo[1024] whereas the working was char buf[size], which I cribbed from grp.cc:internal_getgroups(). Oh well, I suspected that I did that as well. As I said in the other reply, I never saw any alignment requirements for GetTokenInformation before. I just don't see any other potential reason for the ERROR_NOACCESS in this case. I'll fix that in grp.cc, too. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat
Re: setup-1.7 defaults to Just me
On Wed, Apr 16, 2008 at 02:49:33AM -0700, Brian Dessent wrote: Don't you love discovering these little pearls of joy inside the Win32 API? They're like little rays of sunshine. No wait, the opposite. Windoze rulez! cgf
setup-1.7 defaults to Just me
Brian, I just found that, regardless of my privileges, setup-1.7 defaults to install for just me instead of all users while the standard setup defaults to all users. Why does that happen? Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat
Re: setup-1.7 defaults to Just me
Corinna Vinschen wrote: I just found that, regardless of my privileges, setup-1.7 defaults to install for just me instead of all users while the standard setup defaults to all users. Why does that happen? This is very odd. Setup's is_admin() was returning 0 despite the user belonging to the administrators group, and debugging revealed that the cause was the following: // Get the group token information UCHAR token_info[1024]; PTOKEN_GROUPS groups = (PTOKEN_GROUPS) token_info; DWORD token_info_len = sizeof (token_info); status = GetTokenInformation (token, TokenGroups, token_info, token_info_len, token_info_len); CloseHandle (token); if (!status) return 0; For whatever reason, GetTokenInformation was failing and returning ERROR_NOACCESS when passed a 1024 byte buffer. I changed the code to first call it with NULL to get the desired size, and that seems to have satisfied it. I cannot explain why it would object to a 1024 byte buffer, maybe you have some idea. I'll install an updated setup-1.7.exe in a moment. Brian