| Sys-Group-GIDhelper documentation | Contained in the Sys-Group-GIDhelper distribution. |
Sys::Group::GIDhelper - Helps for locating free GIDs.
Version 0.0.2
use Sys::Group::GIDhelper;
#implements it with the default values
my $foo = Sys::Group::GIDhelper->new();
#sets the min to 0 and the max to 4000
my $foo = Sys::Group::GIDhelper->new({max=>'0', min=>'4000'});
#finds the first free one
my $first = $foo->firstfree();
if(defined($first)){
print $first."\n";
}else{
print "not found\n";
}
#finds the first last one
my $last = $foo->lastfree();
if(defined($last)){
print $last."\n";
}else{
print "not found\n";
}
This initiates the module. It accepts one arguement, a hash. Please See below for accepted values.
The minimum GID.
The maximum GID.
This finds the first free GID. If it returns undef, no free ones were found.
This finds the first last UID. If it returns undef, no free ones were found.
Implement various backends for system, LDAP, and passwd.
Zane C. Bowers, <vvelox at vvelox.net>
Please report any bugs or feature requests to bug-sys-group-gidhelper at rt.cpan.org, or through
the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sys-Group-UIDhelper. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Sys::Group::GIDhelper
You can also look for information at:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Sys-Group-GIDhelper
Copyright 2008 Zane C. Bowers, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Sys-Group-GIDhelper documentation | Contained in the Sys-Group-GIDhelper distribution. |
package Sys::Group::GIDhelper; use warnings; use strict;
our $VERSION = '0.0.2';
sub new { my %args; if(defined($_[1])){ %args= %{$_[1]}; }; my $self={error=>undef, set=>undef}; bless $self; #set default max #this number is based on FreeBSD $self->{max}=32767; if (defined($args{max})) { $self->{max}=$args{max}; } #this is choosen as on most systems 1000 is the general base for #new groups $self->{min}=1000; if (defined($args{min})) { $self->{min}=$args{min}; } return $self; }
sub firstfree { my $self=$_[0]; my $int=$self->{min}; while ( $int <= $self->{max}) { if (!getgrgid($int)) { return $int } $int++; } return undef; }
sub lastfree { my $self=$_[0]; my $int=$self->{max}; while ( $int >= $self->{min}) { if (!getgrgid($int)) { return $int } $int--; } return undef; } #=head2 errorBlank # #A internal function user for clearing an error. # #=cut # #blanks the error flags #sub errorBlank{ # my $self=$_[0]; # # #error handling # $self->{error}=undef; # $self->{errorString}=""; # # return 1; #};
1; # End of Sys::Group::GIDhelper