source:
scripts/patches/udev-027-permissions-1.patch@
8185815
Last change on this file since 8185815 was 7f65c0e, checked in by , 19 years ago | |
---|---|
|
|
File size: 3.8 KB |
-
udev-add.c
Submitted By: Jim Gifford (jim at linuxfromscratch dot org) Date: 2004-06-21 Initial Package Version: 027 Origin: Jim Gifford and Zack Winkles Upstream Status: N/A Description: Reverts tweak node unlink handling http://linuxusb.bkbits.net:8080/udev/cset@1.759?nav=index.html|tags|ChangeSet@..1.7601 Symptons of problem: When cron executes a bash script, /dev/null changes from the permissions lists in udev.rules to 600. This patch seems to correct the issue, I am submitting it as a temporary fix util a better fix can be found. diff -Naur udev-027.orig/udev-add.c udev-027/udev-add.c
old new 105 105 return 0; 106 106 } 107 107 108 static int make_node(char *file , int major, int minor, unsigned int mode, uid_t uid, gid_t gid)108 static int make_node(char *filename, int major, int minor, unsigned int mode, uid_t uid, gid_t gid) 109 109 { 110 struct stat stats; 111 int retval = 0; 112 113 if (stat(file, &stats) != 0) 114 goto create; 115 116 /* preserve node with already correct numbers, to not change the inode number */ 117 if (((stats.st_mode & S_IFMT) == S_IFBLK || (stats.st_mode & S_IFMT) == S_IFCHR) && 118 (stats.st_rdev == makedev(major, minor))) { 119 dbg("preserve file '%s', cause it has correct dev_t", file); 120 goto perms; 121 } 122 123 if (unlink(file) != 0) 124 dbg("unlink(%s) failed with error '%s'", file, strerror(errno)); 125 else 126 dbg("already present file '%s' unlinked", file); 110 int retval; 127 111 128 create: 129 retval = mknod(file, mode, makedev(major, minor)); 112 retval = mknod(filename, mode, makedev(major, minor)); 130 113 if (retval != 0) { 131 114 dbg("mknod(%s, %#o, %u, %u) failed with error '%s'", 132 file , mode, major, minor, strerror(errno));115 filename, mode, major, minor, strerror(errno)); 133 116 goto exit; 134 117 } 135 118 136 perms: 137 dbg("chmod(%s, %#o)", file, mode);138 if (chmod(file, mode) != 0) {139 dbg("chmod(%s, %#o) failed with error '%s'", file, mode, strerror(errno));119 dbg("chmod(%s, %#o)", filename, mode); 120 if (chmod(filename, mode) != 0) { 121 dbg("chmod(%s, %#o) failed with error '%s'", 122 filename, mode, strerror(errno)); 140 123 goto exit; 141 124 } 142 125 143 126 if (uid != 0 || gid != 0) { 144 dbg("chown(%s, %u, %u)", file , uid, gid);145 if (chown(file , uid, gid) != 0) {127 dbg("chown(%s, %u, %u)", filename, uid, gid); 128 if (chown(filename, uid, gid) != 0) { 146 129 dbg("chown(%s, %u, %u) failed with error '%s'", 147 file , uid, gid, strerror(errno));130 filename, uid, gid, strerror(errno)); 148 131 goto exit; 149 132 } 150 133 } … … 184 167 endutent(); 185 168 } 186 169 170 static int unlink_entry(char *filename) 171 { 172 struct stat stats; 173 int retval = 0; 174 175 if (lstat(filename, &stats) == 0) { 176 if ((stats.st_mode & S_IFMT) != S_IFDIR) { 177 retval = unlink(filename); 178 if (retval) { 179 dbg("unlink(%s) failed with error '%s'", 180 filename, strerror(errno)); 181 } 182 } 183 } 184 return retval; 185 } 186 187 187 static int create_node(struct udevice *dev, int fake) 188 188 { 189 189 char filename[NAME_SIZE]; … … 253 253 } 254 254 255 255 if (!fake) { 256 unlink_entry(filename); 256 257 info("creating device node '%s'", filename); 257 258 if (make_node(filename, dev->major, dev->minor, dev->mode, uid, gid) != 0) 258 259 goto error; … … 269 270 for (i = 1; i <= dev->partitions; i++) { 270 271 strfieldcpy(partitionname, filename); 271 272 strintcat(partitionname, i); 273 unlink_entry(partitionname); 272 274 make_node(partitionname, dev->major, 273 275 dev->minor + i, dev->mode, uid, gid); 274 276 } … … 302 304 303 305 strfieldcat(linktarget, &dev->name[tail]); 304 306 307 if (!fake) 308 unlink_entry(filename); 309 305 310 dbg("symlink(%s, %s)", linktarget, filename); 306 311 if (!fake) { 307 unlink(filename);308 312 if (symlink(linktarget, filename) != 0) 309 313 dbg("symlink(%s, %s) failed with error '%s'", 310 314 linktarget, filename, strerror(errno));
Note:
See TracBrowser
for help on using the repository browser.