udev-node.c revision c80d766c8072dd0be311dcd31c17f9719775be44
/*
* Copyright (C) 2003-2013 Kay Sievers <kay@vrfy.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <grp.h>
#include <dirent.h>
#include "udev.h"
#include "smack-util.h"
char target[UTIL_PATH_SIZE];
char *s;
size_t l;
int i = 0;
int tail = 0;
int err = 0;
/* use relative link */
target[0] = '\0';
if (node[i] == '/')
tail = i+1;
i++;
}
s = target;
l = sizeof(target);
while (slink[i] != '\0') {
if (slink[i] == '/')
l = strpcpy(&s, l, "../");
i++;
}
if (l == 0) {
goto exit;
}
/* preserve link with correct target, do not replace node of other device */
goto exit;
char buf[UTIL_PATH_SIZE];
int len;
goto exit;
}
}
}
} else {
do {
break;
if (err != 0)
if (err == 0)
goto exit;
}
do {
break;
if (err != 0)
if (err != 0) {
goto exit;
}
if (err != 0) {
}
exit:
return err;
}
/* find device node of device with highest priority */
static const char *link_find_prioritized(struct udev_device *dev, bool add, const char *stackdir, char *buf, size_t bufsize) {
int priority = 0;
if (add) {
}
return target;
for (;;) {
struct udev_device *dev_db;
break;
continue;
/* did we find ourself? */
continue;
const char *devnode;
log_debug("'%s' claims priority %i for '%s'",
}
}
}
}
return target;
}
/* manage "stack of names" with possibly specified device priorities */
char name_enc[UTIL_PATH_SIZE];
char dirname[UTIL_PATH_SIZE];
const char *target;
char buf[UTIL_PATH_SIZE];
} else {
}
if (add) {
int err;
do {
int fd;
break;
if (fd >= 0)
else
}
}
struct udev_list_entry *list_entry;
/* update possible left-over symlinks */
struct udev_list_entry *list_entry_current;
int found;
/* check if old link name still belongs to this device */
found = 0;
found = 1;
break;
}
}
if (found)
continue;
log_debug("update old name, '%s' no longer belonging to '%s'",
}
}
struct udev_list *seclabel_list) {
struct udev_list_entry *entry;
int err = 0;
else
goto out;
}
log_debug("found node '%s' with non-matching devnum %s, skip handling",
goto out;
}
if (apply) {
bool selinux = false;
bool smack = false;
if (err < 0)
if (err < 0)
} else {
}
/* apply SECLABEL{$module}=$label */
selinux = true;
else
smack = true;
else
} else
}
/* set the defaults */
if (!selinux)
if (!smack)
}
/* always update timestamp when we re-use the node, like on media change events */
out:
return err;
}
struct udev_list *seclabel_list) {
char filename[UTIL_PATH_SIZE];
struct udev_list_entry *list_entry;
log_debug("handling device node '%s', devnum=%s, mode=%#o, uid=%d, gid=%d",
return;
/* always add /dev/{block,char}/$major:$minor */
}
struct udev_list_entry *list_entry;
char filename[UTIL_PATH_SIZE];
/* remove /dev/{block,char}/$major:$minor */
}