From owner-freebsd-stable@freebsd.org Sun Jan 5 23:13:55 2020 Return-Path: Delivered-To: freebsd-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 20FEA1E9A0B for ; Sun, 5 Jan 2020 23:13:55 +0000 (UTC) (envelope-from li-fbsd@citylink.dinoex.sub.org) Received: from uucp.dinoex.org (uucp.dinoex.sub.de [IPv6:2001:1440:5001:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "uucp.dinoex.sub.de", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47rZFt1fp8z3PDv for ; Sun, 5 Jan 2020 23:13:53 +0000 (UTC) (envelope-from li-fbsd@citylink.dinoex.sub.org) Received: from uucp.dinoex.sub.de (uucp.dinoex.org [185.220.148.12]) by uucp.dinoex.org (8.16.0.41/8.16.0.41) with ESMTPS id 005ND9Lg033513 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Mon, 6 Jan 2020 00:13:10 +0100 (CET) (envelope-from li-fbsd@citylink.dinoex.sub.org) X-MDaemon-Deliver-To: X-Authentication-Warning: uucp.dinoex.sub.de: Host uucp.dinoex.org [185.220.148.12] claimed to be uucp.dinoex.sub.de Received: from citylink.dinoex.sub.org (uucp@localhost) by uucp.dinoex.sub.de (8.16.0.41/8.16.0.41/Submit) with UUCP id 005ND98N033512 for freebsd-stable@FreeBSD.ORG; Mon, 6 Jan 2020 00:13:09 +0100 (CET) (envelope-from li-fbsd@citylink.dinoex.sub.org) Received: from gate.oper.dinoex.org (gate-e [192.168.98.2]) by citylink.dinoex.sub.de (8.15.2/8.15.2) with ESMTP id 005MuLV4049610 for ; Sun, 5 Jan 2020 23:56:21 +0100 (CET) (envelope-from li-fbsd@citylink.dinoex.sub.org) Received: from gate.oper.dinoex.org (gate-e [192.168.98.2]) by gate.oper.dinoex.org (8.15.2/8.15.2) with ESMTP id 005Ms0ai049198 for ; Sun, 5 Jan 2020 23:54:00 +0100 (CET) (envelope-from li-fbsd@citylink.dinoex.sub.org) Received: (from news@localhost) by gate.oper.dinoex.org (8.15.2/8.15.2/Submit) id 005Ms0LF049197 for freebsd-stable@FreeBSD.ORG; Sun, 5 Jan 2020 23:54:00 +0100 (CET) (envelope-from li-fbsd@citylink.dinoex.sub.org) X-Authentication-Warning: gate.oper.dinoex.org: news set sender to li-fbsd@citylink.dinoex.sub.org using -f From: Peter Subject: session mgmt: does POSIX indeed prohibit NOOP execution? Date: Sun, 05 Jan 2020 23:41:32 +0100 Organization: n/a Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Injection-Info: oper.dinoex.de; logging-data="48316"; mail-complaints-to="usenet@citylink.dinoex.sub.org" User-Agent: Opera Mail/12.16 (FreeBSD) Sender: li-fbsd@citylink.dinoex.sub.org To: freebsd-stable@FreeBSD.ORG X-Milter: Spamilter (Reciever: uucp.dinoex.sub.de; Sender-ip: 185.220.148.12; Sender-helo: uucp.dinoex.sub.de; ) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (uucp.dinoex.org [185.220.148.12]); Mon, 06 Jan 2020 00:13:12 +0100 (CET) X-Rspamd-Queue-Id: 47rZFt1fp8z3PDv X-Spamd-Bar: +++++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of li-fbsd@citylink.dinoex.sub.org has no SPF policy when checking 2001:1440:5001:1::2) smtp.mailfrom=li-fbsd@citylink.dinoex.sub.org X-Spamd-Result: default: False [5.48 / 15.00]; ARC_NA(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MV_CASE(0.50)[]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-stable@freebsd.org]; AUTH_NA(1.00)[]; RCPT_COUNT_ONE(0.00)[1]; HAS_ORG_HEADER(0.00)[]; NEURAL_SPAM_MEDIUM(0.99)[0.994,0]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; NEURAL_SPAM_LONG(1.00)[0.999,0]; TO_DN_NONE(0.00)[]; IP_SCORE(0.28)[ip: (0.75), ipnet: 2001:1440::/32(0.38), asn: 8469(0.30), country: DE(-0.02)]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[peter@citylink.dinoex.sub.org,li-fbsd@citylink.dinoex.sub.org]; DMARC_NA(0.00)[sub.org]; MID_RHS_NOT_FQDN(0.50)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:8469, ipnet:2001:1440::/32, country:DE]; SUBJECT_ENDS_QUESTION(1.00)[]; FROM_NEQ_ENVFROM(0.00)[peter@citylink.dinoex.sub.org, li-fbsd@citylink.dinoex.sub.org] X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jan 2020 23:13:55 -0000 > pgrp = getpid(); > if(setpgid(0, pgrp) < 0) > err(1, "setpgid"); This appears to me a program trying to deemonize itself (in the old style when there was only job control but no session management). In the case this program is already properly daemonized, e.g. by starting it from /usr/sbin/daemon, this code now fails, invoking the err() clause and thereby aborting. From what I could find out, POSIX does not allow a session leader to do setpgid() on itself. When a program is invoked via /usr/sbin/daemon, it should already be session leader AND group leader, and then the above code WOULD be a NOOP, unless POSIX would require the setpgid() to fail and thereby the program to abort - which, btw, is NOT a NOOP :( So, where is the mistake here? Option 1: I have completely misunderstood something. Then please tell me what. Option 2: The quoted code is bogus. Then why is it in base? option 3: The setpgid() behaviour is bogus. It may stop a session leader from executing it, but it should detect a NOOP and just go thru with it. Then why don't we fix that? Option 4: POSIX is bogus. Unlikely, because as far as I could find out, that part of it was written following the Berkeley implementation.