package Util;
use strict;
-use Crypt::Blowfish;
my $blocksize = 8; # A blowfish block is 8 bytes
my $configfile = "/etc/userdir-ldap/userdir-ldap.conf";
+#my $configfile = "/home/randolph/projects/userdir-ldap/userdir-ldap.conf";
my %config = &ReadConfigFile;
+my $hascryptix = 1;
+eval 'use Crypt::Blowfish';
+if ($@) {
+ $hascryptix = undef;
+ print "No cryptix\n";
+}
+
sub CreateKey {
my $keysize = shift;
my $input;
$input .= " " x ($blocksize - (length($input) % $blocksize)) if (length($input % $blocksize));
- for ($pos = 0; $pos < length($input); $pos += $blocksize) {
- $output .= unpack("H16", $cipher->encrypt(substr($input, $pos, $blocksize)));
+ for ($pos = 0; $pos < length($input); $pos += $blocksize) {
+ $output .= unpack("H16", $cipher->encrypt(substr($input, $pos, $blocksize))) if ($hascryptix);
}
return $output;
}
for ($pos = 0; $pos < length($input); $pos += $blocksize*2) {
$portion = pack("H16", substr($input, $pos, $blocksize*2));
- $output .= $cipher->decrypt($portion);
+ $output .= $cipher->decrypt($portion) if ($hascryptix);
}
$output =~ s/ +$//;
sub FetchKey {
my $fingerprint = shift;
- my ($out, $keyringparam);
+ my ($out, $keyringparam) = undef;
foreach (split(/:/, $config{keyrings})) {
$keyringparam .= "--keyring $_ ";
$fingerprint = "0x".$fingerprint;
$/ = undef; # just suck it up ....
- open(FP, "$config{gpg} $keyringparam --list-sigs --fingerprint $fingerprint|");
+ open(FP, "$config{gpg} --no-options --no-default-keyring $keyringparam --list-sigs --fingerprint $fingerprint|");
$out = <FP>;
close FP;
- open(FP, "$config{gpg} $keyringparam --export -a $fingerprint|");
+ open(FP, "$config{gpg} --no-options --no-default-keyring $keyringparam --export -a $fingerprint|");
$out .= <FP>;
close FP;
$/ = "\n";
# Chop off any trailing comments
s/#.*//;
($attr, $setting) = split(/=/, $_, 2);
- $setting =~ s/"//g;
+ $setting =~ s/"//g; #"
$setting =~ s/;$//;
$attr =~ s/^ +//; $attr =~ s/ +$//;
$setting =~ s/^ +//; $setting =~ s/ +$//;