summaryrefslogtreecommitdiffstats
path: root/init/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/util.c')
-rwxr-xr-xinit/util.c15
1 files changed, 1 insertions, 14 deletions
diff --git a/init/util.c b/init/util.c
index 743748b..918bc05 100755
--- a/init/util.c
+++ b/init/util.c
@@ -23,9 +23,7 @@
#include <errno.h>
#include <time.h>
-#ifdef HAVE_SELINUX
#include <selinux/label.h>
-#endif
#include <sys/stat.h>
#include <sys/types.h>
@@ -89,9 +87,7 @@ int create_socket(const char *name, int type, mode_t perm, uid_t uid, gid_t gid)
{
struct sockaddr_un addr;
int fd, ret;
-#ifdef HAVE_SELINUX
char *secon;
-#endif
fd = socket(PF_UNIX, type, 0);
if (fd < 0) {
@@ -110,14 +106,12 @@ int create_socket(const char *name, int type, mode_t perm, uid_t uid, gid_t gid)
goto out_close;
}
-#ifdef HAVE_SELINUX
secon = NULL;
if (sehandle) {
ret = selabel_lookup(sehandle, &secon, addr.sun_path, S_IFSOCK);
if (ret == 0)
setfscreatecon(secon);
}
-#endif
ret = bind(fd, (struct sockaddr *) &addr, sizeof (addr));
if (ret) {
@@ -125,10 +119,8 @@ int create_socket(const char *name, int type, mode_t perm, uid_t uid, gid_t gid)
goto out_unlink;
}
-#ifdef HAVE_SELINUX
setfscreatecon(NULL);
freecon(secon);
-#endif
chown(addr.sun_path, uid, gid);
chmod(addr.sun_path, perm);
@@ -468,31 +460,27 @@ int make_dir(const char *path, mode_t mode)
{
int rc;
-#ifdef HAVE_SELINUX
char *secontext = NULL;
if (sehandle) {
selabel_lookup(sehandle, &secontext, path, mode);
setfscreatecon(secontext);
}
-#endif
rc = mkdir(path, mode);
-#ifdef HAVE_SELINUX
if (secontext) {
int save_errno = errno;
freecon(secontext);
setfscreatecon(NULL);
errno = save_errno;
}
-#endif
+
return rc;
}
int restorecon(const char *pathname)
{
-#ifdef HAVE_SELINUX
char *secontext = NULL;
struct stat sb;
int i;
@@ -509,6 +497,5 @@ int restorecon(const char *pathname)
return -errno;
}
freecon(secontext);
-#endif
return 0;
}