[setup - the official Cygwin setup program] branch master, updated. release_2.920-5-g495b0148

Jon TURNEY jturney@sourceware.org
Tue Aug 16 14:30:14 GMT 2022




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=495b0148b29d30a0b52f0fbc240ff9648af80516

commit 495b0148b29d30a0b52f0fbc240ff9648af80516
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Fri Jul 8 16:46:14 2022 +0100

    Defer setting group until after All Users/Just For Me is chosen

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=45d8e84e692ebdda636fc84733ae9fca9ca4bf5c

commit 45d8e84e692ebdda636fc84733ae9fca9ca4bf5c
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Fri Jul 8 15:56:59 2022 +0100

    Drop group change while running postinstall scripts
    
    Drop group change while running postinstall scripts.  This was only for
    the benefit of mkgroup/mkpasswd being run by the postinstall script,
    which we don't do any more.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=82e62d6d8f9dcb9ba2a34da0e4437b29402951f7

commit 82e62d6d8f9dcb9ba2a34da0e4437b29402951f7
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Sun Aug 14 17:00:29 2022 +0100

    Update bootstrap.sh
    
    Prefer x64 toolchain, if available
    Don't use x86 MinGW.org toolchain (no longer distributed in cygwin since 2016)


Diff:
---
 bootstrap.sh   |  6 ++----
 main.cc        |  2 +-
 postinstall.cc | 13 -------------
 root.cc        |  5 +++++
 win32.cc       | 13 ++-----------
 win32.h        |  2 +-
 6 files changed, 11 insertions(+), 30 deletions(-)

diff --git a/bootstrap.sh b/bootstrap.sh
index 6dcd0ed3..b5bf87be 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -28,12 +28,10 @@ fi
 
 if [[ "$1" =~ "--host=" ]]; then
 	host="${1#--host=}"
-elif hash i686-w64-mingw32-g++ 2> /dev/null; then
-	host="i686-w64-mingw32"
-elif hash i686-pc-mingw32-g++ 2> /dev/null; then
-	host="i686-pc-mingw32"
 elif hash x86_64-w64-mingw32-g++ 2> /dev/null; then
 	host="x86_64-w64-mingw32"
+elif hash i686-w64-mingw32-g++ 2> /dev/null; then
+	host="i686-w64-mingw32"
 else
 	echo "mingw32 or mingw64 target g++ required for building setup"
 	exit 1
diff --git a/main.cc b/main.cc
index 3a8c5ea5..1cc8a0c1 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/postinstall.cc b/postinstall.cc
index e990f520..32bc401b 100644
--- a/postinstall.cc
+++ b/postinstall.cc
@@ -249,11 +249,6 @@ do_postinstall_reflector (void *p)
     // Tell the postinstall results page the results string
     PostInstallResults.SetResultsString(s);
 
-    /* Revert primary group to admins group.  This allows to create all the
-       state files written by setup as admin group owned. */
-    if (root_scope == IDC_ROOT_SYSTEM)
-      nt_sec.setAdminGroup ();
-
     // Tell the progress page that we're done running scripts
     Progress.PostMessageNow (WM_APP_POSTINSTALL_THREAD_COMPLETE, 0,
                           s.empty() ? IDD_DESKTOP : IDD_POSTINSTALL);
@@ -268,14 +263,6 @@ static HANDLE context[2];
 void
 do_postinstall (HINSTANCE h, HWND owner)
 {
-  /* Switch back to original primary group.  Otherwise we end up with a
-     broken passwd entry for the current user.
-     FIXME: Unfortunately this has the unfortunate side-effect that *all*
-     files created via postinstall are group owned by the original primary
-     group of the user.  Find a way to avoid this at one point. */
-  if (root_scope == IDC_ROOT_SYSTEM)
-    nt_sec.resetPrimaryGroup ();
-
   context[0] = h;
   context[1] = owner;
 
diff --git a/root.cc b/root.cc
index 1723a532..9f072d7a 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 55072a90..ea3d53af 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 (),
@@ -350,11 +350,7 @@ NTSecurity::setDefaultSecurity (bool isAdmin)
       NoteFailedAPI ("SetTokenInformation(owner)");
       return;
     }
-  /* Get original primary group.  The token's primary group will be reset
-     to the original group right before we call the postinstall scripts.
-     This is necessary, otherwise, if the installing user is a domain user,
-     the group information created by the postinstall calls to `mkpasswd -c,
-     mkgroup -c' will be plain wrong. */
+  /* Get original primary group */
   if (!GetTokenInformation (token.theHANDLE (), TokenPrimaryGroup,
 			    &primaryGroupSID, sizeof primaryGroupSID, &size))
     {
@@ -362,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 02c1d06e..bf3ff101 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:



More information about the Cygwin-apps-cvs mailing list