X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev%2Fudev_node.c;h=80c4f0a5f3556fb2b43ec45223e860291aec8ab4;hb=ecc9ec579feb4b7cc86bcf7caed3cb841faf3c9e;hp=462f1b633b880c695301511c778c3799d261764b;hpb=7d563a17f3967890331daf08d43f2f005418139b;p=elogind.git diff --git a/udev/udev_node.c b/udev/udev_node.c index 462f1b633..80c4f0a5f 100644 --- a/udev/udev_node.c +++ b/udev/udev_node.c @@ -1,20 +1,18 @@ /* - * Copyright (C) 2003 Greg Kroah-Hartman - * Copyright (C) 2004-2006 Kay Sievers + * Copyright (C) 2004-2008 Kay Sievers * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ #include @@ -31,7 +29,6 @@ #include "udev.h" #include "udev_rules.h" -#include "udev_selinux.h" #define TMP_FILE_EXT ".udev-tmp" @@ -51,15 +48,15 @@ int udev_node_mknod(struct udevice *udevice, const char *file, dev_t devt, mode_ if (((stats.st_mode & S_IFMT) == (mode & S_IFMT)) && (stats.st_rdev == devt)) { info(udevice->udev, "preserve file '%s', because it has correct dev_t\n", file); preserve = 1; - selinux_setfilecon(udevice->udev, file, udevice->dev->kernel, mode); + udev_selinux_lsetfilecon(udevice->udev, file, mode); } else { info(udevice->udev, "atomically replace existing file '%s'\n", file); strlcpy(file_tmp, file, sizeof(file_tmp)); strlcat(file_tmp, TMP_FILE_EXT, sizeof(file_tmp)); unlink(file_tmp); - selinux_setfscreatecon(udevice->udev, file_tmp, udevice->dev->kernel, mode); + udev_selinux_setfscreatecon(udevice->udev, file_tmp, mode); err = mknod(file_tmp, mode, devt); - selinux_resetfscreatecon(udevice->udev); + udev_selinux_resetfscreatecon(udevice->udev); if (err != 0) { err(udevice->udev, "mknod(%s, %#o, %u, %u) failed: %s\n", file_tmp, mode, major(devt), minor(devt), strerror(errno)); @@ -73,9 +70,9 @@ int udev_node_mknod(struct udevice *udevice, const char *file, dev_t devt, mode_ } } else { info(udevice->udev, "mknod(%s, %#o, (%u,%u))\n", file, mode, major(devt), minor(devt)); - selinux_setfscreatecon(udevice->udev, file, udevice->dev->kernel, mode); + udev_selinux_setfscreatecon(udevice->udev, file, mode); err = mknod(file, mode, devt); - selinux_resetfscreatecon(udevice->udev); + udev_selinux_resetfscreatecon(udevice->udev); if (err != 0) { err(udevice->udev, "mknod(%s, %#o, (%u,%u) failed: %s\n", file, mode, major(devt), minor(devt), strerror(errno)); @@ -151,16 +148,16 @@ static int node_symlink(struct udevice *udevice, const char *node, const char *s buf[len] = '\0'; if (strcmp(target, buf) == 0) { info(udevice->udev, "preserve already existing symlink '%s' to '%s'\n", slink, target); - selinux_setfilecon(udevice->udev, slink, NULL, S_IFLNK); + udev_selinux_lsetfilecon(udevice->udev, slink, S_IFLNK); goto exit; } } } } else { info(udevice->udev, "creating symlink '%s' to '%s'\n", slink, target); - selinux_setfscreatecon(udevice->udev, slink, NULL, S_IFLNK); + udev_selinux_setfscreatecon(udevice->udev, slink, S_IFLNK); retval = symlink(target, slink); - selinux_resetfscreatecon(udevice->udev); + udev_selinux_resetfscreatecon(udevice->udev); if (retval == 0) goto exit; } @@ -169,9 +166,9 @@ static int node_symlink(struct udevice *udevice, const char *node, const char *s strlcpy(slink_tmp, slink, sizeof(slink_tmp)); strlcat(slink_tmp, TMP_FILE_EXT, sizeof(slink_tmp)); unlink(slink_tmp); - selinux_setfscreatecon(udevice->udev, slink, NULL, S_IFLNK); + udev_selinux_setfscreatecon(udevice->udev, slink, S_IFLNK); retval = symlink(target, slink_tmp); - selinux_resetfscreatecon(udevice->udev); + udev_selinux_resetfscreatecon(udevice->udev); if (retval != 0) { err(udevice->udev, "symlink(%s, %s) failed: %s\n", target, slink_tmp, strerror(errno)); goto exit; @@ -286,7 +283,7 @@ void udev_node_update_symlinks(struct udevice *udevice, struct udevice *udevice_ } /* export symlinks to environment */ - remove_trailing_chars(symlinks, ' '); + util_remove_trailing_chars(symlinks, ' '); if (symlinks[0] != '\0') setenv("DEVLINKS", symlinks, 1);