summaryrefslogtreecommitdiff
blob: 5130816f24f341e1d2cdcae363aff6109e57711c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
--- evms-2.5.5.orig/engine/discover.c
+++ evms-2.5.5/engine/discover.c
@@ -28,6 +28,8 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+#include <sys/types.h>
+#include <grp.h>
 
 #include "fullengine.h"
 #include "discover.h"
@@ -162,9 +164,23 @@
 	int rc = 0;
 	dev_t devt = makedev(major, minor);
 	char dir_name[EVMS_OBJECT_NODE_PATH_LEN + EVMS_NAME_SIZE + 1];
+	struct group *disk;
 
 	LOG_PROC_ENTRY();
 
+	/* 
+	 * Debian-specific: We want all devices to be owned by the
+	 * group disk, not root.
+	 */
+	disk = getgrnam("disk");
+	if (disk) {
+		if (setegid(disk->gr_gid) != 0) {
+			LOG_WARNING("could not setegid to group disk (%s), continuing as group root\n", strerror(errno));
+		}
+	} else {
+		LOG_WARNING("could not find group disk (%s), continuing as group root\n", strerror(errno));
+	}
+	
 	/* Make sure major:minor is valid. */
 	if (major != 0) {
 		switch (hasa_dev_node(name, major, minor)) {
@@ -227,6 +243,12 @@
 		LOG_DEBUG("Device node %s is for major %d, minor %d.\n", name, major, minor);
 	}
 
+	if (disk) {
+		if (setegid(getgid()) != 0) {
+			LOG_WARNING("could not setegid back to old group (%s)\n", strerror(errno));
+		}
+	}
+
 	LOG_PROC_EXIT_INT(rc);
 	return rc;
 }