Commit 47ef94ac authored by Kay Sievers's avatar Kay Sievers

udev: add some O_CLOEXEC

parent daa9cf54
......@@ -212,7 +212,7 @@ static int rebuild_queue_file(struct udev_queue_export *udev_queue_export)
}
/* create new queue file */
new_queue_file = fopen("/run/udev/queue.tmp", "w+");
new_queue_file = fopen("/run/udev/queue.tmp", "w+e");
if (new_queue_file == NULL)
goto error;
seqnum = udev_queue_export->seqnum_max;
......
......@@ -125,7 +125,7 @@ static bool is_mounted(const char *device)
if (stat(device, &statbuf) < 0)
return -ENODEV;
fp = fopen("/proc/self/mountinfo", "r");
fp = fopen("/proc/self/mountinfo", "re");
if (fp == NULL)
return -ENOSYS;
while (fscanf(fp, "%*s %*s %i:%i %*[^\n]", &maj, &min) == 2) {
......
......@@ -410,7 +410,7 @@ int main(int argc, char **argv)
const char *filearg = argv[optind+1];
if (strchr(filearg, '/')) {
/* Keymap file argument is a path */
FILE *f = fopen(filearg, "r");
FILE *f = fopen(filearg, "re");
if (f)
merge_table(fd, f);
else
......@@ -421,12 +421,12 @@ int main(int argc, char **argv)
char keymap_path[PATH_MAX];
FILE *f;
snprintf(keymap_path, sizeof(keymap_path), "%s%s", SYSCONFDIR "/udev/keymaps/", filearg);
f = fopen(keymap_path, "r");
f = fopen(keymap_path, "re");
if (f) {
merge_table(fd, f);
} else {
snprintf(keymap_path, sizeof(keymap_path), "%s%s", UDEVLIBEXECDIR "/keymaps/", filearg);
f = fopen(keymap_path, "r");
f = fopen(keymap_path, "re");
if (f)
merge_table(fd, f);
else
......
......@@ -180,7 +180,7 @@ static int get_file_options(struct udev *udev,
int c;
int retval = 0;
fd = fopen(config_file, "r");
fd = fopen(config_file, "re");
if (fd == NULL) {
if (errno == ENOENT) {
return 1;
......
......@@ -750,7 +750,7 @@ static void rename_netif_kernel_log(struct ifreq ifr)
int klog;
FILE *f;
klog = open("/dev/kmsg", O_WRONLY);
klog = open("/dev/kmsg", O_WRONLY|O_CLOEXEC);
if (klog < 0)
return;
......
......@@ -745,7 +745,7 @@ static int import_file_into_properties(struct udev_device *dev, const char *file
FILE *f;
char line[UTIL_LINE_SIZE];
f = fopen(filename, "r");
f = fopen(filename, "re");
if (f == NULL)
return -1;
while (fgets(line, sizeof(line), f) != NULL)
......@@ -1645,7 +1645,7 @@ static int parse_file(struct udev_rules *rules, const char *filename)
}
log_debug("read rules file: %s\n", filename);
f = fopen(filename, "r");
f = fopen(filename, "re");
if (f == NULL)
return -1;
......@@ -2322,7 +2322,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
FILE *f;
bool imported = false;
f = fopen("/proc/cmdline", "r");
f = fopen("/proc/cmdline", "re");
if (f != NULL) {
char cmdline[4096];
......@@ -2607,7 +2607,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
log_debug("ATTR '%s' writing '%s' %s:%u\n", attr, value,
&rules->buf[rule->rule.filename_off],
rule->rule.filename_line);
f = fopen(attr, "w");
f = fopen(attr, "we");
if (f != NULL) {
if (fprintf(f, "%s", value) <= 0)
log_error("error writing ATTR{%s}: %m\n", attr);
......
......@@ -807,7 +807,7 @@ static void static_dev_create_from_modules(struct udev *udev)
uname(&kernel);
util_strscpyl(modules, sizeof(modules), ROOTPREFIX "/lib/modules/", kernel.release, "/modules.devname", NULL);
f = fopen(modules, "r");
f = fopen(modules, "re");
if (f == NULL)
return;
......@@ -871,7 +871,7 @@ static int mem_size_mb(void)
char buf[4096];
long int memsize = -1;
f = fopen("/proc/meminfo", "r");
f = fopen("/proc/meminfo", "re");
if (f == NULL)
return -1;
......@@ -907,7 +907,7 @@ static int convert_db(struct udev *udev)
if (access(filename, F_OK) < 0)
return 0;
f = fopen("/dev/kmsg", "w");
f = fopen("/dev/kmsg", "we");
if (f != NULL) {
fprintf(f, "<30>systemd-udevd[%u]: converting old udev database\n", getpid());
fclose(f);
......@@ -1264,7 +1264,7 @@ int main(int argc, char *argv[])
sd_notify(1, "READY=1");
}
f = fopen("/dev/kmsg", "w");
f = fopen("/dev/kmsg", "we");
if (f != NULL) {
fprintf(f, "<30>systemd-udevd[%u]: starting version " VERSION "\n", getpid());
fclose(f);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment