mirror of
https://github.com/SELinuxProject/selinux
synced 2025-01-11 16:09:47 +00:00
sepolicy: update setup.py to remove C module
Signed-off-by: Jason Zaman <jason@perfinion.com>
This commit is contained in:
parent
97d5f6a24f
commit
7e04f545f2
@ -61,8 +61,6 @@ POTFILES = \
|
||||
../gui/usersPage.py \
|
||||
../secon/secon.c \
|
||||
booleans.py \
|
||||
../sepolicy/info.c \
|
||||
../sepolicy/search.c \
|
||||
../sepolicy/sepolicy.py \
|
||||
../sepolicy/sepolicy/communicate.py \
|
||||
../sepolicy/sepolicy/__init__.py \
|
||||
|
@ -18,7 +18,7 @@ BASHCOMPLETIONS=sepolicy-bash-completion.sh
|
||||
|
||||
all: python-build
|
||||
|
||||
python-build: info.c search.c common.h policy.h policy.c
|
||||
python-build:
|
||||
$(PYTHON) setup.py build
|
||||
|
||||
clean:
|
||||
|
@ -1,69 +0,0 @@
|
||||
#include "Python.h"
|
||||
|
||||
#ifdef UNUSED
|
||||
#elif defined(__GNUC__)
|
||||
# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
|
||||
#elif defined(__LCLINT__)
|
||||
# define UNUSED(x) /*@unused@*/ x
|
||||
#else
|
||||
# define UNUSED(x) x
|
||||
#endif
|
||||
|
||||
#define py_decref(x) { if (x) Py_DECREF(x); }
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
# define PyIntObject PyLongObject
|
||||
# define PyInt_Type PyLong_Type
|
||||
# define PyInt_Check(op) PyLong_Check(op)
|
||||
# define PyInt_CheckExact(op) PyLong_CheckExact(op)
|
||||
# define PyInt_FromString PyLong_FromString
|
||||
# define PyInt_FromUnicode PyLong_FromUnicode
|
||||
# define PyInt_FromLong PyLong_FromLong
|
||||
# define PyInt_FromSize_t PyLong_FromSize_t
|
||||
# define PyInt_FromSsize_t PyLong_FromSsize_t
|
||||
# define PyInt_AsLong PyLong_AsLong
|
||||
# define PyInt_AS_LONG PyLong_AS_LONG
|
||||
# define PyInt_AsSsize_t PyLong_AsSsize_t
|
||||
# define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
|
||||
# define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
|
||||
# define PyString_FromString PyUnicode_FromString
|
||||
# define PyString_AsString PyUnicode_AsUTF8
|
||||
#endif
|
||||
|
||||
static int py_append_string(PyObject *list, const char* value)
|
||||
{
|
||||
int rt;
|
||||
PyObject *obj = PyString_FromString(value);
|
||||
if (!obj) return -1;
|
||||
rt = PyList_Append(list, obj);
|
||||
Py_DECREF(obj);
|
||||
return rt;
|
||||
}
|
||||
|
||||
static int py_append_obj(PyObject *list, PyObject *obj)
|
||||
{
|
||||
int rt;
|
||||
if (!obj) return -1;
|
||||
rt = PyList_Append(list, obj);
|
||||
return rt;
|
||||
}
|
||||
|
||||
static int py_insert_obj(PyObject *dict, const char *name, PyObject *obj)
|
||||
{
|
||||
int rt;
|
||||
if (!obj) return -1;
|
||||
rt = PyDict_SetItemString(dict, name, obj);
|
||||
return rt;
|
||||
}
|
||||
|
||||
static int py_insert_string(PyObject *dict, const char *name, const char* value)
|
||||
{
|
||||
int rt;
|
||||
PyObject *obj = PyString_FromString(value);
|
||||
if (!obj) return -1;
|
||||
rt = PyDict_SetItemString(dict, name, obj);
|
||||
Py_DECREF(obj);
|
||||
return rt;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,116 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
* Python bindings to search SELinux Policy rules.
|
||||
*
|
||||
* @author Dan Walsh <dwalsh@redhat.com>
|
||||
*
|
||||
* Copyright (C) 2012 Red Hat, INC
|
||||
*
|
||||
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#ifdef UNUSED
|
||||
#elif defined(__GNUC__)
|
||||
# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
|
||||
#elif defined(__LCLINT__)
|
||||
# define UNUSED(x) /*@unused@*/ x
|
||||
#else
|
||||
# define UNUSED(x) x
|
||||
#endif
|
||||
|
||||
#include "policy.h"
|
||||
apol_policy_t *global_policy = NULL;
|
||||
|
||||
/* other */
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define COPYRIGHT_INFO "Copyright (C) 2003-2007 Tresys Technology, LLC"
|
||||
|
||||
PyObject *wrap_policy(PyObject *UNUSED(self), PyObject *args){
|
||||
const char *policy_file;
|
||||
apol_vector_t *mod_paths = NULL;
|
||||
apol_policy_path_type_e path_type = APOL_POLICY_PATH_TYPE_MONOLITHIC;
|
||||
apol_policy_path_t *pol_path = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "z", &policy_file))
|
||||
return NULL;
|
||||
|
||||
if (global_policy)
|
||||
apol_policy_destroy(&global_policy);
|
||||
|
||||
int policy_load_options = 0;
|
||||
|
||||
pol_path = apol_policy_path_create(path_type, policy_file, mod_paths);
|
||||
if (!pol_path) {
|
||||
apol_vector_destroy(&mod_paths);
|
||||
PyErr_SetString(PyExc_RuntimeError,strerror(ENOMEM));
|
||||
return NULL;
|
||||
}
|
||||
apol_vector_destroy(&mod_paths);
|
||||
|
||||
global_policy = apol_policy_create_from_policy_path(pol_path, policy_load_options, NULL, NULL);
|
||||
apol_policy_path_destroy(&pol_path);
|
||||
if (!global_policy) {
|
||||
PyErr_SetString(PyExc_RuntimeError,strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyMethodDef methods[] = {
|
||||
{"policy", (PyCFunction) wrap_policy, METH_VARARGS,
|
||||
"Initialize SELinux policy for use with search and info"},
|
||||
{"info", (PyCFunction) wrap_info, METH_VARARGS,
|
||||
"Return SELinux policy info about types, attributes, roles, users"},
|
||||
{"search", (PyCFunction) wrap_search, METH_VARARGS,
|
||||
"Search SELinux Policy for allow, neverallow, auditallow, dontaudit and transition records"},
|
||||
{NULL, NULL, 0, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
|
||||
static struct PyModuleDef module_def =
|
||||
{
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"_policy", /* name of module */
|
||||
"", /* module documentation, may be NULL */
|
||||
-1, /* size of per-interpreter state of the module, or -1 if the module keeps state in global variables. */
|
||||
(PyMethodDef*)&methods,
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC PyInit__policy(void)
|
||||
{
|
||||
PyObject *m;
|
||||
m = PyModule_Create(&module_def);
|
||||
init_info(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
#else // python 2
|
||||
|
||||
void init_policy(void) {
|
||||
PyObject *m;
|
||||
m = Py_InitModule("_policy", methods);
|
||||
init_info(m);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,7 +0,0 @@
|
||||
#include <apol/policy.h>
|
||||
extern apol_policy_t *global_policy;
|
||||
extern PyObject *wrap_info(PyObject *self, PyObject *args);
|
||||
extern void init_info (PyObject *m);
|
||||
extern PyObject *wrap_search(PyObject *self, PyObject *args);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,6 @@
|
||||
# Author: Ryan Hallisey <rhallise@redhat.com>
|
||||
# Author: Jason Zaman <perfinion@gentoo.org>
|
||||
|
||||
from . import _policy
|
||||
import selinux
|
||||
import setools
|
||||
import glob
|
||||
@ -149,7 +148,6 @@ def policy(policy_file):
|
||||
global _pol
|
||||
|
||||
try:
|
||||
_policy.policy(policy_file)
|
||||
_pol = setools.SELinuxPolicy(policy_file)
|
||||
except:
|
||||
raise ValueError(_("Failed to read %s policy file") % policy_file)
|
||||
|
@ -2,11 +2,21 @@
|
||||
|
||||
# Author: Thomas Liu <tliu@redhat.com>
|
||||
# Author: Dan Walsh <dwalsh@redhat.com>
|
||||
import os
|
||||
from distutils.core import setup, Extension
|
||||
policy = Extension("sepolicy._policy",
|
||||
libraries=["apol", "qpol"],
|
||||
sources=["policy.c", "info.c", "search.c"]
|
||||
)
|
||||
from distutils.core import setup
|
||||
|
||||
setup(name="sepolicy", version="1.1", description="Python SELinux Policy Analyses bindings", author="Daniel Walsh", author_email="dwalsh@redhat.com", ext_modules=[policy], packages=["sepolicy", "sepolicy.templates", "sepolicy.help"], package_data={'sepolicy': ['*.glade'], 'sepolicy.help': ['*.txt', '*.png']})
|
||||
setup(
|
||||
name="sepolicy",
|
||||
version="1.1",
|
||||
description="Python SELinux Policy Analyses bindings",
|
||||
author="Daniel Walsh",
|
||||
author_email="dwalsh@redhat.com",
|
||||
packages=[
|
||||
"sepolicy",
|
||||
"sepolicy.templates",
|
||||
"sepolicy.help"
|
||||
],
|
||||
package_data={
|
||||
'sepolicy': ['*.glade'],
|
||||
'sepolicy.help': ['*.txt', '*.png']
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user