Commit Graph

6 Commits

Author SHA1 Message Date
Panu Matilainen 307872f71b Fix POPT_ARG_STRING memleaks in librpmbuild
popt always returned malloc'ed memory for POPT_ARG_STRING items, but
for whatever historical reason rpm systematically passed const char *
pointers as targets, making them look non-freeable. Besides changing
just the types and adding free()'s, const-correctness requires extra
tweaks as there's mixed use from string literals and poptGetArg() which
does return const pointers.
2020-02-03 17:09:04 +01:00
Panu Matilainen bc0ad090ed Port parsePolicies() to use parseLines(), no functional changes 2019-04-17 13:18:50 +02:00
Panu Matilainen 8f3c798b12 Make package exists/does not exist error more informative
Rearrange the message to "linenum: line: message" which is a more
logical order of things (I think), and in particular, include the
actual actual package name in the message. In order to do that,
consolidate the error logging inside lookupPackage() where we
now get a slightly hysterical logic around the error messages but what
the hey, its not like this is an exported API.
2016-11-11 14:26:03 +02:00
Panu Matilainen 7d3cebfb92 Eliminate dead NULL-assignments on parsePolicies() exit 2011-05-27 16:21:12 +03:00
Panu Matilainen a32705e737 Use ARGV_t for package fileFile, fileList and policyList
- Similar to commit 1e3db59b56,
  all these end up being passed to argvSplit() to process them line
  by line in the end, collect them in the argv to start with saving
  a whole lotta huffing and puffing in the process
2010-10-28 10:24:20 +03:00
Steve Lawrence 383e275648 Add new %sepolicy section to the spec file format
The %sepolicy section is used to describe SELinux policy to be included
in a package. It's syntax is similar to other sections (%files, %pre,
%post, etc.) in that you can provide a string and -n after the
declaration to specify policy should be added to a subpackage.

For example:

%sepolicy
 # policy in this section will be added to the main package

%sepolicy foo
 # policy in this section will be added to the '<mainpackage>-foo' subpackage

%sepolicy -n bar
 # policy in this section will be added to the 'bar' subpackage

The %sepolicy section contains zero or more %semodule directives, with the
following format:

%semodule [OPTIONS] path/to/module.pp

The available options are:

-b, --base
	The module is a base module

-n, --name=NAME
	The name of the module. If not given, assumes the name is the basename of
	the module file with file extensions removed.

-t, --types=TYPES
	One or more comma-separated strings specifying which policy types the
	module can work with. To explicitly state that a module can work with any
	policy type, "default" can be specified as the value. If not specified,
	assumes the module can work with any policy type, and assigns the types as
	"default".

Below is an example of this new format:

  %sepolicy
  %semodule -n foo -t mls policy/foo.pp
  %semodule -n bar -t strict,targeted,mls -b policy/bar.pp

This also adds new header tags to store the new information:
 RPMTAG_POLICYNAMES        (string array)
 RPMTAG_POLICYTYPES        (string array)
 RPMTAG_POLICYTYPESINDEXES (uint32 array)
 RPMTAG_POLICYFLAGS        (uint32 array)

The index of NAMES and FLAGS maps directly to the index of RPMTAG_POLICIES.
However, because a single policy can have multiple types, the mapping for
TYPES is not direct. For this, the index maps to TYPESINDEXES, which
contains the index of the policy that the type maps to. This is similar to
how DIRINDEXES is used to map DIRNAMES and BASENAMES. As an example, the
previous %sepolicy section would have the following header tags:

RPMTAG_POLICIES:
 0: <foo.pp data, base64 encoded>
 1: <bar.pp data, base64 encoded>

RPMTAG_POLICYNAMES:
 0: foo
 1: bar

RPMTAG_POLICYFLAGS:
 0: 0
 1: 1	# assumes flag 1 == BASE

RPMTAG_POILCYTYPES:        RPMTAG_POLICYTYPESINDEXES:
 0: mls                     0: 0
 1: strict                  1: 1
 2: targeted                2: 1
 3: mls                     3: 1
2010-09-01 09:04:27 +03:00