Bug#928935: Invoke-run: add a way to not stop sysv scripts

2019-05-19 Thread Dmitry Bogatov


[2019-05-17 22:02] Lorenz 
> Hi,
>
> > True. Here are patches. What do you think?
>
> I haven't had time to test but the patch looks good to me, just an
> observation:
> to my experience
>
> /etc/init.d/${service} status
>
> is not always reliable in term of both results and exit codes, we will have
> the chance to fix a certain number of sysv init scripts because of this

True. Actually, according to Policy, "status" command is not mandatory,
but I know no better way to figure out, whether sysvinit instance is
running.

Let us hope, that for most non-restartible sevices "status" command
exists and behaves reasonably.
-- 
Note, that I send and fetch email in batch, once every 24 hours.
 If matter is urgent, try https://t.me/kaction
 --



Bug#928935: Invoke-run: add a way to not stop sysv scripts

2019-05-17 Thread Lorenz
Hi,

> True. Here are patches. What do you think?

I haven't had time to test but the patch looks good to me, just an
observation:
to my experience

/etc/init.d/${service} status

is not always reliable in term of both results and exit codes, we will have
the
chance to fix a certain number of sysv init scripts because of this

thanks



Il giorno gio 16 mag 2019 alle ore 10:54 Dmitry Bogatov 
ha scritto:

