From owner-freebsd-arch@freebsd.org Thu Dec 24 23:13:53 2015 Return-Path: Delivered-To: freebsd-arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AC38AA50ABD for ; Thu, 24 Dec 2015 23:13:53 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mailhost.stack.nl", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 7229C14E3 for ; Thu, 24 Dec 2015 23:13:53 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 0F7A83592E1 for ; Fri, 25 Dec 2015 00:13:50 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id BA5BF28494; Fri, 25 Dec 2015 00:13:49 +0100 (CET) Date: Fri, 25 Dec 2015 00:13:49 +0100 From: Jilles Tjoelker To: freebsd-arch@freebsd.org Subject: Expanding _PATH_DEFPATH Message-ID: <20151224231349.GA5821@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Dec 2015 23:13:53 -0000 In there is a #define _PATH_DEFPATH which is set to /usr/bin:/bin. This does not include /sbin, /usr/sbin and ports (/usr/local/bin and /usr/local/sbin) directories and is therefore often insufficient. This is rarely a problem because _PATH_DEFPATH is overridden by /etc/login.conf, ~/.login_conf and/or shell startup files. _PATH_DEFPATH is still used as a default by execlp(), execvp(), posix_spawnp() and sh if PATH is not set, and by cron. Especially the latter is a common trap (most recently in PR 204813). We can fix it for 99% by changing _PATH_DEFPATH to /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin This is the path in the default class in the default /etc/login.conf, excluding ~/bin which would not be expanded properly in a string constant. For consistency, the _PATH_DEFPATH for RESCUE below and in 3 man pages (exec.3, posix_spawn.3, crontab.5) need to be adjusted as well. -- Jilles Tjoelker