diff options
author | katzj <katzj> | 2005-06-17 20:53:31 +0000 |
---|---|---|
committer | katzj <katzj> | 2005-06-17 20:53:31 +0000 |
commit | 29549c37ff777c9c8ce5e35385f1b2975aada908 (patch) | |
tree | 0df2b884f1d562eccae6015ef0cd0903b6c2ed41 /src | |
parent | d4b15286d03862f05e4e69570e10ba5aeb282e6e (diff) | |
download | mock-29549c37ff777c9c8ce5e35385f1b2975aada908.tar.gz mock-29549c37ff777c9c8ce5e35385f1b2975aada908.tar.xz mock-29549c37ff777c9c8ce5e35385f1b2975aada908.zip |
* build libselinux-mock as a shared lib that gets installed into LIBDIR
* LD_PRELOAD libselinux-mock if we're running with selinux. this involves
linking with libselinux. if you're anti-selinux, build with
'make NOSELINUX=1'. this lets mock work on systems running targeted policy
at least
only ugliness here is that if the preload is being used, you get errors
about being unable to load it in the chroot from ld. it doesn't cause
problems, it's just aesthetically ugly.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 22 | ||||
-rw-r--r-- | src/mock-helper.c | 14 |
2 files changed, 28 insertions, 8 deletions
diff --git a/src/Makefile b/src/Makefile index 7c103f6..8e62ea7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -5,14 +5,28 @@ MOCKGROUP=mock DESTDIR='' INSTALL=/usr/bin/install MKDIR=/bin/mkdir + +ifndef NOSELINUX +SELINUXFLAGS=-DUSE_SELINUX=1 -lselinux +endif + +ifneq (,$(filter ppc64 x86_64 s390x,$(shell uname -m))) +LIBDIR = /usr/lib64 +else +LIBDIR = /usr/lib +endif + all: - $(CC) -o $(EXECUTABLE) mock-helper.c + $(CC) $(CFLAGS) -o $(EXECUTABLE) mock-helper.c $(SELINUXFLAGS) + $(CC) $(CFLAGS) -fPIC -c selinux-mock.c + $(LD) -shared -o libselinux-mock.so selinux-mock.o clean: rm -f $(EXECUTABLE) - rm -f *~ *.bak + rm -f *~ *.bak *.o *.so install: - $(MKDIR) -p $(DESTDIR)/$(SBINDIR) - $(INSTALL) -m 4750 $(EXECUTABLE) $(DESTDIR)/$(PKGDIR)/$(SBINDIR)/$(EXECUTABLE) + $(MKDIR) -p $(DESTDIR)/$(SBINDIR) $(DESTDIR)/$(LIBDIR) + $(INSTALL) -m 4750 $(EXECUTABLE) $(DESTDIR)/$(SBINDIR)/$(EXECUTABLE) + $(INSTALL) -m 755 libselinux-mock.so $(DESTDIR)/$(LIBDIR) diff --git a/src/mock-helper.c b/src/mock-helper.c index 6360521..e2da915 100644 --- a/src/mock-helper.c +++ b/src/mock-helper.c @@ -15,6 +15,10 @@ #include <stdlib.h> #include <string.h> +#ifdef USE_SELINUX +#include <selinux/selinux.h> +#endif + /* pull in configure'd defines */ char *rootsdir = ROOTSDIR; @@ -158,13 +162,15 @@ do_command (const char *filename, char *const argv[]) printf ("\n"); */ - /* add LD_PRELOAD for our selinux lib if MOCK_LD_PRELOAD is set */ - envvar = getenv ("MOCK_LD_PRELOAD"); - if (envvar != 0) +#ifdef USE_SELINUX + /* add LD_PRELOAD for our selinux lib if selinux is in use is set */ + if (is_selinux_enabled() != -1) { - ld_preload = strdup("LD_PRELOAD=" LIBDIR "/libselinux-mock.so"); + ld_preload = strdup("LD_PRELOAD=libselinux-mock.so"); + printf("adding ld_preload of %s\n", ld_preload); env[idx++] = ld_preload; } +#endif for (i = 0; i < ALLOWED_ENV_SIZE; ++i) { |