Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[TIP] Auto-scramble screen exiting from console
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Risorse italiane (documentazione e tools)
View previous topic :: View next topic  
Author Message
FonderiaDigitale
Veteran
Veteran


Joined: 06 Nov 2003
Posts: 1710
Location: Rome, Italy

PostPosted: Thu Dec 09, 2004 5:13 pm    Post subject: [TIP] Auto-scramble screen exiting from console Reply with quote

Ovvero:

Quote:
vi e' mai capitato di andare in giro in un ambiente 'ostile' (posto di lavoro, aula studio, meeting..) dove il vostro portatile o il vostro pc e' sotto gli occhi di tutti?
penso di si. probabilmente saprete anche che quando uscite da un terminale ( o shell qualsiasi ) si puo' sempre risalire in su con Shift/Bloc Scorr e vedere cosa avete digitato o qual'e' stato l'ultimo output in console prima di sloggarvi. Non bello.
Questo script manda una serie di caratteri casuali sullo schermo fino a riempire il buffer di scroll per aggirare gli spioni. e lo fa anche se la shell crasha.


Procedura (da root, ovviamente :D)

Metodologia n.1
1. creare lo script
Code:
mkdir -p /etc/profile.d
nano -w /etc/profile.d/autoscramble_console
Code:

cleanexit() {
   local lines
   lines=$(expr ${COLUMNS} \* 3)
   cat /dev/urandom 2>&1|head -n${lines}|uuencode -m -
   clear
}

# scramble screen on exit
trap cleanexit 0
trap cleanexit 1
trap cleanexit 3
trap cleanexit 6
trap cleanexit 9
trap cleanexit 15


se non avete abilitato il sourcing automatico di tutti i file presenti in /etc/profile.d, fatelo adesso:
Code:
nano -w /etc/profile

Code:

[....]
for file in /etc/profile.d/*; do . ${file}; done


Metodologia n.2
Invece di usare il metodo suddetto, possiamo anche usare il file ~/.bash_logout di modo tale da rendere il tutto piu granulare.
In questa sede usiamo una configurazione centrale, ma lo stesso vale per i files per-utente.

Code:
touch /etc/bash_logout
chmod 644 /etc/bash_logout
nano -w /etc/bash_logout

Code:
lines=$((${COLUMNS} \* 3))
cat /dev/urandom 2>&1|head -n${lines}|uuencode -m -
clear

Per usarlo per ogni utente, basta fare un symlink al file nella ${HOME}
Code:
ln -s /etc/bash_logout ~/.bash_logout

nel caso di utente corrente, altrimenti sostituire ~ con /home/utente
Possiamo addirittura fare in modo che quando vengono creati nuovi utenti, questi gia abbiano il file:
Code:
ln -sf /etc/bash_logout /etc/skel/.bash_logout

(-f in quanto nel mio layout predefinito c'e' gia un file, ma contiene solo 'clear')
Per usare il giochino gia dalla sessione corrente,
Code:
source /etc/profile


Buon divertimento!
_________________
Come disse un amico, i sistemisti sono un po' come gli artigiani per l'informatica :)


Last edited by FonderiaDigitale on Thu Dec 09, 2004 8:26 pm; edited 2 times in total
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30837
Location: here

PostPosted: Thu Dec 09, 2004 5:15 pm    Post subject: Reply with quote

Utilissimo script lo aggiungero' ai post utilissimi sezione tips. :lol: :lol: :lol:
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
gutter
Bodhisattva
Bodhisattva


Joined: 13 Mar 2004
Posts: 7162
Location: Aarau, Aargau, Switzerland

PostPosted: Thu Dec 09, 2004 5:45 pm    Post subject: Reply with quote

Interessante :D
_________________
Registered as User #281564 and Machines #163761
Back to top
View user's profile Send private message
Dhaki
Guru
Guru


Joined: 16 Jun 2004
Posts: 325
Location: Ticino - CH

PostPosted: Thu Dec 09, 2004 5:47 pm    Post subject: Reply with quote

Ehehe geniale per una scuola 8)

EDIT: Uhm... ho notato adesso (sono root) che aprendo una shell (xterm) e chiudendola genera lo stesso questo codice... non é molto simpatico diciamo. C'é un modo per evitare questo?
Non si potrebbe usare .bash_logout per far eseguire dei comandi al logout?
Back to top
View user's profile Send private message
FonderiaDigitale
Veteran
Veteran


Joined: 06 Nov 2003
Posts: 1710
Location: Rome, Italy

PostPosted: Thu Dec 09, 2004 6:17 pm    Post subject: Reply with quote

certo.
basta che inserisci il contenuto della funzione cleanexit() dentro il file ~/.bash_logout

EDIT: aggiungo questa possibilita' al primo post :)
_________________
Come disse un amico, i sistemisti sono un po' come gli artigiani per l'informatica :)
Back to top
View user's profile Send private message
Dhaki
Guru
Guru


Joined: 16 Jun 2004
Posts: 325
Location: Ticino - CH

PostPosted: Thu Dec 09, 2004 7:01 pm    Post subject: Re: [TIP] Auto-scramble screen exiting from console Reply with quote

FonderiaDigitale wrote:

Per usarlo per ogni utente, basta fare un symlink al file nella ${HOME}
Code:
ln -s /etc/bash_logout /etc/.bash_logout

Non dovrebbe essere:
Code:
ln -s /etc/bash_logout /$HOME/.bash_logout

mmh?
Back to top
View user's profile Send private message
FonderiaDigitale
Veteran
Veteran


Joined: 06 Nov 2003
Posts: 1710
Location: Rome, Italy

PostPosted: Thu Dec 09, 2004 8:25 pm    Post subject: Reply with quote

si, distrazione: correggo subito.
grazie di avermelo fatto presente :)
_________________
Come disse un amico, i sistemisti sono un po' come gli artigiani per l'informatica :)
Back to top
View user's profile Send private message
=DvD=
Veteran
Veteran


Joined: 25 Mar 2004
Posts: 1353

PostPosted: Thu Dec 09, 2004 8:40 pm    Post subject: Reply with quote

Karma a te!
Back to top
View user's profile Send private message
gaffiere
Guru
Guru


Joined: 13 Nov 2003
Posts: 406
Location: Provincia Milano

PostPosted: Sat Dec 11, 2004 5:39 pm    Post subject: Reply with quote

cool 8)

see ya
_________________
Thomaz "Gaffiere"
Middle-Earth XP2200+, 1Gb Ram, 80Gb + 160Gb Hd, SbLive!, Nvidia 6800GT AGP8x
Gentoo Gnu/Linux 2.6.12-gentoo-r10
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Risorse italiane (documentazione e tools) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum