diff options
author | Chmouel Boudjnah <chmouel@mandriva.org> | 1999-07-01 12:29:54 +0000 |
---|---|---|
committer | Chmouel Boudjnah <chmouel@mandriva.org> | 1999-07-01 12:29:54 +0000 |
commit | e1729dfdb9c341fe0b9fed7d7b0a80691a547d82 (patch) | |
tree | b72fd8f59af166fe944ebcf114d648ed5644f752 /perl-install/run_program.pm | |
parent | b50e655e352e2524fb3fb84b2bb4bc96e6a04cf0 (diff) | |
download | drakx-backup-do-not-use-e1729dfdb9c341fe0b9fed7d7b0a80691a547d82.tar drakx-backup-do-not-use-e1729dfdb9c341fe0b9fed7d7b0a80691a547d82.tar.gz drakx-backup-do-not-use-e1729dfdb9c341fe0b9fed7d7b0a80691a547d82.tar.bz2 drakx-backup-do-not-use-e1729dfdb9c341fe0b9fed7d7b0a80691a547d82.tar.xz drakx-backup-do-not-use-e1729dfdb9c341fe0b9fed7d7b0a80691a547d82.zip |
"See_The_Changelog"
Diffstat (limited to 'perl-install/run_program.pm')
-rw-r--r-- | perl-install/run_program.pm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/perl-install/run_program.pm b/perl-install/run_program.pm new file mode 100644 index 000000000..e4f2a7ef8 --- /dev/null +++ b/perl-install/run_program.pm @@ -0,0 +1,30 @@ +package run_program; + +use diagnostics; +use strict; + +use log; + +1; + +sub run($@) { rooted('', @_) } + +sub rooted($$@) { + my ($root, $name, @args) = @_; + + log::l("running: $name @args" . ($root ? " with root $root" : "")); + $root ? $root .= '/' : ($root = ''); + + fork and wait, return $? == 0; + { + open STDIN, "/dev/null" or die "can't open /dev/null as stdin"; + + open STDERR, ">> /dev/tty5" or open STDERR, ">> /tmp/exec.log" or die "runProgramRoot can't log :("; + open STDOUT, ">> /dev/tty5" or open STDOUT, ">> /tmp/exec.log" or die "runProgramRoot can't log :("; + + $root and chroot $root; + chdir "/"; + + exec $name, @args or log::l("exec of $name failed: $!"), exit(-1); + } +} |