-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Package: base-files
Version: 4.0.4
Severity: wishlist
Tags: patch

As part of the GSoC project PamNssInstaller
(http://wiki.debian.org/SummerOfCode2008/PamNssDebianInstaller).
Some modifications would be needed in base-files.
  - Providing a script called update-nsswitch. In charge of modifing
nsswitch.conf
  - Modification in debian/rules for installing it under /sbin
  - update-nsswitch manpage

- -- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.25-2-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages base-files depends on:
ii  base-passwd                   3.5.17     Debian base system master
password
ii  mawk [awk]                    1.3.3-11.1 a pattern scanning and text
proces

base-files recommends no packages.

base-files suggests no packages.

- -- no debconf information
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAki20lMACgkQ2bQWnnlfiVRJfACfSwq/qJeS9tlr8Fx0wdsqT9uX
GikAoMlDva1N1PyEgANaWOgPiRf54R86
=xMNC
-----END PGP SIGNATURE-----
diff -Naur base-files-4.0.4ORIGINAL/debian/directory-list base-files-4.0.4/debian/directory-list
--- base-files-4.0.4ORIGINAL/debian/directory-list	2005-07-12 17:31:01.000000000 +0200
+++ base-files-4.0.4/debian/directory-list	2008-07-31 23:57:13.000000000 +0200
@@ -22,6 +22,7 @@
 usr/share/dict
 usr/share/info
 usr/share/man
+usr/share/man/man1
 usr/share/misc
 usr/src
 var
diff -Naur base-files-4.0.4ORIGINAL/debian/rules base-files-4.0.4/debian/rules
--- base-files-4.0.4ORIGINAL/debian/rules	2008-03-11 11:02:27.000000000 +0100
+++ base-files-4.0.4/debian/rules	2008-07-31 23:57:13.000000000 +0200
@@ -34,8 +34,10 @@
 	cd debian && install -m 755 preinst postinst tmp/DEBIAN
 	cd debian && install -m 644 conffiles tmp/DEBIAN
 	cd debian/tmp && install -d `cat ../directory-list`
+	install -p -m 755 sbin/update-* debian/tmp/sbin
 	install -p -m 644 share/* debian/tmp/usr/share/base-files
 	install -p -m 644 licenses/* debian/tmp/usr/share/common-licenses
+	install -p -m 644 man/man1/* debian/tmp/usr/share/man/man1
 	ln -s GFDL-1.2 debian/tmp/usr/share/common-licenses/GFDL
 	ln -s LGPL-3 debian/tmp/usr/share/common-licenses/LGPL
 	ln -s GPL-3 debian/tmp/usr/share/common-licenses/GPL
@@ -54,7 +56,9 @@
 		> debian/tmp/etc/issue.net
 	gzip -9 $(docdir)/changelog
 	cd debian/tmp && \
-		md5sum `find usr -type f` > DEBIAN/md5sums
+		md5sum `find usr -type f` > DEBIAN/md5sums && \
+		md5sum  `find sbin -type f ` >> DEBIAN/md5sums
+		
 	chown -R root:root debian/tmp
 	cd debian/tmp && chown root:src     usr/src
 	cd debian/tmp && chown root:staff   var/local
diff -Naur base-files-4.0.4ORIGINAL/man/man1/update-nsswitch.1.gz base-files-4.0.4/man/man1/update-nsswitch.1.gz
--- base-files-4.0.4ORIGINAL/man/man1/update-nsswitch.1.gz	1970-01-01 01:00:00.000000000 +0100
+++ base-files-4.0.4/man/man1/update-nsswitch.1.gz	2008-07-31 23:57:13.000000000 +0200
@@ -0,0 +1,3 @@
+‹‡jHupdate-nsswitch.1TÁnÛ0=W_Aä2 H\ì°ãݚ¢Ö$h2`Eڃjѱ0[ò$9A€~ü([EMAIL PROTECTED]‹ßã#Ÿ”mn`ÒµJœï:Õ>‹l}‹ËÛ9ˆÑ&<ÌàÖ*]jô0³ÂšâGï:'ƒ¶Æ3Äú~±\­óµÈ¾ÁHli-Ÿ¤Gÿ[Ûrý‰,'’‡™T
+Ä3K‡Ý£x`ä«ùúû]¾Úä˅ØTZ¡[òñ“Ð*¹×fÒJ„`mMh¢’#…UJŠéoT	[EMAIL PROTECTED] ³/™8ʳÙI†ØTDÖk…¥6Ô¥ƒ&µÃ!¨)F¡º†'ìù5ªLŽ,º³3B¹J™„µÖk†#qqmðÓºš4Ž0"'ór§÷hÀÛÎȸOXZ‡ðŸÀ)ûÈgç琗`ì‰Þºá8u¡—¯¦œJÙÕdÁ”ƒ~6]W ûÒ`Ry±˜¾M¡6#A©í}•„c=Ütˆ`B¢=8úÓـŠÇO¯l`û9öè<aÁÊizü
+ŠŠg+¬Û—ƒÉ+—;„¸I–Ù¬Ø6ó_—·«söÍ¥Rё©´áT ¢N;Ûµ}ÿio
) »ߥ¦THv‚R×Ԟß&âcÞW´º,Ñ¡	Ìë?B3m%m©ie=I—3ö89€z…Í{dŒ½.ÐO
†ƒu¿™"ìÄqrLËÍõòçâê«ÃÐ93y]Â]|>b½}=õµo5‹eћO,H~`»ÙB&«Æ¢£®çDM.aõä­rðzÌ<žÌ­w†Ž«
lÔIÚïß;.ÄÉA×9Û'‡ÅÅÛ÷WPu4Ïxûý6r¸Ý±WÃíhè	ü2z¸…ø]’g
\ No newline at end of file
diff -Naur base-files-4.0.4ORIGINAL/sbin/update-nsswitch base-files-4.0.4/sbin/update-nsswitch
--- base-files-4.0.4ORIGINAL/sbin/update-nsswitch	1970-01-01 01:00:00.000000000 +0100
+++ base-files-4.0.4/sbin/update-nsswitch	2008-07-31 23:57:13.000000000 +0200
@@ -0,0 +1,214 @@
+#!/usr/bin/perl -w
+#
+# update-nsswitch
+#
+# Copyright (C) 2004 Fabio Tranchitella <[EMAIL PROTECTED]>
+# Copyright (C) 2004 Giuseppe Sacco <[EMAIL PROTECTED]>
+#
+# update-nsswitch is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published
+# by the Free Software Foundation; either version 2 of the License,
+# or (at your option) any later version.
+# 2008 Developer Juan Luis Belmonte <[EMAIL PROTECTED]>
+
+use strict;
+use Getopt::Long;
+use File::Basename qw(basename);
+use File::Temp qw(tempfile);
+
+my $CONF_FILE = "/etc/nsswitch.conf";
+my $VERSION   = '0.03';
+
+sub main {
+	my ( $m_add, $m_remove, $m_version, $m_help, $before, $after, $database,
+		$actionitem );
+	$m_add = $m_remove = 0;
+	$after = $before = $actionitem = "";
+
+	GetOptions(
+		'add|a'        => \$m_add,
+		'remove|r'     => \$m_remove,
+		'database=s'   => \$database,
+		'before=s'     => \$before,
+		'after=s'      => \$after,
+		'actionitem=s' => \$actionitem,
+		'version|v'    => \$m_version,
+		'help|h'       => \$m_help
+	);
+
+	version() if ($m_version);
+	usage()
+	  if ( $m_help
+		or ( $m_add + $m_remove ) != 1
+		or not $database
+		or not @ARGV
+		or ( $after ne "" and $before ne "" ) );
+
+	my $source = shift @ARGV if @ARGV;
+
+	if ($m_add) {
+		return add( $source, $database, $after, $before, $actionitem );
+	}
+	else {
+		return remove( $source, $database );
+	}
+
+}
+
+sub add {
+	my ( $source, $database, $after, $before, $actionitem ) = @_;
+	my $output = "";
+	$actionitem = " [" . "$actionitem" . "]" if ( $actionitem ne "" );
+	my $sourceaction = $source
+	  . $actionitem
+	  ; # solves multiple concatenations on multiple databases with action item calls
+	my @newdbs;
+	my @indbs = split /,/, $database;
+	my $exist = "";
+
+## Splits the whole databases string in a string for existent and an array of non-existent db's
+	foreach my $var (@indbs) {
+		chomp($var);
+		open( IN, $CONF_FILE ) or die "Couldn't open $CONF_FILE $!\n";
+		my $m = 0;
+		while (<IN>) {
+			chomp;
+			if ( $_ =~ /$var/ ) {
+				$m = 1;
+				$exist .= "$var,";
+				last;
+			}
+		}
+		if ( $m eq 0 ) {
+			push( @newdbs, $var );
+		}
+		close IN;
+	}
+
+	open( IN, $CONF_FILE ) or die "Couldn't open $CONF_FILE $!\n";
+
+	#  only the existent databases are going into this loop
+	while (<IN>) {
+		if ( $_ =~ /^#/ or $_ =~ /^[\s\t]+/ ) {
+
+			$output .= $_;
+		}
+		elsif ( $_ =~ /(\S+):[\s\t]+([\S ]+)/ ) {
+			my ( $db, $s ) = ( $1, $2 );
+			if ( $exist =~ /$db/ and $_ !~ /\s$source/ ) {
+
+				## DEFAULT ACTION  if before & after not blank or both blank or if one defined but not exists
+				if (   ( $after eq "" and $before eq "" )
+					or ( $after ne "" and $before ne "" ) )
+				{
+					$after = "THELAST";
+				}
+				if (   ( ( $before ne "" ) and ( $_ !~ /$before/ ) )
+					or ( ( $after ne "" ) and ( $_ !~ /$after/ ) ) )
+				{
+					$after = "THELAST";
+				}
+				###
+
+				if ( $after ne "" ) {
+					if ( $_ =~ /($after( |\t)+)|($after$)/ ) {
+						$_ =~ s/$&/$& $sourceaction /ig;
+					}
+					elsif ( $after eq "THELAST" ) {
+						chop($_);
+
+						$_ = $_ . " $sourceaction" . "\n";
+					}
+				}
+
+				if ( $before ne "" ) {
+					if ( $_ =~ /($before( |\t)+)|($before$)/ ) {
+						$_ =~ s/$&/$sourceaction  $&/ig;
+					}
+				}
+			}
+			$output .= $_;
+		}
+	}
+	close IN;
+
+	# loop for new  databses  addings
+	foreach (@newdbs) {
+		$output .= "$_:\t$sourceaction \n ";
+
+	}
+	tempFile($output);
+}
+
+sub remove {
+	my ( $source, $database ) = @_;
+	my $output = "";
+	open( IN, $CONF_FILE ) or die "Couldn't open $CONF_FILE $!\n";
+	while (<IN>) {
+		if ( $_ =~ /^#/ or $_ =~ /^[\s\t]+/ ) {
+			$output .= $_;
+		}
+		elsif ( $_ =~ /(\S+):[\s\t]+([\S ]+)/ ) {
+			my ( $db, $s ) = ( $1, $2 );
+			if ( $database =~ /$db/ and $_ =~ /\s$source/ ) {
+				$_ =~ s/\s?$source(\s\[[^\]]+\])?//ig;
+				if ( $_ !~ /^\S+:[\s\t]+(\S)+/ ) {
+					last;
+				}
+			}
+			$output .= $_;
+		}
+	}
+	close IN;
+
+	tempFile($output);
+
+}
+
+sub tempFile {
+	my ($output) = @_;
+
+	my ( $tmp, $filetmp ) = tempfile('nsswitch.conf.tmpXXXX')
+	  or die("Couldn't open a temporary file: $!\n");
+	print $tmp $output;
+	close($tmp);
+
+#	rename( $CONF_FILE, "nsswitch.conf.backup" );                       ###Uncomment to createbackup of nsswitch
+	rename( "$filetmp", $CONF_FILE )
+	  or die "Couldn't rename " . $filetmp . ": $!\n";
+	return 0;
+
+}
+
+sub usage {
+	print <<EOT;
+Usage: update-nsswitch [OPTIONS] MODE SOURCE
+
+Options:
+  --version             output version information and exit
+  --help                display this help and exit
+  --database=DB1,DB2..  modify only DB1,DB2... databases
+  --before=SOURCE       add the new source before SOURCE
+  --after=SOURCE        add the new source after SOURCE
+  --actionitem=ACTION   specify the status action clauses quoted between "" (without []) 
+
+Modes:
+  --add SOURCE          add a new source
+  --remove SOURCE       remove an existing source 
+
+EOT
+	exit 0;
+}
+
+sub version {
+	print <<EOT;
+update-pam $VERSION
+EOT
+	exit 0;
+}
+
+######################################
+## MAIN CALL, PLEASE DON'T CHANGE IT #
+######################################
+
+exit main();

Reply via email to