Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cpiLi-0004YC-1s for pgsql-hackers@arkaria.postgresql.org; Sun, 19 Mar 2017 21:26:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cpiLh-0002by-A6 for pgsql-hackers@arkaria.postgresql.org; Sun, 19 Mar 2017 21:26:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cpiLg-0002bo-7W for pgsql-hackers@postgresql.org; Sun, 19 Mar 2017 21:26:48 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cpiLc-0005cI-7l; Sun, 19 Mar 2017 21:26:47 +0000 Received: by mail-lf0-x242.google.com with SMTP id r36so8799830lfi.0; Sun, 19 Mar 2017 14:26:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=JH0eYxarpgfDvfpW69Vfi1s7ic8DeWgezghn1rewLaw=; b=ZIlpLkF/WpKd8AUTWbJn/M+0OEYm5xbZzJMzKXuEwy5IHVWAHGFRpnYn+BQiwJccVw 0Vx91zXVuxHVvBIGDQqPxWfPbdO4VE1+hqzFfx8fD+oq8a4rMzgtycm9TQN5GglPr//o hBHy3sYwTaQtncpd1/QVXvbBLKYtcs7cKbV4R5iSZ4g0HtfRV98Zh1yMa6xuF4pHFLew uT2PWpdY0SnRBXmpDhiIxu254cd4ZjsljRiUxAXuaNCp2Gegw1ZMB/iXc6kJRTPZaWbe chx0ht2s2SFn9ATOiPQ7ZWQ/KWp1DfeeC7kAjD95xcUJ6vLGhV7V+WzUo/prCMtvKyQp Trlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=JH0eYxarpgfDvfpW69Vfi1s7ic8DeWgezghn1rewLaw=; b=S7tEftlNO1DLauzLP1b05J2ClXlHN+0Y9lvQbMQa13+UdltRyz2cDomQWfsdx8HM5S v0bTP1N08BDeXihTXab5bxXFUVm/1JR+i229q1PT9qimB7+YyViQxfuTzCPXCPfgMFTN RHleNZQHUaTf48tH2le5VSDxLh9glKiOUDPPliYeOb3EhxNj94kqJj4IgoHk1TvQCG+r WaDLhhBXGwJhk96seXTHyHMj+yj1yupeJe+sOsIZaWBB6dVrlO9PyUrAB0/lEOWI97Oa AKNlePIzOt3fGksiHnKUJsfh+zj4jD81LXi+pmA0mb2U+0jHyftZaGkBjUdsQ+elWl+A A7pQ== X-Gm-Message-State: AFeK/H2pIxu0KsICaDQFgYyZjGO8TLG2T2bExRw3z9d6WupfbDCicib/URZTUlMP4FSejg== X-Received: by 10.25.167.203 with SMTP id q194mr6807949lfe.138.1489958802231; Sun, 19 Mar 2017 14:26:42 -0700 (PDT) Received: from [192.168.1.99] (dsl-hkibrasgw1-50df7f-241.dhcp.inet.fi. [80.223.127.241]) by smtp.gmail.com with ESMTPSA id s5sm2703369ljd.27.2017.03.19.14.26.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Mar 2017 14:26:41 -0700 (PDT) Subject: Re: [COMMITTERS] pgsql: Fix and simplify check for whether we're running as Windows serv To: Tom Lane , Dave Page References: <16609.1489773427@sss.pgh.pa.us> Cc: pgsql-hackers@postgreSQL.org From: Heikki Linnakangas Message-ID: Date: Sun, 19 Mar 2017 23:26:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 MIME-Version: 1.0 In-Reply-To: <16609.1489773427@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 03/17/2017 07:57 PM, Tom Lane wrote: > Heikki Linnakangas writes: >> Fix and simplify check for whether we're running as Windows service. > > This seems to have broken narwhal: > > Creating library file: libpostgres.a > ../../src/port/libpgport_srv.a(win32security_srv.o)(.text+0x109): In function `pgwin32_is_admin': > C:/msys/1.0/local/pgbuildfarm/buildroot/HEAD/pgsql.build/src/port/win32security.c:77: undefined reference to `CheckTokenMembership' > ../../src/port/libpgport_srv.a(win32security_srv.o)(.text+0x127):C:/msys/1.0/local/pgbuildfarm/buildroot/HEAD/pgsql.build/src/port/win32security.c:77: undefined reference to `CheckTokenMembership' > ../../src/port/libpgport_srv.a(win32security_srv.o)(.text+0x264): In function `pgwin32_is_service': > C:/msys/1.0/local/pgbuildfarm/buildroot/HEAD/pgsql.build/src/port/win32security.c:138: undefined reference to `CheckTokenMembership' > ../../src/port/libpgport_srv.a(win32security_srv.o)(.text+0x302):C:/msys/1.0/local/pgbuildfarm/buildroot/HEAD/pgsql.build/src/port/win32security.c:163: undefined reference to `CheckTokenMembership' > collect2: ld returned 1 exit status > make[2]: *** [postgres] Error 1 Hmm. The other MinGW animals are not having that problem. According to the MSDN docs [1], CheckTokenMembership() is defined in the Advapi32 library. In pg_ctl.c and in src/include/common/restricted_token.c, we currently do this, for another function that's in Advapi32: > /* > * Mingw headers are incomplete, and so are the libraries. So we have to load > * a whole lot of API functions dynamically. Since we have to do this anyway, > * also load the couple of functions that *do* exist in minwg headers but not > * on NT4. That way, we don't break on NT4. > */ > typedef BOOL (WINAPI * __CreateRestrictedToken) (HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE); > typedef BOOL (WINAPI * __IsProcessInJob) (HANDLE, HANDLE, PBOOL); > typedef HANDLE (WINAPI * __CreateJobObject) (LPSECURITY_ATTRIBUTES, LPCTSTR); > typedef BOOL (WINAPI * __SetInformationJobObject) (HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD); > typedef BOOL (WINAPI * __AssignProcessToJobObject) (HANDLE, HANDLE); > typedef BOOL (WINAPI * __QueryInformationJobObject) (HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD, LPDWORD); CheckTokenMembership() is probably one of those missing functions, like CreateRestrictedToken. I'd like to bump our minimum requirements,and stop supporting old MinGW versions that don't have those headers. I'm not sure what version they were added in, but frogmouth doesn't have this problem, and it uses gcc 4.5.0. Once we do that, we can simplify pg_ctl.c and restricted_token.c to not open advapi32.dll dynamically, and call those functions the usual way. It's not very nice to change the requirements in a minor version, but I don't think this would be a real problem for anyone. Not many people build PostgreSQL using MinGW, let alone with an ancient version of it. But if people don't agree, we could instead revert this patch and apply the smaller V2 patch [2] instead, in the back-branches. Thoughts? Any objections to requiring a newer version of MinGW? Any objections to do so in the next minor release? [1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa376389%28v=vs.85%29.aspx [2] https://www.postgresql.org/message-id/CAB7nPqSvfu%3DKpJ%3DNX%2BYAHmgAmQdzA7N5h31BjzXeMgczhGCC%2BQ%40mail.gmail.com - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers