Skip to contentSkip to conversation

package/makedevs: add "l" type for symlinks ownership change

PATCH New angelo70 at gmail.com 1 participant 1 message Oct 12, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/makedevs: add "l" type for symlinks ownership change

From: Angelo Dureghello <[email protected]>

Add to makedevs the 'l' type, to allow symlinks ownership change. Add related change on the makedevs doc.

---
 docs/manual/makedev-syntax.txt |  1 +
 package/makedevs/makedevs.c    | 12 ++++++++++++
 2 files changed, 13 insertions(+)
docs/manual/makedev-syntax.txt +1 -0
index 2c98531..2392dc1 100644
@@ -27,6 +27,7 @@ There are a few non-trivial blocks here:
   * c: a character device file
   * b: a block device file
   * p: a named pipe
+  * l: a symbolic link, for ownership changes only
 - +mode+, +uid+ and +gid+ are the usual permissions settings
 - +major+ and +minor+ are here for device files - set to - for other
   files
package/makedevs/makedevs.c +12 -0
index ab90b93..026533e 100644
@@ -474,6 +474,18 @@ int main(int argc, char **argv)
 				ret = EXIT_FAILURE;
 				goto loop;
 			}
+		} else if (type == 'l') {
+			struct stat st;
+			if ((lstat(full_name, &st) < 0 || !S_ISLNK(st.st_mode))) {
+				bb_perror_msg("line %d: invalid link for %s", linenum, full_name);
+				ret = EXIT_FAILURE;
+				goto loop;
+			}
+			if (lchown(full_name, uid, gid) == -1) {
+				bb_perror_msg("line %d: chown failed for %s", linenum, full_name);
+				ret = EXIT_FAILURE;
+				goto loop;
+			}
 		} else
 		{
 			dev_t rdev;
Signature · 1 line
1.8.4.rc3