Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Jul 2020 17:41:45 +0200
From:      Joachim Desroches <joachim.desroches@epfl.ch>
To:        freebsd-rc@freebsd.org
Subject:   directory, user and limits question
Message-ID:  <20200713154145.n7d3jzd6rfxw5uvu@stormbringer.localdomain>

next in thread | raw e-mail | index | archive | help

--wlq4fynebpr6apl3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Dear freebsd-rc,

I just recently dived into writing my own RC scripts. I have read the
rc.subr(8) manpage as well as the "Practical rc.d scripting in BSD"
document, and I have a few questions as to how things are what the are
and how to attain a certain goal.

My first questions stem from reading the limits(1) manpage. Since limits
can handle both setting environment variables and the user running the
command, why does setting ${name}_env and ${name}_user call respectively
env(1) and su(1) ? Would it not be more elegant to simply use the
corresponding flags in limits(1), since it is called anyway ?

Secondly, I am trying to have the `command` of my rc script called in a
specific directory. This works as expected by setting ${name}_chdir, so
that doit becomes `cd ... && limits -C daemon ${command}...`. However,
if I also set ${name}_user, then the command run by limits becomes
`su -m $user -c 'sh -c $command'`, which completely annihilates the
previous `cd ...`.=20

What is the correct way of running a command in a specific directory as
a specific user ? Since settings ${name}_user seems to cancel
${name}_chdir (as well as any manual changes done in ${name}_prepend).

Cheers and happy hacking,

--=20
Joachim Desroches


--wlq4fynebpr6apl3
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEElB0ILab0vb9X09M/aLBzxSTE0YoFAl8MgLkACgkQaLBzxSTE
0Yo+MRAArZ1Z4WT9i3aQjPuaDMXkGRSfrv0EnOZtMZwFBK6Y2MhSRDfhsyvhgStu
nE6kOpoJYO6zBCmbMw8ErEvQgPCO9kI+hD75FAJSOStWtDga9MXMB6y2OLXCPHND
0t6puwqdmLJu9owIWID1Y1IzIi+CTZYj2NFK48Q7Z6iLzBQZL/v8XoMXHyLwBybD
t5ayhRDlH6XobLxxj8j5Lh2YHuevOfm/ZdLnpUcSAWbQRJ6cvLHCcnhw6Sdf1UHC
oqWlpB6Aj6pZ5aeJDCU0jyrf1YdR/bElnGjk9Do9bEQ1S2vFh/h1m7ETqhVpoUx5
5ISzIJ7s4OwWJyj7sFW2I5+U0yorfPkmpmBFoShXX947klqS6akRx7hLlORbu5O4
feW3Rq9adtbTjow5T73DjP7Rub+92XO67eFw7iCveVK4Nv3PNRCFfrRiv/WQYTIU
PAj6SECsoH2m/Ta/43khUCP8nyD+SPaULXAnjL4le0GaIY/b16AVW3jqmV/THKho
acDikK0+873/K7schuIMibi7yn4t7hVHf/6rXjhOOSc8SFD+5HOyBE60jDzhhlHz
xQvpNhPxGFLgblb+3KuDMcxUzi59My9I27yDkzGv304dmcGR81oCLnpVZ8z94S7Y
9FB7jJVs/h8rpVryDt9iYzDhN8q8IBIsmiNLtBHfbWjr5T427Bw=
=Xnqb
-----END PGP SIGNATURE-----

--wlq4fynebpr6apl3--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200713154145.n7d3jzd6rfxw5uvu>