From cc0c6f1498197ed5b1b15bfa94c2f1043e6fbb0e Mon Sep 17 00:00:00 2001 From: mmaslano Date: Fri, 17 Aug 2007 15:16:14 +0200 Subject: [PATCH] Into with_selinux and with_pam part was added variables used only there. In Makefile are libs set by variables. --- Makefile | 16 ++++++++++++++-- security.c | 13 +++++++------ structs.h | 5 +++-- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 0e38b63..dbd1a2e 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,19 @@ DESTETC = $(DESTROOT)/../etc INCLUDE = -I. #INCLUDE = #<> -LIBS = -lselinux -lpam -lpam_misc -laudit +ifdef WITH_SELINUX +SELINUX_LIBS=-lselinux +SELINUX_DEFS=-DWITH_SELINUX +endif +ifdef WITH_PAM +PAM_LIBS=-lpam -lpam_misc +PAM_DEFS=-DWITH_PAM +endif +ifdef WITH_AUDIT +AUDIT_LIBS=-laudit +AUDIT_DEFS=-DWITH_AUDIT +endif +LIBS = $(SELINUX_LIBS) $(PAM_LIBS) $(AUDIT_LIBS) #<> #CDEBUG = -O #CDEBUG = -g @@ -70,7 +82,7 @@ LINTFLAGS = -hbxa $(INCLUDE) $(DEBUGGING) #<> CC = gcc -Wall -Wno-unused -Wno-comment #<> -DEFS = -DWITH_SELINUX -DWITH_PAM -DWITH_AUDIT +DEFS = $(SELINUX_DEFS) $(PAM_DEFS) $(AUDIT_DEFS) #(SGI IRIX systems need this) #DEFS = -D_BSD_SIGNALS -Dconst= #<> diff --git a/security.c b/security.c index 2aafa82..7f9878f 100644 --- a/security.c +++ b/security.c @@ -190,6 +190,7 @@ int get_security_context( const char *name, int crontab_fd, security_context_t *rcontext, const char *tabname) { +#ifdef WITH_SELINUX security_context_t scontext=NULL; security_context_t file_context=NULL; struct av_decision avd; @@ -199,8 +200,6 @@ int get_security_context( const char *name, *rcontext = NULL; -#ifdef WITH_SELINUX - if (is_selinux_enabled() <= 0) return 0; @@ -286,14 +285,14 @@ int crontab_security_access(void) crontab environment */ static char ** build_env(char **cronenv) { +#ifdef WITH_PAM char **jobenv = cronenv; - char **pamenv = pam_getenvlist(pamh); char *cronvar; int count = 0; - jobenv = env_copy(pamenv); + /* Now add the cron environment variables. Since env_set() overwrites existing variables, this will let cron's environment settings override pam's */ @@ -304,6 +303,8 @@ static char ** build_env(char **cronenv) return NULL; } } - - return jobenv; + return jobenv; +#else + return env_copy(cronenv); +#endif } diff --git a/structs.h b/structs.h index a98b1cc..b309bf8 100644 --- a/structs.h +++ b/structs.h @@ -44,6 +44,9 @@ typedef struct _entry { * * These are the crontabs. */ +#ifndef WITH_SELINUX +#define security_context_t unsigned +#endif typedef struct _user { struct _user *next, *prev; /* links */ @@ -51,9 +54,7 @@ typedef struct _user { char *tabname; /* /etc/cron.d/ file name or NULL */ time_t mtime; /* last modtime of crontab */ entry *crontab; /* this person's crontab */ -#ifdef WITH_SELINUX security_context_t scontext; /* SELinux security context */ -#endif } user; typedef struct _cron_db { -- 2.40.0