summaryrefslogtreecommitdiffstats
path: root/pyfirstaidkit/utils.py
diff options
context:
space:
mode:
authorJoel Andres Granados <jgranado@redhat.com>2008-01-02 14:32:07 +0100
committerJoel Andres Granados <jgranado@redhat.com>2008-01-02 14:32:07 +0100
commit26da06a02b8cbeea5aea9eccc2de55d33ade23bf (patch)
tree7bb10032a86f8015dcee987697c480ef24d32872 /pyfirstaidkit/utils.py
parent403519b478ffbe5b433b1fd2fb7babe12c693af2 (diff)
downloadfirstaidkit-26da06a02b8cbeea5aea9eccc2de55d33ade23bf.tar.gz
firstaidkit-26da06a02b8cbeea5aea9eccc2de55d33ade23bf.tar.xz
firstaidkit-26da06a02b8cbeea5aea9eccc2de55d33ade23bf.zip
Move from tasker to pyfirstaidkit to try to follow the standard in site-packages.
Diffstat (limited to 'pyfirstaidkit/utils.py')
-rw-r--r--pyfirstaidkit/utils.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/pyfirstaidkit/utils.py b/pyfirstaidkit/utils.py
new file mode 100644
index 0000000..139bb39
--- /dev/null
+++ b/pyfirstaidkit/utils.py
@@ -0,0 +1,38 @@
+# First Aid Kit - diagnostic and repair tool for Linux
+# Copyright (C) 2007 Martin Sivak <msivak@redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import os
+import sys
+import subprocess
+
+def spawnvch(executable, params, chroot): #returns errorcode
+ """Simpliest chroot modification of spawn
+ executable - path to binary to execute (in chroot!)
+ params - it's parameters
+ chroot - directory to chroot to
+
+Returns the error code returned by process"""
+
+ pid = os.fork()
+ if pid==0: #child
+ os.chroot(chroot)
+ os.execv(executable, params)
+ os.exit(1)
+ else:
+ res = os.waitpid(pid, 0)
+ return os.WEXITSTATUS(res)
+