logging_init("create_floppy_devices");
udev_set_log_fn(udev, log_fn);
- selinux_init(udev);
+ udev_selinux_init(udev);
while ((c = getopt(argc, argv, "cudm:U:G:M:t:")) != -1) {
switch (c) {
print_nodes = 1;
break;
case 'U':
- uid = lookup_user(udev, optarg);
+ uid = util_lookup_user(udev, optarg);
break;
case 'G':
- gid = lookup_group(udev, optarg);
+ gid = util_lookup_group(udev, optarg);
break;
case 'M':
mode = strtol(optarg, NULL, 0);
i++;
}
- selinux_exit(udev);
+ udev_selinux_exit(udev);
udev_unref(udev);
exit:
return 0;
devpath_to_db_path(udev,
udev_device_get_devpath(udev_device),
filename, sizeof(filename));
- create_path(udev, filename);
+ util_create_path(udev, filename);
unlink(filename);
udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device))
util_strlcpy(program, cmd, sizeof(program));
udev_event_apply_format(event, program, sizeof(program));
envp = udev_device_get_properties_envp(event->dev);
- if (run_program(event->udev, program, envp, NULL, 0, NULL) != 0) {
+ if (util_run_program(event->udev, program, envp, NULL, 0, NULL) != 0) {
if (!udev_list_entry_get_flag(list_entry))
err = -1;
}
if (add) {
info(udev, "creating index: '%s'\n", filename);
- create_path(udev, filename);
+ util_create_path(udev, filename);
fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0644);
if (fd > 0)
close(fd);
} else {
info(udev, "removing index: '%s'\n", filename);
unlink(filename);
- delete_path(udev, filename);
+ util_delete_path(udev, filename);
}
return 0;
}
info(udev, "no reference left, remove '%s'\n", slink);
if (!test) {
unlink(slink);
- delete_path(udev, slink);
+ util_delete_path(udev, slink);
}
goto out;
}
/* create symlink to the target with the highest priority */
info(udev, "'%s' with target '%s' has the highest priority %i, create it\n", slink, target, priority);
if (!test) {
- create_path(udev, slink);
+ util_create_path(udev, slink);
node_symlink(udev, target, slink);
}
out:
struct udev_list_entry *list_entry;
int err = 0;
- create_path(udev, udev_device_get_devnode(dev));
+ util_create_path(udev, udev_device_get_devnode(dev));
if (strcmp(owner, "root") == 0)
uid = 0;
if (endptr[0] == '\0')
uid = (uid_t) id;
else
- uid = lookup_user(udev, owner);
+ uid = util_lookup_user(udev, owner);
}
if (strcmp(group, "root") == 0)
if (endptr[0] == '\0')
gid = (gid_t) id;
else
- gid = lookup_group(udev, group);
+ gid = util_lookup_group(udev, group);
}
info(udev, "creating device node '%s', devnum=%d:%d, mode=%#o, uid=%d, gid=%d\n",
info(udev, "removing device node '%s'\n", devnode);
if (!test)
- err = unlink_secure(udev, devnode);
+ err = util_unlink_secure(udev, devnode);
if (err)
return err;
snprintf(partitionname, sizeof(partitionname), "%s%d", devnode, i);
partitionname[sizeof(partitionname)-1] = '\0';
if (!test)
- unlink_secure(udev, partitionname);
+ util_unlink_secure(udev, partitionname);
}
}
- delete_path(udev, devnode);
+ util_delete_path(udev, devnode);
return err;
}
char *line;
envp = udev_device_get_properties_envp(dev);
- if (run_program(udev, program, envp, result, sizeof(result), &reslen) != 0)
+ if (util_run_program(udev, program, envp, result, sizeof(result), &reslen) != 0)
return -1;
line = result;
util_strlcpy(program, key_val(rule, &rule->program), sizeof(program));
udev_event_apply_format(event, program, sizeof(program));
envp = udev_device_get_properties_envp(dev);
- if (run_program(event->udev, program, envp, result, sizeof(result), NULL) != 0) {
+ if (util_run_program(event->udev, program, envp, result, sizeof(result), NULL) != 0) {
dbg(event->udev, "PROGRAM is false\n");
event->program_result[0] = '\0';
if (rule->program.operation != KEY_OP_NOMATCH)
if (event->tmp_node[0] != '\0') {
dbg(event->udev, "removing temporary device node\n");
- unlink_secure(event->udev, event->tmp_node);
+ util_unlink_secure(event->udev, event->tmp_node);
event->tmp_node[0] = '\0';
}
return 0;
strtoul(value, &endptr, 10);
if (endptr[0] != '\0') {
char owner[32];
- uid_t uid = lookup_user(rules->udev, value);
+ uid_t uid = util_lookup_user(rules->udev, value);
dbg(rules->udev, "replacing username='%s' by id=%i\n", value, uid);
sprintf(owner, "%u", (unsigned int) uid);
add_rule_key(rule, &rule->owner, operation, owner);
strtoul(value, &endptr, 10);
if (endptr[0] != '\0') {
char group[32];
- gid_t gid = lookup_group(rules->udev, value);
+ gid_t gid = util_lookup_group(rules->udev, value);
dbg(rules->udev, "replacing groupname='%s' by id=%i\n", value, gid);
sprintf(group, "%u", (unsigned int) gid);
add_rule_key(rule, &rule->group, operation, group);
util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename));
util_strlcat(filename, "/.udev/rules.d", sizeof(filename));
if (stat(filename, &statbuf) != 0) {
- create_path(udev, filename);
+ util_create_path(udev, filename);
udev_selinux_setfscreatecon(udev, filename, S_IFDIR|0755);
mkdir(filename, 0755);
udev_selinux_resetfscreatecon(udev);
#include "udev.h"
-int create_path(struct udev *udev, const char *path)
+int util_create_path(struct udev *udev, const char *path)
{
char p[UTIL_PATH_SIZE];
char *pos;
if (stat(p, &stats) == 0 && (stats.st_mode & S_IFMT) == S_IFDIR)
return 0;
- if (create_path(udev, p) != 0)
+ if (util_create_path(udev, p) != 0)
return -1;
dbg(udev, "mkdir '%s'\n", p);
return -1;
}
-int delete_path(struct udev *udev, const char *path)
+int util_delete_path(struct udev *udev, const char *path)
{
char p[UTIL_PATH_SIZE];
char *pos;
/* Reset permissions on the device node, before unlinking it to make sure,
* that permisions of possible hard links will be removed too.
*/
-int unlink_secure(struct udev *udev, const char *filename)
+int util_unlink_secure(struct udev *udev, const char *filename)
{
int retval;
return retval;
}
-uid_t lookup_user(struct udev *udev, const char *user)
+uid_t util_lookup_user(struct udev *udev, const char *user)
{
struct passwd *pw;
uid_t uid = 0;
return uid;
}
-extern gid_t lookup_group(struct udev *udev, const char *group)
+extern gid_t util_lookup_group(struct udev *udev, const char *group)
{
struct group *gr;
gid_t gid = 0;
return gid;
}
-int run_program(struct udev *udev, const char *command, char **envp,
- char *result, size_t ressize, size_t *reslen)
+int util_run_program(struct udev *udev, const char *command, char **envp,
+ char *result, size_t ressize, size_t *reslen)
{
int status;
int outpipe[2] = {-1, -1};
#define DEFAULT_FAKE_PARTITIONS_COUNT 15
#define UDEV_EVENT_TIMEOUT 180
-/* linux/include/linux/kobject.h */
-#define UEVENT_BUFFER_SIZE 2048
-#define UEVENT_NUM_ENVP 32
-
#define UDEV_CTRL_SOCK_PATH "@" UDEV_PREFIX "/org/kernel/udev/udevd"
#define UDEV_MAX(a,b) ((a) > (b) ? (a) : (b))
extern void udev_node_update_old_links(struct udev_device *dev, struct udev_device *dev_old, int test);
/* udev-util.c */
-extern int create_path(struct udev *udev, const char *path);
-extern int delete_path(struct udev *udev, const char *path);
-extern int unlink_secure(struct udev *udev, const char *filename);
-extern uid_t lookup_user(struct udev *udev, const char *user);
-extern gid_t lookup_group(struct udev *udev, const char *group);
-extern int run_program(struct udev *udev, const char *command, char **envp,
- char *result, size_t ressize, size_t *reslen);
+extern int util_create_path(struct udev *udev, const char *path);
+extern int util_delete_path(struct udev *udev, const char *path);
+extern int util_unlink_secure(struct udev *udev, const char *filename);
+extern uid_t util_lookup_user(struct udev *udev, const char *user);
+extern gid_t util_lookup_group(struct udev *udev, const char *group);
+extern int util_run_program(struct udev *udev, const char *command, char **envp,
+ char *result, size_t ressize, size_t *reslen);
/* udev-selinux.c */
#ifndef USE_SELINUX
switch (state) {
case EVENT_QUEUED:
if(unlink(filename_failed) == 0)
- delete_path(event->udev, filename_failed);
- create_path(event->udev, filename);
+ util_delete_path(event->udev, filename_failed);
+ util_create_path(event->udev, filename);
udev_selinux_setfscreatecon(event->udev, filename, S_IFLNK);
symlink(udev_device_get_devpath(event->dev), filename);
udev_selinux_resetfscreatecon(event->udev);
udev_device_get_devpath_old(event->dev), udev_device_get_devpath(event->dev));
} else {
if (unlink(filename_failed) == 0)
- delete_path(event->udev, filename_failed);
+ util_delete_path(event->udev, filename_failed);
}
unlink(filename);
/* clean up possibly empty queue directory */
if (udev_list_is_empty(&exec_list) && udev_list_is_empty(&running_list))
- delete_path(event->udev, filename);
+ util_delete_path(event->udev, filename);
break;
case EVENT_FAILED:
/* move failed event to the failed directory */
- create_path(event->udev, filename_failed);
+ util_create_path(event->udev, filename_failed);
rename(filename, filename_failed);
/* clean up possibly empty queue directory */
if (udev_list_is_empty(&exec_list) && udev_list_is_empty(&running_list))
- delete_path(event->udev, filename);
+ util_delete_path(event->udev, filename);
break;
}
}
util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename));
util_strlcat(filename, "/.udev/uevent_seqnum", sizeof(filename));
- create_path(udev, filename);
+ util_create_path(udev, filename);
fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0644);
if (fd >= 0) {
write(fd, seqnum, len);