From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sa-prd-fep-045.btinternet.com (mailomta2-sa.btinternet.com [213.120.69.8]) by sourceware.org (Postfix) with ESMTPS id 16BEB385800B for ; Tue, 12 Jul 2022 12:55:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 16BEB385800B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dronecode.org.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=dronecode.org.uk Received: from sa-prd-rgout-001.btmx-prd.synchronoss.net ([10.2.38.4]) by sa-prd-fep-045.btinternet.com with ESMTP id <20220712125507.QQAD16833.sa-prd-fep-045.btinternet.com@sa-prd-rgout-001.btmx-prd.synchronoss.net>; Tue, 12 Jul 2022 13:55:07 +0100 Authentication-Results: btinternet.com; none X-SNCR-Rigid: 613006A930AA1B33 X-Originating-IP: [86.144.41.14] X-OWM-Source-IP: 86.144.41.14 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-VadeSecure-score: verdict=clean score=0/300, class=clean X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvfedrudejhedggeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuueftkffvkffujffvgffngfevqffopdfqfgfvnecuuegrihhlohhuthemuceftddunecunecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheplfhonhcuvfhurhhnvgihuceojhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukheqnecuggftrfgrthhtvghrnhepleeitdejhfdtveekheeugeffgeevfedtjeejveefhfeiffefkedtvdetheehieejnecukfhppeekiedrudeggedrgedurddugeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhephhgvlhhopehlohgtrghlhhhoshhtrdhlohgtrghlughomhgrihhnpdhinhgvthepkeeirddugeegrdeguddrudegpdhmrghilhhfrhhomhepjhhonhdrthhurhhnvgihsegurhhonhgvtghouggvrdhorhhgrdhukhdpnhgspghrtghpthhtohepvddprhgtphhtthhopegthihgfihinhdqrghpphhssegthihgfihinhdrtghomhdprhgtphhtthhopehjohhnrdhtuhhrnhgvhiesughrohhnvggtohguvgdrohhrghdruhhk X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from localhost.localdomain (86.144.41.14) by sa-prd-rgout-001.btmx-prd.synchronoss.net (5.8.716.04) (authenticated as jonturney@btinternet.com) id 613006A930AA1B33; Tue, 12 Jul 2022 13:55:07 +0100 From: Jon Turney To: cygwin-apps@cygwin.com Cc: Jon Turney 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 Message-Id: <20220712125449.14050-3-jon.turney@dronecode.org.uk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220712125449.14050-1-jon.turney@dronecode.org.uk> References: <20220712125449.14050-1-jon.turney@dronecode.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1200.3 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin-apps@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin package maintainer discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jul 2022 12:55:09 -0000 --- 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