mirror of
https://github.com/SELinuxProject/setools
synced 2025-05-16 23:29:16 +00:00
Remove bzip2 dependency.
This was needed for bzipped .pp files, but loading modules is no longer supported.
This commit is contained in:
parent
3ca3ed6b27
commit
a7fe3639ec
@ -18,7 +18,6 @@ To run SETools command line tools, the following packages are required:
|
|||||||
* NetworkX 1.8+
|
* NetworkX 1.8+
|
||||||
* setuptools
|
* setuptools
|
||||||
* libselinux Python bindings (optional but recommended)
|
* libselinux Python bindings (optional but recommended)
|
||||||
* libbz2
|
|
||||||
|
|
||||||
To run SETools graphical tools, the following packages are also required:
|
To run SETools graphical tools, the following packages are also required:
|
||||||
* PyQt5
|
* PyQt5
|
||||||
|
@ -13,9 +13,6 @@
|
|||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
#define HAVE_INTTYPES_H 1
|
#define HAVE_INTTYPES_H 1
|
||||||
|
|
||||||
/* Define to 1 if you have the `bz2' library (-lbz2). */
|
|
||||||
#define HAVE_LIBBZ2 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `sepol' library (-lsepol). */
|
/* Define to 1 if you have the `sepol' library (-lsepol). */
|
||||||
#define HAVE_LIBSEPOL 1
|
#define HAVE_LIBSEPOL 1
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ int qpol_module_create_from_file(const char *path, qpol_module_t ** module)
|
|||||||
int error = 0;
|
int error = 0;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
char *data = NULL;
|
char *data = NULL;
|
||||||
ssize_t size;
|
|
||||||
|
|
||||||
if (module)
|
if (module)
|
||||||
*module = NULL;
|
*module = NULL;
|
||||||
@ -74,22 +73,12 @@ int qpol_module_create_from_file(const char *path, qpol_module_t ** module)
|
|||||||
error = errno;
|
error = errno;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
size = qpol_bunzip(infile, &data);
|
if (!qpol_is_file_mod_pkg(infile)) {
|
||||||
|
error = ENOTSUP;
|
||||||
if (size > 0) {
|
goto err;
|
||||||
if (!qpol_is_data_mod_pkg(data)) {
|
}
|
||||||
error = ENOTSUP;
|
rewind(infile);
|
||||||
goto err;
|
sepol_policy_file_set_fp(spf, infile);
|
||||||
}
|
|
||||||
sepol_policy_file_set_mem(spf, data, size);
|
|
||||||
} else {
|
|
||||||
if (!qpol_is_file_mod_pkg(infile)) {
|
|
||||||
error = ENOTSUP;
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
rewind(infile);
|
|
||||||
sepol_policy_file_set_fp(spf, infile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sepol_module_package_create(&smp)) {
|
if (sepol_module_package_create(&smp)) {
|
||||||
error = EIO;
|
error = EIO;
|
||||||
@ -102,14 +91,7 @@ int qpol_module_create_from_file(const char *path, qpol_module_t ** module)
|
|||||||
}
|
}
|
||||||
free(tmp);
|
free(tmp);
|
||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
if (size > 0) {
|
rewind(infile);
|
||||||
// Re setting the memory location has the effect of rewind
|
|
||||||
// API is not accessible from here to explicitly "rewind" the
|
|
||||||
// in-memory file.
|
|
||||||
sepol_policy_file_set_mem(spf, data, size);
|
|
||||||
} else {
|
|
||||||
rewind(infile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sepol_module_package_read(smp, spf, 0)) {
|
if (sepol_module_package_read(smp, spf, 0)) {
|
||||||
error = EIO;
|
error = EIO;
|
||||||
|
101
libqpol/util.c
101
libqpol/util.c
@ -1,101 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file
|
|
||||||
*
|
|
||||||
* Implementation of utility functions.
|
|
||||||
*
|
|
||||||
* @author Jeremy A. Mowery jmowery@tresys.com
|
|
||||||
* @author Jason Tang jtang@tresys.com
|
|
||||||
*
|
|
||||||
* Copyright (C) 2006-2008 Tresys Technology, LLC
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include "qpol_internal.h"
|
|
||||||
|
|
||||||
#include <qpol/util.h>
|
|
||||||
|
|
||||||
#include <glob.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
const char *libqpol_get_version(void)
|
|
||||||
{
|
|
||||||
return LIBQPOL_VERSION_STRING;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <bzlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define BZ2_MAGICSTR "BZh"
|
|
||||||
#define BZ2_MAGICLEN (sizeof(BZ2_MAGICSTR)-1)
|
|
||||||
|
|
||||||
/* qpol_bunzip() uncompresses a file to '*data', returning the total number of
|
|
||||||
* uncompressed bytes in the file.
|
|
||||||
* Returns -1 if file could not be decompressed.
|
|
||||||
* Originally from libsemanage/src/direct_api.c, with slight mods */
|
|
||||||
ssize_t qpol_bunzip(FILE *f, char **data)
|
|
||||||
{
|
|
||||||
BZFILE* b;
|
|
||||||
size_t nBuf;
|
|
||||||
char buf[1<<18];
|
|
||||||
size_t size = sizeof(buf);
|
|
||||||
int bzerror;
|
|
||||||
size_t total=0;
|
|
||||||
int small=0; // Set to 1 to use less memory decompressing (about 2x slower)
|
|
||||||
|
|
||||||
bzerror = fread(buf, 1, BZ2_MAGICLEN, f);
|
|
||||||
rewind(f);
|
|
||||||
if ((bzerror != BZ2_MAGICLEN) || memcmp(buf, BZ2_MAGICSTR, BZ2_MAGICLEN))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
b = BZ2_bzReadOpen ( &bzerror, f, 0, small, NULL, 0 );
|
|
||||||
if ( bzerror != BZ_OK ) {
|
|
||||||
BZ2_bzReadClose ( &bzerror, b );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *uncompress = realloc(NULL, size);
|
|
||||||
|
|
||||||
while ( bzerror == BZ_OK) {
|
|
||||||
nBuf = BZ2_bzRead ( &bzerror, b, buf, sizeof(buf));
|
|
||||||
if (( bzerror == BZ_OK ) || ( bzerror == BZ_STREAM_END )) {
|
|
||||||
if (total + nBuf > size) {
|
|
||||||
size *= 2;
|
|
||||||
uncompress = realloc(uncompress, size);
|
|
||||||
}
|
|
||||||
memcpy(&uncompress[total], buf, nBuf);
|
|
||||||
total += nBuf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( bzerror != BZ_STREAM_END ) {
|
|
||||||
BZ2_bzReadClose ( &bzerror, b );
|
|
||||||
free(uncompress);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
BZ2_bzReadClose ( &bzerror, b );
|
|
||||||
|
|
||||||
*data = uncompress;
|
|
||||||
return total;
|
|
||||||
}
|
|
||||||
|
|
2
setup.py
2
setup.py
@ -127,12 +127,10 @@ ext_py_mods = [Extension('setools.policyrep._qpol',
|
|||||||
'libqpol/terule_query.c',
|
'libqpol/terule_query.c',
|
||||||
'libqpol/type_query.c',
|
'libqpol/type_query.c',
|
||||||
'libqpol/user_query.c',
|
'libqpol/user_query.c',
|
||||||
'libqpol/util.c',
|
|
||||||
'libqpol/policy_parse.c',
|
'libqpol/policy_parse.c',
|
||||||
'libqpol/policy_scan.c',
|
'libqpol/policy_scan.c',
|
||||||
'libqpol/xen_query.c'],
|
'libqpol/xen_query.c'],
|
||||||
include_dirs=['libqpol', 'libqpol/include', 'include'],
|
include_dirs=['libqpol', 'libqpol/include', 'include'],
|
||||||
libraries=['bz2'],
|
|
||||||
extra_compile_args=['-Werror', '-Wextra',
|
extra_compile_args=['-Werror', '-Wextra',
|
||||||
'-Waggregate-return',
|
'-Waggregate-return',
|
||||||
'-Wcast-align',
|
'-Wcast-align',
|
||||||
|
Loading…
Reference in New Issue
Block a user