Patchwork [v3,1/5] makedevs: Create blocks of devices with the correct uid/gid

login
register
mail settings
Submitter Peter Kjellerstedt
Date May 30, 2013, 12:18 p.m.
Message ID <2e7062acdcc5114d0b1dd9b90344b6ff85e6c4a8.1369916015.git.pkj@axis.com>
Download mbox | patch
Permalink /patch/50825/
State New
Headers show

Comments

Peter Kjellerstedt - May 30, 2013, 12:18 p.m.
When creating a block of devices (i.e., when count > 0), the wrong
path was used with the call to chown(), effectively trying to change
the owner of some (probably) non-existent file. Thus the created
device nodes were always owned by root.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch

diff --git a/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c b/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
index c7ad722..247d6c1 100644
--- a/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
+++ b/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
@@ -130,7 +130,7 @@  static void add_new_device(char *name, char *path, unsigned long uid,
 		timestamp = sb.st_mtime;
 	}
 
-	mknod(name, mode, rdev);
+	mknod(path, mode, rdev);
 	chown(path, uid, gid);
 //	printf("Device: %s %s  UID: %ld  GID: %ld  MODE: %ld  MAJOR: %d  MINOR: %d\n",
 //			path, name, uid, gid, mode, (short)(rdev >> 8), (short)(rdev & 0xff));
@@ -198,7 +198,7 @@  static int interpret_table_entry(char *line)
 		error_msg_and_die("Device table entries require absolute paths");
 	}
 	name = xstrdup(path + 1);
-	sprintf(path, "%s/%s\0", rootdir, name);
+	sprintf(path, "%s/%s", rootdir, name);
 
 	switch (type) {
 	case 'd':
@@ -223,6 +223,7 @@  static int interpret_table_entry(char *line)
 
 			for (i = start; i < count; i++) {
 				sprintf(buf, "%s%d", name, i);
+				sprintf(path, "%s/%s%d", rootdir, name, i);
 				/* FIXME:  MKDEV uses illicit insider knowledge of kernel 
 				 * major/minor representation...  */
 				rdev = MKDEV(major, minor + (i * increment - start));