ManaTools::Shared::RunProgram

SYNOPSYS
Functions
POD ERRORS


SYNOPSYS

rManaTools::Shared::RunProgram enables to:

run programs in foreground or in background,

to retrieve their stdout or stderr

Most functions exits in a normal form & a rooted one. e.g.:

“run()” & “rooted()”

“get_stdout()” & “rooted_get_stdout()”

Most functions exits in a normal form & one that die. e.g.:

“run()” & “run_or_die()”

“rooted()” & “rooted_or_die()”

Functions

set_default_timeout($seconds)

Alters defaults timeout (eg for harddrake service)

run_or_die($name, @args)

Runs $name with @args parameterXs. Dies if it exit code is not 0.

rooted_or_die($root, $name, @args)

Similar to run_or_die() but runs in chroot in $root

get_stdout($name, @args)

Similar to run_or_die() but return stdout of program:

a list of lines in list context

a string of concatenated lines in scalar context

get_stdout_raw($options, $name, @args)

Similar to get_stdout() but allow to pass options to raw()

rooted_get_stdout($root, $name, @args)

Similar to get_stdout() but runs in chroot in $root

run($name, @args)

Runs $name with @args parameters.

rooted($root, $name, @args)

Similar to run() but runs in chroot in $root

raw($options, $name, @args)

The function used by all the other, making every combination possible. Runs $name with @args parameters. $options is a hash ref that can contains:

root: $name will be chrooted in $root prior to run

as_user: $name will be run as $ENV{ PKEXEC_UID } or with the UID of parent process. Implies setuid

sensitive_arguments: parameters will be hidden in logs (b/c eg there’s a password)

detach: $name will be run in the background. Default is foreground

chdir: $name will be run in a different default directory

setuid: contains a getpwnam(3) struct ; $name will be with droped privileges ; make sure environment is set right and keep a copy of the X11 cookie

timeout: execution of $name will be aborted after “timeout” seconds

exitcode: function will return the exit code of the process

eg:

“ManaTools::Shared::RunProgram::raw({ root => $::prefix, sensitive_arguments => 1 }, “echo −e $user−>{password} | cryptsetup luksFormat $device”);”

“ManaTools::Shared::RunProgram::raw({ detach => 1 }, ‘/etc/rc.d/init.d/dm’, ‘>’, ‘/dev/null’, ‘2>’, ‘/dev/null’, ‘restart’);”

get_parent_uid()

Returns UID of the parent process.

POD ERRORS

Hey! The above document had some coding errors, which are explained below:
Around line 58:

=over without closing =back