summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-08-27 17:39:58 +0200
committerDave Reisner <dreisner@archlinux.org>2013-08-28 13:37:50 +0200
commit9c1a65a9c82080dec2e52d03613584bbc1340cf0 (patch)
tree654fd97d7b24697e25eb91de4be88c1540e4a8eb
parent60475ade761e85ef2c1b0f2daef569b134d44fc0 (diff)
downloadmkinitcpio-9c1a65a9c82080dec2e52d03613584bbc1340cf0.tar.gz
mkinitcpio-9c1a65a9c82080dec2e52d03613584bbc1340cf0.tar.xz
mkinitcpio: preserve permissions if run as root
Running as non-root is usually for my own dev purposes, but someone might do this and be surprised when a directory/file that needs permissions other than root isn't preserved. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rwxr-xr-xmkinitcpio6
1 files changed, 5 insertions, 1 deletions
diff --git a/mkinitcpio b/mkinitcpio
index 2d8c579..8139ee0 100755
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -203,8 +203,12 @@ build_image() {
;;
esac
- cpio_opts=('-R' '0:0' '-0' '-o' '-H' 'newc')
+ cpio_opts=('-0' '-o' '-H' 'newc')
(( _optquiet )) && cpio_opts+=('--quiet')
+ if (( EUID != 0 )); then
+ warning 'Not building as root, ownership cannot be preserved'
+ cpio_opts+=('-R' '0:0')
+ fi
# write version stamp
printf '%s' "$version" > "$BUILDROOT/VERSION"