Commit graph

115 commits

Author SHA1 Message Date
Stephen Smalley
a08010023b Update ChangeLogs and bump VERSIONs to an intermediate value.
2.1.99 is just a placeholder to distinguish it from the prior release.
2.2 will be the released version.  Switching to 2-component versions.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-10-25 15:14:23 -04:00
Stephen Smalley
cfada081f4 libsemanage gained a dependency on libaudit.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-10-24 15:10:57 -04:00
Dan Walsh
6f84cfd00c If you are pushing data onto the list that already exists, then return success.
Do not push the data in a second time.
2013-10-24 13:58:38 -04:00
Dan Walsh
56d9d20a64 Pull auditing into libsemanage.
In the past we wrote audit into the semanage tool chain.  But if a tool like useradd
called dirreclty into libsemanage we did not get auditing.  Now useradd calls directly,
so we need this patch.

Another fix in this patch is to default the login mappings MLS to the selected SELinux User.
If a caller just specified the name staff_u, then the code will look up the range of staff_u
and apply it to the mapping.
2013-10-24 13:58:38 -04:00
Dan Walsh
b14294c01f Remove the policy.kern after policy is build and replace with symbolic link.
We want to shink the space required by selinux-policy for small cloud images.
This file has no purpose after policy is built.
2013-10-24 13:58:38 -04:00
Dan Walsh
1fbb15eb11 Add Laurent Bigonville fix to look at MAX_UID as well as MIN_UID in genhomedircon 2013-10-24 13:58:38 -04:00
Dan Walsh
2540b20096 Laurent Bigonville patch to fix various minor manpage issues and correct section numbering. 2013-10-24 13:58:37 -04:00
Eric Paris
3f52a123af libsemanage: semanage_store: fix segfault introduced to fix memory leak
In the patch to fix a minor memory leak, I introduced a garuanteed
segfault.  The point to the stack variable will never be NULL, whereas
the value on the stack will be.

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:43:22 -05:00
Eric Paris
e9410c9b06 VERSION BUMP FOR UPSTREAM PUSH 2013-02-05 20:22:02 -05:00
Eric Paris
295abb370b libsemanage: semanage_store: do not leak memory in semanage_exec_prog
If vork() failed we would leak the arguments created in split_args().
Reorder the function so it will hopefully be easy to read and will not
leak memory.

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:19:05 -05:00
Eric Paris
d1c606ba46 libsemanage: genhomedircon: remove useless conditional in get_home_dirs
We have minuid_set = 0 at the top of the function and then do a test
like:

if (!minuid_set || something)

But since minuid_set is always 0, we always call this code.  Get rid of
the pointless conditional.

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:19:05 -05:00
Eric Paris
e1400f0404 libsemanage: genhomedircon: double free in get_home_dirs
Right before the call to semanage_list_sort() we do some cleanup.
Including endpwent(); free(rbuf); semanage_list_destroy(&shells);  If
the call to the list sort fails we will go to fail: and will do those
cleanups a second time.  Whoops.  Do the list sort before the generic
cleanups so the failure code isn't run after the default cleanup.

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:19:04 -05:00
Eric Paris
d0c7f6ea4f libsemanage: fcontext_record: do not leak on error in semanage_fcontext_key_create
If the strdup failed, we would return without freeing tmp_key.  This is
obviously a memory leak.  So free that if we are finished with it.

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:19:04 -05:00
Eric Paris
7d83d86ba1 libsemanage: genhomedircon: do not leak on failure in write_gen_home_dir_context
We generate a list of users, but we do not free that list on error.
Just keep popping and freeing them on error.

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:19:04 -05:00
Eric Paris
06f2a7c3a9 libsemanage: semanage_store: do not leak fd
We use creat to create the lock file needed later.  But we never close
that fd, so it just sits around until the program exits.  After we
create the file we don't need to hold onto the fd.  close it.

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:19:04 -05:00
Eric Paris
5812ec2fbb libsemanage: genhomedircon: do not leak shells list
If get_home_dirs() was called without usepasswd we would generate the
entire shell list, but would never use that list.  We would then not
free that list when we returned the homedir_list.  Instead, do not
create the list of shells until after we know it will be used.

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:19:04 -05:00
Eric Paris
78d618422b libsemanage: semanage_store: do not leak on strdup failure
Inside split_args we do a = realloc(b) and strdup.  If the realloc
succeeds and then the strdup fails, we return NULL to the caller.  The
caller will then jump to an error code which will do a free(b).  This is
fine if the realloc failed, but is a big problem if realloc worked.  If
it worked b is now meaningless and a needs to be freed.

