Author: wayland Date: 2009-02-27 12:34:30 +0100 (Fri, 27 Feb 2009) New Revision: 25619
Modified: docs/Perl6/Spec/S16-io.pod docs/Perl6/Spec/S29-functions.pod Log: Did some work on users and groups Modified: docs/Perl6/Spec/S16-io.pod =================================================================== --- docs/Perl6/Spec/S16-io.pod 2009-02-27 11:10:45 UTC (rev 25618) +++ docs/Perl6/Spec/S16-io.pod 2009-02-27 11:34:30 UTC (rev 25619) @@ -24,8 +24,10 @@ corresponding global function, it's merely an exported version of the method. -=head1 Overridable IO handles +=head1 IO +=head2 Overridable IO handles + In Perl 6, there are the I<standard> IO handles, and any number of overriding inner filehandles for the same symbol. @@ -65,15 +67,78 @@ } # stdout reverts to outer scope's definition -=head1 Roles and Classes +=head2 Roles and Classes The roles and classes that define most of the functionality for IO are defined in S32-setting-library/IO.pod. The main functions used are listed in S29 with references to S32-setting-library/IO.pod. +=head1 Users and Groups + +=head2 User role + +role User { + has $username; # Username (some descendants(?) may want to implement a real $name) + has $id; # User ID + has $dir; # Home directory for files +} + +=item new + + method User new($Username?, $UID?) {...} + +Creates a new User object, fetching the information either by username or user ID. + +=item write + + method write() {...} + +Tries to write the current User object to the user database. This may well fail. + +=item Str + +When converted to a Str, returns $username. + +=item Num + +When converted to a Num, returns $uid. + +=head2 OS::Unix::User role + +role OS::Unix::User does User { + has $password; + has $gid; + has $gecos; + has $shell; +} + +All the information is naturally fetched from the system via getpwuid, getpwnam, or the +like. + +=head2 Group role + +role Group { + has $name; + has $id; + has @members; +} + +=item new + + method Group new(:$Name, :$ID); + +=item write + + method write(); + +Tries to write the group entry into the system group database. + =head1 Additions Please post errors and feedback to perl6-language. If you are making a general laundry list, please separate messages by topic. =cut + +=encoding utf8 + Modified: docs/Perl6/Spec/S29-functions.pod =================================================================== --- docs/Perl6/Spec/S29-functions.pod 2009-02-27 11:10:45 UTC (rev 25618) +++ docs/Perl6/Spec/S29-functions.pod 2009-02-27 11:34:30 UTC (rev 25619) @@ -420,53 +420,6 @@ my $address = gethost("foo.example.com").addr; my $hostname = gethost(:addr<"10.1.2.3">); -=item getpw - - our OS::PW multi getpw() - our OS::PW multi getpw( Int $uid ) - our OS::PW multi getpw( Str $name ) - - our OS::PW multi method OS::PWEnt::getpw( OS::PWEnt $pw: ) - our OS::PW multi method OS::PWEnt::getpw( OS::PWEnt $pw: Int $uid ) - our OS::PW multi method OS::PWEnt::getpw( OS::PWEnt $pw: Str $name ) - -The C<getpw> function operates on system login information, returning -data about users in the form of an C<OS::PW> object ("PW" refers -to the historical C<getpw*> functions that are part of the POSIX -standard, and stands for "password"). - -When given no parameters, the "next" user entry is returned (C<undef> is -returned when the list of users has been exhausted). - -When C<$uid> is provided, a user with the given UID is found and returned. -C<undef> is returned if no matching entry is found. - -When C<$name> is provided, a user with the matching name is found and -returned. C<undef> is returned if no matching entry is found. - -The return value is an object that represents the system-specific -information about the user. When numified, this object returns the -UID of the user. When stringified, this object returns the username. - -Therefore, the typical convention of: - - my Int $uid = getpw(~$name); - -and - - my Str $name = getpw(+$uid); - -Will work as expected. - -See the documentation for the C<OS::PW> and C<OS::PWEnt> classes for more -information and the equivalent of the Perl 5 setpwent / endpwent functions. - -WARNING: Even when used as a method on an C<OS::PWEnt> object, there -may be system-specific, global state associated with the implementation -of these routines. - -[Note: TODO setpgrp setpriority times -ajs ] - =item chroot our Bool multi chroot ( Str $path = CALLER::<$_> ) @@ -828,6 +781,10 @@ See Exegesis 7. +=item getgrgid, getgrnam, getpwnam, getpwuid + +The User and Group roles in S16 cover most of these. + =item length() This word is banned in Perl 6. You must specify units. In practise, this probably means @@ -948,8 +905,6 @@ endpwent endservent getgrent -getgrgid -getgrnam gethostbyaddr gethostbyname gethostent @@ -965,8 +920,6 @@ getprotobynumber getprotoent getpwent -getpwnam -getpwuid getservbyname getservbyport getservent