Re: How to trap ctrl-alt-del?

2016-12-05 Thread Jean Louis
Thank you. How could I forget simple permissions? Now I am using it
that way.

On Thu, Dec 01, 2016 at 06:15:48PM +, Laurent Bercot wrote:
> > The s6-poweroff is for root user, and I have users who wish to
> > poweroff, and I don't want to give them sudo rights to power off the
> > computer. That is why I am searching for simple solution.
> 
>  Create a "poweroff" group.
>  Add all the users you want to that group.
>  chown root:poweroff /bin/s6-poweroff
>  chmod 4750 /bin/s6-poweroff
> 
>  Now, all users in the group "poweroff" have the right to call
> s6-poweroff. They don't have any other privileges.
> 
> --
>  Laurent
> 


Re: How to trap ctrl-alt-del?

2016-12-01 Thread Jean Louis
On Thu, Dec 01, 2016 at 06:15:48PM +, Laurent Bercot wrote:
> > The s6-poweroff is for root user, and I have users who wish to
> > poweroff, and I don't want to give them sudo rights to power off the
> > computer. That is why I am searching for simple solution.
> 
>  Create a "poweroff" group.
>  Add all the users you want to that group.
>  chown root:poweroff /bin/s6-poweroff
>  chmod 4750 /bin/s6-poweroff
> 
>  Now, all users in the group "poweroff" have the right to call
> s6-poweroff. They don't have any other privileges.
> 
> --
>  Laurent

Thank you much.

Jean


Re: How to trap ctrl-alt-del?

2016-12-01 Thread Laurent Bercot

The s6-poweroff is for root user, and I have users who wish to
poweroff, and I don't want to give them sudo rights to power off the
computer. That is why I am searching for simple solution.


 Create a "poweroff" group.
 Add all the users you want to that group.
 chown root:poweroff /bin/s6-poweroff
 chmod 4750 /bin/s6-poweroff

 Now, all users in the group "poweroff" have the right to call
s6-poweroff. They don't have any other privileges.

--
 Laurent



Re: How to trap ctrl-alt-del?

2016-12-01 Thread Jean Louis
OK that is correct, I need to configure acpid, for power off.

And I will leave defaults of reboot with ctrl-alt-del

The s6-poweroff is for root user, and I have users who wish to
poweroff, and I don't want to give them sudo rights to power off the
computer. That is why I am searching for simple solution.

Jean

On Thu, Dec 01, 2016 at 07:33:16PM +0800, Casper Ti. Vector wrote:
> Setting `kernel.ctrl-alt-del' to 0 just makes C-A-D send SIGINT to PID 1
> (instead of triggering a hard reboot).  If you want to make SIGINT
> trigger a grace shutdown, you can modify the SIGINT handler in the
> `service/.s6-svscan' directory.
> 
> But I personally do not think changing signal semantics (which is
> already a mess [1]) is the way to go; instead, I recommend using
> s6-poweroff(8) from s6-linux-init if you are already using that package.
> 
> If you machine is ACPI-enabled, you can also configure acpid to spawn
> s6-poweroff(8) when the power button is pressed, so you may push the
> button to power off your machine.
> 
> [1]  2:mss:1377:201608:hiocpcghpahbaiedeihc>.
> 
> On Thu, Dec 01, 2016 at 02:06:50PM +0300, Jean Louis wrote:
> > What exactly should I change or do, that simply does power off?
> 
> -- 
> My current OpenPGP key:
> RSA4096/0x227E8CAAB7AA186C (expires: 2020.10.19)
> 7077 7781 B859 5166 AE07 0286 227E 8CAA B7AA 186C
> 


Re: How to trap ctrl-alt-del?

2016-12-01 Thread Casper Ti. Vector
Setting `kernel.ctrl-alt-del' to 0 just makes C-A-D send SIGINT to PID 1
(instead of triggering a hard reboot).  If you want to make SIGINT
trigger a grace shutdown, you can modify the SIGINT handler in the
`service/.s6-svscan' directory.

But I personally do not think changing signal semantics (which is
already a mess [1]) is the way to go; instead, I recommend using
s6-poweroff(8) from s6-linux-init if you are already using that package.

If you machine is ACPI-enabled, you can also configure acpid to spawn
s6-poweroff(8) when the power button is pressed, so you may push the
button to power off your machine.

