pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: mysqld rc.d script



    Date:        Thu, 10 Apr 2025 15:59:11 +0100 (BST)
    From:        Stephen Borrill <netbsd%precedence.co.uk@localhost>
    Message-ID:  <Pine.NEB.4.64.2504101546580.1680@ugly>

  | For a) we can use perl to change the effective uid directly with $>= 

Or you could just delete -m so the command runs using the mysql_user's shell
instead.   Or explicitly set SHELL=/bin/sh and keep the -m.
To avoid the shell hanging around, just use 'exec logger ...'

Not saying that these ways are better than your proposal, esp as perl
is already being used, just they are alternatives.

  | For b) we can close stderr

No, don't do that, you get undefined behaviour running commands with
any of stdin/stdout/stderr closed (eg: should the command open a file,
that file would get fd==2 as the first available, and any messages to
stderr would get sent to that file, along with whatever other use the
application has for it .. and potentially two FILE struct referencing
the same fd, which is a recipe for a mess).   Just don't.

Use 2>/dev/null instead.   perl might be smart enough to recognise when
one of those fds is closed, and open something to replace any which are,
but doing it that way (2>&-) is a very bad habit to get into.

Also, in a script (of any kind, other than perhaps a csh script, which
is something best avoided) don't use `` for command substitution, use $( )
instead.  The semantics are better.

Using `...` interactively is often OK, one less char to type, and
it is rare to manually type something complicated enough that `` cmdsubs
cause problems, but in a script, 1 extra char, not worth saving.

kre



Home | Main Index | Thread Index | Old Index