Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libselinux/src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ void set_selinuxmnt(const char *mnt)
static void init_lib(void) __attribute__ ((constructor));
static void init_lib(void)
{
SELINUX_PROTECT_ERRNO;
selinux_page_size = sysconf(_SC_PAGE_SIZE);
init_selinuxmnt();
#ifndef ANDROID
Expand Down
10 changes: 10 additions & 0 deletions libselinux/src/selinux_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <selinux/selinux.h>
#include <pthread.h>
#include <errno.h>


extern int require_seusers ;
Expand Down Expand Up @@ -131,4 +132,13 @@ void *reallocarray(void *ptr, size_t nmemb, size_t size);
#define IGNORE_DEPRECATED_DECLARATION_END
#endif

static inline void selinux_reset_errno(int *saved_errno) {
if (*saved_errno < 0)
return;

errno = *saved_errno;
}

#define SELINUX_PROTECT_ERRNO __attribute__((__cleanup__(selinux_reset_errno))) \
__attribute__((__unused__)) int __selinux_saved_errno = errno
#endif /* SELINUX_INTERNAL_H_ */