#include "udev.h"
#include "udev_version.h"
#include "udev_dbus.h"
+#include "udev_selinux.h"
#include "logging.h"
#include "namedev.h"
#include "udevdb.h"
int retval;
struct stat stats;
- strncpy(p, file, sizeof(p));
+ strfieldcpy(p, file);
pos = strchr(p+1, '/');
while (1) {
pos = strchr(pos+1, '/');
int i;
int tail;
- strncpy(filename, udev_root, sizeof(filename));
- strncat(filename, dev->name, sizeof(filename));
+ strfieldcpy(filename, udev_root);
+ strfieldcat(filename, dev->name);
switch (dev->type) {
case 'b':
info("creating device partition nodes '%s[1-%i]'", filename, dev->partitions);
if (!fake) {
for (i = 1; i <= dev->partitions; i++) {
- sprintf(partitionname, "%s%i", filename, i);
+ strfieldcpy(partitionname, filename);
+ strintcat(partitionname, i);
make_node(partitionname, dev->major,
dev->minor + i, dev->mode, uid, gid);
}
}
}
+ if (!fake)
+ selinux_add_node(filename);
+
/* create symlink if requested */
if (dev->symlink[0] != '\0') {
symlinks = dev->symlink;
if (linkname == NULL || linkname[0] == '\0')
break;
- strncpy(filename, udev_root, sizeof(filename));
- strncat(filename, linkname, sizeof(filename));
+ strfieldcpy(filename, udev_root);
+ strfieldcat(filename, linkname);
dbg("symlink '%s' to node '%s' requested", filename, dev->name);
if (!fake)
if (strrchr(linkname, '/'))
}
while (linkname[i] != '\0') {
if (linkname[i] == '/')
- strcat(linktarget, "../");
+ strfieldcat(linktarget, "../");
i++;
}
- if (linktarget[0] == '\0')
- strcpy(linktarget, "./");
- strcat(linktarget, &dev->name[tail]);
+ strfieldcat(linktarget, &dev->name[tail]);
/* unlink existing files to ensure that our symlink is created */
if (!fake && (lstat(filename, &stats) == 0)) {
char dev_path[SYSFS_PATH_MAX];
struct sysfs_class_device *class_dev = NULL;
- strcpy(dev_path, sysfs_path);
- strcat(dev_path, device_name);
+ strfieldcpy(dev_path, sysfs_path);
+ strfieldcat(dev_path, device_name);
dbg("looking at '%s'", dev_path);
/* open up the sysfs class device for this thing... */
int loop = SECONDS_TO_WAIT_FOR_DEV;
int retval;
- strcpy(filename, sysfs_path);
- strcat(filename, path);
- strcat(filename, "/dev");
+ strfieldcpy(filename, sysfs_path);
+ strfieldcat(filename, path);
+ strfieldcat(filename, "/dev");
while (loop--) {
struct stat buf;