Sah-Schemas-Unix
view release on metacpan or search on metacpan
Note that this schema does not check whether the UID exists (has
record in the user database e.g. "/etc/passwd"). To do that, use the
"unix::uid::exists" schema.
* unix::uid::exists
User identifier (UID) that has to exist (has associated username) on
the system.
Existing means having a user name associated with this UID, i.e.
"getpwuid" returns a record.
Support coercion from an existing user name.
* unix::username
Unix account name.
The checking follows POSIX rules: does not begin with a hyphen and
only contains [A-Za-z0-9._-].
lib/Data/Sah/Filter/perl/Unix/check_uid_exists.pm view on Meta::CPAN
sub filter {
my %args = @_;
my $dt = $args{data_term};
my $res = {};
$res->{expr_filter} = join(
"",
"do { my \$tmp = $dt+0; my \@tmp = getpwuid(\$tmp); if (!\@tmp) { [\"UID \$tmp is not associated with any user\", \$tmp] } else { [undef, \$tmp] } }",
);
$res;
}
1;
# ABSTRACT:
__END__
lib/Data/Sah/Filter/perl/Unix/convert_uid_to_unix_user.pm view on Meta::CPAN
sub filter {
my %args = @_;
my $dt = $args{data_term};
my $res = {};
$res->{expr_filter} = join(
"",
"do { my \$tmp = $dt; if (\$tmp =~ /\\A[0-9]+\\z/) { my \@pw = getpwuid(\$tmp); \@pw ? [undef, \$pw[0]] : [\"UID \$tmp has no associated username\", \$tmp] } else { [undef, \$tmp] } }",
);
$res;
}
1;
# ABSTRACT:
__END__
lib/Data/Sah/Filter/perl/Unix/try_convert_uid_to_unix_user.pm view on Meta::CPAN
sub filter {
my %args = @_;
my $dt = $args{data_term};
my $res = {};
$res->{expr_filter} = join(
"",
"do { my \$tmp = $dt; if (\$tmp =~ /\\A[0-9]+\\z/) { my \@pw = getpwuid(\$tmp); \@pw ? \$pw[0] : \$tmp } else { \$tmp } }",
);
$res;
}
1;
# ABSTRACT:
__END__
lib/Sah/Schema/unix/uid/exists.pm view on Meta::CPAN
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2022-09-08'; # DATE
our $DIST = 'Sah-Schemas-Unix'; # DIST
our $VERSION = '0.021'; # VERSION
our $schema = ["unix::uid" => {
summary => 'User identifier (UID) that has to exist (has associated username) on the system',
description => <<'_',
Existing means having a user name associated with this UID, i.e. `getpwuid`
returns a record.
Support coercion from an existing user name.
_
'prefilters' => ['Unix::convert_unix_user_to_uid', 'Unix::check_uid_exists'],
}];
1;
# ABSTRACT: User identifier (UID) that has to exist (has associated username) on the system
lib/Sah/Schema/unix/uid/exists.pm view on Meta::CPAN
% ./myapp.pl --help
myapp - Routine to do blah ...
...
% ./myapp.pl --version
% ./myapp.pl --arg1 ...
=head1 DESCRIPTION
Existing means having a user name associated with this UID, i.e. C<getpwuid>
returns a record.
Support coercion from an existing user name.
=head1 HOMEPAGE
Please visit the project's homepage at L<https://metacpan.org/release/Sah-Schemas-Unix>.
=head1 SOURCE
lib/Sah/SchemaR/unix/uid/exists.pm view on Meta::CPAN
## no critic: TestingAndDebugging::RequireStrict
package Sah::SchemaR::unix::uid::exists;
our $DATE = '2022-09-08'; # DATE
our $VERSION = '0.021'; # VERSION
our $rschema = do{my$var={base=>"unix::uid",clsets_after_base=>[{description=>"\nExisting means having a user name associated with this UID, i.e. `getpwuid`\nreturns a record.\n\nSupport coercion from an existing user name.\n\n",prefilters=>["Unix::c...
1;
# ABSTRACT: User identifier (UID) that has to exist (has associated username) on the system
__END__
=pod
=encoding UTF-8
lib/Sah/Schemas/Unix.pm view on Meta::CPAN
Note that this schema does not check whether the UID exists (has record in the
user database e.g. C</etc/passwd>). To do that, use the C<unix::uid::exists>
schema.
=item * L<unix::uid::exists|Sah::Schema::unix::uid::exists>
User identifier (UID) that has to exist (has associated username) on the system.
Existing means having a user name associated with this UID, i.e. C<getpwuid>
returns a record.
Support coercion from an existing user name.
=item * L<unix::username|Sah::Schema::unix::username>
Unix account name.
The checking follows POSIX rules: does not begin with a hyphen and only contains
( run in 0.370 second using v1.01-cache-2.11-cpan-8d75d55dd25 )