Fixed root check oopsie.
This commit is contained in:
parent
bf8ab31fe5
commit
58bfe20a91
28
wipe.pl
28
wipe.pl
@ -9,16 +9,25 @@ use v5.10;
|
||||
# loose badass and you don't need no stinkin' safety net.
|
||||
use constant CONFIRMATION_PHRASE => "I am a pretty pink pineapple!";
|
||||
|
||||
if ($>) {
|
||||
say "This program requires root, sorry.";
|
||||
exit;
|
||||
}
|
||||
|
||||
my $termios = POSIX::Termios->new;
|
||||
$termios->getattr(fileno(STDIN));
|
||||
# fetch this value once and cache it
|
||||
my $startup_lflag = $termios->getlflag();
|
||||
|
||||
# set termios lflag to not echo keystrokes, and take us out of line mode
|
||||
$termios->setlflag($startup_lflag & ~(ECHO | ECHOK | ICANON));
|
||||
$termios->setattr(fileno(STDIN), TCSANOW);
|
||||
|
||||
END { # reset termios lflag on exit
|
||||
$termios->setlflag($startup_lflag);
|
||||
$termios->setattr(fileno(STDIN), TCSANOW);
|
||||
}
|
||||
|
||||
if ($>) {
|
||||
say "This program requires root, sorry.";
|
||||
exit;
|
||||
}
|
||||
|
||||
# define some colors for convenience
|
||||
my %color = (
|
||||
# use tput to support anything with a terminfo entry
|
||||
@ -36,15 +45,6 @@ if (!$notreally && CONFIRMATION_PHRASE) {
|
||||
do { say; exit } unless CONFIRMATION_PHRASE eq $confirm;
|
||||
}
|
||||
|
||||
# set termios lflag to not echo keystrokes, and take us out of line mode
|
||||
$termios->setlflag($startup_lflag & ~(ECHO | ECHOK | ICANON));
|
||||
$termios->setattr(fileno(STDIN), TCSANOW);
|
||||
|
||||
END { # reset termios lflag on exit
|
||||
$termios->setlflag($startup_lflag);
|
||||
$termios->setattr(fileno(STDIN), TCSANOW);
|
||||
}
|
||||
|
||||
# create our random data and store it in RAM so we can keep reusing it
|
||||
open(my $drand, "<", "/dev/urandom");
|
||||
my $clobber;
|
||||
|
Loading…
x
Reference in New Issue
Block a user