From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.1 Date: Thu, 1 Oct 2020 19:25:34 +0200 From: Alexey Gladkov To: Arseny Maslennikov Message-ID: <20201001172534.ifraykilpepx3fbb@comp-core-i7-2640m-0182e6> References: <47512e07a05fdc1ebf794e304eade1c4c13605fb.1576183643.git.legion@altlinux.org> <20200917131052.GD286846@cello> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="vxdmip65shsbqzil" Content-Disposition: inline In-Reply-To: <20200917131052.GD286846@cello> Cc: ALT Linux Team development discussions , ldv@altlinux.org Subject: Re: [devel] [PATCH hasher-priv v1 2/3] Add systemd and sysvinit service files X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Oct 2020 17:25:41 -0000 Archived-At: List-Archive: List-Post: --vxdmip65shsbqzil Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 17, 2020 at 04:10:52PM +0300, Arseny Maslennikov wrote: > On Fri, Dec 13, 2019 at 12:42:04PM +0100, Alex Gladkov wrote: > > From: Alexey Gladkov > >=20 > > Signed-off-by: Alexey Gladkov > > --- > > hasher-priv/Makefile | 4 ++ > > hasher-priv/hasher-privd.service | 11 ++++ > > hasher-priv/hasher-privd.sysvinit | 86 +++++++++++++++++++++++++++++++ > > 3 files changed, 101 insertions(+) > > create mode 100644 hasher-priv/hasher-privd.service > > create mode 100755 hasher-priv/hasher-privd.sysvinit > >=20 > > diff --git a/hasher-priv/Makefile b/hasher-priv/Makefile > > index 82aa385..c73216f 100644 > > --- a/hasher-priv/Makefile > > +++ b/hasher-priv/Makefile > > @@ -14,6 +14,8 @@ MAN8PAGES =3D $(PROJECT).8 hasher-useradd.8 > > TARGETS =3D $(PROJECT) hasher-privd hasher-useradd $(HELPERS) $(MAN5PA= GES) $(MAN8PAGES) > > =20 > > sysconfdir =3D /etc > > +initdir=3D$(sysconfdir)/rc.d/init.d > > +systemd_unitdir=3D/lib/systemd/system > > libexecdir =3D /usr/lib > > sbindir =3D /usr/sbin > > mandir =3D /usr/share/man > > @@ -72,6 +74,8 @@ install: all > > $(MKDIR_P) -m750 $(DESTDIR)$(helperdir) > > $(INSTALL) -p -m700 $(PROJECT) $(DESTDIR)$(helperdir)/ > > $(INSTALL) -p -m755 $(HELPERS) $(DESTDIR)$(helperdir)/ > > + $(MKDIR_P) -m755 $(DESTDIR)$(initdir) > > + $(INSTALL) -p -m755 hasher-privd.sysvinit $(DESTDIR)$(initdir)/hasher= -privd >=20 > The systemd service is not installed. I don't really care about systemd. I'm not an expert in creating services for it. I hope that someone who can create and test the service. It may be you :) > > $(MKDIR_P) -m755 $(DESTDIR)$(sbindir) > > $(INSTALL) -p -m755 hasher-privd $(DESTDIR)$(sbindir)/ > > $(INSTALL) -p -m755 hasher-useradd $(DESTDIR)$(sbindir)/ > > diff --git a/hasher-priv/hasher-privd.service b/hasher-priv/hasher-priv= d.service > > new file mode 100644 > > index 0000000..e5ed9ac > > --- /dev/null > > +++ b/hasher-priv/hasher-privd.service > > @@ -0,0 +1,11 @@ > > +[Unit] > > +Description=3DA privileged helper for the hasher project > > +ConditionVirtualization=3D!container >=20 > In response to earlier reviewers: hasher-priv as of today does not work > inside a userns-unprivileged container and does not produce clear > diagnostics (and, from my own experience when I was joining ALT, the > developers did not as well). Thus, for now this condition is justified. > Perhaps in the future, when (and if) we introduce the ability to reuse a > mainstream container runtime as the hasher environment for users R and > B, it would make sense for us to lift this condition. >=20 > > +Documentation=3Dman:hasher-priv(8) >=20 > Ah yes, I forgot. The patchset contains no changes to the man pages, so > the effort and behaviour change is not reflected. I agree it's best to > revisit them once we're done with the code, though. >=20 > > + > > +[Service] > > +ExecStart=3D/usr/sbin/hasher-privd >=20 > Suggested replacement: > "ExecStart=3D/usr/sbin/hasher-privd -f" >=20 > The service implicitly, by default, has Type=3Dsimple, which means the > following: > - the main process(-es) is defined by the ExecStart=3D command line(-s) > and is intended to persist while the service is launched and active; > - its pid/tgid is tracked by the service manager and can be queried; > - the service manager puts it into its own cgroup; > - its standard output and standard error are redirected to system log; > - (follows from the above) the main process never has a controlling > terminal or standard file descriptors pointing to any terminal, its > sid is equal to its tgid =E2=80=94 and so it does not have to perform > manual steps to daemonize. >=20 > > +Restart=3Don-failure > > + > > +[Install] > > +WantedBy=3Dmulti-user.target > > diff --git a/hasher-priv/hasher-privd.sysvinit b/hasher-priv/hasher-pri= vd.sysvinit > > new file mode 100755 > > index 0000000..914fb53 > > --- /dev/null > > +++ b/hasher-priv/hasher-privd.sysvinit > > @@ -0,0 +1,86 @@ > > +#! /bin/sh > > + > > +### BEGIN INIT INFO > > +# Short-Description: A privileged helper for the hasher project > > +# Description: A privileged helper for the hasher project > > +# Provides: hasher-priv > > +# Required-Start: $remote_fs > > +# Required-Stop: $remote_fs > > +# Default-Start: 2 3 4 5 > > +# Default-Stop: 0 1 6 > > +### END INIT INFO > > + > > +WITHOUT_RC_COMPAT=3D1 > > + > > +# Source function library. > > +. /etc/init.d/functions > > + > > +NAME=3Dhasher-privd > > +PIDFILE=3D"/var/run/$NAME.pid" > > +LOCKFILE=3D"/var/lock/subsys/$NAME" > > +RETVAL=3D0 > > + > > +start() > > +{ > > + start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" -- "$NAME" > > + RETVAL=3D$? > > + return $RETVAL > > +} > > + > > +stop() > > +{ > > + stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" "$NAME" > > + RETVAL=3D$? > > + return $RETVAL > > +} > > + > > +restart() > > +{ > > + stop > > + start > > +} > > + > > +# See how we were called. > > +case "$1" in > > + start) > > + start > > + ;; > > + stop) > > + stop > > + ;; > > + status) > > + status --pidfile "$PIDFILE" "$NAME" > > + RETVAL=3D$? > > + ;; > > + restart) > > + restart > > + ;; > > + reload) > > + restart > > + ;; > > + condstart) > > + if [ ! -e "$LOCKFILE" ]; then > > + start > > + fi > > + ;; > > + condstop) > > + if [ -e "$LOCKFILE" ]; then > > + stop > > + fi > > + ;; > > + condrestart) > > + if [ -e "$LOCKFILE" ]; then > > + restart > > + fi > > + ;; > > + condreload) > > + if [ -e "$LOCKFILE" ]; then > > + reload > > + fi > > + ;; > > + *) > > + msg_usage "${0##*/} {start|stop|status|restart|reload|condstart|cond= stop|condrestart|condreload}" > > + RETVAL=3D1 > > +esac > > + > > +exit $RETVAL > > --=20 > > 2.24.0 > >=20 --=20 Rgrds, legion --vxdmip65shsbqzil Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSuzIk+w2aWgaEZLHKOFEXcaOMeVAUCX3YRDgAKCRCOFEXcaOMe VFCkAJ9pLaRatY4lu34HTHQQGGcrW4QZwACgk+xIX8/sLkrSg3C+NFn7ZAuN2DU= =nZ2B -----END PGP SIGNATURE----- --vxdmip65shsbqzil--