MigrationTools-47/0040755000175200017500000000000010365576010013103 5ustar lukehpadlMigrationTools-47/ads/0040755000175200017500000000000010365576010013652 5ustar lukehpadlMigrationTools-47/ads/migrate_passwd_ads.pl0100755000175200017500000000750610365576010020057 0ustar lukehpadl#!/usr/bin/perl # # $HP: migrate_passwd_ads.pl,v 1.3 2000/12/20 18:42:13 slee Exp $ # $Id: migrate_passwd_ads.pl,v 1.3 2006/01/25 04:18:08 lukeh Exp $ # # Copyright (c) 1997-2006 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # require 'migrate_common.ph'; $PROGRAM = "migrate_passwd.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); &parse_args(); &open_files(); while() { chop; next if /^#/; next if /^\+/; local($user, $pwd, $uid, $gid, $gecos, $homedir, $shell) = split(/:/); if ($use_stdout) { &dump_user(STDOUT, $user, $pwd, $uid, $gid, $gecos, $homedir, $shell); } else { &dump_user(OUTFILE, $user, $pwd, $uid, $gid, $gecos, $homedir, $shell); } } sub dump_user { local($HANDLE, $user, $pwd, $uid, $gid, $gecos, $homedir, $shell) = @_; local($name,$office,$wphone,$hphone)=split(/,/,$gecos); local($sn); local($givenname); local($cn); local(@tmp); if ($DEFAULT_CN eq "yes") { if ($name) { $cn = $name; } else { $cn = $user; } } else { $cn = $user; } $_ = $cn; @tmp = split(/\s+/); $sn = $tmp[$#tmp]; pop(@tmp); $givenname=join(' ',@tmp); print $HANDLE "dn: cn=$cn,$NAMINGCONTEXT\n"; print $HANDLE "objectClass: user\n"; print $HANDLE "cn: $cn\n"; print $HANDLE "sAMAccountName: $user\n"; print $HANDLE "uid: $user\n"; # if ($SYNC_NISDOMAIN) { # print $HANDLE "syncNisDomain: $SYNC_NISDOMAIN\n"; # } if ($EXTENDED_SCHEMA) { if ($wphone) { print $HANDLE "telephoneNumber: $wphone\n"; } if ($office) { print $HANDLE "roomNumber: $office\n"; } if ($hphone) { print $HANDLE "homePhone: $hphone\n"; } if ($givenname) { print $HANDLE "givenName: $givenname\n"; } print $HANDLE "sn: $sn\n"; if ($DEFAULT_MAIL_DOMAIN) { print $HANDLE "mail: $user@","$DEFAULT_MAIL_DOMAIN\n"; } } if ($shell) { print $HANDLE "loginShell: $shell\n"; } if ($uid ne "") { print $HANDLE "uidNumber: $uid\n"; } if ($gid ne "") { print $HANDLE "gidNumber: $gid\n"; } if ($homedir) { print $HANDLE "unixHomeDirectory: $homedir\n"; } if ($gecos) { print $HANDLE "gecos: $gecos\n"; } # if ($pwd && $pwd ne "x" && $pwd ne "*") { # print $HANDLE "userPassword: {CRYPT}$pwd\n"; # } print $HANDLE "\n"; } close(INFILE); if (OUTFILE != STDOUT) { close(OUTFILE); } MigrationTools-47/ads/migrate_all_online_ads.sh0100755000175200017500000001660210365576010020666 0ustar lukehpadl#!/bin/sh # # $HP: migrate_all_online_ads.sh,v 1.3 2000/12/20 18:42:11 slee Exp $ # $Id: migrate_all_online_ads.sh,v 1.3 2006/01/25 04:18:08 lukeh Exp $ # # Copyright (c) 1997-2006 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # generic migration script for flat files, YP and NetInfo. # uses ldapadd SHELL=/bin/sh export SHELL DB=/tmp/nis.$$.ldif #if [ "X$ETC_ALIASES" = "X" ]; then # ETC_ALIASES=/etc/aliases #fi #if [ "X$ETC_FSTAB" = "X" ]; then # ETC_FSTAB=/etc/fstab #fi #if [ "X$ETC_HOSTS" = "X" ]; then # ETC_HOSTS=/etc/hosts #fi #if [ "X$ETC_NETWORKS" = "X" ]; then # ETC_NETWORKS=/etc/networks #fi if [ "X$ETC_PASSWD" = "X" ]; then ETC_PASSWD=/etc/passwd fi if [ "X$ETC_GROUP" = "X" ]; then ETC_GROUP=/etc/group fi #if [ "X$ETC_SERVICES" = "X" ]; then # ETC_SERVICES=/etc/services #fi #if [ "X$ETC_PROTOCOLS" = "X" ]; then # ETC_PROTOCOLS=/etc/protocols #fi #if [ "X$ETC_RPC" = "X" ]; then # ETC_RPC=/etc/rpc #fi #if [ "X$ETC_NETGROUP" = "X" ]; then # ETC_NETGROUP=/etc/netgroup #fi if [ -z "${LDAPMODIFY}" ] then LDAPMODIFY="/usr/xad/bin/ldapmodify" fi if [ ! -x "${LDAPMODIFY}" ] then echo "Error: Incomplete installation of the LDAP Client tools fileset." echo " Missing ${LDAPMODIFY} tool" else LDAPADD="/usr/xad/bin/ldapmodify -a -c" fi if [ -z "${PERL}" ] then PERL="/usr/bin/perl" fi if [ ! -x "${PERL}" ] then echo "Error: Incomplete installation of the LDAP Client tools fileset." echo " Missing ${PERL} tool" fi if [ "X$LDAP_BASEDN" = "X" ]; then defaultcontext=`$PERL -e 'require "migrate_common.ph"; print \$DEFAULT_BASE';` question="Enter the X.500 naming context you wish to import into: [$defaultcontext]" echo "$question " | tr -d '\012' > /dev/tty read LDAP_BASEDN if [ "X$LDAP_BASEDN" = "X" ]; then if [ "$defaultcontext" = "X" ]; then echo "You must specify a default context." exit 2 else LDAP_BASEDN=$defaultcontext fi fi fi export LDAP_BASEDN if [ "X$SYNC_NISDOMAIN" = "X" ]; then defaultnisdomain=`$PERL -e 'require "migrate_common.ph"; print \$SYNC_NISDOMAIN';` question="Enter the NIS Domain you wish to import into: [$defaultnisdomain]" echo "$question " | tr -d '\012' > /dev/tty read SYNC_NISDOMAIN if [ "X$SYNC_NISDOMAIN" = "X" ]; then if [ "$defaultnisdomain" = "X" ]; then echo "You must specify a default NIS Domain." exit 2 else SYNC_NISDOMAIN=$defaultnisdomain fi fi fi export SYNC_NISDOMAIN if [ "X$LDAPHOST" = "X" ]; then question="Enter the name of your LDAP server [ldap]:" echo "$question " | tr -d '\012' > /dev/tty read LDAPHOST if [ "X$LDAPHOST" = "X" ]; then LDAPHOST="ldap" fi fi if [ "X$LDAP_BINDDN" = "X" ]; then question="Enter the manager DN: [cn=Administrator,cn=Users,$LDAP_BASEDN]:" echo "$question " | tr -d '\012' > /dev/tty read LDAP_BINDDN if [ "X$LDAP_BINDDN" = "X" ]; then LDAP_BINDDN="cn=Administrator,cn=Users,$LDAP_BASEDN" fi fi export LDAP_BINDDN if [ "X$LDAP_BINDCRED" = "X" ]; then question="Enter the credentials to bind with:" echo "$question " | tr -d '\012' > /dev/tty stty -echo read LDAP_BINDCRED stty echo echo fi if [ "X$CN" = "X" ]; then echo echo "Do you wish to use the user's account name or proper name (as defined in the" echo "GECOS field) to define the entry's distinguished name? Note: if you wish to" echo "use the proper name, it must be unique for each entry. Examples:" echo echo "Account Name:" echo " DN: cn=jchan,cn=users,dc=localdom,dc=myorg,dc=org" echo echo "Proper Name:" echo " DN: cn=James Chan,cn=users,dc=localdom,dc=myorg,dc=org" echo while ( true ) do question="[a]ccount Name or [p]roper name? [p]:" echo "$question " | tr -d '\012' > /dev/tty CN="$(line | tr "[:upper:]" "[:lower:]")" if [ "$CN" = "a" ] ; then CN="no" break; elif [ "$CN" = "p" ] ; then CN="yes" break; else echo "Please select \"a\" or \"p\"." fi done fi export CN echo echo echo "Importing into $LDAP_BASEDN..." echo #echo "Creating naming context entries..." #$PERL migrate_base.pl -n > $DB #echo "Migrating aliases..." #$PERL migrate_aliases.pl $ETC_ALIASES >> $DB #echo "Migrating fstab..." #$PERL migrate_fstab.pl $ETC_FSTAB >> $DB echo "Migrating groups..." $PERL migrate_group_ads.pl $ETC_GROUP >> $DB #echo "Migrating hosts..." #$PERL migrate_hosts.pl $ETC_HOSTS >> $DB #echo "Migrating networks..." #$PERL migrate_networks.pl $ETC_NETWORKS >> $DB echo "Migrating users..." $PERL migrate_passwd_ads.pl $ETC_PASSWD >> $DB #echo "Migrating protocols..." #$PERL migrate_protocols.pl $ETC_PROTOCOLS >> $DB #echo "Migrating rpcs..." #$PERL migrate_rpc.pl $ETC_RPC >> $DB #echo "Migrating services..." #$PERL migrate_services.pl $ETC_SERVICES >> $DB #echo "Migrating netgroups..." #$PERL migrate_netgroup.pl $ETC_NETGROUP >> $DB #echo "Migrating netgroups (by user)..." #$PERL migrate_netgroup_byuser.pl $ETC_NETGROUP >> $DB #echo "Migrating netgroups (by host)..." #$PERL migrate_netgroup_byhost.pl $ETC_NETGROUP >> $DB echo "Your data has been migrated to the following ldif file: $DB" question="Do you wish to import that file into your directory now (y/n):" echo "$question " | tr -d '\012' > /dev/tty read yn if [[ "$yn" = "y" || "$yn" = "Y" || "$yn" = "yes" ]] then echo "Importing into LDAP..." $LDAPADD -h $LDAPHOST -D "$LDAP_BINDDN" -w "$LDAP_BINDCRED" -f $DB err=$? if [ $err -ne 0 ]; then echo "$LDAPADD: returned error $err" echo "Your new ldif database file exists in: $DB" e=$? else echo "$LDAPADD: succeeded" rm -f $DB e=$? fi else echo "You may import the ldif file into the directory with the following" echo "command: $LDAPADD -h $LDAPHOST -D "$LDAP_BINDDN" -w password -f $DB" exit 1 fi if [ "X$EXIT" != "Xno" ]; then exit $e fi MigrationTools-47/ads/migrate_group_ads.pl0100755000175200017500000000535210365576010017707 0ustar lukehpadl#!/usr/bin/perl # # $HP: migrate_group_ads.pl,v 1.3 2000/12/20 18:42:13 slee Exp $ # $Id: migrate_group_ads.pl,v 1.2 2006/01/25 04:10:31 lukeh Exp $ # # Copyright (c) 1997 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # Group migration tool # # require 'migrate_common.ph'; $PROGRAM = "migrate_group.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); &parse_args(); &open_files(); while() { chop; next if /^#/; next if /^\+/; local($group, $pwd, $gid, $users) = split(/:/); if ($use_stdout) { &dump_group(STDOUT, $group, $pwd, $gid, $users); } else { &dump_group(OUTFILE, $group, $pwd, $gid, $users); } } sub dump_group { local($HANDLE, $group, $pwd, $gid, $users) = @_; local(@members) = split(/,/, $users); print $HANDLE "dn: cn=$group,$NAMINGCONTEXT\n"; print $HANDLE "objectClass: group\n"; print $HANDLE "cn: $group\n"; print $HANDLE "sAMAccountName: $group\n"; print $HANDLE "gidNumber: $gid\n"; @members = uniq($group, @members); foreach $_ (@members) { print $HANDLE "memberUid: $_\n"; } # if ($SYNC_NISDOMAIN) { # print $HANDLE "syncNisDomain: $SYNC_NISDOMAIN\n"; # } print $HANDLE "\n"; } close(INFILE); if (OUTFILE != STDOUT) { close(OUTFILE); } MigrationTools-47/ads/migrate_all_nis_online_ads.sh0100755000175200017500000000561210365576010021536 0ustar lukehpadl#!/bin/sh # # $HP: migrate_all_nis_online_ads.sh,v 1.2 2000/11/21 06:37:04 slee Exp $ # $Id: migrate_all_nis_online_ads.sh,v 1.3 2006/01/25 04:18:08 lukeh Exp $ # # Copyright (c) 1997-2006 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # Migrate NIS/YP accounts using ldapadd # PATH=$PATH:. export PATH TMPDIR="/tmp" ETC_PASSWD="$TMPDIR/passwd.$$.ldap" ETC_GROUP="$TMPDIR/group.$$.ldap" #ETC_SERVICES="$TMPDIR/services.$$.ldap" #ETC_PROTOCOLS="$TMPDIR/protocols.$$.ldap" #ETC_FSTAB="$TMPDIR/fstab.$$.ldap" #ETC_RPC="$TMPDIR/rpc.$$.ldap" #ETC_HOSTS="$TMPDIR/hosts.$$.ldap" #ETC_NETWORKS="$TMPDIR/networks.$$.ldap" #ETC_ALIASES="$TMPDIR/aliases.$$.ldap" EXIT=no question="Enter the NIS domain to import from (optional): " echo "$question " | tr -d '\012' > /dev/tty read DOM if [ "X$DOM" = "X" ]; then DOMFLAG="" else DOMFLAG="-d $DOM" fi ypcat $DOMFLAG passwd > $ETC_PASSWD ypcat $DOMFLAG group > $ETC_GROUP #ypcat $DOMFLAG services > $ETC_SERVICES #ypcat $DOMFLAG protocols > $ETC_PROTOCOLS #touch $ETC_FSTAB #ypcat $DOMFLAG rpc.byname > $ETC_RPC #ypcat $DOMFLAG hosts > $ETC_HOSTS #ypcat $DOMFLAG networks > $ETC_NETWORKS ##ypcat $DOMFLAG -k aliases > $ETC_ALIASES . migrate_all_online_ads.sh rm -f $ETC_PASSWD rm -f $ETC_GROUP #rm -f $ETC_SERVICES #rm -f $ETC_PROTOCOLS #rm -f $ETC_FSTAB #rm -f $ETC_RPC #rm -f $ETC_HOSTS #rm -f $ETC_NETWORKS #rm -f $ETC_ALIASES MigrationTools-47/ads/migrate_base.pl0100755000175200017500000000666010365576010016641 0ustar lukehpadl#!/usr/bin/perl # # $HP: migrate_base.pl,v 1.2 2000/11/21 06:37:05 slee Exp $ # $Id: migrate_base.pl,v 1.1 2001/08/12 15:19:36 lukeh Exp $ # # Copyright (c) 1997 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # LDIF entries for base DN # # require 'migrate_common.ph'; $PROGRAM = "migrate_base.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); $classmap{'o'} = 'organization'; $classmap{'dc'} = 'domain'; $classmap{'l'} = 'locality'; $classmap{'ou'} = 'organizationalUnit'; $classmap{'c'} = 'country'; $classmap{'nismapname'} = 'nisMap'; $classmap{'cn'} = 'container'; sub gen_suffix { @dn_components = split(/,/, $DEFAULT_BASE); for ($dnloc = $#dn_components; $dnloc >= 0; $dnloc--) { &base_ldif; } } sub base_ldif { # we don't handle multivalued RDNs here; they're unlikely # in a base DN. # Don't escape commas either XXX local ($rdn) = $dn_components[$dnloc]; local ($remaining_dn) = join(',', @dn_components[($dnloc + 1)..$#dn_components]); ldif_entry($rdn, $remaining_dn); } sub ldif_entry { # remove leading, trailing whitespace local ($lhs, $rhs) = @_; local ($type, $val) = split(/\=/, $lhs); local ($dn); if ($rhs ne "") { $dn = $lhs . ',' . $rhs; } else { $dn = $lhs; } $type =~ s/$\s*//; $type =~ s/^\s*//; $type =~ tr/A-Z/a-z/; $val =~ s/$\s*//; $val =~ s/^\s*//; print "dn: $dn\n"; print "$type: $val\n"; print "objectClass: top\n"; print "objectClass: $classmap{$type}\n"; if ($EXTENDED_SCHEMA) { if ($DEFAULT_MAIL_DOMAIN) { print "objectClass: domainRelatedObject\n"; print "associatedDomain: $DEFAULT_MAIL_DOMAIN\n"; } } print "\n"; } sub gen_namingcontexts { # uniq naming contexts local (@ncs, $map, $nc); foreach $map (keys %NAMINGCONTEXT) { $nc = $NAMINGCONTEXT{$map}; if (!grep(/^$nc$/, @ncs)) { push(@ncs, $nc); &ldif_entry($nc, $DEFAULT_BASE); } } } sub main { if ($ARGV[0] ne "-n") { &gen_suffix(); } &gen_namingcontexts(); } &main; MigrationTools-47/ads/migrate_common.ph0100755000175200017500000001147310365576010017211 0ustar lukehpadl# # $Id: migrate_common.ph,v 1.2 2006/01/25 04:10:31 lukeh Exp $ # # Copyright (c) 1997 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # Common defines for MigrationTools # #$NAMINGCONTEXT{'aliases'} = "ou=Aliases"; #$NAMINGCONTEXT{'fstab'} = "ou=Mounts"; $NAMINGCONTEXT{'passwd'} = "cn=Users"; #$NAMINGCONTEXT{'netgroup_byuser'} = "nisMapName=netgroup.byuser"; #$NAMINGCONTEXT{'netgroup_byhost'} = "nisMapName=netgroup.byhost"; $NAMINGCONTEXT{'group'} = "cn=Users"; #$NAMINGCONTEXT{'netgroup'} = "ou=Netgroup"; #$NAMINGCONTEXT{'hosts'} = "cn=Computers"; #$NAMINGCONTEXT{'networks'} = "ou=Networks"; #$NAMINGCONTEXT{'protocols'} = "ou=Protocols"; #$NAMINGCONTEXT{'rpc'} = "ou=Rpc"; #$NAMINGCONTEXT{'services'} = "ou=Services"; # Default DNS domain $DEFAULT_MAIL_DOMAIN = "padl.com"; # Default base # If we haven't set the default base, guess it automagically. if (!defined($DEFAULT_BASE)) { $DEFAULT_BASE = &domain_expand($DEFAULT_MAIL_DOMAIN); $DEFAULT_BASE =~ s/,$//; } # # allow environment variables to override predefines # if (defined($ENV{'LDAP_BASEDN'})) { $DEFAULT_BASE = $ENV{'LDAP_BASEDN'}; } if (defined($ENV{'SYNC_NISDOMAIN'})) { $SYNC_NISDOMAIN = $ENV{'SYNC_NISDOMAIN'}; } elsif (defined($ENV{'LDAP_BASEDN'})) { $SYNC_NISDOMAIN = $ENV{'LDAP_BASEDN'}; $SYNC_NISDOMAIN =~ s/^[^=]*=([^,]*),.*$/$1/; $SYNC_NISDOMAIN =~ s/^\s+//; $SYNC_NISDOMAIN =~ s/\s+$//; } if (defined($ENV{'LDAP_DEFAULT_MAIL_DOMAIN'})) { $DEFAULT_MAIL_DOMAIN = $ENV{'DEFAULT_MAIL_DOMAIN'}; } # binddn used for alias owner (otherwise uid=root,...) if (defined($ENV{'LDAP_BINDDN'})) { $DEFAULT_OWNER = $ENV{'LDAP_BINDDN'}; } if (defined($ENV{'CN'})) { $DEFAULT_CN = $ENV{'CN'}; } else { $DEFAULT_CN = "yes"; } # turn this on to support more general object clases # such as person. $EXTENDED_SCHEMA = 0; # Default Kerberos realm if ($EXTENDED_SCHEMA) { $DEFAULT_REALM = $DEFAULT_MAIL_DOMAIN; $DEFAULT_REALM =~ tr/a-z/A-Z/; } if (-x "/usr/sbin/revnetgroup") { $REVNETGROUP = "/usr/sbin/revnetgroup"; } elsif (-x "/usr/lib/yp/revnetgroup") { $REVNETGROUP = "/usr/lib/yp/revnetgroup"; } sub parse_args { if ($#ARGV < 0) { print STDERR "Usage: $PROGRAM infile [outfile]\n"; exit 1; } $INFILE = $ARGV[0]; if ($#ARGV > 0) { $OUTFILE = $ARGV[1]; } } sub open_files { open(INFILE); if ($OUTFILE) { open(OUTFILE,">$OUTFILE"); $use_stdout = 0; } else { $use_stdout = 1; } } # moved from migrate_hosts.pl # lukeh 10/30/97 sub domain_expand { local($first) = 1; local($dn); local(@namecomponents) = split(/\./, $_[0]); foreach $_ (@namecomponents) { $first = 0; $dn .= "dc=$_,"; } $dn .= $DEFAULT_BASE; return $dn; } # case insensitive unique sub uniq { local($name) = shift(@_); local(@vec) = sort {uc($a) cmp uc($b)} @_; local(@ret); local($next, $last); foreach $next (@vec) { if ((uc($next) ne uc($last)) && (uc($next) ne uc($name))) { push (@ret, $next); } $last = $next; } return @ret; } # concatenate naming context and # organizational base sub getsuffix { local($program) = shift(@_); local($nc); $program =~ s/^migrate_(.*)\.pl$/$1/; $nc = $NAMINGCONTEXT{$program}; if ($nc eq "") { return $DEFAULT_BASE; } else { return $nc . ',' . $DEFAULT_BASE; } } 1; MigrationTools-47/MigrationTools.spec0100644000175200017500000000137710365576010016736 0ustar lukehpadlSummary: Migration scripts for LDAP Name: MigrationTools Version: 42 Release: 1 Source: ftp://ftp.padl.com/pub/%{name}-%{version}.tar.gz URL: http://www.padl.com/ Copyright: BSD Group: Networking/Utilities BuildRoot: /tmp/rpm-%{name}-root Prefix: /usr/local %description The MigrationTools are a set of Perl scripts for migrating users, groups, aliases, hosts, netgroups, networks, protocols, RPCs, and services from existing nameservices (flat files, NIS, and NetInfo) to LDAP. %prep export RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/usr/local/%{name} %setup %build %install cp -a migrate_* $RPM_BUILD_ROOT/usr/local/%{name} %clean rm -rf $RPM_BUILD_ROOT %files /usr/local/%{name} %doc README MigrationTools-47/migrate_netgroup_byhost.pl0100755000175200017500000000541610365576010020411 0ustar lukehpadl#!/usr/bin/perl # # $Id: migrate_netgroup_byhost.pl,v 1.3 2003/04/15 03:09:34 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # netgroup migration tool # # require 'migrate_common.ph'; $PROGRAM = "migrate_netgroup_byhost.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); if (!(-x $REVNETGROUP)) { exit 1; } &parse_args(); &open_files(); print "dn: nisMapName=netgroup.byhost,$NAMINGCONTEXT\n"; print "objectClass: nisMap\n"; print "objectClass: top\n"; print "nisMapName: netgroup.byhost\n"; print "\n"; open(REVNETGROUP, "$REVNETGROUP -h < $INFILE |"); while() { chop; next unless ($_); next if /^#/; s/#(.*)$//; local($key, $val) = split(/\s+/); if ($use_stdout) { &dump_netgroupbyhost(STDOUT, $key, $val); } else { &dump_netgroupbyhost(OUTFILE, $key, $val); } } sub dump_netgroupbyhost { local($HANDLE, $key, $val) = @_; return if (!$key); print $HANDLE "dn: cn=$key,$NAMINGCONTEXT\n"; print $HANDLE "objectClass: nisObject\n"; print $HANDLE "objectClass: top\n"; print $HANDLE "nisMapName: netgroup.byhost\n"; print $HANDLE "cn: $key\n"; print $HANDLE "nisMapEntry: $val\n"; print $HANDLE "\n"; } close(INFILE); close(REVNETGROUP); if (OUTFILE != STDOUT) { close(OUTFILE); } MigrationTools-47/migrate_all_nis_offline.sh0100644000175200017500000000544710365576010020301 0ustar lukehpadl#!/bin/sh # # $Id: migrate_all_nis_offline.sh,v 1.4 2004/09/24 05:49:08 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # migrates NIS/YP accounts using ldif2ldbm # PATH=$PATH:. export PATH TMPDIR="/tmp" ETC_PASSWD="$TMPDIR/passwd.$$.ldap" ETC_GROUP="$TMPDIR/group.$$.ldap" ETC_SERVICES="$TMPDIR/services.$$.ldap" ETC_PROTOCOLS="$TMPDIR/protocols.$$.ldap" ETC_FSTAB="$TMPDIR/fstab.$$.ldap" ETC_RPC="$TMPDIR/rpc.$$.ldap" ETC_HOSTS="$TMPDIR/hosts.$$.ldap" ETC_NETWORKS="$TMPDIR/networks.$$.ldap" ETC_ALIASES="$TMPDIR/aliases.$$.ldap" EXIT=no question="Enter the NIS domain to import from (optional): " echo "$question " | tr -d '\012' > /dev/tty read DOM if [ "X$DOM" = "X" ]; then DOMFLAG="" else DOMFLAG="-d $DOM" fi ypcat $DOMFLAG passwd > $ETC_PASSWD ypcat $DOMFLAG group > $ETC_GROUP ypcat $DOMFLAG services > $ETC_SERVICES ypcat $DOMFLAG protocols > $ETC_PROTOCOLS touch $ETC_FSTAB ypcat $DOMFLAG rpc.byname > $ETC_RPC ypcat $DOMFLAG hosts > $ETC_HOSTS ypcat $DOMFLAG networks > $ETC_NETWORKS #ypcat $DOMFLAG -k aliases > $ETC_ALIASES . migrate_all_offline.sh rm -f $ETC_PASSWD rm -f $ETC_GROUP rm -f $ETC_SERVICES rm -f $ETC_PROTOCOLS rm -f $ETC_FSTAB rm -f $ETC_RPC rm -f $ETC_HOSTS rm -f $ETC_NETWORKS rm -f $ETC_ALIASES MigrationTools-47/Make.rules0100644000175200017500000000124610365576010015034 0ustar lukehpadl#ident $Id: Make.rules,v 1.6 2002/08/12 16:40:10 lukeh Exp $ TOOLS= \ migrate_aliases.pl \ migrate_automount.pl \ migrate_fstab.pl \ migrate_group.pl \ migrate_passwd.pl \ migrate_hosts.pl \ migrate_networks.pl \ migrate_profile.pl \ migrate_protocols.pl \ migrate_rpc.pl \ migrate_services.pl \ migrate_netgroup.pl \ migrate_netgroup_byhost.pl \ migrate_netgroup_byuser.pl \ migrate_all_offline.sh \ migrate_all_nis_offline.sh \ migrate_all_netinfo_offline.sh \ migrate_all_nisplus_offline.sh \ migrate_all_online.sh \ migrate_all_nis_online.sh \ migrate_all_netinfo_online.sh \ migrate_all_nisplus_online.sh \ migrate_base.pl \ migrate_slapd_conf.pl MigrationTools-47/migrate_aliases.pl0100755000175200017500000000510210365576010016567 0ustar lukehpadl#!/usr/bin/perl # # $Id: migrate_aliases.pl,v 1.9 2003/04/15 03:09:33 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # alias migration tool # thanks to Dave McPike # require 'migrate_common.ph'; $PROGRAM = "migrate_aliases.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); &parse_args(); &open_files(); while() { chop; next unless ($_); next if /^#/; s/#(.*)$//; local($name, $memberstr) = split(/:/,$_,2); if ($use_stdout) { &dump_alias(STDOUT, $name, $memberstr); } else { &dump_alias(OUTFILE, $name, $memberstr); } } sub dump_alias { local($HANDLE, $name, $memberstr) = @_; local(@aliases) = split(/,/, $memberstr); local $dname = &escape_metacharacters($name); print $HANDLE "dn: cn=$dname,$NAMINGCONTEXT\n"; print $HANDLE "cn: $name\n"; print $HANDLE "objectClass: nisMailAlias\n"; print $HANDLE "objectClass: top\n"; foreach $_ (@aliases) { s/^\s+//g; print $HANDLE "rfc822MailMember: $_\n"; } print $HANDLE "\n"; } close(INFILE); if (OUTFILE != STDOUT) { close(OUTFILE); } MigrationTools-47/README0100644000175200017500000000360210365576010013761 0ustar lukehpadl ================================================================== MigrationTools ================================================================== THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY AND WITHOUT SUPPORT. These tools are freely redistributable according to the license included with the source files. They may be bundled with LDAP/NIS migration products. See RFC 2307 for more information. You need perl to run these. Edit migrate_common.ph and change the following site-specific variables to reflect your installation: $DEFAULT_MAIL_DOMAIN $DEFAULT_BASE Then run the tools on each of your /etc database files, eg. to migrate protocols you might do: ./migrate_protocols.pl /etc/protocols protocols.ldif where the first argument is the input file and the last argument is the output file. You then can concatenate all your output files together and load that into your LDAP database with an online or offline import tool (such as ldapadd and slapadd, respectively). The following table will tell you which migration shell script to use: Script Existing nameservice LDAP online =================================================================== migrate_all_online.sh /etc flat files YES migrate_all_offline.sh /etc flat files NO migrate_all_netinfo_online.sh NetInfo YES migrate_all_netinfo_offline.sh NetInfo NO migrate_all_nis_online.sh Sun NIS/YP YES migrate_all_nis_offline.sh Sun NIS/YP NO migrate_all_nisplus_online.sh Sun NIS+ YES migrate_all_nisplus_offline.sh Sun NIS+ NO (The online scripts use ldapadd; the offline scripts use ldif2ldbm.) MigrationTools Copyright (C) 1996-2001 Luke Howard. All rights reserved. You may contact the maintainers at support@padl.com. MigrationTools-47/migrate_rpc.pl0100755000175200017500000000530610365576010015740 0ustar lukehpadl#!/usr/bin/perl # # $Id: migrate_rpc.pl,v 1.6 2003/04/15 03:09:34 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # Rpc migration tool # # require 'migrate_common.ph'; $PROGRAM = "migrate_rpc.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); &parse_args(); &open_files(); while() { chop; next unless ($_); next if /^#/; s/#(.*)$//; local($rpcname, $rpcnumber, @aliases) = split(/\s+/); if ($use_stdout) { &dump_rpc(STDOUT, $rpcname, $rpcnumber, @aliases); } else { &dump_rpc(OUTFILE, $rpcname, $rpcnumber, @aliases); } } sub dump_rpc { local($HANDLE, $rpcname, $rpcnumber, @aliases) = @_; return if (!$rpcname); print $HANDLE "dn: cn=$rpcname,$NAMINGCONTEXT\n"; print $HANDLE "objectClass: oncRpc\n"; print $HANDLE "objectClass: top\n"; # workaround typo in RFC 2307 where description # was made MUST instead of MAY print $HANDLE "description: RPC $rpcname\n"; print $HANDLE "oncRpcNumber: $rpcnumber\n"; print $HANDLE "cn: $rpcname\n"; @aliases = uniq($rpcname, @aliases); foreach $_ (@aliases) { print $HANDLE "cn: $_\n"; } print $HANDLE "\n"; } close(INFILE); if (OUTFILE != STDOUT) { close(OUTFILE); } MigrationTools-47/migrate_all_offline.sh0100755000175200017500000001145310365576010017425 0ustar lukehpadl#!/bin/sh # # $Id: migrate_all_offline.sh,v 1.15 2004/09/24 05:49:09 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # Migrate all entities from flat files. # # Make sure that you configure migrate_common.ph to suit # your site's X.500 naming context and DNS mail domain; # the defaults may not be correct. # # Luke Howard April 1997 # DB="/tmp/nis.$$.ldif" if [ "X$ETC_ALIASES" = "X" ]; then ETC_ALIASES=/etc/aliases fi #if [ "X$ETC_FSTAB" = "X" ]; then # ETC_FSTAB=/etc/fstab #fi if [ "X$ETC_HOSTS" = "X" ]; then ETC_HOSTS=/etc/hosts fi if [ "X$ETC_NETWORKS" = "X" ]; then ETC_NETWORKS=/etc/networks fi if [ "X$ETC_PASSWD" = "X" ]; then ETC_PASSWD=/etc/passwd fi if [ "X$ETC_GROUP" = "X" ]; then ETC_GROUP=/etc/group fi if [ "X$ETC_SERVICES" = "X" ]; then ETC_SERVICES=/etc/services fi if [ "X$ETC_PROTOCOLS" = "X" ]; then ETC_PROTOCOLS=/etc/protocols fi if [ "X$ETC_RPC" = "X" ]; then ETC_RPC=/etc/rpc fi if [ "X$ETC_NETGROUP" = "X" ]; then ETC_NETGROUP=/etc/netgroup fi # saves having to change #! path in each script if [ "X$PERL" = "X" ]; then if [ -x /usr/bin/perl ]; then PERL="/usr/bin/perl" elif [ -x /usr/local/bin/perl ]; then PERL="/usr/local/bin/perl" else echo "Can't find Perl!" exit 1 fi fi if [ "X$LDIF2LDBM" = "X" ]; then if [ -x /usr/local/etc/ldif2ldbm ]; then LDIF2LDBM="/usr/local/etc/ldif2ldbm" elif [ -x /usr/local/sbin/ldif2ldbm ]; then LDIF2LDBM="/usr/local/sbin/ldif2ldbm" elif [ -x /usr/sbin/ldif2ldbm ]; then LDIF2LDBM="/usr/sbin/ldif2ldbm" elif [ -x "$NSHOME/bin/slapd/server/ns-slapd" ]; then LDIF2LDBM="$NSHOME/bin/slapd/server/ns-slapd ldif2db -f $NSHOME/slapd-$serverID" elif [ -x /usr/iplanet/servers/bin/slapd/server/dsimport ]; then LDIF2LDBM="/usr/iplanet/servers/bin/slapd/server/dsimport" elif [ -x /usr/local/sbin/slapadd ]; then SLAPADD="/usr/local/sbin/slapadd" elif [ -x /usr/sbin/slapadd ]; then SLAPADD="/usr/sbin/slapadd" else echo "Can't find ldif2ldbm or slapadd!" exit 2 fi fi echo "Creating naming context entries..." $PERL migrate_base.pl > $DB echo "Migrating aliases..." $PERL migrate_aliases.pl $ETC_ALIASES >> $DB #echo "Migrating fstab..." #$PERL migrate_fstab.pl $ETC_FSTAB >> $DB echo "Migrating groups..." $PERL migrate_group.pl $ETC_GROUP >> $DB echo "Migrating hosts..." $PERL migrate_hosts.pl $ETC_HOSTS >> $DB echo "Migrating networks..." $PERL migrate_networks.pl $ETC_NETWORKS >> $DB echo "Migrating users..." $PERL migrate_passwd.pl $ETC_PASSWD >> $DB echo "Migrating protocols..." $PERL migrate_protocols.pl $ETC_PROTOCOLS >> $DB echo "Migrating rpcs..." $PERL migrate_rpc.pl $ETC_RPC >> $DB echo "Migrating services..." $PERL migrate_services.pl $ETC_SERVICES >> $DB echo "Migrating netgroups..." $PERL migrate_netgroup.pl $ETC_NETGROUP >> $DB echo "Importing into LDAP..." echo "Migrating netgroups (by user)..." $PERL migrate_netgroup_byuser.pl $ETC_NETGROUP >> $DB echo "Migrating netgroups (by host)..." $PERL migrate_netgroup_byhost.pl $ETC_NETGROUP >> $DB echo "Preparing LDAP database..." if [ "X$SLAPADD" = "X" ]; then $LDIF2LDBM -i $DB else $SLAPADD -l $DB fi EXITCODE=$? if [ $EXITCODE -ne 0 ]; then echo "Migration failed: saving failed LDIF to $DB" else rm -f $DB fi if [ "X$EXIT" != "Xno" ]; then exit $EXITCODE fi echo "Done." MigrationTools-47/migrate_group.pl0100755000175200017500000000520010365576010016301 0ustar lukehpadl#!/usr/bin/perl # # $Id: migrate_group.pl,v 1.7 2003/04/15 03:09:33 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # Group migration tool # # require 'migrate_common.ph'; $PROGRAM = "migrate_group.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); &parse_args(); &open_files(); while() { chop; next if /^#/; next if /^\+/; local($group, $pwd, $gid, $users) = split(/:/); if ($use_stdout) { &dump_group(STDOUT, $group, $pwd, $gid, $users); } else { &dump_group(OUTFILE, $group, $pwd, $gid, $users); } } sub dump_group { local($HANDLE, $group, $pwd, $gid, $users) = @_; local(@members) = split(/,/, $users); print $HANDLE "dn: cn=$group,$NAMINGCONTEXT\n"; print $HANDLE "objectClass: posixGroup\n"; print $HANDLE "objectClass: top\n"; print $HANDLE "cn: $group\n"; if ($pwd) { print $HANDLE "userPassword: {crypt}$pwd\n"; } print $HANDLE "gidNumber: $gid\n"; @members = uniq($group, @members); foreach $_ (@members) { print $HANDLE "memberUid: $_\n"; } print $HANDLE "\n"; } close(INFILE); if (OUTFILE != STDOUT) { close(OUTFILE); } MigrationTools-47/migrate_all_nisplus_offline.sh0100644000175200017500000000567410365576010021207 0ustar lukehpadl#!/bin/sh # # $Id: migrate_all_nisplus_offline.sh,v 1.6 2004/09/24 05:49:08 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # migrates NIS+ accounts using ldif2ldbm # PATH=$PATH:/usr/lib/nis:. export PATH TMPDIR="/tmp" ETC_PASSWD="$TMPDIR/passwd.$$.ldap" ETC_GROUP="$TMPDIR/group.$$.ldap" ETC_SERVICES="$TMPDIR/services.$$.ldap" ETC_PROTOCOLS="$TMPDIR/protocols.$$.ldap" ETC_FSTAB="$TMPDIR/fstab.$$.ldap" ETC_RPC="$TMPDIR/rpc.$$.ldap" ETC_HOSTS="$TMPDIR/hosts.$$.ldap" ETC_NETWORKS="$TMPDIR/networks.$$.ldap" ETC_NETGROUP="$TMPDIR/netgroup.$$.ldap" ETC_ALIASES="$TMPDIR/aliases.$$.ldap" EXIT=no question="Enter the NIS+ domain to import from (optional): " echo "$question " | tr -d '\012' > /dev/tty read DOM if [ "X$DOM" = "X" ]; then DOM="`domainname`." else DOM="$DOM." fi nisaddent -d passwd $DOM > $ETC_PASSWD nisaddent -d group $DOM > $ETC_GROUP nisaddent -d services $DOM > $ETC_SERVICES nisaddent -d protocols $DOM > $ETC_PROTOCOLS touch $ETC_FSTAB nisaddent -d rpc $DOM > $ETC_RPC nisaddent -d hosts $DOM > $ETC_HOSTS nisaddent -d networks $DOM > $ETC_NETWORKS nisaddent -d netgroup $DOM > $ETC_NETGROUP niscat mail_aliases.org_dir.$DOM > $ETC_ALIASES . migrate_all_offline.sh rm -f $ETC_PASSWD rm -f $ETC_GROUP rm -f $ETC_SERVICES rm -f $ETC_PROTOCOLS rm -f $ETC_FSTAB rm -f $ETC_RPC rm -f $ETC_HOSTS rm -f $ETC_NETWORKS rm -f $ETC_NETGROUP rm -f $ETC_ALIASES MigrationTools-47/migrate_all_netinfo_online.sh0100755000175200017500000000535510365576010021015 0ustar lukehpadl#!/bin/sh # # $Id: migrate_all_netinfo_online.sh,v 1.4 2004/09/24 05:49:08 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # Migrates NetInfo accounts using ldapadd # PATH=$PATH:. export PATH TMPDIR="/tmp" ETC_PASSWD="$TMPDIR/passwd.$$.ldap" ETC_GROUP="$TMPDIR/group.$$.ldap" ETC_SERVICES="$TMPDIR/services.$$.ldap" ETC_PROTOCOLS="$TMPDIR/protocols.$$.ldap" ETC_FSTAB="$TMPDIR/fstab.$$.ldap" ETC_RPC="$TMPDIR/rpc.$$.ldap" ETC_HOSTS="$TMPDIR/hosts.$$.ldap" ETC_NETWORKS="$TMPDIR/networks.$$.ldap" ETC_ALIASES="$TMPDIR/aliases.$$.ldap" EXIT=no question="Enter the NetInfo domain to import from [/]:" echo "$question " | tr -d '\012' > /dev/tty read DOM if [ "X$DOM" = "X" ]; then DOM="/" fi nidump passwd $DOM > $ETC_PASSWD nidump group $DOM > $ETC_GROUP nidump services $DOM > $ETC_SERVICES nidump protocols $DOM > $ETC_PROTOCOLS nidump fstab $DOM > $ETC_FSTAB nidump rpc $DOM > $ETC_RPC nidump hosts $DOM > $ETC_HOSTS nidump networks $DOM > $ETC_NETWORKS nidump aliases $DOM > $ETC_ALIASES . migrate_all_online.sh rm -f $ETC_PASSWD rm -f $ETC_GROUP rm -f $ETC_SERVICES rm -f $ETC_PROTOCOLS rm -f $ETC_FSTAB rm -f $ETC_RPC rm -f $ETC_HOSTS rm -f $ETC_NETWORKS rm -f $ETC_ALIASES MigrationTools-47/migrate_protocols.pl0100755000175200017500000000534210365576010017200 0ustar lukehpadl#!/usr/bin/perl # # $Id: migrate_protocols.pl,v 1.7 2003/04/15 03:09:34 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # protocol migration tool # # require 'migrate_common.ph'; $PROGRAM = "migrate_protocols.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); &parse_args(); &open_files(); while() { chop; next unless ($_); next if /^#/; s/#(.*)$//; local($name, $number, @aliases) = split(/\s+/); if ($use_stdout) { &dump_protocol(STDOUT, $name, $number, @aliases); } else { &dump_protocol(OUTFILE, $name, $number, @aliases); } } sub dump_protocol { local($HANDLE, $name, $number, @aliases) = @_; local $dname = &escape_metacharacters($name); print $HANDLE "dn: cn=$dname,$NAMINGCONTEXT\n"; print $HANDLE "objectClass: ipProtocol\n"; print $HANDLE "objectClass: top\n"; # workaround typo in RFC 2307 where description # was made MUST instead of MAY print $HANDLE "description: Protocol $name\n"; print $HANDLE "ipProtocolNumber: $number\n"; print $HANDLE "cn: $name\n"; @aliases = uniq($name, @aliases); foreach $_ (@aliases) { print $HANDLE "cn: $_\n"; } print $HANDLE "\n"; } close(INFILE); if (OUTFILE != STDOUT) { close(OUTFILE); } MigrationTools-47/migrate_hosts.pl0100755000175200017500000000524510365576010016316 0ustar lukehpadl#!/usr/bin/perl # # $Id: migrate_hosts.pl,v 1.5 2003/04/15 03:09:34 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # hosts migration tool # # require 'migrate_common.ph'; $PROGRAM = "migrate_hosts.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); &parse_args(); &open_files(); while() { chop; next unless ($_); next if /^#/; s/#(.*)$//; local($hostaddr, $hostname, @aliases) = split(/\s+/); if ($use_stdout) { &dump_host(STDOUT, $hostaddr, $hostname, @aliases); } else { &dump_host(OUTFILE, $hostaddr, $hostname, @aliases); } } sub dump_host { local($HANDLE, $hostaddr, $hostname, @aliases) = @_; local($dn); return if (!$hostaddr); print $HANDLE "dn: cn=$hostname,$NAMINGCONTEXT\n"; print $HANDLE "objectClass: top\n"; print $HANDLE "objectClass: ipHost\n"; print $HANDLE "objectClass: device\n"; print $HANDLE "ipHostNumber: $hostaddr\n"; print $HANDLE "cn: $hostname\n"; @aliases = uniq($hostname, @aliases); foreach $_ (@aliases) { if ($_ ne $hostname) { print $HANDLE "cn: $_\n"; } } print $HANDLE "\n"; } close(INFILE); if (OUTFILE != STDOUT) { close(OUTFILE); } MigrationTools-47/CVSVersionInfo.txt0100644000175200017500000000033010365576010016452 0ustar lukehpadl# Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.49 2006/01/25 04:18:12 lukeh Exp $ # $Name: MigrationTools-47 $ ProjectName: MigrationTools ProjectVersion: 47 ProjectMaintainer: lukeh MigrationTools-47/migrate_automount.pl0100644000175200017500000000626410365576010017210 0ustar lukehpadl#!/usr/bin/perl # # migrate_automount.pl by Adrian Likins # Based on migrate_services.pl, Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # services migration tool # require 'migrate_common.ph'; $PROGRAM = "migrate_automount.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); &parse_args(); &open_files(); $mapname=$ARGV[0]; # normalize the mapname $mapname =~ s?/etc/(.*)?$1?; if ($use_stdout){ $HANDLE=STDOUT; } else { $HANDLE=OUTFILE; } # setup the top level for this automounter map print $HANDLE "dn: nisMapName=$mapname,$NAMINGCONTEXT\n"; print $HANDLE "objectClass: top\n"; print $HANDLE "objectClass: nisMap\n"; print $HANDLE "nisMapName: $mapname\n"; print $HANDLE "\n"; while() { chop; next unless ($_); next if /^#/; s/#(.*)$//; # local($mountkey, $portproto, @aliases) = split(/\s+/); if(m/(.*?)\s(.*)/){ $key = $1; $value = $2; } if ($use_stdout) { &dump_automount(STDOUT,$key,$value,$mapname); } else { &dump_automount(OUTFILE, $key,$value,$mapname); } } sub dump_automount { local($HANDLE, $key, $value,$mapname) = @_; # local($port, $proto) = split(/\//, $portproto); return if (!$mapname); if ($key eq "*"){ # since * isnt a valid attrib, replace it with "/" # which isnt a valid filename :-> print $HANDLE "dn: cn=/,nisMapName=$mapname,$NAMINGCONTEXT\n"; } else { print $HANDLE "dn: cn=$key,nisMapName=$mapname,$NAMINGCONTEXT\n"; } print $HANDLE "objectClass: nisObject\n"; print $HANDLE "cn: $key\n"; print $HANDLE "nisMapEntry: $value\n"; print $HANDLE "nisMapName: $mapname\n"; print $HANDLE "\n"; } close(INFILE); if (OUTFILE != STDOUT) { close(OUTFILE); } MigrationTools-47/migrate_services.pl0100755000175200017500000002340610365576010017000 0ustar lukehpadl#!/usr/bin/perl -w # # $Id: migrate_services.pl,v 1.8 2003/04/15 03:09:34 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Heavily mangled by Bob Apthorpe sometime in June, 2002. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # services migration tool # # require 'migrate_common.ph'; $PROGRAM = "migrate_services.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); # keep Perl quiet $use_stdout = 0; &parse_args(); &open_files(); my %services = (); my %portmap = (); &parse_services(\%services, \%portmap); my $service_ldif = &build_service_records(\%services, \%portmap); if ($use_stdout) { print STDOUT $service_ldif; } else { print OUTFILE $service_ldif; } close(INFILE); if (OUTFILE ne STDOUT) { close(OUTFILE); } ##### Subroutines ##### sub parse_services { my $Rh_services = shift; my $Rh_portmap = shift; # A note about $Rh_services: # $Rh_services is a reference to a hash of service # information. The structure is: # # $Rh_services->{$port}{$servicename}{$proto}{'cn'} = $canonicalservicename; # $Rh_services->{$port}{$servicename}{$proto}{'aliases'}{$alias} = 1; # # so @ports = keys(%{$Rh_services}); # @services_on_a_port = keys(%{$Rh_services->{$port}}); # # Aliases are stored in a hash to keep them normalized, though # it's sort of a waste since the aliases are normalized again when # protocols are combined while creating records. It's not clear # you save any space by storing aliases as a list (allowing multiple # identical names to be stored until being normalized away at the # end) vs storing them as a hash (storing useless hash values # to keep the aliases normalized as keys.) It's also not clear # this is even worth worrying about... my %svcmap = (); my %protocols_found = (); my $card = ''; readloop: while(defined($card = )) { next readloop if ($card =~ m/^\s*#/o || $card eq "\n"); $card =~ s/#.*//o; my ($servicename, $portproto, @aliases) = split(m/\s+/o, $card); my ($rawport, $proto) = split(m#[/,]#o, $portproto); # Find services specifying a port range (e.g. X11.) my $loport = ''; my $hiport = ''; if ($rawport =~ m#(\d+)-(\d+)#o) { $loport = $1; $hiport = $2; } else { $loport = int($rawport); $hiport = $loport; } $hiport = $loport if (!defined($hiport) || ($hiport < $loport)); # Track the number of unique ports used by a service. foreach ($loport .. $hiport) { $Rh_portmap->{$servicename}{$proto}{$_} = 1; } my $indivport = ''; foreach $indivport ($loport .. $hiport) { unless (exists($Rh_services->{$indivport}{$servicename}{$proto}{'cn'})) { # We've never seen this port/protocol pair # before so we take the first occurence of # the name as the canonical one, in case # we see repeated listings later (see below) $svcmap{$indivport}{$proto} = $servicename; $Rh_services->{$indivport}{$servicename}{$proto}{'cn'} = $servicename; foreach ($servicename, @aliases) { $Rh_services->{$indivport}{$servicename}{$proto}{'aliases'}{$_} = 1; } } else { # We've seen this port/protocol pair # before so we'll add the service name and # any aliases as aliases in the original # (canonical) record. my $canonical_svc = $svcmap{$indivport}{$proto}; foreach ($servicename, @aliases) { $Rh_services->{$indivport}{$canonical_svc}{$proto}{'aliases'}{$_} = 1; } } } } return; } sub build_service_records { my $Rh_services = shift; my $Rh_portmap = shift; foreach $port (sort {$a <=> $b} (keys %{$Rh_services})) { foreach $servicename (keys %{$Rh_services->{$port}}) { my @protocols = (keys %{$Rh_services->{$port}{$servicename}}); my %tmpaliases = (); # Note on the suffix: # If a service name applies to a range of # ports, add a suffix to the cn and the aliases # to ensure unique dn's for each service. The NIS # schema that defines ipService (1.3.6.1.1.1.2.3) # and ipServicePort (1.3.6.1.1.1.1.15) only # allows a single port to be associated with a # service name so we have to mangle the cn to # differentiate the dn's for each port. This is # ugly; the alternative is to change the schema or # the format of the services file. "Irresistable # Force, meet Immovable Object..." my $suffix = ''; foreach $proto (@protocols) { # Only add suffix if it's absolutely necessary if (scalar(keys(%{$Rh_portmap->{$servicename}{$proto}})) > 1) { $suffix = "+ipServicePort=" . &escape_metacharacters($port); } # Normalize aliases across protocols. Yet # another uncomfortable compromise. foreach (keys %{$Rh_services->{$port}{$servicename}{$proto}{'aliases'}}) { $tmpaliases{$_} = 1; } } my @aliases = keys(%tmpaliases); # Finally we build LDIF records for services. $svcrecords .= "dn: cn=" . &escape_metacharacters($servicename) . $suffix . ",$NAMINGCONTEXT\n" . "objectClass: ipService\n" . "objectClass: top\n" . "ipServicePort: $port\n" . join('', map { "ipServiceProtocol: $_\n" } (@protocols)) . join('', map { "cn: $_\n" } (@aliases)) . "\n"; } } return $svcrecords; } __END__ =head1 NAME migrate_services.pl - translate /etc/services into LDIF format for easy migration into LDAP. =head1 SYNOPSIS migrate_services.pl /etc/services /tmp/services.ldif which produces LDIF entries similar to: dn: cn=rtmp,ou=Services,dc=padl,dc=com objectClass: ipService objectClass: top ipServicePort: 1 ipServiceProtocol: ddp cn: rtmp dn: cn=tcpmux,ou=Services,dc=padl,dc=com objectClass: ipService objectClass: top ipServicePort: 1 ipServiceProtocol: udp ipServiceProtocol: tcp cn: tcpmux dn: cn=nbp,ou=Services,dc=padl,dc=com objectClass: ipService objectClass: top ipServicePort: 2 ipServiceProtocol: ddp cn: nbp dn: cn=compressnet+ipServicePort=2,ou=Services,dc=padl,dc=com objectClass: ipService objectClass: top ipServicePort: 2 ipServiceProtocol: udp ipServiceProtocol: tcp cn: compressnet dn: cn=discard,ou=Services,dc=padl,dc=com objectClass: ipService objectClass: top ipServicePort: 9 ipServiceProtocol: udp ipServiceProtocol: tcp cn: null cn: sink cn: Discard cn: discard =head1 USAGE migrate_services.pl services_file [ translated_file.ldif ] =head1 DESCRIPTION migrate_services.pl parses /etc/services into LDIF format according to the NIS LDAP schema. Services spanning a range of ports are uniquely identified by using multivalued RDNs. Due to a limitation in the NIS schema, there is an assumed one-to-one association between port and service name (though, oddly, multiple protocol names are allowed.) =head1 HOMEPAGE Module Home: http://www.padl.com/OSS/MigrationTools.html =head1 AUTHOR Luke Howard Heavily mangled by Bob Apthorpe sometime in June, 2002. =head1 LICENSE Copyright (c) 1997-2003 Luke Howard. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by Luke Howard. 4. The name of the other may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =cut MigrationTools-47/migrate_netgroup.pl0100755000175200017500000000741510365576010017022 0ustar lukehpadl#!/usr/bin/perl # # $Id: migrate_netgroup.pl,v 1.8 2003/04/15 03:09:34 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # netgroup migration tool # line continuation support by Bob Apthorpe # require 'migrate_common.ph'; $PROGRAM = "migrate_netgroup.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); &parse_args(); &open_files(); local $continuing = 0; local $card = ''; local $record = ''; readloop: while(defined($card = )) { chomp $card; next readloop unless ($card); next readloop if ($card =~ m/^\s*#/o); $card =~ s/#.*$//o; $card =~ s/^\s+//o; $card =~ s/\s+$//o; unless ($continuing) { if ($record) { local($netgroupname, @members) = split(m/\s+/o, $record); if ($use_stdout) { &dump_netgroup(STDOUT, $netgroupname, @members); } else { &dump_netgroup(OUTFILE, $netgroupname, @members); } $record = ''; } } if ($card =~ m#\\\s*$#o) { $card =~ s#\s*\\\s*$# #o; $continuing = 1; } else { $continuing = 0; } if ($record) { $record .= ' ' . $card; } else { $record = $card; } } if ($continuing) { print STDERR <<"TRUNCMSG"; # Warning: It appears your netgroup file has been truncated or there's a # stray continuation marker (\\) in the file. The record causing problems # is: # $record # Sorry. TRUNCMSG } else { if ($record) { local($netgroupname, @members) = split(m/\s+/o, $record); if ($use_stdout) { &dump_netgroup(STDOUT, $netgroupname, @members); } else { &dump_netgroup(OUTFILE, $netgroupname, @members); } $record = ''; } } sub ces_uniq { local(@vec) = sort @_; local(@ret); local($next, $last); foreach $next (@vec) { if ($next ne $last) { push (@ret, $next); } $last = $next; } return @ret; } sub dump_netgroup { local($HANDLE, $netgroupname, @members) = @_; return if (!$netgroupname); print $HANDLE "dn: cn=$netgroupname,$NAMINGCONTEXT\n"; print $HANDLE "objectClass: nisNetgroup\n"; print $HANDLE "objectClass: top\n"; print $HANDLE "cn: $netgroupname\n"; @members = ces_uniq(@members); foreach $_ (@members) { if (/^\(/) { print $HANDLE "nisNetgroupTriple: $_\n"; } else { print $HANDLE "memberNisNetgroup: $_\n"; } } print $HANDLE "\n"; } close(INFILE); if (OUTFILE != STDOUT) { close(OUTFILE); } MigrationTools-47/migrate_profile.pl0100755000175200017500000000454210365576010016615 0ustar lukehpadl#!/usr/bin/perl # # $Id: migrate_profile.pl,v 1.3 2003/04/15 03:09:34 lukeh Exp $ # # Copyright (c) 2001-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # LDIF entries for base DN # # require 'migrate_common.ph'; $PROGRAM = "migrate_profile.pl"; sub gen_profile { print "dn: cn=config,$DEFAULT_BASE\n"; print "cn: config\n"; print "objectClass: DUAConfigProfile\n"; print "objectClass: posixNamingProfile\n"; print "defaultServerList: $LDAPHOST\n"; print "defaultSearchBase: $DEFAULT_BASE\n"; print "defaultSearchScope: one\n"; foreach $_ (keys %NAMINGCONTEXT) { if (!/_/) { print "serviceSearchDescriptor: $_:$NAMINGCONTEXT{$_},$DEFAULT_BASE\n"; } } print "\n"; } sub main { if ($#ARGV < 0) { print STDERR "Usage: $PROGRAM ldaphost\n"; exit 1; } $LDAPHOST = $ARGV[0]; &gen_profile(); } &main; MigrationTools-47/migrate_base.pl0100755000175200017500000000522310365576010016064 0ustar lukehpadl#!/usr/bin/perl # # $Id: migrate_base.pl,v 1.8 2003/07/21 14:37:28 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # LDIF entries for base DN # # require 'migrate_common.ph'; $PROGRAM = "migrate_base.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); sub gen_namingcontexts { # uniq naming contexts local (@ncs, $map, $nc); foreach $map (keys %NAMINGCONTEXT) { $nc = $NAMINGCONTEXT{$map}; if (!grep(/^$nc$/, @ncs)) { push(@ncs, $nc); &ldif_entry(STDOUT, $nc, $DEFAULT_BASE); } } } sub gen_suffix { @dn_components = split(/,/, $DEFAULT_BASE); if ($#dn_components == 0) { $dnloc = 0; &base_ldif; } else { for ($dnloc = ($#dn_components-1); $dnloc >= 0; $dnloc--) { &base_ldif; } } } sub base_ldif { # we don't handle multivalued RDNs here; they're unlikely # in a base DN. # Don't escape commas either XXX local ($rdn) = $dn_components[$dnloc]; local ($remaining_dn) = join(',', @dn_components[($dnloc + 1)..$#dn_components]); &ldif_entry(STDOUT, $rdn, $remaining_dn); } sub main { if ($ARGV[0] ne "-n") { &gen_suffix(); } &gen_namingcontexts(); } &main; MigrationTools-47/migrate_all_nisplus_online.sh0100644000175200017500000000565310365576010021046 0ustar lukehpadl#!/bin/sh # # $Id: migrate_all_nisplus_online.sh,v 1.7 2004/09/24 05:49:08 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # Migrate NIS+ accounts using ldapadd # PATH=$PATH:. export PATH TMPDIR="/tmp" ETC_PASSWD="$TMPDIR/passwd.$$.ldap" ETC_GROUP="$TMPDIR/group.$$.ldap" ETC_SERVICES="$TMPDIR/services.$$.ldap" ETC_PROTOCOLS="$TMPDIR/protocols.$$.ldap" ETC_FSTAB="$TMPDIR/fstab.$$.ldap" ETC_RPC="$TMPDIR/rpc.$$.ldap" ETC_HOSTS="$TMPDIR/hosts.$$.ldap" ETC_NETWORKS="$TMPDIR/networks.$$.ldap" ETC_NETGROUP="$TMPDIR/netgroup.$$.ldap" ETC_ALIASES="$TMPDIR/aliases.$$.ldap" EXIT=no question="Enter the NIS+ domain to import from (optional): " echo "$question " | tr -d '\012' > /dev/tty read DOM if [ "X$DOM" = "X" ]; then DOM="`domainname`." else DOM="$DOM." fi nisaddent -d passwd $DOM > $ETC_PASSWD nisaddent -d group $DOM > $ETC_GROUP nisaddent -d services $DOM > $ETC_SERVICES nisaddent -d protocols $DOM > $ETC_PROTOCOLS touch $ETC_FSTAB nisaddent -d rpc $DOM > $ETC_RPC nisaddent -d hosts $DOM > $ETC_HOSTS nisaddent -d networks $DOM > $ETC_NETWORKS nisaddent -d netgroup $DOM > $ETC_NETGROUP niscat mail_aliases.org_dir.$DOM > $ETC_ALIASES . migrate_all_online.sh rm -f $ETC_PASSWD rm -f $ETC_GROUP rm -f $ETC_SERVICES rm -f $ETC_PROTOCOLS rm -f $ETC_FSTAB rm -f $ETC_RPC rm -f $ETC_HOSTS rm -f $ETC_NETWORKS rm -f $ETC_NETGROUP rm -f $ETC_ALIASES MigrationTools-47/migrate_common.ph0100644000175200017500000002125210365576010016433 0ustar lukehpadl# # $Id: migrate_common.ph,v 1.22 2003/04/15 03:09:33 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # Common defines for MigrationTools # # Naming contexts. Key is $PROGRAM with migrate_ and .pl # stripped off. $NETINFOBRIDGE = (-x "/usr/sbin/mkslapdconf"); if ($NETINFOBRIDGE) { $NAMINGCONTEXT{'aliases'} = "cn=aliases"; $NAMINGCONTEXT{'fstab'} = "cn=mounts"; $NAMINGCONTEXT{'passwd'} = "cn=users"; $NAMINGCONTEXT{'netgroup_byuser'} = "cn=netgroup.byuser"; $NAMINGCONTEXT{'netgroup_byhost'} = "cn=netgroup.byhost"; $NAMINGCONTEXT{'group'} = "cn=groups"; $NAMINGCONTEXT{'netgroup'} = "cn=netgroup"; $NAMINGCONTEXT{'hosts'} = "cn=machines"; $NAMINGCONTEXT{'networks'} = "cn=networks"; $NAMINGCONTEXT{'protocols'} = "cn=protocols"; $NAMINGCONTEXT{'rpc'} = "cn=rpcs"; $NAMINGCONTEXT{'services'} = "cn=services"; } else { $NAMINGCONTEXT{'aliases'} = "ou=Aliases"; $NAMINGCONTEXT{'fstab'} = "ou=Mounts"; $NAMINGCONTEXT{'passwd'} = "ou=People"; $NAMINGCONTEXT{'netgroup_byuser'} = "nisMapName=netgroup.byuser"; $NAMINGCONTEXT{'netgroup_byhost'} = "nisMapName=netgroup.byhost"; $NAMINGCONTEXT{'group'} = "ou=Group"; $NAMINGCONTEXT{'netgroup'} = "ou=Netgroup"; $NAMINGCONTEXT{'hosts'} = "ou=Hosts"; $NAMINGCONTEXT{'networks'} = "ou=Networks"; $NAMINGCONTEXT{'protocols'} = "ou=Protocols"; $NAMINGCONTEXT{'rpc'} = "ou=Rpc"; $NAMINGCONTEXT{'services'} = "ou=Services"; } # Default DNS domain $DEFAULT_MAIL_DOMAIN = "padl.com"; # Default base $DEFAULT_BASE = "dc=padl,dc=com"; # Turn this on for inetLocalMailReceipient # sendmail support; add the following to # sendmail.mc (thanks to Petr@Kristof.CZ): ##### CUT HERE ##### #define(`confLDAP_DEFAULT_SPEC',`-h "ldap.padl.com"')dnl #LDAPROUTE_DOMAIN_FILE(`/etc/mail/ldapdomains')dnl #FEATURE(ldap_routing)dnl ##### CUT HERE ##### # where /etc/mail/ldapdomains contains names of ldap_routed # domains (similiar to MASQUERADE_DOMAIN_FILE). $DEFAULT_MAIL_HOST = "mail.padl.com"; # turn this on to support more general object clases # such as person. $EXTENDED_SCHEMA = 0; # # allow environment variables to override predefines # if (defined($ENV{'LDAP_BASEDN'})) { $DEFAULT_BASE = $ENV{'LDAP_BASEDN'}; } if (defined($ENV{'LDAP_DEFAULT_MAIL_DOMAIN'})) { $DEFAULT_MAIL_DOMAIN = $ENV{'LDAP_DEFAULT_MAIL_DOMAIN'}; } if (defined($ENV{'LDAP_DEFAULT_MAIL_HOST'})) { $DEFAULT_MAIL_HOST = $ENV{'LDAP_DEFAULT_MAIL_HOST'}; } # binddn used for alias owner (otherwise uid=root,...) if (defined($ENV{'LDAP_BINDDN'})) { $DEFAULT_OWNER = $ENV{'LDAP_BINDDN'}; } if (defined($ENV{'LDAP_EXTENDED_SCHEMA'})) { $EXTENDED_SCHEMA = $ENV{'LDAP_EXTENDED_SCHEMA'}; } # If we haven't set the default base, guess it automagically. if (!defined($DEFAULT_BASE)) { $DEFAULT_BASE = &domain_expand($DEFAULT_MAIL_DOMAIN); $DEFAULT_BASE =~ s/,$//o; } # Default Kerberos realm if ($EXTENDED_SCHEMA) { $DEFAULT_REALM = $DEFAULT_MAIL_DOMAIN; $DEFAULT_REALM =~ tr/a-z/A-Z/; } if (-x "/usr/sbin/revnetgroup") { $REVNETGROUP = "/usr/sbin/revnetgroup"; } elsif (-x "/usr/lib/yp/revnetgroup") { $REVNETGROUP = "/usr/lib/yp/revnetgroup"; } $classmap{'o'} = 'organization'; $classmap{'dc'} = 'domain'; $classmap{'l'} = 'locality'; $classmap{'ou'} = 'organizationalUnit'; $classmap{'c'} = 'country'; $classmap{'nismapname'} = 'nisMap'; $classmap{'cn'} = 'container'; sub parse_args { if ($#ARGV < 0) { print STDERR "Usage: $PROGRAM infile [outfile]\n"; exit 1; } $INFILE = $ARGV[0]; if ($#ARGV > 0) { $OUTFILE = $ARGV[1]; } } sub open_files { open(INFILE); if ($OUTFILE) { open(OUTFILE,">$OUTFILE"); $use_stdout = 0; } else { $use_stdout = 1; } } # moved from migrate_hosts.pl # lukeh 10/30/97 sub domain_expand { local($first) = 1; local($dn); local(@namecomponents) = split(/\./, $_[0]); foreach $_ (@namecomponents) { $first = 0; $dn .= "dc=$_,"; } $dn .= $DEFAULT_BASE; return $dn; } # case insensitive unique sub uniq { local($name) = shift(@_); local(@vec) = sort {uc($a) cmp uc($b)} @_; local(@ret); local($next, $last); foreach $next (@vec) { if ((uc($next) ne uc($last)) && (uc($next) ne uc($name))) { push (@ret, $next); } $last = $next; } return @ret; } # concatenate naming context and # organizational base sub getsuffix { local($program) = shift(@_); local($nc); $program =~ s/^migrate_(.*)\.pl$/$1/; $nc = $NAMINGCONTEXT{$program}; if ($nc eq "") { return $DEFAULT_BASE; } else { return $nc . ',' . $DEFAULT_BASE; } } sub ldif_entry { # remove leading, trailing whitespace local ($HANDLE, $lhs, $rhs) = @_; local ($type, $val) = split(/\=/, $lhs); local ($dn); if ($rhs ne "") { $dn = $lhs . ',' . $rhs; } else { $dn = $lhs; } $type =~ s/\s*$//o; $type =~ s/^\s*//o; $type =~ tr/A-Z/a-z/; $val =~ s/\s*$//o; $val =~ s/^\s*//o; print $HANDLE "dn: $dn\n"; print $HANDLE "$type: $val\n"; print $HANDLE "objectClass: top\n"; print $HANDLE "objectClass: $classmap{$type}\n"; if ($EXTENDED_SCHEMA) { if ($DEFAULT_MAIL_DOMAIN) { print $HANDLE "objectClass: domainRelatedObject\n"; print $HANDLE "associatedDomain: $DEFAULT_MAIL_DOMAIN\n"; } } print $HANDLE "\n"; } # Added Thu Jun 20 16:40:28 CDT 2002 by Bob Apthorpe # to solve problems with embedded plusses in # protocols and mail aliases. sub escape_metacharacters { local($name) = @_; # From Table 3.1 "Characters Requiring Quoting When Contained # in Distinguished Names", p87 "Understanding and Deploying LDAP # Directory Services", Howes, Smith, & Good. # 1) Quote backslash # Note: none of these are very elegant or robust and may cause # more trouble than they're worth. That's why they're disabled. # 1.a) naive (escape all backslashes) # $name =~ s#\\#\\\\#og; # # 1.b) mostly naive (escape all backslashes not followed by # a backslash) # $name =~ s#\\(?!\\)#\\\\#og; # # 1.c) less naive and utterly gruesome (replace solitary # backslashes) # $name =~ s{ # Replace # (?;])#\\$1#g; return $name; } 1; MigrationTools-47/migrate_all_nis_online.sh0100644000175200017500000000544310365576010020137 0ustar lukehpadl#!/bin/sh # # $Id: migrate_all_nis_online.sh,v 1.4 2004/09/24 05:49:08 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # Migrate NIS/YP accounts using ldapadd # PATH=$PATH:. export PATH TMPDIR="/tmp" ETC_PASSWD="$TMPDIR/passwd.$$.ldap" ETC_GROUP="$TMPDIR/group.$$.ldap" ETC_SERVICES="$TMPDIR/services.$$.ldap" ETC_PROTOCOLS="$TMPDIR/protocols.$$.ldap" ETC_FSTAB="$TMPDIR/fstab.$$.ldap" ETC_RPC="$TMPDIR/rpc.$$.ldap" ETC_HOSTS="$TMPDIR/hosts.$$.ldap" ETC_NETWORKS="$TMPDIR/networks.$$.ldap" ETC_ALIASES="$TMPDIR/aliases.$$.ldap" EXIT=no question="Enter the NIS domain to import from (optional): " echo "$question " | tr -d '\012' > /dev/tty read DOM if [ "X$DOM" = "X" ]; then DOMFLAG="" else DOMFLAG="-d $DOM" fi ypcat $DOMFLAG passwd > $ETC_PASSWD ypcat $DOMFLAG group > $ETC_GROUP ypcat $DOMFLAG services > $ETC_SERVICES ypcat $DOMFLAG protocols > $ETC_PROTOCOLS touch $ETC_FSTAB ypcat $DOMFLAG rpc.byname > $ETC_RPC ypcat $DOMFLAG hosts > $ETC_HOSTS ypcat $DOMFLAG networks > $ETC_NETWORKS #ypcat $DOMFLAG -k aliases > $ETC_ALIASES . migrate_all_online.sh rm -f $ETC_PASSWD rm -f $ETC_GROUP rm -f $ETC_SERVICES rm -f $ETC_PROTOCOLS rm -f $ETC_FSTAB rm -f $ETC_RPC rm -f $ETC_HOSTS rm -f $ETC_NETWORKS rm -f $ETC_ALIASES MigrationTools-47/migrate_all_online.sh0100755000175200017500000001444510365576010017273 0ustar lukehpadl#!/bin/sh # # $Id: migrate_all_online.sh,v 1.16 2004/09/24 05:49:09 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # generic migration script for flat files, YP and NetInfo. # uses ldapadd SHELL=/bin/sh export SHELL DB=/tmp/nis.$$.ldif if [ "X$ETC_ALIASES" = "X" ]; then ETC_ALIASES=/etc/aliases fi #if [ "X$ETC_FSTAB" = "X" ]; then # ETC_FSTAB=/etc/fstab #fi if [ "X$ETC_HOSTS" = "X" ]; then ETC_HOSTS=/etc/hosts fi if [ "X$ETC_NETWORKS" = "X" ]; then ETC_NETWORKS=/etc/networks fi if [ "X$ETC_PASSWD" = "X" ]; then ETC_PASSWD=/etc/passwd fi if [ "X$ETC_GROUP" = "X" ]; then ETC_GROUP=/etc/group fi if [ "X$ETC_SERVICES" = "X" ]; then ETC_SERVICES=/etc/services fi if [ "X$ETC_PROTOCOLS" = "X" ]; then ETC_PROTOCOLS=/etc/protocols fi if [ "X$ETC_RPC" = "X" ]; then ETC_RPC=/etc/rpc fi if [ "X$ETC_NETGROUP" = "X" ]; then ETC_NETGROUP=/etc/netgroup fi if [ "X$LDAPADD" = "X" ]; then if [ -x ldapadd ]; then LDAPADD=ldapadd elif [ -x /usr/local/bin/ldapadd ]; then LDAPADD="/usr/local/bin/ldapadd" elif [ -x /usr/bin/ldapadd ]; then LDAPADD="/usr/bin/ldapadd" elif [ -x "$NSHOME/bin/slapd/server/ldapmodify" ]; then LDAPADD="$NSHOME/bin/slapd/server/ldapmodify -a -c" elif [ -x /usr/iplanet/servers/shared/bin/ldapmodify ]; then LDAPADD="/usr/iplanet/servers/shared/bin/ldapmodify -a -c" fi fi if [ "X$LDAPADD" = "X" ]; then echo "Please set the LDAPADD environment variable to point to ldapadd." echo exit 1 fi # saves having to change #! path in each script if [ "X$PERL" = "X" ]; then if [ -x /usr/bin/perl ]; then PERL="/usr/bin/perl" elif [ -x /usr/local/bin/perl ]; then PERL="/usr/local/bin/perl" else echo "Can't find Perl!" exit 1 fi fi if [ "X$LDAP_BASEDN" = "X" ]; then defaultcontext=`$PERL -e 'require "migrate_common.ph"; print \$DEFAULT_BASE';` question="Enter the X.500 naming context you wish to import into: [$defaultcontext]" echo "$question " | tr -d '\012' > /dev/tty read LDAP_BASEDN if [ "X$LDAP_BASEDN" = "X" ]; then if [ "X$defaultcontext" = "X" ]; then echo "You must specify a default context." exit 2 else LDAP_BASEDN=$defaultcontext fi fi fi export LDAP_BASEDN if [ "X$LDAPHOST" = "X" ]; then question="Enter the hostname of your LDAP server [ldap]:" echo "$question " | tr -d '\012' > /dev/tty read LDAPHOST if [ "X$LDAPHOST" = "X" ]; then LDAPHOST="ldap" fi fi if [ "X$LDAP_BINDDN" = "X" ]; then question="Enter the manager DN: [cn=manager,$LDAP_BASEDN]:" echo "$question " | tr -d '\012' > /dev/tty read LDAP_BINDDN if [ "X$LDAP_BINDDN" = "X" ]; then LDAP_BINDDN="cn=manager,$LDAP_BASEDN" fi fi export LDAP_BINDDN if [ "X$LDAP_BINDCRED" = "X" ]; then question="Enter the credentials to bind with:" echo "$question " | tr -d '\012' > /dev/tty stty -echo read LDAP_BINDCRED stty echo echo fi if [ "X$LDAP_PROFILE" = "X" ]; then question="Do you wish to generate a DUAConfigProfile [yes|no]?" echo "$question " | tr -d '\012' > /dev/tty read LDAP_PROFILE if [ "X$LDAP_PROFILE" = "X" ]; then LDAP_PROFILE="no" fi fi echo echo "Importing into $LDAP_BASEDN..." echo echo "Creating naming context entries..." $PERL migrate_base.pl -n > $DB if [ "X$LDAP_PROFILE" = "Xyes" ]; then echo "Creating DUAConfigProfile entry..." $PERL migrate_profile.pl "$LDAPHOST" >> $DB fi echo "Migrating aliases..." $PERL migrate_aliases.pl $ETC_ALIASES >> $DB #echo "Migrating fstab..." #$PERL migrate_fstab.pl $ETC_FSTAB >> $DB echo "Migrating groups..." $PERL migrate_group.pl $ETC_GROUP >> $DB echo "Migrating hosts..." $PERL migrate_hosts.pl $ETC_HOSTS >> $DB echo "Migrating networks..." $PERL migrate_networks.pl $ETC_NETWORKS >> $DB echo "Migrating users..." $PERL migrate_passwd.pl $ETC_PASSWD >> $DB echo "Migrating protocols..." $PERL migrate_protocols.pl $ETC_PROTOCOLS >> $DB echo "Migrating rpcs..." $PERL migrate_rpc.pl $ETC_RPC >> $DB echo "Migrating services..." $PERL migrate_services.pl $ETC_SERVICES >> $DB echo "Migrating netgroups..." $PERL migrate_netgroup.pl $ETC_NETGROUP >> $DB echo "Migrating netgroups (by user)..." $PERL migrate_netgroup_byuser.pl $ETC_NETGROUP >> $DB echo "Migrating netgroups (by host)..." $PERL migrate_netgroup_byhost.pl $ETC_NETGROUP >> $DB echo "Importing into LDAP..." if [ -x /usr/sbin/slapadd ]; then $LDAPADD -x -h $LDAPHOST -D "$LDAP_BINDDN" -w "$LDAP_BINDCRED" -f $DB elif [ -x /usr/local/sbin/slapadd ]; then $LDAPADD -x -h $LDAPHOST -D "$LDAP_BINDDN" -w "$LDAP_BINDCRED" -f $DB else $LDAPADD -h $LDAPHOST -D "$LDAP_BINDDN" -w "$LDAP_BINDCRED" -f $DB fi if [ $? -ne 0 ]; then echo "$LDAPADD: returned non-zero exit status: saving failed LDIF to $DB" e=$? else echo "$LDAPADD: succeeded" e=$? rm -f $DB fi if [ "X$EXIT" != "Xno" ]; then exit $e fi MigrationTools-47/migrate_passwd.pl0100755000175200017500000001270510365576010016456 0ustar lukehpadl#!/usr/bin/perl # # $Id: migrate_passwd.pl,v 1.17 2005/03/05 03:15:55 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # Password migration tool. Migrates /etc/shadow as well, if it exists. # # Thanks to Peter Jacob Slot . # require 'migrate_common.ph'; $PROGRAM = "migrate_passwd.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); &parse_args(); &read_shadow_file(); &open_files(); while() { chop; 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(/:/); if ($use_stdout) { &dump_user(STDOUT, $user, $pwd, $uid, $gid, $gecos, $homedir, $shell); } else { &dump_user(OUTFILE, $user, $pwd, $uid, $gid, $gecos, $homedir, $shell); } } sub dump_user { local($HANDLE, $user, $pwd, $uid, $gid, $gecos, $homedir, $shell) = @_; local($name,$office,$wphone,$hphone)=split(/,/,$gecos); local($sn); local($givenname); local($cn); local(@tmp); if ($name) { $cn = $name; } else { $cn = $user; } $_ = $cn; @tmp = split(/\s+/); $sn = $tmp[$#tmp]; pop(@tmp); $givenname=join(' ',@tmp); print $HANDLE "dn: uid=$user,$NAMINGCONTEXT\n"; print $HANDLE "uid: $user\n"; print $HANDLE "cn: $cn\n"; if ($EXTENDED_SCHEMA) { if ($wphone) { print $HANDLE "telephoneNumber: $wphone\n"; } if ($office) { print $HANDLE "roomNumber: $office\n"; } if ($hphone) { print $HANDLE "homePhone: $hphone\n"; } if ($givenname) { print $HANDLE "givenName: $givenname\n"; } print $HANDLE "sn: $sn\n"; if ($DEFAULT_MAIL_DOMAIN) { print $HANDLE "mail: $user\@$DEFAULT_MAIL_DOMAIN\n"; } if ($DEFAULT_MAIL_HOST) { print $HANDLE "mailRoutingAddress: $user\@$DEFAULT_MAIL_HOST\n"; print $HANDLE "mailHost: $DEFAULT_MAIL_HOST\n"; print $HANDLE "objectClass: inetLocalMailRecipient\n"; } print $HANDLE "objectClass: person\n"; print $HANDLE "objectClass: organizationalPerson\n"; print $HANDLE "objectClass: inetOrgPerson\n"; } else { print $HANDLE "objectClass: account\n"; } print $HANDLE "objectClass: posixAccount\n"; print $HANDLE "objectClass: top\n"; if ($DEFAULT_REALM) { print $HANDLE "objectClass: kerberosSecurityObject\n"; } if ($shadowUsers{$user} ne "") { &dump_shadow_attributes($HANDLE, split(/:/, $shadowUsers{$user})); } else { print $HANDLE "userPassword: {crypt}$pwd\n"; } if ($DEFAULT_REALM) { print $HANDLE "krbName: $user\@$DEFAULT_REALM\n"; } if ($shell) { print $HANDLE "loginShell: $shell\n"; } if ($uid ne "") { print $HANDLE "uidNumber: $uid\n"; } else { print $HANDLE "uidNumber:\n"; } if ($gid ne "") { print $HANDLE "gidNumber: $gid\n"; } else { print $HANDLE "gidNumber:\n"; } if ($homedir) { print $HANDLE "homeDirectory: $homedir\n"; } else { print $HANDLE "homeDirectory:\n"; } if ($gecos) { print $HANDLE "gecos: $gecos\n"; } print $HANDLE "\n"; } close(INFILE); if (OUTFILE != STDOUT) { close(OUTFILE); } sub read_shadow_file { open(SHADOW, "/etc/shadow") || return; while() { chop; ($shadowUser) = split(/:/, $_); $shadowUsers{$shadowUser} = $_; } close(SHADOW); } sub dump_shadow_attributes { local($HANDLE, $user, $pwd, $lastchg, $min, $max, $warn, $inactive, $expire, $flag) = @_; print $HANDLE "objectClass: shadowAccount\n"; if ($pwd) { print $HANDLE "userPassword: {crypt}$pwd\n"; } if ($lastchg ne "") { print $HANDLE "shadowLastChange: $lastchg\n"; } if ($min) { print $HANDLE "shadowMin: $min\n"; } if ($max) { print $HANDLE "shadowMax: $max\n"; } if ($warn) { print $HANDLE "shadowWarning: $warn\n"; } if ($inactive) { print $HANDLE "shadowInactive: $inactive\n"; } if ($expire) { print $HANDLE "shadowExpire: $expire\n"; } if ($flag) { print $HANDLE "shadowFlag: $flag\n"; } } MigrationTools-47/migrate_networks.pl0100755000175200017500000000537610365576010017037 0ustar lukehpadl#!/usr/bin/perl # # $Id: migrate_networks.pl,v 1.5 2003/04/15 03:09:34 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # networks migration tool # # require 'migrate_common.ph'; $PROGRAM = "migrate_networks.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); &parse_args(); &open_files(); while() { chop; next unless ($_); next if /^#/; s/#(.*)$//; local($networkname, $networkaddr, @aliases) = split(/\s+/); if ($use_stdout) { &dump_network(STDOUT, $networkaddr, $networkname, @aliases); } else { &dump_network(OUTFILE, $networkaddr, $networkname, @aliases); } } sub dump_network { local($HANDLE, $networkaddr, $networkname, @aliases) = @_; local($dn, $revnetwork); return if (!$networkaddr); local($cn) = $networkname; # could be $revnetwork print $HANDLE "dn: cn=$networkname,$NAMINGCONTEXT\n"; print $HANDLE "objectClass: ipNetwork\n"; print $HANDLE "objectClass: top\n"; print $HANDLE "ipNetworkNumber: $networkaddr\n"; print $HANDLE "cn: $networkname\n"; @aliases = uniq($networkname, @aliases); foreach $_ (@aliases) { if ($_ ne $networkname) { print $HANDLE "cn: $_\n"; } } print $HANDLE "\n"; } close(INFILE); if (OUTFILE != STDOUT) { close(OUTFILE); } MigrationTools-47/migrate_fstab.pl0100755000175200017500000000555610365576010016262 0ustar lukehpadl#!/usr/bin/perl # # $Id: migrate_fstab.pl,v 1.6 2003/04/15 03:09:33 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # fstab migration tool # These classes were not published in RFC 2307. # They are used by MacOS X Server, however. # require 'migrate_common.ph'; $PROGRAM = "migrate_fstab.pl"; $NAMINGCONTEXT = &getsuffix($PROGRAM); &parse_args(); &open_files(); while() { chop; next if /^#/; s/#(.*)$//; local($fsname, $dir, $type, $opts, $freq, $passno) = split(/\s+/); if ($use_stdout) { &dump_mount(STDOUT, $fsname, $dir, $type, $opts, $freq, $passno); } else { &dump_mount(OUTFILE, $fsname, $dir, $type, $opts, $freq, $passno); } } sub dump_mount { local($HANDLE, $fsname, $fsdir, $type, $opts, $freq, $passno) = @_; local (@options) = split(/,/, $opts); print $HANDLE "dn: cn=$fsname,$NAMINGCONTEXT\n"; print $HANDLE "cn: $fsname\n"; print $HANDLE "objectClass: mount\n"; print $HANDLE "objectClass: top\n"; print $HANDLE "mountDirectory: $fsdir\n"; print $HANDLE "mountType: $type\n"; if (defined($freq)) { print $HANDLE "mountDumpFrequency: $freq\n"; } if (defined($passno)) { print $HANDLE "mountPassNo: $passno\n"; } foreach $_ (@options) { print $HANDLE "mountOption: $_\n"; } print $HANDLE "\n"; } close(INFILE); if (OUTFILE != STDOUT) { close(OUTFILE); } MigrationTools-47/migrate_slapd_conf.pl0100755000175200017500000000650110365576010017262 0ustar lukehpadl#!/usr/bin/perl # # $Id: migrate_slapd_conf.pl,v 1.5 2003/04/15 03:09:34 lukeh Exp $ # # Copyright (c) 2001-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # LDIF entries for base DN # # require 'migrate_common.ph'; $PROGRAM = "migrate_slapd_conf.pl"; push (@SCHEMAS, "core.schema"); push (@SCHEMAS, "cosine.schema"); push (@SCHEMAS, "nis.schema"); push (@SCHEMAS, "autofs.schema"); push (@SCHEMAS, "rfc822MailMember.schema"); push (@SCHEMAS, "DUAConfigProfile.schema"); sub gen_slapd_conf { print "# @(#)slapd.conf generated by migrate_slapd_conf.pl\n"; $creationTime = localtime; print "# Creation date: ", $creationTime, "\n"; print "#\n"; print "# See slapd.conf(5) for details on configuration options.\n"; print "# This file should NOT be world readable.\n"; print "#\n"; foreach $schema (@SCHEMAS) { print "include\t$ROOTDIR/etc/openldap/schema/$schema\n"; } print "\n"; print <) { chop; next unless ($_); next if /^#/; s/#(.*)$//; local($key, $val) = split(/\s+/); if ($use_stdout) { &dump_netgroupbyuser(STDOUT, $key, $val); } else { &dump_netgroupbyuser(OUTFILE, $key, $val); } } sub dump_netgroupbyuser { local($HANDLE, $key, $val) = @_; return if (!$key); print $HANDLE "dn: cn=$key,$NAMINGCONTEXT\n"; print $HANDLE "objectClass: nisObject\n"; print $HANDLE "objectClass: top\n"; print $HANDLE "nisMapName: netgroup.byuser\n"; print $HANDLE "cn: $key\n"; print $HANDLE "nisMapEntry: $val\n"; print $HANDLE "\n"; } close(INFILE); close(REVNETGROUP); if (OUTFILE != STDOUT) { close(OUTFILE); } MigrationTools-47/migrate_all_netinfo_offline.sh0100755000175200017500000000536110365576010021150 0ustar lukehpadl#!/bin/sh # # $Id: migrate_all_netinfo_offline.sh,v 1.4 2004/09/24 05:49:08 lukeh Exp $ # # Copyright (c) 1997-2003 Luke Howard. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Luke Howard. # 4. The name of the other may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE LUKE HOWARD ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL LUKE HOWARD BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # Migrates NetInfo accounts using ldif2ldbm # PATH=$PATH:. export PATH TMPDIR="/tmp" ETC_PASSWD="$TMPDIR/passwd.$$.ldap" ETC_GROUP="$TMPDIR/group.$$.ldap" ETC_SERVICES="$TMPDIR/services.$$.ldap" ETC_PROTOCOLS="$TMPDIR/protocols.$$.ldap" ETC_FSTAB="$TMPDIR/fstab.$$.ldap" ETC_RPC="$TMPDIR/rpc.$$.ldap" ETC_HOSTS="$TMPDIR/hosts.$$.ldap" ETC_NETWORKS="$TMPDIR/networks.$$.ldap" ETC_ALIASES="$TMPDIR/aliases.$$.ldap" EXIT=no question="Enter the NetInfo domain to import from [/]:" echo "$question " | tr -d '\012' > /dev/tty read DOM if [ "X$DOM" = "X" ]; then DOM="/" fi nidump passwd $DOM > $ETC_PASSWD nidump group $DOM > $ETC_GROUP nidump services $DOM > $ETC_SERVICES nidump protocols $DOM > $ETC_PROTOCOLS nidump fstab $DOM > $ETC_FSTAB nidump rpc $DOM > $ETC_RPC nidump hosts $DOM > $ETC_HOSTS nidump networks $DOM > $ETC_NETWORKS nidump aliases $DOM > $ETC_ALIASES . migrate_all_offline.sh rm -f $ETC_PASSWD rm -f $ETC_GROUP rm -f $ETC_SERVICES rm -f $ETC_PROTOCOLS rm -f $ETC_FSTAB rm -f $ETC_RPC rm -f $ETC_HOSTS rm -f $ETC_NETWORKS rm -f $ETC_ALIASES