From: Jason Tishler <Jason.Tishler@dothill.com>
To: DJ Delorie <dj@delorie.com>
Cc: cygwin@sourceware.cygnus.com
Subject: [PATCH]: setup.exe defaults install scope (was Re: mount points and inetd)
Date: Tue, 19 Sep 2000 11:50:00 -0000 [thread overview]
Message-ID: <20000919145000.B18108@DP> (raw)
In-Reply-To: <200009191417.KAA16418@envy.delorie.com>
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
next prev parent reply other threads:[~2000-09-19 11:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-09-16 23:56 mount points and inetd Chris Abbey
2000-09-16 23:59 ` Robert Collins
2000-09-17 1:06 ` Chris Abbey
2000-09-17 1:13 ` Robert Collins
2000-09-17 1:41 ` Chris Abbey
2000-09-18 13:11 ` DJ Delorie
2000-09-18 13:10 ` DJ Delorie
2000-09-18 21:11 ` Chris Abbey
2000-09-19 0:37 ` Andrej Borsenkow
2000-09-19 6:42 ` Jason Tishler
2000-09-19 7:17 ` DJ Delorie
2000-09-19 11:50 ` Jason Tishler [this message]
2000-09-19 14:18 ` Corinna Vinschen
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20000919145000.B18108@DP \
--to=jason.tishler@dothill.com \
--cc=cygwin@sourceware.cygnus.com \
--cc=dj@delorie.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).