From 0df6b8d376c6cbac0ed3df910cdcc10c06bd3e18 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Thu, 18 Mar 2010 13:06:24 -0700 Subject: Add methods for managing group membership, and some more constraints. --- usr/src/libpiny/lib/Piny/Group.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'usr/src/libpiny/lib/Piny/Group.pm') diff --git a/usr/src/libpiny/lib/Piny/Group.pm b/usr/src/libpiny/lib/Piny/Group.pm index 4b957a7..c1df42d 100644 --- a/usr/src/libpiny/lib/Piny/Group.pm +++ b/usr/src/libpiny/lib/Piny/Group.pm @@ -35,6 +35,30 @@ has 'members' => , init_arg => undef ); +# Public methods + +sub add_member { + my ( $s, @users ) = @_; + + foreach my $user ( @users ) { + system( "adduser", $user->username( ), $s->groupname( ) ); + $user->clear_groups( ); + }; + + $s->clear_members( ); +}; + +sub remove_member { + my ( $s, @users ) = @_; + + foreach my $user ( @users ) { + system( "deluser", $user->username( ), $s->groupname( ) ); + $user->clear_groups( ); + }; + + $s->clear_members( ); +}; + # Builder methods # If constructed with just one argument, then -- cgit v1.2.3