Seite wählen

NETWAYS Blog

Weekly Snap: Update on Updian, SSO in Apache and Perl compilation with PAR::Packer

24 – 28 October looked at the latest version of Updian and shared tips for compiling Perl as well as SSO in Apache.
To begin, Ronny brought us up to scratch on Updian’s latest release. As previously introduced, Updian is a simple update engine for Debian. Compared to v0.2, the new v0.3 has a slicker interface, with sorted lists and generally clearer display of large lists and views. SSH connections can now be specified where the standard port 22 doesn’t apply, and different ports can be used on different servers. To top it off, users of ‘debian-goodies’ can try ’checkrestart’ for a colour-coded view of services for libs that need to be restarted.
Gunnar then introduced the handy PAR::Packer Perl module that compiles Perl scripts with their dependencies linked into a single binary. Platform independent, he showed how to install PAR::Packer on Windows with the help of CPAN and Strawberry Perl. For more info, he recommended http://search.cpan.org/dist/PAR/lib/PAR/Tutorial.pod
Last but not least, Lennart showed how to use ‘single sign on’ (SSO) in Apache with group-specific authentication in an Active Directory environment. Put otherwise, he set out to authenticate a web server via Kerberos ticket and check downstream, whether a user is in a group whose members may access a website. He began by creating a user in Active Directory, and generating a key on the domain controller to which the user is given a principal name. Then he copied the apache2.keytab file to the web server and used kinit to check the apache2.keytab for accuracy, and klist to determine the principal name in advance. Finally, he loaded mod_ldap, mod_authnz_ldap and mod_auth_kerb and configured the browser for SSO access.

Perl-Scripts mit PAR::Packer kompilieren

Manchmal ist es notwendig, Perl-Scripts auf Systeme zu verteilen, auf denen entweder kein Perl installiert ist oder auf dem keine zusätzlichen Perl-Module installiert werden können.
Für diesen Fall gibt es ein Perl-Modul namens PAR::Packer, mit dem beliebige Perl-Scripts inklusive aller Abhängigkeiten kompiliert und in ein einziges Binary gelinkt werden können.
PAR::Packer ist dabei plattformunabhängig und kann so z.B. unter Windows und Linux eingesetzt werden.
Zunächst installieren wir PAR::Packer mit Hilfe von CPAN:
# cpan install PAR::Packer

Je nach Anzahl der noch fehlenden Perl-Module kann dies einige Minuten dauern. Da Windows von Haus aus kein Perl anbietet, muss dieses evtl. vorher installiert werden (Tipp: Strawberry Perl – .
Danach können wir unser erstes Perl-Script kompilieren:
$ cat hello.pl
print "Hello World!\n";
$ pp -o hello hello.pl
$

Als Ergebnis erhalten wir ein Binary namens „hello“, das nun neben dem kompilierten Script auch die Teile der Perl-Laufzeitumgebung enthalten, die zum Ausführen des Scripts notwendig sind. Das Binary hat dabei keine Abhängigkeiten auf Perl-Libraries:
$ ldd hello
linux-vdso.so.1 => (0x00007fffad7ff000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5a23cc0000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5a23921000)
/lib64/ld-linux-x86-64.so.2 (0x00007f5a23f0a000)

Ansonsten verhält sich das Binary genauso wie unser ursprüngliches Perl-Script:
$ ./hello
Hello World!
$

Weitere Informationen zu PAR::Packer gibt es z.B. unter http://search.cpan.org/dist/PAR/lib/PAR/Tutorial.pod.