diff options
author | Julian Blake Kongslie <jblake@omgwallhack.org> | 2010-07-07 14:07:06 -0700 |
---|---|---|
committer | Julian Blake Kongslie <jblake@omgwallhack.org> | 2010-07-07 14:07:06 -0700 |
commit | 4fa79cd01321b079ad94c6041038bd3a7dcc0958 (patch) | |
tree | 5c55ffa7d5f06827a18a9c38e953226160530fa9 /usr/src/libpiny/lib/Piny/Group.pm | |
parent | 7b243125659e9a13126198b2b790a697552d59e5 (diff) | |
download | piny-code-4fa79cd01321b079ad94c6041038bd3a7dcc0958.tar.gz piny-code-4fa79cd01321b079ad94c6041038bd3a7dcc0958.zip |
Lots more ikiwiki integration stuff in libpiny.
Diffstat (limited to 'usr/src/libpiny/lib/Piny/Group.pm')
-rw-r--r-- | usr/src/libpiny/lib/Piny/Group.pm | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/usr/src/libpiny/lib/Piny/Group.pm b/usr/src/libpiny/lib/Piny/Group.pm index a4d3c27..ac064da 100644 --- a/usr/src/libpiny/lib/Piny/Group.pm +++ b/usr/src/libpiny/lib/Piny/Group.pm @@ -15,7 +15,7 @@ has 'gid' => , lazy_build => 1 ); -has 'groupname' => +has 'name' => ( is => 'ro' , isa => 'Str' , lazy_build => 1 @@ -41,7 +41,7 @@ sub add_member { my ( $s, @users ) = @_; foreach my $user ( @users ) { - system( "/usr/sbin/adduser", $user->username( ), $s->groupname( ) ); + system( "/usr/sbin/adduser", $user->name( ), $s->name( ) ); $user->clear_groups( ); }; @@ -52,7 +52,7 @@ sub remove_member { my ( $s, @users ) = @_; foreach my $user ( @users ) { - system( "/usr/sbin/deluser", $user->username( ), $s->groupname( ) ); + system( "/usr/sbin/deluser", $user->name( ), $s->name( ) ); $user->clear_groups( ); }; @@ -62,8 +62,8 @@ sub remove_member { # Builder methods # If constructed with just one argument, then -# * If that argument is numeric, treat it as a UID. -# * Otherwise, treat it as a username. +# * If that argument is numeric, treat it as a GID. +# * Otherwise, treat it as a name. around BUILDARGS => sub { my ( $orig, $class ) = ( shift, shift ); @@ -71,7 +71,7 @@ around BUILDARGS => sub { if ( $_[0] =~ m/^\d+$/ ) { return $class->$orig( gid => $_[0] ); } else { - return $class->$orig( groupname => $_[0] ); + return $class->$orig( name => $_[0] ); }; } else { return $class->$orig( @_ ); @@ -81,12 +81,12 @@ around BUILDARGS => sub { sub BUILD { my ( $s ) = @_; - if ( not ( $s->has_gid( ) or $s->has_groupname( ) ) ) { - die "You must provide either GID or groupname!"; + if ( not ( $s->has_gid( ) or $s->has_name( ) ) ) { + die "You must provide either GID or name!"; }; - if ( $s->has_gid( ) and $s->has_groupname( ) ) { - die "You must not provide both GID and groupname!"; + if ( $s->has_gid( ) and $s->has_name( ) ) { + die "You must not provide both GID and name!"; }; }; @@ -96,7 +96,7 @@ sub _build_gid { return $s->grent( )->[2]; }; -sub _build_groupname { +sub _build_name { my ( $s ) = @_; return $s->grent( )->[0]; @@ -109,9 +109,9 @@ sub _build_grent { my @res = getgrgid( $s->gid( ) ); die "getgrgid( " . $s->gid( ) . " ) failed: $!" unless @res; return \@res; - } elsif ( $s->has_groupname( ) ) { - my @res = getgrnam( $s->groupname( ) ); - die "getgrnam( " . $s->groupname( ) . " ) failed: $!" unless @res; + } elsif ( $s->has_name( ) ) { + my @res = getgrnam( $s->name( ) ); + die "getgrnam( " . $s->name( ) . " ) failed: $!" unless @res; return \@res; } else { die "Not enough information provided to lookup group!"; @@ -122,7 +122,7 @@ sub _build_members { my ( $s ) = @_; return [ ] if ( $s->grent( )->[3] eq "" ); - return [ map { Piny::User->new( username => $_ ) } split( /:/, $s->grent( )->[3] ) ]; + return [ map { Piny::User->new( name => $_ ) } split( /:/, $s->grent( )->[3] ) ]; }; # Moose boilerplate |