mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
udev: kill udev_selinux_setfscreateconat()
This commit is contained in:
parent
9e13dbae50
commit
3b49d09a3d
@ -180,14 +180,12 @@ static inline void udev_selinux_init(struct udev *udev) {}
|
||||
static inline void udev_selinux_exit(struct udev *udev) {}
|
||||
static inline void udev_selinux_lsetfilecon(struct udev *udev, const char *file, unsigned int mode) {}
|
||||
static inline void udev_selinux_setfscreatecon(struct udev *udev, const char *file, unsigned int mode) {}
|
||||
static inline void udev_selinux_setfscreateconat(struct udev *udev, int dfd, const char *file, unsigned int mode) {}
|
||||
static inline void udev_selinux_resetfscreatecon(struct udev *udev) {}
|
||||
#else
|
||||
void udev_selinux_init(struct udev *udev);
|
||||
void udev_selinux_exit(struct udev *udev);
|
||||
void udev_selinux_lsetfilecon(struct udev *udev, const char *file, unsigned int mode);
|
||||
void udev_selinux_setfscreatecon(struct udev *udev, const char *file, unsigned int mode);
|
||||
void udev_selinux_setfscreateconat(struct udev *udev, int dfd, const char *file, unsigned int mode);
|
||||
void udev_selinux_resetfscreatecon(struct udev *udev);
|
||||
#endif
|
||||
|
||||
|
@ -82,28 +82,3 @@ void udev_selinux_resetfscreatecon(struct udev *udev)
|
||||
if (setfscreatecon(selinux_prev_scontext) < 0)
|
||||
err(udev, "setfscreatecon failed: %m\n");
|
||||
}
|
||||
|
||||
void udev_selinux_setfscreateconat(struct udev *udev, int dfd, const char *file, unsigned int mode)
|
||||
{
|
||||
char filename[UTIL_PATH_SIZE];
|
||||
|
||||
if (!selinux_enabled)
|
||||
return;
|
||||
|
||||
/* resolve relative filename */
|
||||
if (file[0] != '/') {
|
||||
char procfd[UTIL_PATH_SIZE];
|
||||
char target[UTIL_PATH_SIZE];
|
||||
ssize_t len;
|
||||
|
||||
snprintf(procfd, sizeof(procfd), "/proc/%u/fd/%u", getpid(), dfd);
|
||||
len = readlink(procfd, target, sizeof(target));
|
||||
if (len <= 0 || len == sizeof(target))
|
||||
return;
|
||||
target[len] = '\0';
|
||||
|
||||
util_strscpyl(filename, sizeof(filename), target, "/", file, NULL);
|
||||
file = filename;
|
||||
}
|
||||
udev_selinux_setfscreatecon(udev, file, mode);
|
||||
}
|
||||
|
@ -871,36 +871,29 @@ static void static_dev_create_from_modules(struct udev *udev)
|
||||
/* needed for standalone udev operations */
|
||||
static void static_dev_create_links(struct udev *udev)
|
||||
{
|
||||
DIR *dir;
|
||||
struct stdlinks {
|
||||
const char *link;
|
||||
const char *target;
|
||||
};
|
||||
static const struct stdlinks stdlinks[] = {
|
||||
{ "core", "/proc/kcore" },
|
||||
{ "fd", "/proc/self/fd" },
|
||||
{ "stdin", "/proc/self/fd/0" },
|
||||
{ "stdout", "/proc/self/fd/1" },
|
||||
{ "stderr", "/proc/self/fd/2" },
|
||||
{ "/dev/core", "/proc/kcore" },
|
||||
{ "/dev/fd", "/proc/self/fd" },
|
||||
{ "/dev/stdin", "/proc/self/fd/0" },
|
||||
{ "/dev/stdout", "/proc/self/fd/1" },
|
||||
{ "/dev/stderr", "/proc/self/fd/2" },
|
||||
};
|
||||
unsigned int i;
|
||||
|
||||
dir = opendir("/dev");
|
||||
if (dir == NULL)
|
||||
return;
|
||||
|
||||
for (i = 0; i < ELEMENTSOF(stdlinks); i++) {
|
||||
struct stat sb;
|
||||
|
||||
if (stat(stdlinks[i].target, &sb) == 0) {
|
||||
udev_selinux_setfscreateconat(udev, dirfd(dir), stdlinks[i].link, S_IFLNK);
|
||||
if (symlinkat(stdlinks[i].target, dirfd(dir), stdlinks[i].link) < 0 && errno == EEXIST)
|
||||
utimensat(dirfd(dir), stdlinks[i].link, NULL, AT_SYMLINK_NOFOLLOW);
|
||||
udev_selinux_setfscreatecon(udev, stdlinks[i].link, S_IFLNK);
|
||||
if (symlink(stdlinks[i].target, stdlinks[i].link) < 0 && errno == EEXIST)
|
||||
utimensat(AT_FDCWD, stdlinks[i].link, NULL, AT_SYMLINK_NOFOLLOW);
|
||||
udev_selinux_resetfscreatecon(udev);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
static int mem_size_mb(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user