I change the function interface to return an error and to update "b"
from the caller.

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:19:03 -05:00
Eric Paris
d16ebaace1 libsemanage: semanage_store: rewrite for readability
We did a bunch of:

	if ((blah = function(a0, a1, a2)) == NULL) {
		goto err;
	} else {
		something = blah;
	}

Which takes 5 lines and is a pain to read.  Instead:

	blah = function(a0, a1, a2);
	if (blah == NULL)
		goto err;
	something = blah;

Which takes 4 lines and is easier to read!

Winning!

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:19:03 -05:00
Eric Paris
2276a2fa51 libsemanage: fixes from coverity
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:45 -05:00
Eric Paris
6064f9672c libsemange: redo genhomedircon minuid
Just a little less code.  No real change.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:44 -05:00
Dan Walsh
c9b09be424 libsemanage: Cleanup/fix enable/disable/remove module.
If you specified a portion of the module name the code would disable the module rather
then giving you an error.  For example.

semodule -d http

Would disable the httpd module.
As a matter of fact

semodule -r h

Would disable the first module file name that began with h.

This patch gets the real file name out of the modules and compares it to the name specified.
It also consolodates a bunch of duplicated code, and fixes a return code bug.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:42 -05:00
rhatdan
28baa721e0 libsemanage: Add sefcontext_compile to compile regex everytime policy is rebuilt
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-01 12:08:58 -05:00
Eric Paris
8638197342 Version bumps for upstream push 2012-09-13 10:33:58 -04:00
Xin Ouyang
18649484ee libsemanage: Fix segfault for building standard policies.
If you are building "standard" policies(not MCS/MLS), libsemanage
will crash, which caused by strdup() to "level" NULL pointers.
For example, semodule -s refpolicy -b base.pp -i a.pp

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 21:15:53 -04:00
Eric Paris
b0b22829eb libsemanage: do boolean name substitution
So people can use -P and it will work.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 13:17:30 -04:00
Eric Paris
1024ea34c6 libselinux: libsemanage: remove PYTHONLIBDIR and ruby equivalent
We generate pkg-config --libs and use that to build the libselinux
python so file.  We do not use it to build the libsemanage versions.  We
also never use the ruby equivalent.  So stop calling pkg-config
uselessly.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 12:16:19 -04:00
Eric Paris
b2523dc167 libselinux: libsemanage: do not set soname needlessly
We explicitly set the soname of the python and ruby files.  We don't
need this.  We are using the -o name as the soname, so just let the
toolchain do its thing.  It just makes the Makefile nicer to read.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-09-12 12:16:18 -04:00
Eric Paris
f05a71b92d Version bumps for upstream push 2012-06-28 14:02:29 -04:00
Sven Vermeulen
c4f415c244 libsemanage: use after free in python bindings
In python 3.2 we hit a problem where the fconext was garbage.  We didn't
see this in python 2.7.  The reason is because python3.2 would free and
reuse the memory and python 2.7 just happened to leave it alone.
Instead of using memory that python might use for something else, use
strdup() to get a local copy which we can free when we are finished with
it.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-06-28 13:29:23 -04:00
Dan Walsh
4120df1c6e libsemanage: Use default semanage.conf as a fallback
If the private semanage.conf file is unreadable for some reason (usually
ENOENT) fallback to the default file.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-06-28 13:29:23 -04:00
Eric Paris
fade75f1e2 libsemanage: semanage_store: fix snprintf length argument by using asprintf
We calculated a length, allocated a space for the string, then used
snprintf to fill the array giving it a different length.  Rather than
doing all that math ourselves, just use asprintf and let libraries get
it right.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-06-28 13:29:15 -04:00
Eric Paris
a6c9140cbb libsemanage: ignore 80 column limit for readability
80 columns just suck.  Ignore it when we are only a little bit over.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-06-28 11:21:16 -04:00
Eric Paris
824df4b60b libselinux: additional makefile support for rubywrap
SELinux ruby bindings didn't build from the top level
the swig generated .c file wasn't gitignored
use pkg-config for ruby info like we do for python

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-06-28 11:21:16 -04:00
Eric Paris
5d19b70723 libselinux: libsemanage: remove build warning when build swig c files
swig creates C files with warnings.  Turn off the warnings so the build
is clean.  We can't help the code it produces anyway...

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-06-28 11:21:16 -04:00
Eric Paris
7a86fe1a3d bump version and changelog for upstream push 2012-03-28 15:44:05 -04:00
Russell Coker
38e93bad1f libsemanage: fallback-user-level
Having magic numbers in the code is a bad idea, using a macro is better.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-03-28 14:52:14 -04:00
Laurent Bigonville
e55a295b1d libsemanage: Allow to build for several ruby version
This allow to build the ruby module for both ruby 1.8 and 1.9.1 (the
way it's done for the python module)

Signed-off-by: Laurent Bigonville <bigon@debian.org>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-03-28 14:52:14 -04:00
Laurent Bigonville
a8a766ac9f libsemanage: do not link against libpython, this is considered bad in Debian
Do not link against libpython, the interpreter is already linked to it.
In Debian this is usually considered bad practice.

Signed-off-by: Author: Laurent Bigonville <bigon@debian.org>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-03-28 14:52:13 -04:00
Dan Walsh
66dd98b83a libsemanage: Alternate path for semanage.conf
Currently the semanage.conf file is hard coded to /etc/selinux/semanage.conf
even when an alternate root path is specified.  Use the semanage.conf
found inside the altername root instead of the system global version.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-03-28 08:39:07 -04:00
Eric Paris
339f8079d7 update VERSION and Changelog for public push 2011-12-21 12:46:04 -05:00
Dan Walsh
5e46bb8647 libsemanage: Fallback_user_level can be NULL if you are not using MLS
If you build a distribution without MLS turned on, libsemanage will
crash if given a user without a level.  This patch allows users
without levels to be passed in.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-12-21 12:25:28 -05:00
Eric Paris
915b5f885f libsemanage: add ignoredirs config for genhomedircon
For a long time /root has been treated differently in Red Hat
Distributions then upstream policy.

We do not want to label /root the same as a users homedir.  Because of
this we have carried a patch in libsemanage/genhomedircon.c to ignore
/root.

This patch adds a flag to semanage.conf, ignoredirs.  That will allow
distributions or users to specify directories that genhomedircon
should ignore when setting up users homedir labeling.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-12-21 12:25:28 -05:00
Eric Paris
14e4b70b93 Bump Version and Changelog for commit 2011-11-03 15:26:36 -04:00
Dan Walsh
2c4eca16dd libsemanage: create man5dir if not exist
Make new man page directory if it doesn't exist.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-11-02 15:37:11 -04:00
Guido Trentalancia
06f53004d9 libsemanage: semanage.conf man page
Add a new semanage.conf man page.

Signed-off-by: Eric Paris <eparis@redhat.com>
2011-11-02 15:37:11 -04:00
Dan Walsh
86e8daafc3 libselinux: maintain mode even if umask is tighter
When certain programs were run which created new files they would get
default permissions based on the current users umask.  However these
files should get the same permissions as those files which they
replaced.  Do that.

Patch from: Stephen Smalley

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-11-02 15:37:10 -04:00
Eric Paris
c81a43c753 libselinux: libsemanage: libsepol: regenerate .pc on VERSION change
The makefile which generated the package config files did not have the
VERSION file as a dependancy.  Thus if you updated a tree you have
previously build the .pc file wouldn't be rebuilt and the old version
would be reinstalled.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-11-02 15:37:10 -04:00
Eric Paris
418dbc70e8 Bump version and changelog for all components. 2011-09-16 15:34:36 -04:00
Guido Trentalancia
6a53023740 libsemanage: fix semanage_store_access_check calling arguments
A few calls to semanage_store_access_check() in the libsemanage
tests passed an argument even though it is a void function.

Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-09-16 11:54:04 -04:00
Guido Trentalancia
eb695e5a56 whole tree: default make target to all not install
Change the default "make" target for the libraries from "install" to
"all" in the makefiles.

Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-09-16 11:54:04 -04:00