>
> control: tags -1 +pending +patch
>
> [2019-05-13 14:35] Lorenzo Puliti 
> > Hi,
> >
> > In order to avoid conflicts, recent version of invoke-run interpreter
> stops the sysv
> > init scripts before starting the run service.
> > Please note that this logic, when applied to daemons like dbus, slim,
> sddm, lightdm
> > (and possibly others) will break the graphic session, so there is need
> for a way
> > to prevent the sysv script being replaced by the run script while the
> graphic session
> > is active.
> > This also will need support in dh-runit.
>
> True. Here are patches. What do you think?
>
> From 66e9071165250793d8900f17cd5b35ca7b45526b Mon Sep 17 00:00:00 2001
> From: Dmitry Bogatov 
> Date: Tue, 14 May 2019 10:45:06 +
> Subject: [PATCH] invoke-run: add option to not stop sysv scripts
>
> Closes: #928935
> ---
>  debian/contrib/lib/invoke-run | 10 ++
>  1 file changed, 10 insertions(+)
>
> diff --git a/debian/contrib/lib/invoke-run b/debian/contrib/lib/invoke-run
> index a424b73..9fa5c59 100755
> --- a/debian/contrib/lib/invoke-run
> +++ b/debian/contrib/lib/invoke-run
> @@ -40,7 +40,17 @@ if [ -r "/etc/default/${service}" ] ; then
>  fi
>
>  readonly initscript="/etc/init.d/${service}"
> +readonly noreplace="/var/lib/runit/noreplace/${service}"
> +
>  if [ -x "${initscript}" ] ; then
> +   # Stopping some services (e.g display manager) is disruptive
> +   # and must be done only manually by user.
> +   if [ -f "${noreplace}" ] ; then
> +   if "${initscript}" status >/dev/null 2>&1 ; then
> +   sv down "${service}"
> +   exit 0
> +   fi
> +   fi
> "${initscript}" stop
>  fi
>
> And here is patch for dh_runit. It may be more convenient to see it at
> salsa.debian.org/runit-team/dh-runit.
>
> From cb411affcbc2eb183ee5f35e50c3863c0b94f98a Mon Sep 17 00:00:00 2001
> From: Dmitry Bogatov 
> Date: Tue, 14 May 2019 15:41:52 +
> Subject: [PATCH] Add option to mark service as non-restartable
>
> ---
>  dh_runit   | 18 ++
>  t/924903.t |  5 -
>  t/928935.t | 10 ++
>  3 files changed, 32 insertions(+), 1 deletion(-)
>  create mode 100644 t/928935.t
>
> diff --git a/dh_runit b/dh_runit
> index 5ed55b5..4c9820e 100755
> --- a/dh_runit
> +++ b/dh_runit
> @@ -5,6 +5,7 @@ use v5.10.1;
>  use strict;
>  use Debian::Debhelper::Dh_Lib;
>  use File::Find;
> +use File::Path qw(make_path);
>  use File::stat;
>  use feature 'signatures';
>  no warnings 'experimental';
> @@ -17,6 +18,7 @@ sub parse_options($opts) {
>  when (/^name=(.*)$/)   { $conf->{name} = $1; };
>  when (/^since=(.*)$/)  { $conf->{since} = $1; };
>  when (/^logscript$/)   { $conf->{logscript} = 1};
> +when (/^noreplace$/)   { $conf->{noreplace} = 1};
>  when (/^defaults$/){ "do nothing"; };
>  default{ error("unknown option `$opt'"); }
>  }
> @@ -59,6 +61,13 @@ PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) {
>  my $conf = parse_options($opts);
>  my $name = $conf->{name} || basename($path);
>
> +if ($conf->{noreplace}) {
> +make_path("${tmp}/var/lib/runit/noreplace/");
> +open(my $fh, ">", "${tmp}/var/lib/runit/noreplace/${name}")
> +|| die $!;
> +close($fh);
> +}
> +
>  if ( -f $path) {
>  install_dir("$sv_dir/$name");
>  install_prog($path, "$sv_dir/$name/run");
> @@ -182,6 +191,15 @@ version of package. See #923233.
>  If this option is not specified, it means that runscript was provided
>  all history of package.
>
> +=item I
> +
> +Mark service as non-restartible. Interpreter B, provided by
> +I package does not stop sysvinit-managed instance of service to
> +replace it with runit-managed instance when service is marked as
> +non-restartible.
> +
> +Display managers (xdm, kdm, ...) are examples of non-restartible services.
> +
>  =item I
>
>  If you don't need other options, specify this one.
> diff --git a/t/924903.t b/t/924903.t
> index 710ea39..b969314 100644
> --- a/t/924903.t
> +++ b/t/924903.t
> @@ -1,7 +1,7 @@
>  #!/usr/bin/perl
>  use strict;
>  use warnings;
> -use Test::More tests => 3;
> +use Test::More tests => 4;
>  use File::stat;
>  use T;
>
> @@ -11,3 +11,6 @@ ok(-d $path, 'supervise directory correctly created');
>  my $info = stat($path);
>  my $mode = sprintf("%o", $info->mode & 0777);
>  is($mode, '700', 'supervise directory have conservative permissions');
> +
> +my $noreplace = 'debia

Bug#928935: Invoke-run: add a way to not stop sysv scripts

2019-05-16 Thread Dmitry Bogatov


control: tags -1 +pending +patch

[2019-05-13 14:35] Lorenzo Puliti 
> Hi,
>
> In order to avoid conflicts, recent version of invoke-run interpreter stops 
> the sysv
> init scripts before starting the run service.
> Please note that this logic, when applied to daemons like dbus, slim, sddm, 
> lightdm 
> (and possibly others) will break the graphic session, so there is need for a 
> way
> to prevent the sysv script being replaced by the run script while the graphic 
> session
> is active.
> This also will need support in dh-runit.

True. Here are patches. What do you think?

From 66e9071165250793d8900f17cd5b35ca7b45526b Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov 
Date: Tue, 14 May 2019 10:45:06 +
Subject: [PATCH] invoke-run: add option to not stop sysv scripts

Closes: #928935
---
 debian/contrib/lib/invoke-run | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/debian/contrib/lib/invoke-run b/debian/contrib/lib/invoke-run
index a424b73..9fa5c59 100755
--- a/debian/contrib/lib/invoke-run
+++ b/debian/contrib/lib/invoke-run
@@ -40,7 +40,17 @@ if [ -r "/etc/default/${service}" ] ; then
 fi
 
 readonly initscript="/etc/init.d/${service}"
+readonly noreplace="/var/lib/runit/noreplace/${service}"
+
 if [ -x "${initscript}" ] ; then
+   # Stopping some services (e.g display manager) is disruptive
+   # and must be done only manually by user.
+   if [ -f "${noreplace}" ] ; then
+   if "${initscript}" status >/dev/null 2>&1 ; then
+   sv down "${service}"
+   exit 0
+   fi
+   fi
"${initscript}" stop
 fi

And here is patch for dh_runit. It may be more convenient to see it at
salsa.debian.org/runit-team/dh-runit.

From cb411affcbc2eb183ee5f35e50c3863c0b94f98a Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov 
Date: Tue, 14 May 2019 15:41:52 +
Subject: [PATCH] Add option to mark service as non-restartable

---
 dh_runit   | 18 ++
 t/924903.t |  5 -
 t/928935.t | 10 ++
 3 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 t/928935.t

diff --git a/dh_runit b/dh_runit
index 5ed55b5..4c9820e 100755
--- a/dh_runit
+++ b/dh_runit
@@ -5,6 +5,7 @@ use v5.10.1;
 use strict;
 use Debian::Debhelper::Dh_Lib;
 use File::Find;
+use File::Path qw(make_path);
 use File::stat;
 use feature 'signatures';
 no warnings 'experimental';
@@ -17,6 +18,7 @@ sub parse_options($opts) {
 when (/^name=(.*)$/)   { $conf->{name} = $1; };
 when (/^since=(.*)$/)  { $conf->{since} = $1; };
 when (/^logscript$/)   { $conf->{logscript} = 1};
+when (/^noreplace$/)   { $conf->{noreplace} = 1};
 when (/^defaults$/){ "do nothing"; };
 default{ error("unknown option `$opt'"); }
 }
@@ -59,6 +61,13 @@ PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) {
 my $conf = parse_options($opts);
 my $name = $conf->{name} || basename($path);
 
+if ($conf->{noreplace}) {
+make_path("${tmp}/var/lib/runit/noreplace/");
+open(my $fh, ">", "${tmp}/var/lib/runit/noreplace/${name}")
+|| die $!;
+close($fh);
+}
+
 if ( -f $path) {
 install_dir("$sv_dir/$name");
 install_prog($path, "$sv_dir/$name/run");
@@ -182,6 +191,15 @@ version of package. See #923233.
 If this option is not specified, it means that runscript was provided
 all history of package.
 
+=item I
+
+Mark service as non-restartible. Interpreter B, provided by
+I package does not stop sysvinit-managed instance of service to
+replace it with runit-managed instance when service is marked as
+non-restartible.
+
+Display managers (xdm, kdm, ...) are examples of non-restartible services.
+
 =item I
 
 If you don't need other options, specify this one.
diff --git a/t/924903.t b/t/924903.t
index 710ea39..b969314 100644
--- a/t/924903.t
+++ b/t/924903.t
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use strict;
 use warnings;
-use Test::More tests => 3;
+use Test::More tests => 4;
 use File::stat;
 use T;
 
@@ -11,3 +11,6 @@ ok(-d $path, 'supervise directory correctly created');
 my $info = stat($path);
 my $mode = sprintf("%o", $info->mode & 0777);
 is($mode, '700', 'supervise directory have conservative permissions');
+
+my $noreplace = 'debian/dh-runit-test/var/lib/runit/noreplace/test';
+ok(!-f $noreplace, 'noreplace file is correctly absent');
diff --git a/t/928935.t b/t/928935.t
new file mode 100644
index 000..e31756b
--- /dev/null
+++ b/t/928935.t
@@ -0,0 +1,10 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 2;
+use T;
+
+system_ok('dh_runit', 'debian/test.runscript', 'name=test,noreplace');
+
+my $noreplace = 'debian/dh-runit-test/var/lib/runit/noreplace/test';
+ok(-f $noreplace, 'noreplace file correctly created');
 
-- 
Note, that I send and fetch email in batch, once every 24 hours.
 If matter is urgent, try https://

Bug#928935: Invoke-run: add a way to not stop sysv scripts

2019-05-13 Thread Lorenzo Puliti
Package: runit
Version: 2.1.2-30
Severity: normal



-- System Information:
Debian Release: 10.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.20.3-van (SMP w/4 CPU cores; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: runit (via /run/runit.stopit)

Versions of packages runit depends on:
ii  libc6   2.28-10
ii  runit-helper2.8.10
ii  sysuser-helper  1.3.3

Versions of packages runit recommends:
ii  runit-init  2.1.2-30

runit suggests no packages.

-- Configuration Files:
/etc/runit/3 changed [not included]

-- no debconf information

Hi,

In order to avoid conflicts, recent version of invoke-run interpreter stops the 
sysv
init scripts before starting the run service.
Please note that this logic, when applied to daemons like dbus, slim, sddm, 
lightdm 
(and possibly others) will break the graphic session, so there is need for a way
to prevent the sysv script being replaced by the run script while the graphic 
session
is active.
This also will need support in dh-runit.

Thanks,
Lorenzo