Hi

I'm using Image Builder to build an image suitable for Vagrant (a tool that scripts VirtualBox VM setup).

One of the requirements for such a VM is that it has a user called 'vagrant', with a public ssh key in /home/vagrant/.ssh/authorized_keys

Adding these files with image builder was easy (you can see them here if you're curious): https://github.com/marcosscriven/vagran … stom-files

However, the permissions are all reset in https://dev.openwrt.org/browser/trunk/i … 45673#L245

5    define Image/mkfs/prepare/default
246            # Use symbolic permissions to avoid clobbering SUID/SGID/sticky bits
247            - $(FIND) $(TARGET_DIR) -type f -not -perm /0100 -not -name 'ssh_host*' -not -name 'shadow' -print0 | $(XARGS) -0 chmod u+rw,g+r,o+r
248            - $(FIND) $(TARGET_DIR) -type f -perm /0100 -print0 | $(XARGS) -0 chmod u+rwx,g+rx,o+rx
249            - $(FIND) $(TARGET_DIR) -type d -print0 | $(XARGS) -0 chmod u+rwx,g+rx,o+rx
250            $(INSTALL_DIR) $(TARGET_DIR)/tmp $(TARGET_DIR)/overlay
251            chmod 1777 $(TARGET_DIR)/tmp
252    endef

The only way I could find around this was manually patching beforehand:

--- image.mk.origin    2015-06-17 19:03:22.324000000 +0100
+++ image.mk    2015-06-17 19:08:53.108000000 +0100
@@ -253,6 +253,9 @@

define Image/mkfs/prepare
    $(call Image/mkfs/prepare/default)
+                chmod 0700 $(TARGET_DIR)/home/vagrant/.ssh/
+                chmod 0600 $(TARGET_DIR)/home/vagrant/.ssh/authorized_keys
+                chmod ugo-w $(TARGET_DIR)/home/vagrant
endef

This seems a bit hacky, and I wonder if there was a better way?

My full build script it here: https://github.com/marcosscriven/vagran … r/build.sh

If the files don't have these permissions, ssh fails to login using pre-shared keys.