head 1.1; access; symbols OPENPKG_E1_MP_HEAD:1.1 OPENPKG_E1_MP:1.1 OPENPKG_E1_MP_2_STABLE:1.1.2.2 OPENPKG_E1_FP:1.1.2.2 OPENPKG_2_STABLE_MP:1.1 OPENPKG_2_STABLE_20061018:1.1.2.2 OPENPKG_2_STABLE:1.1.0.2; locks; strict; comment @# @; 1.1 date 2005.12.25.13.08.59; author rse; state Exp; branches 1.1.2.1; next ; commitid ipVQsMtl5lIYVZer; 1.1.2.1 date 2005.12.25.13.08.59; author rse; state dead; branches; next 1.1.2.2; commitid iZxwRSmmWscPXUQr; 1.1.2.2 date 2006.10.16.14.58.42; author rse; state Exp; branches; next ; commitid iZxwRSmmWscPXUQr; desc @@ 1.1 log @new package: ypanything 1.1 (NIS/YP Server for Arbitrary Data Sources) @ text @#!@@l_prefix@@/bin/perl ## ## ypanything.passwd.pl: LDAP passwd provider ## use IO::File; use MIME::Base64; # configuration my $host = "localhost"; my $port = "389"; my $bindDN = "CN=Directory Manager"; my $bindPassword = "secret"; my $base = "O=example.com"; my $searchType = "sub"; my $ldapsearch = "@@l_prefix@@/bin/ldapsearch"; # query directory via LDAP my $ldap = new IO::File "$ldapsearch -x -LLL -h '$host' -p '$port'" . " -D '$bindDN' -w '$bindPassword' -b '$base' -s '$searchType'" . " objectClass=posixAccount" . " uid userpassword uidnumber gidnumber gecos homedirectory loginshell |" or die "$!"; my @@pw = (); my $pw = {}; while (<$ldap>) { if (m/^\s*$/) { if (defined($pw)) { push(@@pw, $pw); $pw = {}; } } elsif (m/^([^:]+)::\s*(.*?)\s*$/) { $pw->{$1} .= (defined($pw->{$1}) ? $pw->{$1} . "," : "") . MIME::Base64::decode($2); } elsif (m/^([^:]+):\s*(.*?)\s*$/) { $pw->{$1} = (defined($pw->{$1}) ? $pw->{$1} . "," : "") . $2; } } $ldap->close(); # post-processing and output generation my $O = ""; foreach my $pw (@@pw) { $pw->{"userpassword"} ||= "*"; $pw->{"userpassword"} =~ s/\{crypt\}//ig; $O .= sprintf("%s:%s:%s:%s:%s:%s:%s\n", $pw->{uid}, $pw->{userpassword}, $pw->{uidnumber}, $pw->{gidnumber}, $pw->{gecos}, $pw->{homedirectory}, $pw->{loginshell} ); } # provide output print STDOUT $O; exit(0); @ 1.1.2.1 log @file ypanything.passwd.pl was added on branch OPENPKG_2_STABLE on 2006-10-16 14:58:42 +0000 @ text @d1 57 @ 1.1.2.2 log @Mass merge from CURRENT to 2-STABLE (all packages except those of JUNK class) @ text @a0 57 #!@@l_prefix@@/bin/perl ## ## ypanything.passwd.pl: LDAP passwd provider ## use IO::File; use MIME::Base64; # configuration my $host = "localhost"; my $port = "389"; my $bindDN = "CN=Directory Manager"; my $bindPassword = "secret"; my $base = "O=example.com"; my $searchType = "sub"; my $ldapsearch = "@@l_prefix@@/bin/ldapsearch"; # query directory via LDAP my $ldap = new IO::File "$ldapsearch -x -LLL -h '$host' -p '$port'" . " -D '$bindDN' -w '$bindPassword' -b '$base' -s '$searchType'" . " objectClass=posixAccount" . " uid userpassword uidnumber gidnumber gecos homedirectory loginshell |" or die "$!"; my @@pw = (); my $pw = {}; while (<$ldap>) { if (m/^\s*$/) { if (defined($pw)) { push(@@pw, $pw); $pw = {}; } } elsif (m/^([^:]+)::\s*(.*?)\s*$/) { $pw->{$1} .= (defined($pw->{$1}) ? $pw->{$1} . "," : "") . MIME::Base64::decode($2); } elsif (m/^([^:]+):\s*(.*?)\s*$/) { $pw->{$1} = (defined($pw->{$1}) ? $pw->{$1} . "," : "") . $2; } } $ldap->close(); # post-processing and output generation my $O = ""; foreach my $pw (@@pw) { $pw->{"userpassword"} ||= "*"; $pw->{"userpassword"} =~ s/\{crypt\}//ig; $O .= sprintf("%s:%s:%s:%s:%s:%s:%s\n", $pw->{uid}, $pw->{userpassword}, $pw->{uidnumber}, $pw->{gidnumber}, $pw->{gecos}, $pw->{homedirectory}, $pw->{loginshell} ); } # provide output print STDOUT $O; exit(0); @