Home | History | Annotate | Download | only in newrole
      1 # Installation directories.
      2 PREFIX ?= $(DESTDIR)/usr
      3 BINDIR ?= $(PREFIX)/bin
      4 MANDIR ?= $(PREFIX)/share/man
      5 ETCDIR ?= $(DESTDIR)/etc
      6 LOCALEDIR = /usr/share/locale
      7 PAMH = $(shell ls /usr/include/security/pam_appl.h 2>/dev/null)
      8 AUDITH = $(shell ls /usr/include/libaudit.h 2>/dev/null)
      9 # Enable capabilities to permit newrole to generate audit records.
     10 # This will make newrole a setuid root program.
     11 # The capabilities used are: CAP_AUDIT_WRITE.
     12 AUDIT_LOG_PRIV ?= n
     13 # Enable capabilities to permit newrole to utilitize the pam_namespace module.
     14 # This will make newrole a setuid root program.
     15 # The capabilities used are: CAP_SYS_ADMIN, CAP_CHOWN, CAP_FOWNER and
     16 # CAP_DAC_OVERRIDE. 
     17 NAMESPACE_PRIV ?= n
     18 # If LSPP_PRIV is y, then newrole will be made into setuid root program.
     19 # Enabling this option will force AUDIT_LOG_PRIV and NAMESPACE_PRIV to be y.
     20 LSPP_PRIV ?= n
     21 VERSION = $(shell cat ../VERSION)
     22 
     23 CFLAGS ?= -Werror -Wall -W
     24 EXTRA_OBJS =
     25 override CFLAGS += -DVERSION=\"$(VERSION)\" $(LDFLAGS) -I$(PREFIX)/include -DUSE_NLS -DLOCALEDIR="\"$(LOCALEDIR)\"" -DPACKAGE="\"policycoreutils\""
     26 LDLIBS += -lselinux -L$(PREFIX)/lib
     27 ifeq ($(PAMH), /usr/include/security/pam_appl.h)
     28 	override CFLAGS += -DUSE_PAM
     29 	EXTRA_OBJS += hashtab.o
     30 	LDLIBS += -lpam -lpam_misc
     31 else
     32 	override CFLAGS += -D_XOPEN_SOURCE=500
     33 	LDLIBS += -lcrypt
     34 endif
     35 ifeq ($(AUDITH), /usr/include/libaudit.h)
     36 	override CFLAGS += -DUSE_AUDIT
     37 	LDLIBS += -laudit
     38 endif
     39 ifeq ($(LSPP_PRIV),y)
     40 	override AUDIT_LOG_PRIV=y
     41 	override NAMESPACE_PRIV=y
     42 endif
     43 ifeq ($(AUDIT_LOG_PRIV),y)
     44 	override CFLAGS += -DAUDIT_LOG_PRIV
     45 	IS_SUID=y
     46 endif
     47 ifeq ($(NAMESPACE_PRIV),y)
     48 	override CFLAGS += -DNAMESPACE_PRIV
     49 	IS_SUID=y
     50 endif
     51 ifeq ($(IS_SUID),y)
     52 	MODE := 4555
     53 	LDLIBS += -lcap-ng
     54 else
     55 	MODE := 0555
     56 endif
     57 
     58 all: newrole
     59 
     60 newrole: newrole.o $(EXTRA_OBJS)
     61 	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
     62 
     63 install: all
     64 	test -d $(BINDIR)      || install -m 755 -d $(BINDIR)
     65 	test -d $(ETCDIR)/pam.d || install -m 755 -d $(ETCDIR)/pam.d
     66 	test -d $(MANDIR)/man1 || install -m 755 -d $(MANDIR)/man1
     67 	install -m $(MODE) newrole $(BINDIR)
     68 	install -m 644 newrole.1 $(MANDIR)/man1/
     69 ifeq ($(PAMH), /usr/include/security/pam_appl.h)
     70 	test -d $(ETCDIR)/pam.d || install -m 755 -d $(ETCDIR)/pam.d
     71 ifeq ($(LSPP_PRIV),y)
     72 	install -m 644 newrole-lspp.pamd $(ETCDIR)/pam.d/newrole
     73 else
     74 	install -m 644 newrole.pamd $(ETCDIR)/pam.d/newrole
     75 endif
     76 endif
     77 
     78 clean:
     79 	rm -f newrole *.o 
     80 
     81 indent:
     82 	../../scripts/Lindent $(wildcard *.[ch])
     83 
     84 relabel: install
     85 	/sbin/restorecon $(BINDIR)/newrole
     86