static char *getoptargs = "u:lerinc";
# endif
#endif
+#ifdef WITH_SELINUX
static char *selinux_context = 0;
+#endif
static PID_T Pid;
static char User[MAX_UNAME], RealUser[MAX_UNAME];
fprintf(stderr, "must be privileged to use -u\n");
exit(ERROR_EXIT);
}
-
+#ifdef WITH_SELINUX
if (crontab_security_access() != 0) {
fprintf(stderr,
"Access denied by SELinux, must be privileged to use -u\n");
exit(ERROR_EXIT);
}
-
+#endif
if (Option == opt_hostset || Option == opt_hostget) {
fprintf(stderr,
"cannot use -u with -n or -c\n");
return retcode;
}
+#if defined(WITH_PAM)
static int cron_open_pam_session(struct passwd *pw) {
- int retcode = 0;
+ int retcode;
-#if defined(WITH_PAM)
retcode = pam_open_session(pamh, PAM_SILENT);
PAM_FAIL_CHECK;
if (retcode == PAM_SUCCESS)
pam_session_opened = 1;
-#endif
return retcode;
}
+#endif
void cron_close_pam(void) {
#if defined(WITH_PAM)
}
+#ifdef WITH_SELINUX
static int cron_authorize_context(security_context_t scontext,
security_context_t file_context) {
-#ifdef WITH_SELINUX
struct av_decision avd;
int retval;
security_class_t tclass;
tclass, bit, &avd);
if (retval || ((bit & avd.allowed) != bit))
return 0;
-#endif
return 1;
}
+#endif
+#ifdef WITH_SELINUX
static int cron_authorize_range(security_context_t scontext,
security_context_t ucontext) {
-#ifdef WITH_SELINUX
struct av_decision avd;
int retval;
security_class_t tclass;
if (retval || ((bit & avd.allowed) != bit))
return 0;
-#endif
return 1;
}
+#endif
#if WITH_SELINUX
/* always uses u->scontext as the default process context, then changes the
}
#endif
+#ifdef WITH_SELINUX
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;
security_context_t rawcontext=NULL;
freecon(file_context);
*rcontext = scontext;
-#endif
return 0;
}
+#endif
-void free_security_context(security_context_t * scontext) {
#ifdef WITH_SELINUX
+void free_security_context(security_context_t * scontext) {
if (*scontext != NULL) {
freecon(*scontext);
*scontext = 0L;
}
-#endif
}
+#endif
-int crontab_security_access(void) {
#ifdef WITH_SELINUX
+int crontab_security_access(void) {
int selinux_check_passwd_access = -1;
if (is_selinux_enabled() > 0) {
security_context_t user_context;
return selinux_check_passwd_access;
}
-#endif
return 0;
}
+#endif
/* Build up the job environment from the PAM environment plus the
* crontab environment
ne = e->next;
free_entry(e);
}
+#ifdef WITH_SELINUX
free_security_context(&(u->scontext));
+#endif
free(u);
}
goto done;
}
+#ifdef WITH_SELINUX
if (get_security_context(pw == NULL ? NULL : uname,
crontab_fd, &u->scontext, tabname) != 0) {
free_user (u);
u = NULL;
goto done;
}
-
+#endif
/* load the crontab
*/
while ((status = load_env (envstr, file)) >= OK) {