Commit Graph

21 Commits

Author SHA1 Message Date
Chris PeBenito
3e2cf79f81 Additional C cleanups. 2018-06-15 20:26:49 -04:00
Chris PeBenito
42001334fe SELinuxPolicy: Revise invalid policy errors. 2018-06-15 20:26:49 -04:00
Chris PeBenito
8b0e93c0d6 Remove source policy loading support and module loading support. 2018-06-15 20:26:49 -04:00
Chris PeBenito
880e8f26d2 libqpol: Revise logging callback.
Process va_args into final message prior to hitting the handler in cython.
2018-06-15 20:26:49 -04:00
Petr Lautrbach
2ac588919d bswap_* macros are defined in byteswap.h
Fixes ImportError on s390x:
/usr/lib64/python3.6/site-packages/setools/policyrep/_qpol.cpython-36m-s390x-linux-gnu.so: undefined symbol: bswap_32
2017-08-10 08:23:47 +02:00
Chris PeBenito
6eaf7a26f5 libqpol: Remove unused syntactic rule functions. 2016-05-20 10:31:18 -04:00
Chris PeBenito
9dc79ce672 qpol: Do not try to infer policy version on source policies.
Version is a compile-time setting.  The policy can also be downgraded
or may not use newer policy version features.

Set source policies to maximum supported policy version supported by
libsepol.
2016-04-26 10:12:03 -04:00
Joshua Brindle
b7b313a086 move linux_types header to libqpol 2016-04-25 12:14:40 -04:00
Joshua Brindle
42fb95a9c9 headers and types not present on Darwin either wrapped or added in linux_types.h 2016-04-22 09:16:27 -04:00
Joshua Brindle
9a89d9b63b remove LIBSELINUX dependency, deprecated functions, and remove symbol map 2016-04-22 09:15:16 -04:00
Richard Haines
dd29dc9c43 setools-V4: libqpol policy V30 updates (xen/xperm statements)
Updated libqpol services to use the latest checkpolicy 2.4 source
files to support Xen and extended permissions (allowxperm etc.).

TODO: Add support for querying the xperm values.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
2016-03-21 10:56:37 -04:00
Chris PeBenito
11fdaa7ad6 Route libqpol meessages through Python logging.
Does not include errors from the lex/yacc.
2015-03-21 16:23:59 -04:00
Chris PeBenito
0b295755de Distinguish policy syntax errors from other OS errors, eg ENOENT.
The policy parser does not set errno, so the libqpol code assumes the
errors from parser code are always invalid syntax, rather than something
else like out of memory.  This may not always be the case, but any other
kind of error is unlikely (and likely catastrophic)
2015-03-06 10:44:32 -05:00
Chris PeBenito
926da1f675 Change libqpol message output.
Changing ERR/WARN/INFO did not catch error output from libsepol.
2015-02-21 17:50:19 -05:00
Nicolas Iooss
edca1ac4c7 Treat literal strings as constant
Literal strings are located in read-only memory and should be "const
char*".  "gcc -Wwrite-strings" warns when using non-const literal
strings with messages like:

    libqpol/policy_parse.y: In function 'yyparse':
    libqpol/policy_parse.y:381:21: warning: passing argument 1 of
    'insert_id' discards 'const' qualifier from pointer target type
         { if (insert_id("T",0)) return -1; }
                     ^

Fix these warnings by using "const char*" instead of "char*" for some
function parameters.

This makes gcc report other warnings about hashtab_search (from
libsepol).  This function incorrectly defines its second parameter as
"char *const key" instead of "const char* key" (this fact is hidden
behind hashtab_key_t typedef).
2014-11-02 13:02:59 -05:00
Nicolas Iooss
2994d1ca1d Cast the 2nd parameter of hashtab_search to hashtab_key_t
"gcc -Wwrite-strings" reported warnings when using hashtab_search (from
libsepol) with string literals as its second parameter is a non-constant
string.

Indeed /usr/include/sepol/policydb/hashtab.h contains:

    typedef char *hashtab_key_t;
    /* ... */
    extern hashtab_datum_t hashtab_search(hashtab_t h, const hashtab_key_t k);

This means the second parameter is "char *const k", not "const char *k".
As a consequence:

* Casting to "const hashtab_key_t" leads to misunderstanding the code.
* "const char*" variables need to be explicitly casted to "char*" or
  "hashtab_key_t" before calling hashtab_search.
* When using "gcc -Wwrite-strings", literal strings need to be casted to
  "char*" or "hashtab_key_t" before calling hashtab_search.
* "gcc -Wcast-qual" reports an awful amount of warnings due to
  const-to-nonconst pointer casts.

Add missing casts to hashtab_key_t to help finding real bugs in
setools/libqpol with gcc flags.
2014-11-02 13:02:58 -05:00
Nicolas Iooss
679accae37 Add missing explicit cast in libqpol/policy.c
libqpol/policy.c:650:36: warning: passing argument 2 of
    'qpol_type_get_isattr' from incompatible pointer type
       if (qpol_type_get_isattr(policy, attr, &isattr)) {
                                        ^
    libqpol/include/qpol/type_query.h:96:13: note: expected 'const
    struct qpol_type_t *' but argument is of type 'struct type_datum_t
    *'
      extern int qpol_type_get_isattr(const qpol_policy_t * policy, const qpol_type_t * datum, unsigned char *isattr);
                 ^
2014-11-02 13:02:57 -05:00
Nicolas Iooss
1a02a86836 Include sys/stat.h in libqpol/policy.c for fstat
The declaration of fstat was missing.  "gcc -Wall" reported:

  libqpol/policy.c: In function 'qpol_policy_open_from_file_opt':
  libqpol/policy.c:1060:3: warning: implicit declaration of function
  'fstat' [-Wimplicit-function-declaration]
     if (fstat(fd, &sb) < 0) {
     ^
2014-11-02 13:02:11 -05:00
Nicolas Iooss
ee7064a711 Add printf format attribute to relevant functions in libqpol
"gcc -Wformat" needs printing functions to be marked with a format
attribute to be able to work.  Add this attribute to some functions in
libqpol, found with "gcc -Werror=missing-format-attribute"

gcc documentation about format attribute:
https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
2014-11-02 13:02:11 -05:00
Nicolas Iooss
7aace4d52a Remove unused variables in libqpol 2014-11-02 13:02:10 -05:00
Chris PeBenito
8363f8edf7 Import libqpol from setools3.
Break setools3 dependence. Also fix SWIG wrapper to work with SWIG 2.x.
2014-10-24 21:00:24 -04:00