Commit Graph

61 Commits

Author SHA1 Message Date
Sven Vermeulen 744482a3e6 Update segenxml to include support for templated booleans and tunables
The segenxml tool is used to generate documentation regarding the policy
definitions. Its output is an XML file that contains the in-line
comments associated with boolean generation as well as interface
definitions.

With booleans also generated inside templates, this information was
(until now) ignored. Templates such as apache's apache_content_template
which created new booleans were not properly documented, as the
in-template comments were ignored.

In this patch, we will go over module code first and seek template
calls. When a template call is matched, the module code is updated
(expanded) with the template content (while substituting the arguments
to get a proper code listing). Only after all templates have been
expanded we seek the necessary boolean definitions.

Changes since v2:
- Fix BOOLEAN statements to match backtick (`) and tick (') usages as
  well
- Fix match for arguments to also include multiple entries ( { ... } )

Changes since v1:
- Also apply the regexp on BOOLEAN to allow generating templated
  boolean/tunable documentation

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
2018-06-10 13:23:01 -04:00
Sven Vermeulen 9d8bb4eb93 Add gentemplates.sh to extract template content
Some of the templates in the reference policy generate new booleans and
tunables, based on the $1, $2, ... parameters passed on. To allow
segenxml, which generates the necessary documentation on booleans, to
keep track of template-generated booleans as well, we need to allow it
to substitute template calls with the actual template content.

The gentemplates.sh script is a helper script that will extract template
code and store it as files (one file per template). These files are then
later on used by the segenxml tool.

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
2018-06-10 13:23:01 -04:00
Chris PeBenito ef6e79a082 Switch all remaining Python references to the Python 3 interpreter. 2018-05-31 17:41:59 -04:00
William Roberts 65620e0f94 fc_sort: use calloc instead of malloc
Rather than using malloc to allocated nodes and setting all the fields,
just use calloc.

Signed-off-by: William Roberts <william.c.roberts@intel.com>
2017-10-18 19:26:36 -07:00
Adam Duskett 6c9cc47e6c fix regex escape sequence error.
python3.6 will error out with the message "invalid escape sequence"
in genhomedircon.py.  This patch fixes these errors by turning the string
in the into a raw string.
2017-10-10 18:00:30 -04:00
Guido Trentalancia 5490639ac9 fc_sort: memory leakages
Avoid memory leakages in the fc_sort executable (now passes
all valgrind AND Clang static analyzer tests fine).

Some NULL pointer checks with or without associated error
reporting.

Some white space and comment formatting fixes.

Optimization: avoid unnecessary operations (unnecessary
memory allocation/deallocation and list copying).

Reverts 7821eb6f37 as such
trick is no longer needed, given that all memory leakages
have now been fixed.

This is the sixth version of this patch. Please do not use
the first version as it introduces a serious bug.

For reference, the original issue reported by the Cland
static analyzer is as follows:

support/fc_sort.c:494:6: warning: Potential leak of memory
pointed to by 'head'
            malloc(sizeof(file_context_bucket_t));

Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
Acked-by: William Roberts <william.c.roberts@intel.com>
2017-10-04 19:29:47 -04:00
Luis A. Lozano cd20f0ba9f Avoid memory leak warning.
Using the LLVM static analyzer, we get a warning about leaked memory
pointed by bcurrent. Since the warning happens within "main" and we
don't care about deallocating the memory and just call "exit" which
gets rid of the warning.
2017-09-05 16:20:44 -07:00
David Sugar f8a4b8e28b Strip spaces from NAME
Strip trailing space(s) from 'NAME' being read from /etc/selinux/config as a trailing space in that name will cause a weird error during the make process for modules built out of tree.  This is seen on current RedHat machines which have space in the 'SELINUXTYPE' variable.
2017-08-31 21:19:32 -04:00
Guido Trentalancia 89b53fafa9 fc_sort: avoid compiler warning/error
Fix a "-Werror=implicit-fallthrough" compiler warning/error on
the switch statement.

This third version (v3) fixes a bug introduced in the first
version and improves the style over the second version.

Signed-off-by: Guido Trentalancia <guido at trentalancia.com>
2017-06-07 19:13:28 -04:00
Daniel Jurgens 25a5b24274 refpolicy: Infiniband pkeys and endports
Every Infiniband network will have a default pkey, so that is labeled.
The rest of the pkey configuration is network specific. The policy allows
access to the default and unlabeled pkeys for sysadm and staff users.
kernel_t is allowed access to all pkeys, which it needs to process and
route management datagrams.

Endports are all unlabeled by default, sysadm users are allowed to
manage the subnet on unlabeled endports. kernel_t is allowed to manage
the subnet on all ibendports, which is required for configuring the HCA.

This patch requires selinux series: "SELinux user space support for
Infiniband RDMA", due to the new ipkeycon labeling mechanism.

Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
2017-05-24 19:23:18 -04:00
Nicolas Iooss 82e7e4e638
Use raw strings in regular expressions
Python 3.6 complains about the strings which are used as regular
expression in the support scripts:

    File "support/segenxml.py", line 37
        INTERFACE = re.compile("^\s*(interface|template)\(`(\w*)'")
                              ^
    SyntaxError: invalid escape sequence \s
2017-04-08 12:29:07 +02:00
cgzones 33fd9ae139 fix travis and genhomedircon 2017-03-18 18:38:20 +01:00
cgzones 3b3e6f75d3 travis: run make xml, html and install(-.*)? targets 2017-03-18 15:35:15 +01:00
cgzones 82b0a6d4d5 convert build scripts to python3 2017-03-15 02:09:20 +01:00
cgzones d3462090d5 m4 errprint: add __program__ info 2017-03-08 17:16:27 +01:00
Chris PeBenito 4c16ca2d66 Only display the WERROR notice if there actually are errors. 2017-02-18 13:59:33 -05:00
Chris PeBenito dd03d589e2 Implement WERROR build option to treat warnings as errors.
Add this to all Travis-CI builds.
2017-02-18 10:20:20 -05:00
cgzones d8cb498284 remove trailing whitespaces 2016-12-06 13:45:13 +01:00
Chris PeBenito 2035047958 Merge pull request #43 from williamcroberts/google-patch
fc_sort: cleanup warnings caught by clang tidy / static analyzer.
2016-10-19 18:37:25 -04:00
Rahul Chaudhry 0412d1ace4 fc_sort: cleanup warnings caught by clang tidy / static analyzer.
Value stored to 'i' is never read.
Variable 'j' is never used.
2016-10-19 13:29:20 -07:00
Sean Placchetti 71f96eb3c4 Update specfile
Minor tweaks to specfile
2016-10-17 07:37:51 -04:00
Sean Placchetti 502463589e Update to refpolicy spec file
Missing forwardslash
2016-10-11 15:35:07 -04:00
William Roberts cb4491c19e fc_sort: strip whitespace errors
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-01-07 08:41:32 -08:00
Chris PeBenito bf0cfe940a Add systemd build option. 2015-10-20 15:01:23 -04:00
Nicolas Iooss ad2d828797 Create tmp directory when compiling a .mod.fc file in a modular way
When compiling modules using support/Makefile.devel (which is installed
in /usr/share/selinux/*/include/Makefile) with "make -j9", the build
fails because tmp/ does not exist.

Add the missing command to create tmp/ when running tmp/%.mod.fc target.

Gentoo bug: https://bugs.gentoo.org/show_bug.cgi?id=530178
2014-12-02 09:26:54 -05:00
Chris PeBenito 5b2a2998b8 Need the __future__ import for python2 if using print(). 2014-05-13 09:39:00 -04:00
Nicolas Iooss 1c8c76c927 Make support/policyvers.py compatible with Python 3
Add parenthesis around print statement, like in other Python scripts.
2014-05-13 08:18:46 -04:00
Nicolas Iooss aa3fa6d2fd fc_sort: make outfile argument optional
When working on fc_sort to try to understand why using /usr/s?bin/... file
contexts has been reported not to work properly [1], I found it frustrating not
to be able to do "tmp/fc_sort my_filecontexts.fc" and see the result printed on
the screen.  This patch implements this behavior by making optional the second
argument of fc_sort.

[1] commit 36e2216f8 of contrib repository,
http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-refpolicy.git;a=commit;h=36e2216f82192660d063012e69281f27ba20864b
2014-04-04 15:50:57 -04:00
Nicolas Iooss 572c617c91 fc_sort: initialize allocated memory to fix execution on an empty file
When running fc_sort on an empty context file, this program uses uninitialized
pointers when accessing to the elements of a list.  On my system, it goes in a
very long loop (maybe infinite) because uninitialized fields in malloc'ed
structures happen to contain valid pointers in the heap.

This patch fixes this bug by initializing ->next and ->data fields before they
may be read.
2014-04-04 15:47:36 -04:00
Nicolas Iooss eedc944a54 fc_sort: fix typos in comments 2014-04-04 15:47:36 -04:00
Chris PeBenito 0656a81019 Fix support/policyvers.py not to error if building policy on a SELinux-disabled system. 2013-09-23 14:26:32 -04:00
Chris PeBenito 3bf7fd504c Use python libselinux bindings to determine policy version.
This eliminates the hardcoded /selinux in Rules.monolithic, which
broke when the filesystem mount was moved to /sys/fs/selinux.
2013-06-06 09:27:40 -04:00
Chris PeBenito c87f945a5a Fix fc_sort.c warning uncovered by recent gcc
output_name in main was set to argv[2] but then argv[2] rather than
output_name was used later in the function.
2013-02-26 09:16:49 -05:00
Sven Vermeulen afeb8c4cb9 Refactoring code to support python3
This patch includes the necessary refactoring to support python 3.

Changes since v2
- Do not include contrib submodule (no relevant changes there)
- Update in pyplate to fix a failure with str/unicode in doc generation

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
2012-06-26 09:08:48 -04:00
Harry Ciao 46acfdd455 Move role declarations to the top of base.conf
system_r is required by the policy_module macro, which however will
be expanded as empty if the module is built into base.pp. system_r
is defined in the kernel.te, its definition should be moved to the
top of base.conf so that other modules copied earlier into base.conf
than kernel.te could reference system_r in their unconditional block
properly.

Signed-off-by: Harry Ciao <qingtao.cao@windriver.com>
2012-02-29 12:08:22 -05:00
Chris PeBenito d1af485661 Remove rolemap and per-role template support.
This support was deprecated and unused in Reference Policy November 5 2008.
2011-10-14 08:52:21 -04:00
Chris PeBenito 2dd113f11c Move attribute_role decls to top of policy.conf/base.conf. 2011-09-21 08:26:56 -04:00
KaiGai Kohei b98aba85d9 Add sepgsql_contexts into appconfig-*
The attached patch adds sepgsql_contexts file into appconfig-*
directory. This configuration is used to initial labeling on
installation time for each database objects.
We can easily look up an appropriate label using selabel_loopup(3)
APIs. The 'sepgsql_contexts' is default for SE-PostgreSQL.

Thanks,
--
KaiGai Kohei <kaigai@ak.jp.nec.com>
2011-01-04 13:27:40 -05:00
Chris PeBenito 0001e26f4f Increased default number of categories to 1024, from Russell Coker. 2010-06-28 09:04:24 -04:00
Justin P. Mattock d5932a6ac4 Fix a typo in support/genhomedircon.
Fix a typo in support/genhomedircon.

Signed-off-by: Justin P. Mattock <justinmattock@gmail.com>
Signed-off-by: Chris PeBenito <cpebenito@tresys.com>
2010-05-03 11:45:09 -04:00
Chris PeBenito 90286f4292 Fix infrastructure to expand macros in initrc_context when installing.
The initrc_context file uses the mls_systemhigh macro and needs to be properly
expanded based on the build.conf settings.  Add makefile support to do this.
2009-08-10 14:00:34 -04:00
Chris PeBenito 296273a719 trunk: merge UBAC. 2008-11-05 16:10:46 +00:00
Chris PeBenito c5cfd2d405 trunk: Add unused interface/template parameter metadata in XML. 2008-06-24 14:23:40 +00:00
Chris PeBenito 2c12b471ad trunk: add core xselinux support. 2008-04-01 20:23:23 +00:00
Chris PeBenito e276d50e21 trunk: Add iferror.m4 rather generate it out of the Makefiles. 2008-03-06 20:17:46 +00:00
Chris PeBenito 350b6ab767 trunk: merge strict and targeted policies. merge shlib_t into lib_t. 2007-10-02 16:04:50 +00:00
Chris PeBenito 94636e477a trunk: update sources rpm spec file. 2007-09-28 15:14:18 +00:00
Chris PeBenito 96fc0a45be trunk: Fix XML building for external reference builds and headers builds. 2007-09-21 15:06:58 +00:00
Chris PeBenito f6ddd6b9b7 bools in modules fix to require the boolean in optionals that are part of the base module, and move bool declarations in the base module/monolithic 2007-03-30 12:43:15 +00:00
Chris PeBenito dde00d4e70 add refresh target to devel makefile which tries to reload all of the modules currently in the store. 2007-03-29 12:08:00 +00:00