Sah-SchemaBundle-Unix

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

        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: Check that UID exists (has associated username) on the system

__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: Convert UID into Unix username, fail when username does not exist

__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: Try to convert UID into Unix username, leave as-is if cannot convert

__END__

lib/Sah/Schema/unix/uid/exists.pm  view on Meta::CPAN


our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2024-11-15'; # DATE
our $DIST = 'Sah-SchemaBundle-Unix'; # DIST
our $VERSION = '0.022'; # VERSION

our $schema = ["unix::uid" => {
    summary => 'User identifier (UID) that has to exist (has associated username) on the system',
    description => <<'MARKDOWN',

Existing means having a user name associated with this UID, i.e. `getpwuid`
returns a record.

Support coercion from an existing user name.

MARKDOWN
    '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

     __PACKAGE__->add_type(
         sah2type('unix::uid::exists*', name=>'UnixUidExists')
     );
 }

 use My::Types qw(UnixUidExists);
 UnixUidExists->assert_valid($data);

=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-SchemaBundle-Unix>.

=head1 SOURCE

lib/Sah/SchemaBundle/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

lib/Sah/SchemaR/unix/uid/exists.pm  view on Meta::CPAN

## no critic: TestingAndDebugging::RequireStrict
package Sah::SchemaR::unix::uid::exists;

our $DATE = '2024-11-15'; # DATE
our $VERSION = '0.022'; # 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



( run in 0.386 second using v1.01-cache-2.11-cpan-8d75d55dd25 )