chiark / gitweb /
udev: add some O_CLOEXEC
[elogind.git] / src / udev / udevd.c
index a5478a754ed8ab270bf1e0a4c9f533a95ae4b834..176e4e293052e4ced91eadbdd43aec988d78bacf 100644 (file)
@@ -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;
 
@@ -845,10 +845,11 @@ static void static_dev_create_from_modules(struct udev *udev)
                 if (sscanf(devno, "%c%u:%u", &type, &maj, &min) != 3)
                         continue;
 
+                mode  = 0600;
                 if (type == 'c')
-                        mode = S_IFCHR;
+                        mode |= S_IFCHR;
                 else if (type == 'b')
-                        mode = S_IFBLK;
+                        mode |= S_IFBLK;
                 else
                         continue;
 
@@ -870,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;
 
@@ -906,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);
@@ -1263,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);