public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: [PATCH]: setup.exe defaults install scope (was Re: mount points and inetd)
@ 2000-09-19 12:18 Earnie Boyd
  2000-09-19 12:55 ` Jason Tishler
  0 siblings, 1 reply; 3+ messages in thread
From: Earnie Boyd @ 2000-09-19 12:18 UTC (permalink / raw)
  To: Jason Tishler, DJ Delorie; +Cc: cygwin

--- Jason Tishler <Jason.Tishler@dothill.com> wrote:
-8<-
>  static void
>  read_mount_table ()
>  {
> @@ -83,7 +137,7 @@ read_mount_table ()
>        windir[2] = 0;
>        root_dir = concat (windir, "\\cygwin", 0);
>        root_text = IDC_ROOT_BINARY;
> -      root_scope = IDC_ROOT_USER;
> +      root_scope = (is_admin()) ? IDC_ROOT_SYSTEM : IDC_ROOT_USER;
>      }
>  }
>  

Of course you did test this patch, correct?  What happens if I with
administrator privileges have my mounts in IDC_ROOT_USER and not
IDC_ROOT_SYSTEM?  Shouldn't it default to what is already setup in the mount
tables?

Cheers,

=====
--- < http://earniesystems.safeshopper.com > ---
   Earnie Boyd: < mailto:earnie_boyd@yahoo.com >
            __Cygwin: POSIX on Windows__
Cygwin Newbies: < http://gw32.freeyellow.com/ >
           __Minimalist GNU for Windows__
    Mingw Home: < http://www.mingw.org/ >

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

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

* Re: [PATCH]: setup.exe defaults install scope (was Re: mount points and inetd)
  2000-09-19 12:18 [PATCH]: setup.exe defaults install scope (was Re: mount points and inetd) Earnie Boyd
@ 2000-09-19 12:55 ` Jason Tishler
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Tishler @ 2000-09-19 12:55 UTC (permalink / raw)
  To: Earnie Boyd; +Cc: cygwin

Earnie,

On Tue, Sep 19, 2000 at 12:18:00PM -0700, Earnie Boyd wrote:
> --- Jason Tishler <Jason.Tishler@dothill.com> wrote:
> -8<-
> >  static void
> >  read_mount_table ()
> >  {
> > @@ -83,7 +137,7 @@ read_mount_table ()
> >        windir[2] = 0;
> >        root_dir = concat (windir, "\\cygwin", 0);
> >        root_text = IDC_ROOT_BINARY;
> > -      root_scope = IDC_ROOT_USER;
> > +      root_scope = (is_admin()) ? IDC_ROOT_SYSTEM : IDC_ROOT_USER;
> >      }
> >  }
> >  
> 
> Of course you did test this patch, correct?

Yes.  I would not have submit it if I didn't.

> What happens if I with
> administrator privileges have my mounts in IDC_ROOT_USER and not
> IDC_ROOT_SYSTEM?  Shouldn't it default to what is already setup in the mount
> tables?

It does.  You were mislead into an erroneous conclusion due to the limited
context provided by the patch.  Try the following:

static void
read_mount_table ()
{
  int istext;
  int issystem;
  root_dir = find_root_mount (&istext, &issystem);
  if (root_dir)
    {
      if (istext)
        root_text = IDC_ROOT_TEXT;
      else
        root_text = IDC_ROOT_BINARY;
      if (issystem)
        root_scope = IDC_ROOT_SYSTEM;
      else
        root_scope = IDC_ROOT_USER;
    }
  else
    {
      char windir[_MAX_PATH];
      GetWindowsDirectory (windir, sizeof (windir));
      windir[2] = 0;
      root_dir = concat (windir, "\\cygwin", 0);
      root_text = IDC_ROOT_BINARY;
      root_scope = (is_admin()) ? IDC_ROOT_SYSTEM : IDC_ROOT_USER;
    }
}

Jason

-- 
Jason Tishler
Director, Software Engineering       Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corporation         Fax:   +1 (732) 264-8798
82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

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