[1] .

On Thu, Dec 01, 2016 at 02:06:50PM +0300, Jean Louis wrote:
> What exactly should I change or do, that simply does power off?

-- 
My current OpenPGP key:
RSA4096/0x227E8CAAB7AA186C (expires: 2020.10.19)
7077 7781 B859 5166 AE07 0286 227E 8CAA B7AA 186C



Re: How to trap ctrl-alt-del?

2016-12-01 Thread Jean Louis
Thank you much. I have figured out that I had to change kernel
parameter to be:

kernel.ctrl-alt-del = 0

and now I see that ctrl-alt-del reboots, it is by default.

What exactly should I change or do, that is simply does power off?



On Sat, Nov 26, 2016 at 10:36:22PM +0800, Casper Ti. Vector wrote:
> Try s6-linux-init [1]; you can modify the scripts in the `.s6-svscan'
> directory according to your requirements.
> 
> [1] .
> 
> On Sat, Nov 26, 2016 at 03:10:32PM +0300, Jean Louis wrote:
> > Now I wonder how to practically implement the -s option, should I just
> > give it something like "sudo s6-poweroff"?
> 
> -- 
> My current OpenPGP key:
> RSA4096/0x227E8CAAB7AA186C (expires: 2020.10.19)
> 7077 7781 B859 5166 AE07 0286 227E 8CAA B7AA 186C
> 


Re: How to trap ctrl-alt-del?

2016-11-28 Thread Casper Ti. Vector
The mail archive (archive.cgi) seems to be still down.
The git interface (cgit.cgi) is working though...

On Fri, Nov 25, 2016 at 04:26:55PM +0800, Casper Ti. Vector wrote:
> The second is an alternative link in case the server returns an empty
> reply, which is happening to me:
> 
> > % curl -vsS 'http://www.skarnet.org/cgi-bin/archive.cgi?2'
> > *   Trying 2001:4b98:dc0:41:216:3eff:fe4f:d7aa...
> > * TCP_NODELAY set
> > *   Trying 92.243.1.28...
> > * TCP_NODELAY set
> > * Connected to www.skarnet.org (2001:4b98:dc0:41:216:3eff:fe4f:d7aa)
> > * port 80 (#0)
> > > GET /cgi-bin/archive.cgi?2 HTTP/1.1
> > > Host: www.skarnet.org
> > > User-Agent: curl/7.51.0
> > > Accept: */*
> > > 
> > * Curl_http_done: called premature == 0
> > * Empty reply from server
> > * Connection #0 to host www.skarnet.org left intact
> > curl: (52) Empty reply from server

-- 
My current OpenPGP key:
RSA4096/0x227E8CAAB7AA186C (expires: 2020.10.19)
7077 7781 B859 5166 AE07 0286 227E 8CAA B7AA 186C



Re: How to trap ctrl-alt-del?

2016-11-26 Thread Guillermo
2016-11-25 6:28 GMT-03:00 Colin Booth:
>
> On Nov 25, 2016 3:53 AM, "Casper Ti. Vector" wrote:
>>
>> On Fri, Nov 25, 2016 at 11:07:15AM +0300, Jean Louis wrote:
>>>
>>> How may I trap ctrl-alt-del,
>>
>> $ sysctl kernel.ctrl-alt-del=0
>
> This is a bit misleading since most (all?) default builds of linux already
> have kernel.ctrl-alt-del set to zero.

Acually, booting my own system with init=/bin/sh (i.e. without a
"proper" init) a couple of months ago I found the opposite to be true,
and IIUC this is also what happened to the OP. Anyway, if one wants to
trap CTRL+Alt+Del it probably *is* a good idea to explicitly set it
with 'sysctl kernel.ctrl-alt-del=0', or some equivalent of 'echo 0
>/proc/sys/kernel/ctrl-alt-del' after mounting /proc, instead of
relying on whatever happens to be the kernel's default.

2016-11-25 5:07 GMT-03:00 Jean Louis:
>
> While previously the ctrl-alt-del was trapped by SysV (or whatever),
> so that system runs "halt", `[...]

sysvinit does indeed turn CTRL+Alt+Del trapping on explicitly in the C code.

