Automatic console locking at system suspend

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Automatic console locking at system suspend

Alessandro DE LAURENZIS
Hello,

I google-ed a lot, but it seems that there is no trivial solution to
this point.

I extensively use console (and tmux), ending up with a lot of
simultaneously open shells; I normally suspend my laptop when I leave,
so it would be a security enhancement to automatically lock all of them.

Trying to follow the same approach I use to lauch xlock for the X
session, I run the following script from my .kshrc:

just22@poseidon:[~]> cat ./bin/console-lock
#!/bin/sh

# Lock console when SIGUSR1 is received
trap '/usr/bin/lock -np' USR1

# Daemonize...
while /usr/bin/true; do
    sleep 1
done


just22@poseidon:[~]> egrep -A1 -B3 console-lock /home/just22/.kshrc
# In console, activate colour support and auto-lock
if [ "${TERM}" == "vt220" ]; then
    export TERM=wsvt25
    ${HOME}/bin/console-lock &
fi


Now, when I send a USR1 signal to all the open console-lock processes
(manually or by means of /etc/apm/suspend):

just22@poseidon:[~]> pkill -USR1 -f ".*console-lock"

the lock command is correctly spawn in each console, but since the
parent process is in background, it is in background, too (resulting
useless, of course).

How could I improve the idea?

Of course, any suitable alternatives would be welcome.

Thanks in advance

--
Alessandro DE LAURENZIS
[mailto:[hidden email]]
LinkedIn: http://it.linkedin.com/in/delaurenzis

Reply | Threaded
Open this post in threaded view
|

Re: Automatic console locking at system suspend

Ted Unangst-6
On Mon, Apr 21, 2014 at 16:51, Alessandro DE LAURENZIS wrote:

> Hello,
>
> I google-ed a lot, but it seems that there is no trivial solution to
> this point.
>
> I extensively use console (and tmux), ending up with a lot of
> simultaneously open shells; I normally suspend my laptop when I leave,
> so it would be a security enhancement to automatically lock all of them.
>
> Trying to follow the same approach I use to lauch xlock for the X
> session, I run the following script from my .kshrc:

I think you have to use X.

Reply | Threaded
Open this post in threaded view
|

Re: Automatic console locking at system suspend

Alex Shupikov
In reply to this post by Alessandro DE LAURENZIS
Hello

Try slock -- http://tools.suckless.org/slock/


2014-04-22 1:51 GMT+11:00 Alessandro DE LAURENZIS <[hidden email]>:
...

> Of course, any suitable alternatives would be welcome.

--
//Alex

Reply | Threaded
Open this post in threaded view
|

Re: Automatic console locking at system suspend

Tomas Bodzar-4
In reply to this post by Alessandro DE LAURENZIS
On Mon, Apr 21, 2014 at 4:51 PM, Alessandro DE LAURENZIS <
[hidden email]> wrote:

> Hello,
>
> I google-ed a lot, but it seems that there is no trivial solution to
> this point.
>
> I extensively use console (and tmux), ending up with a lot of
> simultaneously open shells; I normally suspend my laptop when I leave,
> so it would be a security enhancement to automatically lock all of them.
>

How about using lock(1) ?


>
> Trying to follow the same approach I use to lauch xlock for the X
> session, I run the following script from my .kshrc:
>
> just22@poseidon:[~]> cat ./bin/console-lock
> #!/bin/sh
>
> # Lock console when SIGUSR1 is received
> trap '/usr/bin/lock -np' USR1
>
> # Daemonize...
> while /usr/bin/true; do
>     sleep 1
> done
>
>
> just22@poseidon:[~]> egrep -A1 -B3 console-lock /home/just22/.kshrc
> # In console, activate colour support and auto-lock
> if [ "${TERM}" == "vt220" ]; then
>     export TERM=wsvt25
>     ${HOME}/bin/console-lock &
> fi
>
>
> Now, when I send a USR1 signal to all the open console-lock processes
> (manually or by means of /etc/apm/suspend):
>
> just22@poseidon:[~]> pkill -USR1 -f ".*console-lock"
>
> the lock command is correctly spawn in each console, but since the
> parent process is in background, it is in background, too (resulting
> useless, of course).
>
> How could I improve the idea?
>
> Of course, any suitable alternatives would be welcome.
>
> Thanks in advance
>
> --
> Alessandro DE LAURENZIS
> [mailto:[hidden email]]
> LinkedIn: http://it.linkedin.com/in/delaurenzis

Reply | Threaded
Open this post in threaded view
|

Re: Automatic console locking at system suspend

Tristan PILAT
> On Mon, Apr 21, 2014 at 4:51 PM, Alessandro DE LAURENZIS <
> [hidden email]> wrote:
>
> > Hello,
> >
> > I google-ed a lot, but it seems that there is no trivial solution to
> > this point.
> >
> > I extensively use console (and tmux), ending up with a lot of
> > simultaneously open shells; I normally suspend my laptop when I leave,
> > so it would be a security enhancement to automatically lock all of them.
> >
>

I advice you to install slock and autolock and then add something like for
example
"exec xautolock -time 10 -locker 'slock' &" to your .xinirc or .xsession
--
Tristan

Reply | Threaded
Open this post in threaded view
|

Re: Automatic console locking at system suspend

Alessandro DE LAURENZIS
Hi Tristan,

No, I'm trying to lock the wscons, not an X session...

Cheers

On 7 May 2014 22:42:35 CEST, Tristan PILAT <[hidden email]> wrote:

>> On Mon, Apr 21, 2014 at 4:51 PM, Alessandro DE LAURENZIS <
>> [hidden email]> wrote:
>>
>> > Hello,
>> >
>> > I google-ed a lot, but it seems that there is no trivial solution
>to
>> > this point.
>> >
>> > I extensively use console (and tmux), ending up with a lot of
>> > simultaneously open shells; I normally suspend my laptop when I
>leave,
>> > so it would be a security enhancement to automatically lock all of
>them.
>> >
>>
>
>I advice you to install slock and autolock and then add something like
>for
>example
>"exec xautolock -time 10 -locker 'slock' &" to your .xinirc or
>.xsession
>--
>Tristan

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Reply | Threaded
Open this post in threaded view
|

Re: Automatic console locking at system suspend

Abel Abraham Camarillo Ojeda-2
You could use tmux, run $ sleep 5; zzz;
then detach from tmux and ^D to logout before system suspends.


On Wed, May 7, 2014 at 8:44 PM, Alessandro DE LAURENZIS <
[hidden email]> wrote:

> Hi Tristan,
>
> No, I'm trying to lock the wscons, not an X session...
>
> Cheers
>
> On 7 May 2014 22:42:35 CEST, Tristan PILAT <[hidden email]>
> wrote:
> >> On Mon, Apr 21, 2014 at 4:51 PM, Alessandro DE LAURENZIS <
> >> [hidden email]> wrote:
> >>
> >> > Hello,
> >> >
> >> > I google-ed a lot, but it seems that there is no trivial solution
> >to
> >> > this point.
> >> >
> >> > I extensively use console (and tmux), ending up with a lot of
> >> > simultaneously open shells; I normally suspend my laptop when I
> >leave,
> >> > so it would be a security enhancement to automatically lock all of
> >them.
> >> >
> >>
> >
> >I advice you to install slock and autolock and then add something like
> >for
> >example
> >"exec xautolock -time 10 -locker 'slock' &" to your .xinirc or
> >.xsession
> >--
> >Tristan
>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.