summaryrefslogtreecommitdiff
path: root/miscutils/makedevs.c
diff options
context:
space:
mode:
authorEric Andersen2005-07-18 22:40:59 +0000
committerEric Andersen2005-07-18 22:40:59 +0000
commit90161c92139c03fdcc060e472a764af604d25858 (patch)
tree8806a3c0e001f4a11e9a2f9bf4ce6fe7530d1ff1 /miscutils/makedevs.c
parent7b71d740b9186633b9a4b1d05247376485e2b805 (diff)
downloadbusybox-90161c92139c03fdcc060e472a764af604d25858.zip
busybox-90161c92139c03fdcc060e472a764af604d25858.tar.gz
Fixup makedevs to handle regular files, and also fix
it to properly update file permissions as specified.
Diffstat (limited to 'miscutils/makedevs.c')
-rw-r--r--miscutils/makedevs.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c
index b6473e7..8a40729 100644
--- a/miscutils/makedevs.c
+++ b/miscutils/makedevs.c
@@ -178,7 +178,30 @@ extern int makedevs_main(int argc, char **argv)
ret = EXIT_FAILURE;
goto loop;
}
- } else {
+ if ((mode != -1) && (chmod(full_name, mode) < 0)){
+ bb_perror_msg("line %d: chmod failed for %s", linenum, full_name);
+ ret = EXIT_FAILURE;
+ goto loop;
+ }
+ } else if (type == 'f') {
+ struct stat st;
+ if ((stat(full_name, &st) < 0 || !S_ISREG(st.st_mode))) {
+ bb_perror_msg("line %d: regular file '%s' does not exist", linenum, full_name);
+ ret = EXIT_FAILURE;
+ goto loop;
+ }
+ if (chown(full_name, uid, gid) == -1) {
+ bb_perror_msg("line %d: chown failed for %s", linenum, full_name);
+ ret = EXIT_FAILURE;
+ goto loop;
+ }
+ if ((mode != -1) && (chmod(full_name, mode) < 0)){
+ bb_perror_msg("line %d: chmod failed for %s", linenum, full_name);
+ ret = EXIT_FAILURE;
+ goto loop;
+ }
+ } else
+ {
dev_t rdev;
if (type == 'p') {
@@ -211,6 +234,10 @@ extern int makedevs_main(int argc, char **argv)
bb_perror_msg("line %d: chown failed for %s", linenum, full_name_inc);
ret = EXIT_FAILURE;
}
+ if ((mode != -1) && (chmod(full_name_inc, mode) < 0)){
+ bb_perror_msg("line %d: chmod failed for %s", linenum, full_name_inc);
+ ret = EXIT_FAILURE;
+ }
}
free(full_name_inc);
} else {
@@ -223,6 +250,10 @@ extern int makedevs_main(int argc, char **argv)
bb_perror_msg("line %d: chown failed for %s", linenum, full_name);
ret = EXIT_FAILURE;
}
+ if ((mode != -1) && (chmod(full_name, mode) < 0)){
+ bb_perror_msg("line %d: chmod failed for %s", linenum, full_name);
+ ret = EXIT_FAILURE;
+ }
}
}
loop: