Fix incorrect handing of chmod