Package: migrationtools
Version: 46.2-1
Severity: important
While trying to migrate a passwd/shadow into LDAP I got this weird issue.
After editing /etc/migrationtools/migrate_common.ph with the following values:
$DEFAULT_MAIL_DOMAIN = "domain.tld.pe";
# Default base
$DEFAULT_BASE = "dc=domain,dc=tld,dc=pe";
# turn this on to support more general object clases
# such as person.
$EXTENDED_SCHEMA = 1;
# Comment this out if your ldap server does not support UTF8 encoding
$USE_UTF8 = 1;
# Uncomment these to exclude Debian-managed system users and groups
$IGNORE_UID_BELOW = 500; # this is due former system wasn't Debian
$IGNORE_GID_BELOW = 100;
then I ran migrate_passwd.pl I got the following output.
dn: uid=usera,ou=People,dc=domain,dc=tld,dc=pe
uid: usera
cn:: QXJtYW5kbyBBZ3JhbW9udGU=
givenName:: QXJtYW5kbw==
sn:: QWdyYW1vbnRl
...
As you can see cn, givenName and sn values were totally wrong and had the
userPassword format. I did more testing and research withouth luck.
Finally I've used the latest MigrationTools version (47) and it went all fine!
I used the same configuration file this time.
This quite puzzles me, but I hadn't much more time to investigate on tha matter.
I'm attaching the diff I've made between those two versions.
regards
-- System Information:
Debian Release: 4.0
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-4-k7
Locale: LANG=es_PE.UTF-8, LC_CTYPE=es_PE.UTF-8 (charmap=UTF-8)
--- /usr/share/migrationtools/migrate_passwd.pl 2006-01-29 10:16:12.000000000
-0500
+++ migrate_passwd.pl 2006-01-24 23:18:16.000000000 -0500
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
-# $Id: migrate_passwd.pl,v 1.16 2003/11/25 23:12:52 lukeh Exp $
+# $Id: migrate_passwd.pl,v 1.17 2005/03/05 03:15:55 lukeh Exp $
#
# Copyright (c) 1997-2003 Luke Howard.
# All rights reserved.
@@ -36,7 +36,6 @@
#
# Thanks to Peter Jacob Slot <[EMAIL PROTECTED]>.
#
-# UTF8 support and random tweaks by Jonas Smedegaard <[EMAIL PROTECTED]>.
require 'migrate_common.ph';
@@ -53,14 +52,31 @@
next if /^\s*$/;
next if /^#/;
next if /^\+/;
-
+
+ s/Ä/Ae/g;
+ s/Ë/Ee/g;
+ s/Ï/Ie/g;
+ s/Ö/Oe/g;
+ s/Ü/Ue/g;
+
+ s/ä/ae/g;
+ s/ë/ee/g;
+ s/ï/ie/g;
+ s/ö/oe/g;
+ s/ü/ue/g;
+ s/ÿ/ye/g;
+ s/ß/ss/g;
+ s/é/e/g;
+
+ s/Æ/Ae/g;
+ s/æ/ae/g;
+ s/Ø/Oe/g;
+ s/ø/oe/g;
+ s/Å/Ae/g;
+ s/å/ae/g;
+
local($user, $pwd, $uid, $gid, $gecos, $homedir, $shell) = split(/:/);
- next if (int($IGNORE_UID_BELOW) and int($uid) < int($IGNORE_UID_BELOW));
- next if (int($IGNORE_UID_ABOVE) and int($uid) > int($IGNORE_UID_ABOVE));
- next if (int($IGNORE_GID_BELOW) and int($gid) < int($IGNORE_GID_BELOW));
- next if (int($IGNORE_GID_ABOVE) and int($gid) > int($IGNORE_GID_ABOVE));
-
if ($use_stdout) {
&dump_user(STDOUT, $user, $pwd, $uid, $gid, $gecos, $homedir,
$shell);
} else {
@@ -84,25 +100,25 @@
$sn = $tmp[$#tmp];
pop(@tmp);
$givenname=join(' ',@tmp);
-
+
print $HANDLE "dn: uid=$user,$NAMINGCONTEXT\n";
print $HANDLE "uid: $user\n";
- &print_utf8($HANDLE, "cn", $cn);
+ print $HANDLE "cn: $cn\n";
if ($EXTENDED_SCHEMA) {
if ($wphone) {
- &print_utf8($HANDLE, "telephoneNumber", $wphone);
+ print $HANDLE "telephoneNumber: $wphone\n";
}
if ($office) {
- &print_utf8($HANDLE, "roomNumber", $office);
+ print $HANDLE "roomNumber: $office\n";
}
if ($hphone) {
- &print_utf8($HANDLE, "homePhone", $hphone);
+ print $HANDLE "homePhone: $hphone\n";
}
if ($givenname) {
- &print_utf8($HANDLE, "givenName", $givenname);
+ print $HANDLE "givenName: $givenname\n";
}
- &print_utf8($HANDLE, "sn", $sn);
+ print $HANDLE "sn: $sn\n";
if ($DEFAULT_MAIL_DOMAIN) {
print $HANDLE "mail: [EMAIL PROTECTED]";
}
@@ -122,7 +138,7 @@
print $HANDLE "objectClass: top\n";
if ($DEFAULT_REALM) {
- print $HANDLE "objectClass: krb5Principal\n";
+ print $HANDLE "objectClass: kerberosSecurityObject\n";
}
if ($shadowUsers{$user} ne "") {
@@ -132,7 +148,7 @@
}
if ($DEFAULT_REALM) {
- print $HANDLE "krb5PrincipalName: [EMAIL PROTECTED]";
+ print $HANDLE "krbName: [EMAIL PROTECTED]";
}
if ($shell) {
@@ -158,9 +174,7 @@
}
if ($gecos) {
-# FIXME: Why does UTF8 encoding fail here? Too long? Restriction in nis schema?
-# &print_utf8($HANDLE, "gecos", $gecos);
- &print_7bit($HANDLE, "gecos", $gecos);
+ print $HANDLE "gecos: $gecos\n";
}
print $HANDLE "\n";
@@ -188,7 +202,7 @@
if ($pwd) {
print $HANDLE "userPassword: {crypt}$pwd\n";
}
- if ($lastchg) {
+ if ($lastchg ne "") {
print $HANDLE "shadowLastChange: $lastchg\n";
}
if ($min) {
@@ -211,79 +225,3 @@
}
}
-sub print_7bit
-{
- local($HANDLE, $attribute, $content) = @_;
-
- for($content) {
- s/Ä/Ae/g;
- s/Ë/Ee/g;
- s/Ï/Ie/g;
- s/Ö/Oe/g;
- s/Ü/Ue/g;
-
- s/ä/ae/g;
- s/ë/ee/g;
- s/ï/ie/g;
- s/ö/oe/g;
- s/ü/ue/g;
- s/ÿ/ye/g;
- s/ß/ss/g;
- s/é/e/g;
-
- s/Æ/Ae/g;
- s/æ/ae/g;
- s/Ø/Oe/g;
- s/ø/oe/g;
- s/Å/Aa/g;
- s/å/aa/g;
-
- }
-
- print $HANDLE "$attribute: $content\n";
-}
-
-sub print_utf8
-{
-# Regexp found on perl-unicode mailinglist in an email posted by
-# Jarkko Hietaniemi <[EMAIL PROTECTED]>
-
- local($HANDLE, $attribute, $content) = @_;
-
- if ($USE_UTF8) {
-# print $HANDLE "$attribute\:: " . &encode_base64(pack("U0U*",
unpack("C*", $content)), "") . "\n";
- for($content) {
-
s/([\x80-\xFF])/chr(0xC0|ord($1)>>6).chr(0x80|ord($1)&0x3F)/eg;
- }
- print $HANDLE "$attribute\:: " . &encode_base64($content, "") .
"\n";
- } else {
- &print_7bit($HANDLE, "$attribute", "$content");
- }
-}
-
-sub encode_base64 ($;$)
-# Found on openldap mailinglist in an email posted by
-# Baruzzi Giovanni <[EMAIL PROTECTED]>
-
-# Historically this module has been implemented as pure perl code.
-# The XS implementation runs about 20 times faster, but the Perl
-# code might be more portable, so it is still here.
-{
- my $res = "";
- my $eol = $_[1];
- $eol = "\n" unless defined $eol;
- pos($_[0]) = 0; # ensure start at the beginning
- while ($_[0] =~ /(.{1,45})/gs) {
- $res .= substr(pack('u', $1), 1);
- chop($res);
- }
- $res =~ tr|` -_|AA-Za-z0-9+/|; # `# help emacs
- # fix padding at the end
- my $padding = (3 - length($_[0]) % 3) % 3;
- $res =~ s/.{$padding}$/'=' x $padding/e if $padding;
- # break encoded string into lines of no more than 76 characters each
- if (length $eol) {
- $res =~ s/(.{1,76})/$1$eol/g;
- }
- $res;
-}