supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Dewayne Geraghty <dewayne.geraghty@heuristicsystems.com.au>
To: Laurent Bercot <ska-supervision@skarnet.org>
Cc: Supervision <supervision@list.skarnet.org>
Subject: Re: s6-log can create current with 640?
Date: Sat, 26 Oct 2019 18:16:28 +1100	[thread overview]
Message-ID: <cb4ac204-ffa7-21f0-cd8b-b9115084e967@heuristicsystems.com.au> (raw)
In-Reply-To: <emc770afe0-6246-4b88-981d-ce474cade704@elzian>

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.


  reply	other threads:[~2019-10-26  7:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23  2:27 Dewayne Geraghty
2019-10-23  4:53 ` Colin Booth
2019-10-23  5:39   ` Dewayne Geraghty
2019-10-23  7:15 ` Jonathan de Boyne Pollard
2019-10-23 23:03   ` Dewayne Geraghty
2019-10-23 23:58     ` Laurent Bercot
2019-10-25  8:20       ` Dewayne Geraghty
2019-10-25 17:06         ` Guillermo
2019-10-26  1:52           ` Dewayne Geraghty
2019-10-26  5:27             ` Laurent Bercot
2019-10-26  7:16               ` Dewayne Geraghty [this message]
2019-10-26 13:08                 ` Laurent Bercot
2019-10-29  7:28               ` Jonathan de Boyne Pollard
     [not found]               ` <a8fbd02e-0265-3d59-89d1-81048665693c@ntlworld.com>
2019-10-29  8:53                 ` Laurent Bercot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cb4ac204-ffa7-21f0-cd8b-b9115084e967@heuristicsystems.com.au \
    --to=dewayne.geraghty@heuristicsystems.com.au \
    --cc=ska-supervision@skarnet.org \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).