From 4fa79cd01321b079ad94c6041038bd3a7dcc0958 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Wed, 7 Jul 2010 14:07:06 -0700 Subject: Lots more ikiwiki integration stuff in libpiny. --- usr/src/libpiny/lib/Piny/User.pm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'usr/src/libpiny/lib/Piny/User.pm') diff --git a/usr/src/libpiny/lib/Piny/User.pm b/usr/src/libpiny/lib/Piny/User.pm index 559adfd..173b592 100644 --- a/usr/src/libpiny/lib/Piny/User.pm +++ b/usr/src/libpiny/lib/Piny/User.pm @@ -25,7 +25,7 @@ has 'uid' => , lazy_build => 1 ); -has 'username' => +has 'name' => ( is => 'ro' , isa => 'Username' , lazy_build => 1 @@ -100,7 +100,7 @@ sub all_users { eval { my $user = $class->new( uid => $info[2] ); # Some forced early evaluation, so error checking happens now. - $user->username( ); + $user->name( ); $user->email( ); push( @ret, $user ); }; @@ -123,7 +123,7 @@ around BUILDARGS => sub { if ( $_[0] =~ m/^\d+$/ ) { return $class->$orig( uid => $_[0] ); } else { - return $class->$orig( username => $_[0] ); + return $class->$orig( name => $_[0] ); }; } else { return $class->$orig( @_ ); @@ -133,12 +133,12 @@ around BUILDARGS => sub { sub BUILD { my ( $s ) = @_; - if ( not ( $s->has_uid( ) or $s->has_username( ) ) ) { - die "You must provide either UID or username!"; + if ( not ( $s->has_uid( ) or $s->has_name( ) ) ) { + die "You must provide either UID or name!"; }; - if ( $s->has_uid( ) and $s->has_username( ) ) { - die "You must not provide both UID and username!"; + if ( $s->has_uid( ) and $s->has_name( ) ) { + die "You must not provide both UID and name!"; }; }; @@ -148,7 +148,7 @@ sub _build_uid { return $s->pwent( )->[2]; }; -sub _build_username { +sub _build_name { my ( $s ) = @_; return $s->pwent( )->[0]; @@ -161,9 +161,9 @@ sub _build_pwent { my @res = getpwuid( $s->uid( ) ); die "getpwuid( " . $s->uid( ) . " ) failed: $!" unless @res; return \@res; - } elsif ( $s->has_username( ) ) { - my @res = getpwnam( $s->username( ) ); - die "getpwnam( " . $s->username( ) . " ) failed: $!" unless @res; + } elsif ( $s->has_name( ) ) { + my @res = getpwnam( $s->name( ) ); + die "getpwnam( " . $s->name( ) . " ) failed: $!" unless @res; return \@res; } else { die "Not enough information provided to lookup user!"; @@ -193,7 +193,7 @@ sub _build_groups { while ( @ent = getgrent( ) ) { next if ( $ent[3] eq "" ); foreach my $member ( split( / /, $ent[3] ) ) { - if ( $member eq $s->username( ) ) { + if ( $member eq $s->name( ) ) { push @res, Piny::Group->new( gid => $ent[2] ); last; }; -- cgit v1.2.3