diff options
author | Michael Janczyk | 2009-04-08 18:49:20 +0200 |
---|---|---|
committer | Michael Janczyk | 2009-04-08 18:49:20 +0200 |
commit | 3e5f20f58619df0b9301603d53c1d0f0e826eb39 (patch) | |
tree | 1fc167b6b1ef8d8c1df0b30ef99e8da8a18ecdad /boot-env/OpenSLX/BootEnvironment/PXE.pm | |
parent | add kiosk & infoscreen plugin to trunk (diff) | |
download | core-3e5f20f58619df0b9301603d53c1d0f0e826eb39.tar.gz core-3e5f20f58619df0b9301603d53c1d0f0e826eb39.tar.xz core-3e5f20f58619df0b9301603d53c1d0f0e826eb39.zip |
added sha1 encryption of PXE menu passwd, thx to Sebastian who actually did the whole thing ;)
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2811 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'boot-env/OpenSLX/BootEnvironment/PXE.pm')
-rw-r--r-- | boot-env/OpenSLX/BootEnvironment/PXE.pm | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/boot-env/OpenSLX/BootEnvironment/PXE.pm b/boot-env/OpenSLX/BootEnvironment/PXE.pm index 160f7193..b8c5b9a6 100644 --- a/boot-env/OpenSLX/BootEnvironment/PXE.pm +++ b/boot-env/OpenSLX/BootEnvironment/PXE.pm @@ -20,6 +20,9 @@ use base qw(OpenSLX::BootEnvironment::Base); use File::Basename; use File::Path; +# for sha1 passwd encryption +use Digest::SHA1; +use MIME::Base64; use OpenSLX::Basics; use OpenSLX::Utils; @@ -202,7 +205,8 @@ sub _getTemplate $pxeTemplate .= "\n# slxsettings configuration\n"; $pxeTemplate .= "TIMEOUT $openslxConfig{'pxe-timeout'}\n" || ""; $pxeTemplate .= "TOTALTIMEOUT $openslxConfig{'pxe-totaltimeout'}\n" || ""; - $pxeTemplate .= "MENU MASTER PASSWD $openslxConfig{'pxe-passwd'}\n" || ""; + my $sha1pass = $self->_sha1pass($openslxConfig{'pxe-passwd'}); + $pxeTemplate .= "MENU MASTER PASSWD $sha1pass\n" || ""; $pxeTemplate .= "MENU TITLE $openslxConfig{'pxe-title'}\n" || ""; # fetch PXE-include, if exists (overwrite existing definitions) @@ -246,4 +250,31 @@ sub _prepareBootloaderConfigFolder return 1; } +# from syslinux 3.73: http://syslinux.zytor.co +sub _random_bytes +{ + my $self = shift; + my $n = shift; + my($v, $i); + + # using perl rand because of problems with encoding(cp850) and 'bytes' + srand($$ ^ time); + $v = ''; + for ( $i = 0 ; $i < $n ; $i++ ) { + $v .= ord(int(rand() * 256)); + } + + return $v; +} + +sub _sha1pass +{ + my $self = shift; + my $pass = shift; + my $salt = shift || MIME::Base64::encode($self->_random_bytes(6), ''); + $pass = Digest::SHA1::sha1_base64($salt, $pass); + + return sprintf('$4$%s$%s$', $salt, $pass); +} + 1; |