Author: Lance Lin Date: Tue, 25 Feb 2025 20:27:50 +0700 Description: Fix FTBFS with GCC-15 --- a/src/cronnext.c +++ b/src/cronnext.c @@ -55,7 +55,7 @@ #ifdef WITH_SELINUX int get_security_context(const char *name, int crontab_fd, - security_context_t *rcontext, const char *tabname) { + char **rcontext, const char *tabname) { /* empty stub */ (void)name; (void)crontab_fd; @@ -64,7 +64,7 @@ return 0; } -void free_security_context(security_context_t *scontext) { +void free_security_context(char **scontext) { /* empty stub */ (void)scontext; } --- a/src/crontab.c +++ b/src/crontab.c @@ -303,7 +303,7 @@ break; #ifdef WITH_SELINUX case 's': - if (getprevcon((security_context_t *) & (selinux_context))) { + if (getprevcon((char **) & (selinux_context))) { fprintf(stderr, "Cannot obtain SELinux process context\n"); exit(ERROR_EXIT); } --- a/src/funcs.h +++ b/src/funcs.h @@ -89,7 +89,7 @@ user *load_user(int, struct passwd *, const char *, const char *, const char *), *find_user(cron_db *, const char *, const char *); -entry *load_entry(FILE *, void (*)(), struct passwd *, char **); +entry *load_entry(FILE *, void (*)(const char *), struct passwd *, char **); FILE *cron_popen(char *, const char *, struct passwd *, char **); @@ -115,11 +115,11 @@ int get_security_context(const char *name, int crontab_fd, - security_context_t *rcontext, + char **rcontext, const char *tabname ); -void free_security_context( security_context_t *scontext ); +void free_security_context( char **scontext ); int crontab_security_access(void); --- a/src/security.c +++ b/src/security.c @@ -94,8 +94,8 @@ static char **build_env(char **cronenv); #ifdef WITH_SELINUX -static int cron_change_selinux_range(user * u, security_context_t ucontext); -static int cron_get_job_range(user * u, security_context_t * ucontextp, +static int cron_change_selinux_range(user * u, char * ucontext); +static int cron_get_job_range(user * u, char ** ucontextp, char **jobenv); #endif @@ -137,7 +137,7 @@ /* we must get the crontab context BEFORE changing user, else * we'll not be permitted to read the cron spool directory :-) */ - security_context_t ucontext = 0; + char * ucontext = 0; if (cron_get_job_range(u, &ucontext, e->envp) < OK) { log_it(e->pwd->pw_name, getpid(), "ERROR", @@ -276,8 +276,8 @@ #ifdef WITH_SELINUX -static int cron_authorize_context(security_context_t scontext, - security_context_t file_context) { +static int cron_authorize_context(char * scontext, + char * file_context) { struct av_decision avd; int retval; security_class_t tclass; @@ -309,8 +309,8 @@ #endif #ifdef WITH_SELINUX -static int cron_authorize_range(security_context_t scontext, - security_context_t ucontext) { +static int cron_authorize_range(char * scontext, + char * ucontext) { struct av_decision avd; int retval; security_class_t tclass; @@ -345,7 +345,7 @@ /* always uses u->scontext as the default process context, then changes the level, and returns it in ucontextp (or NULL otherwise) */ static int -cron_get_job_range(user * u, security_context_t * ucontextp, char **jobenv) { +cron_get_job_range(user * u, char ** ucontextp, char **jobenv) { char *range; if (is_selinux_enabled() <= 0) @@ -398,7 +398,7 @@ #endif #ifdef WITH_SELINUX -static int cron_change_selinux_range(user * u, security_context_t ucontext) { +static int cron_change_selinux_range(user * u, char * ucontext) { char *msg = NULL; if (is_selinux_enabled() <= 0) @@ -481,10 +481,10 @@ #ifdef WITH_SELINUX int get_security_context(const char *name, int crontab_fd, - security_context_t * rcontext, const char *tabname) { - security_context_t scontext = NULL; - security_context_t file_context = NULL; - security_context_t rawcontext=NULL; + char ** rcontext, const char *tabname) { + char * scontext = NULL; + char * file_context = NULL; + char * rawcontext=NULL; context_t current_context = NULL; int retval; char *current_context_str = NULL; @@ -589,7 +589,7 @@ #endif #ifdef WITH_SELINUX -void free_security_context(security_context_t * scontext) { +void free_security_context(char ** scontext) { if (*scontext != NULL) { freecon(*scontext); *scontext = NULL; @@ -601,7 +601,7 @@ int crontab_security_access(void) { int selinux_check_passwd_access = -1; if (is_selinux_enabled() > 0) { - security_context_t user_context; + char * user_context; if (getprevcon_raw(&user_context) == 0) { security_class_t passwd_class; access_vector_t crontab_bit; --- a/src/structs.h +++ b/src/structs.h @@ -57,9 +57,6 @@ * * These are the crontabs. */ -#ifndef WITH_SELINUX -#define security_context_t unsigned -#endif typedef struct _user { struct _user *next, *prev; /* links */ @@ -67,7 +64,7 @@ char *tabname; /* /etc/cron.d/ file name or NULL */ time_t mtime; /* last modtime of crontab */ entry *crontab; /* this person's crontab */ - security_context_t scontext; /* SELinux security context */ + char * scontext; /* SELinux security context */ int system; /* is it a system crontab */ } user; --- a/src/entry.c +++ b/src/entry.c @@ -90,7 +90,7 @@ /* return NULL if eof or syntax error occurs; * otherwise return a pointer to a new entry. */ -entry *load_entry(FILE * file, void (*error_func) (), struct passwd *pw, +entry *load_entry(FILE * file, void (*error_func) (const char *), struct passwd *pw, char **envp) { /* this function reads one crontab entry -- the next -- from a file. * it skips any leading blank lines, ignores comments, and returns