* [PATCH]: setup.exe defaults install scope (was Re: mount points and inetd)
  2000-09-19  7:17         ` DJ Delorie
@ 2000-09-19 11:50           ` Jason Tishler
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Tishler @ 2000-09-19 11:50 UTC (permalink / raw)
  To: DJ Delorie; +Cc: cygwin

DJ,

On Tue, Sep 19, 2000 at 10:17:10AM -0400, DJ Delorie wrote:
> 
> > I can provide you with a "patch" (i.e., code snippets) that tests whether
> > or not the current user is a member of the Administrators group.  Is this
> > the kind of test for which you are looking?
> 
> Yes, but a patch against setup's cvs sources would be best.

OK, you shamed me into it.  If I remember correctly, you preferred inline...

ChangeLog:

Tue Sep 19 14:25:23 2000  Jason Tishler <jt@dothill.com>

    * root.cc (is_admin): New function.
    * root.cc (read_mount_table): Check for administrative priviledges and
    set installation scope as appropriate.

Patch:

Index: root.cc
===================================================================
RCS file: /cvs/src/src/winsup/cinstall/root.cc,v
retrieving revision 2.2
diff -u -p -r2.2 root.cc
--- root.cc	2000/09/07 03:09:30	2.2
+++ root.cc	2000/09/19 18:24:12
@@ -59,6 +59,60 @@ save_dialog (HWND h)
   root_dir = eget (h, IDC_ROOT_DIR, root_dir);
 }
 
+/*
+ * is_admin () determines whether or not the current user is a member of the
+ * Administrators group.  On Windows 9X, the current user is considered an
+ * Administrator by definition.
+ */
+
+static int
+is_admin ()
+{
+  // Windows 9X users are considered Administrators by definition
+  OSVERSIONINFO verinfo;
+  verinfo.dwOSVersionInfoSize = sizeof (verinfo);
+  GetVersionEx (&verinfo);
+  if (verinfo.dwPlatformId != VER_PLATFORM_WIN32_NT)
+    return 1;
+
+  // Get the process token for the current process
+  HANDLE token;
+  BOOL status = OpenProcessToken (GetCurrentProcess(), TOKEN_QUERY, &token);
+  if (!status)
+    return 0;
+
+  // 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;
+
+  // Create the Administrators group SID
+  PSID admin_sid;
+  SID_IDENTIFIER_AUTHORITY authority = SECURITY_NT_AUTHORITY;
+  status = AllocateAndInitializeSid (&authority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &admin_sid);
+  if (!status)
+    return 0;
+
+  // Check to see if the user is a member of the Administrators group
+  status = 0;
+  for (UINT i=0; i<groups->GroupCount; i++) {
+    if (EqualSid(groups->Groups[i].Sid, admin_sid)) {
+      status = 1;
+      break;
+    }
+  }
+
+  // Destroy the Administrators group SID
+  FreeSid (admin_sid);
+
+  // Return whether or not the user is a member of the Administrators group
+  return status;
+}
+
 static void
 read_mount_table ()
 {
@@ -83,7 +137,7 @@ read_mount_table ()
       windir[2] = 0;
       root_dir = concat (windir, "\\cygwin", 0);
       root_text = IDC_ROOT_BINARY;
-      root_scope = IDC_ROOT_USER;
+      root_scope = (is_admin()) ? IDC_ROOT_SYSTEM : IDC_ROOT_USER;
     }
 }
 
Jason

-- 
Jason Tishler
Director, Software Engineering       Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corporation         Fax:   +1 (732) 264-8798
82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

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

end of thread, other threads:[~2000-09-19 12:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-19 12:18 [PATCH]: setup.exe defaults install scope (was Re: mount points and inetd) Earnie Boyd
2000-09-19 12:55 ` Jason Tishler
  -- strict thread matches above, loose matches on Subject: below --
2000-09-16 23:56 mount points and inetd Chris Abbey
2000-09-17  1:06 ` Chris Abbey
2000-09-17  1:13   ` Robert Collins
2000-09-18 13:10     ` DJ Delorie
2000-09-19  6:42       ` Jason Tishler
2000-09-19  7:17         ` DJ Delorie
2000-09-19 11:50           ` [PATCH]: setup.exe defaults install scope (was Re: mount points and inetd) Jason Tishler

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).