2016-11-26 9:10 GMT-03:00 Jean Louis:
>
> Now I wonder how to practically implement the -s option, should I just
> give it something like "sudo s6-poweroff"?
>
> On Fri, Nov 25, 2016 at 12:17:24PM +0300, Jean Louis wrote:
>> Now I found a solution
>> http://www.mail-archive.com/supervision%40list.skarnet.org/msg01038.html

You write a diverted SIGINT handler according to the s6-svscan
documentation, as mentioned earlier, that at some point performs an
's6-svscanctl -6' or 's6-svscanctl -rt' on the scan directory, to make
s6-svscan exec into its 'finish' script with a 'reboot' argument. The
actual rebooting would be done directly or indirectly in the 'finish'
script. What else exactly the diverted SIGINT handler needs to do
depends on your setup, which brings me to...

2016-11-25 5:07 GMT-03:00 Jean Louis:
> [...] now when I have switched to s6-rc an s6-tools, [...]

You say you switched to s6-rc, are you not already running s6-svscan
as process 1 in "divert signals mode" (-s)? Also as mentioned earlier,
there is the s6-linux-init package, and the model of operation of its
s6-linux-init-maker program relies on directly or indirectly
performing an 's6-rc change' from a diverted signal handler to cleanly
bring the services down [1]. Are you using a custom setup instead?

If you use the unmodified s6-linux-init-maker output, you write a
suitable stage2_finish script to bring s6-rc services down, and you
want CTRL+Alt+Del to mean "reboot", then you don't have to do anything
special besides turning the feature on (in the stage2 script or an
s6-rc oneshot); s6-linux-init-maker creates a diverted SIGINT handler
for you (needed for the s6-reboot program to work, now also in
s6-linux-init) that does what you want.

[1] Explained in detail here under the "Shutdown sequence" title:



Re: How to trap ctrl-alt-del?

2016-11-26 Thread Casper Ti. Vector
Try s6-linux-init [1]; you can modify the scripts in the `.s6-svscan'
directory according to your requirements.

[1] .

On Sat, Nov 26, 2016 at 03:10:32PM +0300, Jean Louis wrote:
> Now I wonder how to practically implement the -s option, should I just
> give it something like "sudo s6-poweroff"?

-- 
My current OpenPGP key:
RSA4096/0x227E8CAAB7AA186C (expires: 2020.10.19)
7077 7781 B859 5166 AE07 0286 227E 8CAA B7AA 186C



Re: How to trap ctrl-alt-del?

2016-11-26 Thread Jean Louis
Now I wonder how to practically implement the -s option, should I just
give it something like "sudo s6-poweroff"?

On Fri, Nov 25, 2016 at 12:17:24PM +0300, Jean Louis wrote:
> Now I found a solution 
> http://www.mail-archive.com/supervision@list.skarnet.org/msg01038.html
> 
> Thank you 


Re: How to trap ctrl-alt-del?

2016-11-25 Thread Casper Ti. Vector
On Fri, Nov 25, 2016 at 11:07:15AM +0300, Jean Louis wrote:
> How may I trap ctrl-alt-del,

$ sysctl kernel.ctrl-alt-del=0

> and assign a function to it, so that system nicely shuts down?



The second is an alternative link in case the server returns an empty
reply, which is happening to me:

> % curl -vsS 'http://www.skarnet.org/cgi-bin/archive.cgi?2'
> *   Trying 2001:4b98:dc0:41:216:3eff:fe4f:d7aa...
> * TCP_NODELAY set
> *   Trying 92.243.1.28...
> * TCP_NODELAY set
> * Connected to www.skarnet.org (2001:4b98:dc0:41:216:3eff:fe4f:d7aa)
> * port 80 (#0)
> > GET /cgi-bin/archive.cgi?2 HTTP/1.1
> > Host: www.skarnet.org
> > User-Agent: curl/7.51.0
> > Accept: */*
> > 
> * Curl_http_done: called premature == 0
> * Empty reply from server
> * Connection #0 to host www.skarnet.org left intact
> curl: (52) Empty reply from server

-- 
My current OpenPGP key:
RSA4096/0x227E8CAAB7AA186C (expires: 2020.10.19)
7077 7781 B859 5166 AE07 0286 227E 8CAA B7AA 186C