summaryrefslogtreecommitdiffstats
path: root/isys/isys.c
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2007-10-18 20:27:32 +0000
committerPeter Jones <pjones@redhat.com>2007-10-18 20:27:32 +0000
commitd32c58af29e8ca27fa53726b9e37ba664d44d225 (patch)
treed4756b19b26f55764e020b58a64d881f000d78df /isys/isys.c
parentcfa0b4b12266e8e44f13bc458204b3a11abd9a80 (diff)
downloadanaconda-d32c58af29e8ca27fa53726b9e37ba664d44d225.tar.gz
anaconda-d32c58af29e8ca27fa53726b9e37ba664d44d225.tar.xz
anaconda-d32c58af29e8ca27fa53726b9e37ba664d44d225.zip
- fix selinux labels on $MOUNTPOINT/ and $MOUNTPOINT/lost+found (#335621)
Diffstat (limited to 'isys/isys.c')
-rw-r--r--isys/isys.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/isys/isys.c b/isys/isys.c
index d759a55b8..60e9a353d 100644
--- a/isys/isys.c
+++ b/isys/isys.c
@@ -108,7 +108,8 @@ static PyObject * py_isLdlDasd(PyObject * s, PyObject * args);
static PyObject * doGetMacAddress(PyObject * s, PyObject * args);
static PyObject * doGetIPAddress(PyObject * s, PyObject * args);
#ifdef USESELINUX
-static PyObject * doResetFileContext(PyObject * s, PyObject * args);
+static PyObject * doMatchPathContext(PyObject * s, PyObject * args);
+static PyObject * doSetFileContext(PyObject * s, PyObject * args);
#endif
static PyObject * isWireless(PyObject * s, PyObject * args);
static PyObject * doProbeBiosDisks(PyObject * s, PyObject * args);
@@ -159,7 +160,8 @@ static PyMethodDef isysModuleMethods[] = {
{ "getMacAddress", (PyCFunction) doGetMacAddress, METH_VARARGS, NULL},
{ "getIPAddress", (PyCFunction) doGetIPAddress, METH_VARARGS, NULL},
#ifdef USESELINUX
- { "resetFileContext", (PyCFunction) doResetFileContext, METH_VARARGS, NULL },
+ { "matchPathContext", (PyCFunction) doMatchPathContext, METH_VARARGS, NULL },
+ { "setFileContext", (PyCFunction) doSetFileContext, METH_VARARGS, NULL },
#endif
{ "isWireless", (PyCFunction) isWireless, METH_VARARGS, NULL },
{ "biosDiskProbe", (PyCFunction) doProbeBiosDisks, METH_VARARGS,NULL},
@@ -1066,27 +1068,38 @@ static PyObject * doGetIPAddress(PyObject * s, PyObject * args) {
return Py_BuildValue("s", ret);
}
#ifdef USESELINUX
-static PyObject * doResetFileContext(PyObject * s, PyObject * args) {
+static PyObject * doMatchPathContext(PyObject * s, PyObject * args) {
char *fn, *buf = NULL;
+ int ret;
+
+ if (!PyArg_ParseTuple(args, "s", &fn))
+ return NULL;
+
+ ret = matchpathcon(fn, 0, &buf);
+ if (ret == 0)
+ return Py_BuildValue("s", buf);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject * doSetFileContext(PyObject * s, PyObject * args) {
+ char *fn, *con;
char * root = NULL;
char path[PATH_MAX];
int ret;
- if (!PyArg_ParseTuple(args, "s|s", &fn, &root))
+ if (!PyArg_ParseTuple(args, "ss|s", &fn, &con, &root))
return NULL;
- ret = matchpathcon(fn, 0, &buf);
- /* fprintf(stderr, "matchpathcon returned %d: set %s to %s\n", ret, fn, buf);*/
- if (ret == 0) {
- if (root != NULL)
- snprintf(path, PATH_MAX, "%s/%s", root, fn);
- else
- snprintf(path, PATH_MAX, "%s", root);
-
- ret = lsetfilecon(path, buf);
- }
+ if (root != NULL)
+ snprintf(path, PATH_MAX, "%s/%s", root, fn);
+ else
+ snprintf(path, PATH_MAX, "%s", root);
+
+ ret = lsetfilecon(path, con);
- return Py_BuildValue("s", buf);
+ return Py_BuildValue("i", ret);
}
#endif
static PyObject * py_getDasdPorts(PyObject * o, PyObject * args) {