Skip to content

Commit

Permalink
Autologin (only if config is only readable by owner)
Browse files Browse the repository at this point in the history
  • Loading branch information
H.Merijn Brand - Tux committed Sep 15, 2018
1 parent 4afef7f commit dea909c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/PM/CB/GUI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,12 @@ sub update_time {
sub login_dialog {
my ($self) = @_;
if ($self->{username} && $self->{password}) {
($login, $password) = ($self->{username}, $self->{password});
$self->send_login;
return;
}
my $dialog = $self->{mw}->Dialog(
-title => 'Login',
-default_button => 'Login',
Expand Down
7 changes: 5 additions & 2 deletions pm-cb-g
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ BEGIN {
my $home = $ENV{HOME} || $ENV{USERPROFILE} || $ENV{HOMEPATH};
foreach my $rcf (grep { -s }
"$home/pm-cb.rc", "$home/.pm-cbrc", "$home/.config/pm-cb") {
(stat $rcf)[2] & 022 and next;
my $mode = (stat $rcf)[2];
$mode & 022 and next;
open my $fh, "<", $rcf or next;
while (<$fh>) {
s/\s*#.*$//;
m/^\s*[;#]/ and next;
$mode & 044 && m/password/i and next;
my ($k, $v) = (m/^\s*([-\w]+)\s*[:=]\s*(.*\S)/) or next;
$conf{ lc $k
=~ s{-}{_}gr
Expand All @@ -56,6 +58,7 @@ BEGIN {
=~ s{^(?:no|false)$}{0}ir
=~ s{^(?:yes|true)$}{1}ir;
}

}
exists $conf{show_time} and $conf{no_time} = !delete $conf{show_time};
$conf{font_name} =~ m/\s/ and $conf{font_name} = "{".$conf{font_name}."}";
Expand Down

0 comments on commit dea909c

Please sign in to comment.