source: scripts/patches/udev-027-permissions-1.patch@ 0547e59

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 0547e59 was 7f65c0e, checked in by Jim Gifford <clfs@…>, 19 years ago

r625@server (orig r623): jim | 2005-10-31 12:43:24 -0800
Final Move

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[617118d]1Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
2Date: 2004-06-21
3Initial Package Version: 027
4Origin: Jim Gifford and Zack Winkles
5Upstream Status: N/A
6Description: Reverts tweak node unlink handling
7 http://linuxusb.bkbits.net:8080/udev/cset@1.759?nav=index.html|tags|ChangeSet@..1.7601
8
9 Symptons of problem: When cron executes a bash script, /dev/null changes from the
10 permissions lists in udev.rules to 600. This patch seems to correct the issue,
11 I am submitting it as a temporary fix util a better fix can be found.
12
13diff -Naur udev-027.orig/udev-add.c udev-027/udev-add.c
14--- udev-027.orig/udev-add.c 2004-06-14 16:38:35.000000000 -0400
15+++ udev-027/udev-add.c 2004-06-21 12:44:15.422138488 -0400
16@@ -105,46 +105,29 @@
17 return 0;
18 }
19
20-static int make_node(char *file, int major, int minor, unsigned int mode, uid_t uid, gid_t gid)
21+static int make_node(char *filename, int major, int minor, unsigned int mode, uid_t uid, gid_t gid)
22 {
23- struct stat stats;
24- int retval = 0;
25-
26- if (stat(file, &stats) != 0)
27- goto create;
28-
29- /* preserve node with already correct numbers, to not change the inode number */
30- if (((stats.st_mode & S_IFMT) == S_IFBLK || (stats.st_mode & S_IFMT) == S_IFCHR) &&
31- (stats.st_rdev == makedev(major, minor))) {
32- dbg("preserve file '%s', cause it has correct dev_t", file);
33- goto perms;
34- }
35-
36- if (unlink(file) != 0)
37- dbg("unlink(%s) failed with error '%s'", file, strerror(errno));
38- else
39- dbg("already present file '%s' unlinked", file);
40+ int retval;
41
42-create:
43- retval = mknod(file, mode, makedev(major, minor));
44+ retval = mknod(filename, mode, makedev(major, minor));
45 if (retval != 0) {
46 dbg("mknod(%s, %#o, %u, %u) failed with error '%s'",
47- file, mode, major, minor, strerror(errno));
48+ filename, mode, major, minor, strerror(errno));
49 goto exit;
50 }
51
52-perms:
53- dbg("chmod(%s, %#o)", file, mode);
54- if (chmod(file, mode) != 0) {
55- dbg("chmod(%s, %#o) failed with error '%s'", file, mode, strerror(errno));
56+ dbg("chmod(%s, %#o)", filename, mode);
57+ if (chmod(filename, mode) != 0) {
58+ dbg("chmod(%s, %#o) failed with error '%s'",
59+ filename, mode, strerror(errno));
60 goto exit;
61 }
62
63 if (uid != 0 || gid != 0) {
64- dbg("chown(%s, %u, %u)", file, uid, gid);
65- if (chown(file, uid, gid) != 0) {
66+ dbg("chown(%s, %u, %u)", filename, uid, gid);
67+ if (chown(filename, uid, gid) != 0) {
68 dbg("chown(%s, %u, %u) failed with error '%s'",
69- file, uid, gid, strerror(errno));
70+ filename, uid, gid, strerror(errno));
71 goto exit;
72 }
73 }
74@@ -184,6 +167,23 @@
75 endutent();
76 }
77
78+static int unlink_entry(char *filename)
79+{
80+ struct stat stats;
81+ int retval = 0;
82+
83+ if (lstat(filename, &stats) == 0) {
84+ if ((stats.st_mode & S_IFMT) != S_IFDIR) {
85+ retval = unlink(filename);
86+ if (retval) {
87+ dbg("unlink(%s) failed with error '%s'",
88+ filename, strerror(errno));
89+ }
90+ }
91+ }
92+ return retval;
93+}
94+
95 static int create_node(struct udevice *dev, int fake)
96 {
97 char filename[NAME_SIZE];
98@@ -253,6 +253,7 @@
99 }
100
101 if (!fake) {
102+ unlink_entry(filename);
103 info("creating device node '%s'", filename);
104 if (make_node(filename, dev->major, dev->minor, dev->mode, uid, gid) != 0)
105 goto error;
106@@ -269,6 +270,7 @@
107 for (i = 1; i <= dev->partitions; i++) {
108 strfieldcpy(partitionname, filename);
109 strintcat(partitionname, i);
110+ unlink_entry(partitionname);
111 make_node(partitionname, dev->major,
112 dev->minor + i, dev->mode, uid, gid);
113 }
114@@ -302,9 +304,11 @@
115
116 strfieldcat(linktarget, &dev->name[tail]);
117
118+ if (!fake)
119+ unlink_entry(filename);
120+
121 dbg("symlink(%s, %s)", linktarget, filename);
122 if (!fake) {
123- unlink(filename);
124 if (symlink(linktarget, filename) != 0)
125 dbg("symlink(%s, %s) failed with error '%s'",
126 linktarget, filename, strerror(errno));
Note: See TracBrowser for help on using the repository browser.