From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/2695 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Dewayne Geraghty Newsgroups: gmane.comp.sysutils.supervision.general Subject: Re: s6-log can create current with 640? Date: Sat, 26 Oct 2019 18:16:28 +1100 Message-ID: References: <6f3a28f8-798c-9a55-e79b-2e54b37edf2e@heuristicsystems.com.au> <01b8c564-887f-16cf-405c-8bcfc52c02b1@heuristicsystems.com.au> <62d9001a-73bd-5cfe-4c47-f561c4dfabea@heuristicsystems.com.au> <9f1c10ea-a512-438d-dd3b-4d84119394fe@heuristicsystems.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="89118"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 Cc: Supervision To: Laurent Bercot Original-X-From: supervision-return-2284-gcsg-supervision=m.gmane.org@list.skarnet.org Sat Oct 26 09:18:32 2019 Return-path: Envelope-to: gcsg-supervision@m.gmane.org Original-Received: from alyss.skarnet.org ([95.142.172.232]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1iOGLH-000N1W-AO for gcsg-supervision@m.gmane.org; Sat, 26 Oct 2019 09:18:32 +0200 Original-Received: (qmail 29880 invoked by uid 89); 26 Oct 2019 07:18:56 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm Original-Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Original-Received: (qmail 29873 invoked from network); 26 Oct 2019 07:18:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=heuristicsystems.com.au; s=hsa; t=1572074189; x=1572678990; bh=W+3o/sSp3wR8xJJRYox5K4qsi5p8/LogLXagbSrd/uA=; h=Subject:To:From:Cc:Message-ID:Date; b=EQj5lzljq5fVYlV4Fab73DJj8ZxUbAsZ2Fi/SZNk6gpPMY+Zlq10WHUFq2wVRd4bc kJM/aSyKevyWqGZ8XYU3Wu1F2OYEhI6Cw0euq6mssBSdycd3KWLScl3y5D03qA4++g w0oqBoDdIqnO/3UCirTjshoPSkHraK7GdH4Ppf4jHZ4+lKTN8n2k8 X-Authentication-Warning: b3.hs: Host noddy.hs [10.0.5.3] claimed to be [10.0.5.3] Openpgp: preference=signencrypt In-Reply-To: Content-Language: en-AU Xref: news.gmane.org gmane.comp.sysutils.supervision.general:2695 Archived-At: Hi Laurent, Answers embedded On 26/10/2019 4:27 pm, Laurent Bercot wrote: >> I'd mistakenly assumed execlineb knew where its friends were; though in >> hindsight its a bit much to assume that execlineb internally changes the >> PATH. > > The real question is, why is there a "umask" binary that's not the one > from execline? Non-chainloading non-builtin umask is nonsense, just > like non-chainloading non-builtin cd. > I can only shed a ray of light, though this /usr/bin/umask has been around for some time. I fired up an old FreeBSD 9.2 system that has it. Content being: #!/bin/sh # $FreeBSD: stable/9/usr.bin/alias/generic.sh 151635 2005-10-24 22:32:19Z cperciva $ # This file is in the public domain. builtin ${0##*/} ${1+"$@"} which is the same as 12.1. Why? I can only refer to src logs: ... ------------------------------------------------------------------------ r151635 | cperciva | 2005-10-25 08:32:19 +1000 (Tue, 25 Oct 2005) | 10 lines Use the "builtin" shell function to make sure that the requested command is handled as a shell function. This avoids the following peculiar behaviour when /usr/bin is on a case-insensitive filesystem: # READ foo (... long pause, depending upon the amount of swap space available ...) sh: Resource temporarily unavailable. ... ------------------------------------------------------------------------ r100200 | wollman | 2002-07-17 08:16:05 +1000 (Wed, 17 Jul 2002) | 5 lines A little bit more thought has resulted in a generic script which can implement any of the useless POSIX-required ``regular shell builtin'' utilities, saving one frag and one inode each. The script moves to usr.bin/alias which is alphabetically the first of these commands. ------------------------------------------------------------------------ the last entry before the cvs logs were transferred to svn. Examining the Makefile/usr/src/usr.bin/alias/Makefile # $FreeBSD: stable/12/usr.bin/alias/Makefile 284255 2015-06-11 04:22:17Z sjg $ SCRIPTS=generic.sh SCRIPTSNAME=alias LINKS= ${BINDIR}/alias ${BINDIR}/bg \ ${BINDIR}/alias ${BINDIR}/cd \ ${BINDIR}/alias ${BINDIR}/command \ ${BINDIR}/alias ${BINDIR}/fc \ ${BINDIR}/alias ${BINDIR}/fg \ ${BINDIR}/alias ${BINDIR}/getopts \ ${BINDIR}/alias ${BINDIR}/hash \ ${BINDIR}/alias ${BINDIR}/jobs \ ${BINDIR}/alias ${BINDIR}/read \ ${BINDIR}/alias ${BINDIR}/type \ ${BINDIR}/alias ${BINDIR}/ulimit \ ${BINDIR}/alias ${BINDIR}/umask \ ${BINDIR}/alias ${BINDIR}/unalias \ ${BINDIR}/alias ${BINDIR}/wait and yes they exist in /usr/bin/ >From tcsh # which cd cd: shell built-in command. >From sh # which echo /bin/echo Ok - that's done my head in. > >> Unfortunately it seems that the path can't be set within execlineb >> context. > > Of course it can. What's happening is that both export and envfile > set the PATH *on execution of the next command*, so the command that's > right after them will still be searched with the old PATH. In other words: > > "export PATH /usr/local/bin umask 033 echo blah" will not work, because > umask will still be searched for in the old PATH (but echo would be > searched in the new PATH), but > "export PATH /usr/local/bin exec umask 033 echo blah" will work, because > exec is searched in the old PATH and umask is searched in the new PATH. > > (exec is an execline nop that can be useful in those cases, if you > don't have another command to put between the export PATH and the > command you need to search in the new PATH.) > Thank-you, the explanation helps. I guess through bad experiences with (non-execline) exec, I avoid it unless I really do want to transfer control to it. I think with this example # rm -v /tmp/t1 ; setenv PATH /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin ; execlineb -Pc 'importas op PATH emptyenv export PATH /usr/local/bin:$op exec umask 002 redirfd -w 1 /tmp/t1 echo blah4' ; /bin/ls -l t1 ; cat /tmp/t1 /tmp/t1 -rw-rw-r-- 1 root wheel 6 26 Oct 18:02 t1 blah4 Due to the above discussion around umask, I will have to consider either adding to my execline scripts :( importas op PATH emptyenv export PATH /usr/local/bin:$op or explicit paths as needed. Thank-you to the contributors for your patience.