`mender-artifact install` doesn't respect the provided mode

I’m using mender-artifact install -m <mode> <src> <dst> to install files into a mender artifact, but I’m seeing the file created with the same permissions as the src file, instead of permissions set by the mode flag.

Here are the steps I’m following:

$ stat -c %a src_file
644
$ mender-artifact install -m 0777 src_file artifact.mender:/dst_file
$ tar -xf artifact.mender
$ tar -xzf data/0000.tar.gz
$ debugfs file-system.ext4
debugfs: stat /dst_file
Inode: 3958   Type: regular    Mode:  0600   Flags: 0x80000
Generation: 0    Version: 0x00000000
User:     0   Group:     0   Size: 23707147
File ACL: 0
Links: 1   Blockcount: 46304
Fragment:  Address: 0    Number: 0    Size: 0
ctime: 0x5db20f50 -- Thu Oct 24 20:53:36 2019
atime: 0x5db20f50 -- Thu Oct 24 20:53:36 2019
mtime: 0x5db20f50 -- Thu Oct 24 20:53:36 2019

I’ve added some logic to the mender-artifact install command to verify the mode value I’m passing in is being parsed correctly (0755 parses as -rwxr-xr-x for instance), but it seems like the mode value is not available at the time we actually create the dst file with a debugfs command.

I noticed there’s also a unit test in copy_test.go for Install file, standard permissions (0600), but it’s failing on my machine. Has anyone seen similar behavior or have an idea what’s going on here?

I’m happy to dig in and experiment a little, but I’m not super familiar with Go. Thanks for the help!

Ah, I should call out, I’m using mender-artifact v3.1.0

Tagging @oleorhagen

^ This isn’t quite the right description. This test passes on the mainline 3.1.0 tag, but it fails if I change the test to try installing different permissions. It seems like all files installed with -m get created with the standard 0600 permissions.

hi @sbaxter-izo. I have been able to reproduce this, and you are absolutely right of course. Created a ticket for it here: https://tracker.mender.io/browse/MEN-2880, if you would like to follow the progress.

Great, thanks for the link. I’ll keep an eye out for fixes.