From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-apps@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH setup 2/2] Defer setting group until after All Users/Just For Me is chosen
Date: Tue, 12 Jul 2022 13:54:49 +0100 [thread overview]
Message-ID: <20220712125449.14050-3-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20220712125449.14050-1-jon.turney@dronecode.org.uk>
---
main.cc | 2 +-
root.cc | 5 +++++
win32.cc | 7 +------
win32.h | 2 +-
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/main.cc b/main.cc
index 3a8c5ea..1cc8a0c 100644
--- a/main.cc
+++ b/main.cc
@@ -359,7 +359,7 @@ WinMain (HINSTANCE h,
}
/* Set default DACL and Group. */
- nt_sec.setDefaultSecurity ((root_scope == IDC_ROOT_SYSTEM));
+ nt_sec.setDefaultSecurity ();
/*
If --symlink-type option isn't given, look for winsymlinks in CYGWIN
diff --git a/root.cc b/root.cc
index 1723a53..9f072d7 100644
--- a/root.cc
+++ b/root.cc
@@ -297,6 +297,11 @@ RootPage::OnNext ()
Log (LOG_PLAIN) << "root: " << get_root_dir ()
<< (root_scope == IDC_ROOT_USER ? " user" : " system") << endLog;
+ if (root_scope == IDC_ROOT_SYSTEM)
+ nt_sec.setAdminGroup ();
+ else
+ nt_sec.resetPrimaryGroup ();
+
return 0;
}
diff --git a/win32.cc b/win32.cc
index 62ae4eb..ea3d53a 100644
--- a/win32.cc
+++ b/win32.cc
@@ -308,7 +308,7 @@ NTSecurity::setAdminGroup ()
}
void
-NTSecurity::setDefaultSecurity (bool isAdmin)
+NTSecurity::setDefaultSecurity ()
{
/* Get the processes access token. */
if (!OpenProcessToken (GetCurrentProcess (),
@@ -358,11 +358,6 @@ NTSecurity::setDefaultSecurity (bool isAdmin)
primaryGroupSID.pgrp.PrimaryGroup = (PSID) NULL;
}
groupSID = primaryGroupSID.pgrp.PrimaryGroup;
- /* Try to set the primary group to the Administrators group, but only if
- "Install for all users" has been chosen. If it doesn't work, we're
- no admin and that's all there's to say about it. */
- if (isAdmin)
- setAdminGroup ();
}
bool
diff --git a/win32.h b/win32.h
index 02c1d06..bf3ff10 100644
--- a/win32.h
+++ b/win32.h
@@ -130,7 +130,7 @@ public:
void resetPrimaryGroup();
void setAdminGroup ();
void initialiseWellKnownSIDs ();
- void setDefaultSecurity(bool isAdmin);
+ void setDefaultSecurity ();
bool isRunAsAdmin ();
bool hasSymlinkCreationRights ();
private:
--
2.36.1
next prev parent reply other threads:[~2022-07-12 12:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-12 12:54 [PATCH setup 0/2] Simplify setting group ownership of installed files Jon Turney
2022-07-12 12:54 ` [PATCH setup 1/2] Drop group change while running postinstall scripts Jon Turney
2022-07-12 12:54 ` Jon Turney [this message]
2022-07-13 15:39 ` [PATCH setup 0/2] Simplify setting group ownership of installed files Christian Franke
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=20220712125449.14050-3-jon.turney@dronecode.org.uk \
--to=jon.turney@dronecode.org.uk \
--cc=cygwin-apps@cygwin.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).