From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout03.t-online.de (mailout03.t-online.de [194.25.134.81]) by sourceware.org (Postfix) with ESMTPS id 2B8FC3858403 for ; Fri, 26 Aug 2022 15:02:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2B8FC3858403 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=t-online.de Received: from fwd79.dcpf.telekom.de (fwd79.aul.t-online.de [10.223.144.105]) by mailout03.t-online.de (Postfix) with SMTP id 970355FC; Fri, 26 Aug 2022 17:02:38 +0200 (CEST) Received: from [192.168.2.101] ([79.230.170.147]) by fwd79.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1oRaqy-1DHpCa0; Fri, 26 Aug 2022 17:02:36 +0200 Subject: Re: [PATCH setup] Add new option --chown-admin To: Jon Turney , "cygwin-apps@cygwin.com" References: <3096f251-d7ca-073b-d7d7-751b7fe3e8c1@t-online.de> <405df5c6-ce47-0254-ae4d-4a23ff3533d5@dronecode.org.uk> <5b45ccdc-da32-ff11-037f-c00828f397c5@dronecode.org.uk> <32655945-5075-0823-2a1d-b72caa4b7791@t-online.de> <038c3558-b424-3e4b-9de6-bd3eb6147406@t-online.de> <80661301-d584-3af0-e588-1ec10f3b4108@dronecode.org.uk> From: Christian Franke Message-ID: <9f1a7088-4f4f-999b-3076-be347477c969@t-online.de> Date: Fri, 26 Aug 2022 17:02:35 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 SeaMonkey/2.53.12 MIME-Version: 1.0 In-Reply-To: <80661301-d584-3af0-e588-1ec10f3b4108@dronecode.org.uk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TOI-EXPURGATEID: 150726::1661526156-014551EF-EF7D60C2/0/0 CLEAN NORMAL X-TOI-MSGID: ffe06764-1b7c-480c-950a-e11b7b38058b X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,BODY_8BITS,FREEMAIL_FROM,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Jon Turney wrote: > On 23/08/2022 18:27, Christian Franke wrote: >> Jon Turney wrote: >>> On 12/07/2022 13:50, Jon Turney wrote: >>>> [Replying to the right list this time...] >>>> On 09/07/2022 13:21, Christian Franke wrote: >>> [...] >>>>> >>>>> The UserSettings ctor has a somewhat hidden side effect which sets >>>>> root_scope correctly: >>>>> >>>>>   UserSettings::UserSettings(...); >>>>>    open_settings("setup.rc", ...); >>>>>     io_stream::open("cygfile:///etc/setup/setup.rc", ...); >>>>> io_stream_cygfile::io_stream_cygfile("/etc/setup/setup.rc", ...); >>>>>       get_root_dir_now(); >>>>>        read_mounts(""); >>>>>         read_mounts_nt(""); >>>>>          root_scope = isuser ? IDC_ROOT_USER : IDC_ROOT_SYSTEM; >>>>> >>>>> Conclusion: Regression introduced Feb 24, 2012 (befc9dd). >>>>> >>>> >>>> Thanks for tracking this down. >>>> >>>> That just seems... fractally wrong. >>> >>> I kind of lost track of this.  Is there anything else needed to fix >>> the original problem here?  Or is it solved by the change to defer >>> setting the group until after root_scope is known? >> >> The group seems to be correctly set now. >> >> An old problem still remains: root_scope always ends up as >> IDC_ROOT_SYSTEM if setup is run elevated, regardless off GUI setting. >> Apply the temporary patch from here to see what happens: >> https://sourceware.org/pipermail/cygwin-apps/2022-July/042151.html > > Ah, right, I remember now. > > I think having read_mounts() have a side effect of setting root_scope > is just nonsense now (it might have made some sense back in the day > when the mount table was also stored in the registry). > > So, how about the attached? > > (We should perhaps also set the installation root directory to > something other than C:\cygwin64 if a non-admin user, since they are > unlikely to be able to write there in current windows versions, but > that's difficult from a sequencing point of view in that dialog, and > for backwards compatibility) > >> Possibly difficult to fix, in particular in conjunction with later >> changes via [< Back] button. An easier approach: Remove the GUI >> setting and connect root_scope to -B option. > > Looking for that option is not correct, because we might be running > without -B, but from an already elevated shell.  I think checking > nt_sec.isRunAsAdmin() would be the correct test. Did some quick tests with patch applied. LGTM.