From 52a4dca26ebb8822c9ae64f954dcde89fc64d4fa Mon Sep 17 00:00:00 2001 From: steve Date: Mon, 25 Dec 2006 23:10:50 +0000 Subject: [PATCH] 2006-12-25 23:10:49 by steve Copy the group memberships too. --- hooks/centos4/35-setup-users | 33 +++++++++++++++++++++++++++++++++ hooks/dapper/35-setup-users | 33 +++++++++++++++++++++++++++++++++ hooks/debian/35-setup-users | 33 +++++++++++++++++++++++++++++++++ hooks/edgy/35-setup-users | 33 +++++++++++++++++++++++++++++++++ hooks/gentoo/35-setup-users | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 165 insertions(+) diff --git a/hooks/centos4/35-setup-users b/hooks/centos4/35-setup-users index 1df253c..2611d61 100755 --- a/hooks/centos4/35-setup-users +++ b/hooks/centos4/35-setup-users @@ -58,6 +58,12 @@ foreach my $account ( sort keys( %host ) ) { print "Adding: $account\n"; addAccount( $account ); + + # + # Find any groups the user is member of on the host + # and add them on the guest system + # + addGroups( $account ); } } @@ -142,3 +148,30 @@ sub addAccount } close( SHADOW ); } + + + +# +# Find the groups a user is member of on the host, and add them to +# those groups on the new guest. +# +sub addGroups +{ + my( $username ) = ( @_ ); + + # + # Get the groups. + # + my $groups = `groups $username`; + # split off the usernmame. + if ( $groups =~ /^([^:]+):(.*)/ ) + { + $groups = $2; + print "User: $username is member of the groups: $groups\n"; + } + + foreach my $g ( split( / /, $groups ) ) + { + system( "chroot $prefix /usr/sbin/adduser $username $group" ); + } +} diff --git a/hooks/dapper/35-setup-users b/hooks/dapper/35-setup-users index 1df253c..2611d61 100755 --- a/hooks/dapper/35-setup-users +++ b/hooks/dapper/35-setup-users @@ -58,6 +58,12 @@ foreach my $account ( sort keys( %host ) ) { print "Adding: $account\n"; addAccount( $account ); + + # + # Find any groups the user is member of on the host + # and add them on the guest system + # + addGroups( $account ); } } @@ -142,3 +148,30 @@ sub addAccount } close( SHADOW ); } + + + +# +# Find the groups a user is member of on the host, and add them to +# those groups on the new guest. +# +sub addGroups +{ + my( $username ) = ( @_ ); + + # + # Get the groups. + # + my $groups = `groups $username`; + # split off the usernmame. + if ( $groups =~ /^([^:]+):(.*)/ ) + { + $groups = $2; + print "User: $username is member of the groups: $groups\n"; + } + + foreach my $g ( split( / /, $groups ) ) + { + system( "chroot $prefix /usr/sbin/adduser $username $group" ); + } +} diff --git a/hooks/debian/35-setup-users b/hooks/debian/35-setup-users index 1df253c..2611d61 100755 --- a/hooks/debian/35-setup-users +++ b/hooks/debian/35-setup-users @@ -58,6 +58,12 @@ foreach my $account ( sort keys( %host ) ) { print "Adding: $account\n"; addAccount( $account ); + + # + # Find any groups the user is member of on the host + # and add them on the guest system + # + addGroups( $account ); } } @@ -142,3 +148,30 @@ sub addAccount } close( SHADOW ); } + + + +# +# Find the groups a user is member of on the host, and add them to +# those groups on the new guest. +# +sub addGroups +{ + my( $username ) = ( @_ ); + + # + # Get the groups. + # + my $groups = `groups $username`; + # split off the usernmame. + if ( $groups =~ /^([^:]+):(.*)/ ) + { + $groups = $2; + print "User: $username is member of the groups: $groups\n"; + } + + foreach my $g ( split( / /, $groups ) ) + { + system( "chroot $prefix /usr/sbin/adduser $username $group" ); + } +} diff --git a/hooks/edgy/35-setup-users b/hooks/edgy/35-setup-users index 1df253c..2611d61 100755 --- a/hooks/edgy/35-setup-users +++ b/hooks/edgy/35-setup-users @@ -58,6 +58,12 @@ foreach my $account ( sort keys( %host ) ) { print "Adding: $account\n"; addAccount( $account ); + + # + # Find any groups the user is member of on the host + # and add them on the guest system + # + addGroups( $account ); } } @@ -142,3 +148,30 @@ sub addAccount } close( SHADOW ); } + + + +# +# Find the groups a user is member of on the host, and add them to +# those groups on the new guest. +# +sub addGroups +{ + my( $username ) = ( @_ ); + + # + # Get the groups. + # + my $groups = `groups $username`; + # split off the usernmame. + if ( $groups =~ /^([^:]+):(.*)/ ) + { + $groups = $2; + print "User: $username is member of the groups: $groups\n"; + } + + foreach my $g ( split( / /, $groups ) ) + { + system( "chroot $prefix /usr/sbin/adduser $username $group" ); + } +} diff --git a/hooks/gentoo/35-setup-users b/hooks/gentoo/35-setup-users index 1df253c..2611d61 100755 --- a/hooks/gentoo/35-setup-users +++ b/hooks/gentoo/35-setup-users @@ -58,6 +58,12 @@ foreach my $account ( sort keys( %host ) ) { print "Adding: $account\n"; addAccount( $account ); + + # + # Find any groups the user is member of on the host + # and add them on the guest system + # + addGroups( $account ); } } @@ -142,3 +148,30 @@ sub addAccount } close( SHADOW ); } + + + +# +# Find the groups a user is member of on the host, and add them to +# those groups on the new guest. +# +sub addGroups +{ + my( $username ) = ( @_ ); + + # + # Get the groups. + # + my $groups = `groups $username`; + # split off the usernmame. + if ( $groups =~ /^([^:]+):(.*)/ ) + { + $groups = $2; + print "User: $username is member of the groups: $groups\n"; + } + + foreach my $g ( split( / /, $groups ) ) + { + system( "chroot $prefix /usr/sbin/adduser $username $group" ); + } +}