public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* setup-1.7 defaults to "Just me"
@ 2008-04-15 13:34 Corinna Vinschen
  2008-04-16  4:53 ` Brian Dessent
  0 siblings, 1 reply; 12+ messages in thread
From: Corinna Vinschen @ 2008-04-15 13:34 UTC (permalink / raw)
  To: cygwin-apps

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: setup-1.7 defaults to "Just me"
  2008-04-15 13:34 setup-1.7 defaults to "Just me" Corinna Vinschen
@ 2008-04-16  4:53 ` Brian Dessent
  2008-04-16  8:51   ` Corinna Vinschen
  0 siblings, 1 reply; 12+ messages in thread
From: Brian Dessent @ 2008-04-16  4:53 UTC (permalink / raw)
  To: cygwin-apps

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: setup-1.7 defaults to "Just me"
  2008-04-16  4:53 ` Brian Dessent
@ 2008-04-16  8:51   ` Corinna Vinschen
  2008-04-16  9:10     ` Brian Dessent
  0 siblings, 1 reply; 12+ messages in thread
From: Corinna Vinschen @ 2008-04-16  8:51 UTC (permalink / raw)
  To: cygwin-apps

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: setup-1.7 defaults to "Just me"
  2008-04-16  8:51   ` Corinna Vinschen
@ 2008-04-16  9:10     ` Brian Dessent
  2008-04-16  9:28       ` Corinna Vinschen
  0 siblings, 1 reply; 12+ messages in thread
From: Brian Dessent @ 2008-04-16  9:10 UTC (permalink / raw)
  To: cygwin-apps

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: setup-1.7 defaults to "Just me"
  2008-04-16  9:10     ` Brian Dessent
@ 2008-04-16  9:28       ` Corinna Vinschen
  2008-04-16  9:37         ` Corinna Vinschen
  2008-04-16  9:39         ` Brian Dessent
  0 siblings, 2 replies; 12+ messages in thread
From: Corinna Vinschen @ 2008-04-16  9:28 UTC (permalink / raw)
  To: cygwin-apps

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: setup-1.7 defaults to "Just me"
  2008-04-16  9:28       ` Corinna Vinschen
@ 2008-04-16  9:37         ` Corinna Vinschen
  2008-04-16  9:49           ` Brian Dessent
  2008-04-16  9:39         ` Brian Dessent
  1 sibling, 1 reply; 12+ messages in thread
From: Corinna Vinschen @ 2008-04-16  9:37 UTC (permalink / raw)
  To: cygwin-apps

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: setup-1.7 defaults to "Just me"
  2008-04-16  9:28       ` Corinna Vinschen
  2008-04-16  9:37         ` Corinna Vinschen
@ 2008-04-16  9:39         ` Brian Dessent
  2008-04-16  9:48           ` Corinna Vinschen
  2008-04-16  9:50           ` Corinna Vinschen
  1 sibling, 2 replies; 12+ messages in thread
From: Brian Dessent @ 2008-04-16  9:39 UTC (permalink / raw)
  To: cygwin-apps

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: setup-1.7 defaults to "Just me"
  2008-04-16  9:39         ` Brian Dessent
@ 2008-04-16  9:48           ` Corinna Vinschen
  2008-04-16  9:50           ` Corinna Vinschen
  1 sibling, 0 replies; 12+ messages in thread
From: Corinna Vinschen @ 2008-04-16  9:48 UTC (permalink / raw)
  To: cygwin-apps

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: setup-1.7 defaults to "Just me"
  2008-04-16  9:37         ` Corinna Vinschen
@ 2008-04-16  9:49           ` Brian Dessent
  2008-04-16 10:03             ` Corinna Vinschen
  2008-04-16 16:25             ` Christopher Faylor
  0 siblings, 2 replies; 12+ messages in thread
From: Brian Dessent @ 2008-04-16  9:49 UTC (permalink / raw)
  To: cygwin-apps

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: setup-1.7 defaults to "Just me"
  2008-04-16  9:39         ` Brian Dessent
  2008-04-16  9:48           ` Corinna Vinschen
@ 2008-04-16  9:50           ` Corinna Vinschen
  1 sibling, 0 replies; 12+ messages in thread
From: Corinna Vinschen @ 2008-04-16  9:50 UTC (permalink / raw)
  To: cygwin-apps

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: setup-1.7 defaults to "Just me"
  2008-04-16  9:49           ` Brian Dessent
@ 2008-04-16 10:03             ` Corinna Vinschen
  2008-04-16 16:25             ` Christopher Faylor
  1 sibling, 0 replies; 12+ messages in thread
From: Corinna Vinschen @ 2008-04-16 10:03 UTC (permalink / raw)
  To: cygwin-apps

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: setup-1.7 defaults to "Just me"
  2008-04-16  9:49           ` Brian Dessent
  2008-04-16 10:03             ` Corinna Vinschen
@ 2008-04-16 16:25             ` Christopher Faylor
  1 sibling, 0 replies; 12+ messages in thread
From: Christopher Faylor @ 2008-04-16 16:25 UTC (permalink / raw)
  To: cygwin-apps

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-04-16 16:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-15 13:34 setup-1.7 defaults to "Just me" Corinna Vinschen
2008-04-16  4:53 ` Brian Dessent
2008-04-16  8:51   ` Corinna Vinschen
2008-04-16  9:10     ` Brian Dessent
2008-04-16  9:28       ` Corinna Vinschen
2008-04-16  9:37         ` Corinna Vinschen
2008-04-16  9:49           ` Brian Dessent
2008-04-16 10:03             ` Corinna Vinschen
2008-04-16 16:25             ` Christopher Faylor
2008-04-16  9:39         ` Brian Dessent
2008-04-16  9:48           ` Corinna Vinschen
2008-04-16  9:50           ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).