summaryrefslogtreecommitdiffstats
path: root/isys
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2004-02-24 23:56:01 +0000
committerJeremy Katz <katzj@redhat.com>2004-02-24 23:56:01 +0000
commita21506212bf39045bff678ee4b64999f066420c5 (patch)
treee4d8d820e8521e94c72310e985cdd1e12c950b6e /isys
parent4acbcedd7c666088af3810dc629812031279584c (diff)
downloadanaconda-a21506212bf39045bff678ee4b64999f066420c5.tar.gz
anaconda-a21506212bf39045bff678ee4b64999f066420c5.tar.xz
anaconda-a21506212bf39045bff678ee4b64999f066420c5.zip
add function to reset the file context to what it "should" be
Diffstat (limited to 'isys')
-rw-r--r--isys/Makefile2
-rw-r--r--isys/isys.c19
-rw-r--r--isys/isys.py4
3 files changed, 24 insertions, 1 deletions
diff --git a/isys/Makefile b/isys/Makefile
index e46cd74be..947830ef5 100644
--- a/isys/Makefile
+++ b/isys/Makefile
@@ -8,7 +8,7 @@ OBJECTS = nfsmount.o nfsmount_clnt.o nfsmount_xdr.o imount.o getmacaddr.o \
ethtool.o getipaddr.o
SOBJECTS = $(patsubst %.o,%.lo,$(OBJECTS))
SOURCES = $(patsubst %.o,%.c,$(OBJECTS)) isys.c
-LOADLIBES = -lresolv -lpci -lpopt -lpump -lext2fs -lz -lbterm -lbogl -lwlite -lkudzu -lpci
+LOADLIBES = -lresolv -lpci -lpopt -lpump -lext2fs -lz -lbterm -lbogl -lwlite -lkudzu -lpci -lselinux
PYMODULES = _isys.so
SUBDIRS = gzlib
DIET = diet
diff --git a/isys/isys.c b/isys/isys.c
index fccd2d951..c4cfec5f6 100644
--- a/isys/isys.c
+++ b/isys/isys.c
@@ -39,6 +39,7 @@
#include <linux/hdreg.h>
#include <linux/fb.h>
#include <libintl.h>
+#include <selinux/selinux.h>
#include "md-int.h"
#include "imount.h"
@@ -107,6 +108,7 @@ static PyObject * py_isUsableDasd(PyObject * s, PyObject * args);
static PyObject * py_isLdlDasd(PyObject * s, PyObject * args);
static PyObject * doGetMacAddress(PyObject * s, PyObject * args);
static PyObject * doGetIPAddress(PyObject * s, PyObject * args);
+static PyObject * doResetFileContext(PyObject * s, PyObject * args);
static PyMethodDef isysModuleMethods[] = {
{ "ejectcdrom", (PyCFunction) doEjectCdrom, METH_VARARGS, NULL },
@@ -162,6 +164,7 @@ static PyMethodDef isysModuleMethods[] = {
{ "isLdlDasd", (PyCFunction) py_isLdlDasd, METH_VARARGS, NULL},
{ "getMacAddress", (PyCFunction) doGetMacAddress, METH_VARARGS, NULL},
{ "getIPAddress", (PyCFunction) doGetIPAddress, METH_VARARGS, NULL},
+ { "resetFileContext", (PyCFunction) doResetFileContext, METH_VARARGS, NULL },
{ NULL }
} ;
@@ -1289,6 +1292,22 @@ static PyObject * doGetIPAddress(PyObject * s, PyObject * args) {
return Py_BuildValue("s", ret);
}
+static PyObject * doResetFileContext(PyObject * s, PyObject * args) {
+ char *fn, *buf = NULL;
+ int ret;
+
+ if (!PyArg_ParseTuple(args, "s", &fn))
+ return NULL;
+
+ ret = matchpathcon(fn, 0, &buf);
+ /* fprintf(stderr, "matchpathcon returned %d: set %s to %s\n", ret, fn, buf);*/
+ if (ret == 0) {
+ ret = setfilecon(fn, buf);
+ }
+
+ return Py_BuildValue("s", buf);
+}
+
static PyObject * py_getDasdPorts(PyObject * o, PyObject * args) {
if (!PyArg_ParseTuple(args, "")) return NULL;
diff --git a/isys/isys.py b/isys/isys.py
index f8d591131..f43919eb0 100644
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -18,6 +18,7 @@ import _isys
import string
import os
import os.path
+import sys
import kudzu
from rhpl.log import log
@@ -689,6 +690,9 @@ def getMacAddress(dev):
def getIPAddress(dev):
return _isys.getIPAddress(dev)
+def resetFileContext(fn):
+ return _isys.resetFileContext(fn)
+
def startBterm():
return _isys.startBterm()