App-Transpierce

 view release on metacpan or  search on metacpan

bin/transpierce  view on Meta::CPAN

					die "file $into already exists - aborting"
						if -e $into;

					copy $action{file}{relpath}, $into or die "could not copy into $into: $!";
				}
			};
		},
		create_script => sub {
			$copy_keys->(qw(type dest files));
			$action{desc} = "Create script in $action{dest}\n" . join "\n", map {
				"  $action{type} -> $_->{relpath}"
			} @{$action{files}};

			my $inner_sub = get_script_generator($action{type});

			$action{code} = sub {
				my $output = '';
				foreach my $file (@{$action{files}}) {
					$output .= $inner_sub->($file);
				}

				spurt($action{dest}, $output);
				chmod 0774, $action{dest};
			};
		}
	);

	($types{$type} // die "invalid action type $type")->();

	return \%action;
}

sub run_actions
{
	my (@action_list) = @_;

	if ($describe) {
		say 'Actions:';
	}

	foreach my $action (@action_list) {
		if ($describe) {
			say $action->{desc};
			say '-------';
			next;
		}

		$action->{code}->();
	}
}

sub print_permissions
{
	my ($config) = @_;

	say "Files specified in the config file";
	foreach my $file (@$config) {
		say $file->{relpath};
		say "  mode -> $file->{chmod}";
		say "  uid -> $file->{chown}";
		say "  gid -> $file->{chgrp}";
		say '-------';
	}

	say '';
}

__END__

=head1 NAME

transpierce - script for safer infiltration of sensitive environments

=head1 SYNOPSIS

	transpierce [OPTIONS] TARGET

=head1 OPTIONS

=over

=item -d, --describe

Print a summary of actions which will be taken. Do not execute the actions.

=item -c FILE, --config=FILE

Specify a filepath used for the configuration file. Default is C<transpierce.conf> in TARGET.

=item -e, --self-export

Export the script itself into TARGET directory. It can then be copied over to
the target machine.

=back

=head1 DESCRIPTION

Generate proper files in TARGET directory (by default current working
directory) using contents of configuration file in that directory.

Refer to L<App::Transpierce> for detailed usage explanation.

=head1 AUTHOR

Bartosz Jarzyna, E<lt>bbrtj.pro@gmail.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2023 by Bartosz Jarzyna

FreeBSD 2-clause license - see LICENSE



( run in 0.494 second using v1.01-cache-2.11-cpan-5735350b133 )