set mount option noexec on /tmp in coreos-cloudinit

303 views
Skip to first unread message

baldeynz

unread,
May 8, 2017, 10:38:41 PM5/8/17
to CoreOS User
Hi all
Can someone point me in the right direction with how to set mount options on mount points if im still using cloudinit? e.g i need to set "noexec" on /tmp but im not sure whether its possible without using ignition?
thanks
baldeynz

baldeynz

unread,
May 8, 2017, 10:54:17 PM5/8/17
to CoreOS User
I guess to clarify .. i can see that /tmp seemed to be mounted by /usr/lib64/systemd/system/tmp.mount  but how do i over-ride this using cloudinit?

Alex Crawford

unread,
May 9, 2017, 1:01:50 PM5/9/17
to baldeynz, CoreOS User
On 05/08, baldeynz wrote:
> I guess to clarify .. i can see that /tmp seemed to be mounted by
> /usr/lib64/systemd/system/tmp.mount but how do i over-ride this using
> cloudinit?

You can create a systemd drop-in to override the mount options:

$ cat /etc/systemd/system/tmp.mount.d/noexec.conf
[Mount]
Options=mode=1777,strictatime,nosuid,nodev,noexec

This can be done with either Ignition (via a Container Linux Config):

systemd:
units:
- name: tmp.mount
dropins:
- name: noexec.conf
contents: |
[Mount]
Options=mode=1777,strictatime,nosuid,nodev,noexec

It can also be done with a cloud-config:

#cloud-config

coreos:
units:
- name: tmp.mount
drop-ins:
- name: noexec.conf
content: |
[Mount]
Options=mode=1777,strictatime,nosuid,nodev,noexec

While this can be done with either a Container Linux Config or a
cloud-config, I highly recommend against using coreos-cloudinit. Reason
being, on first boot, /tmp won't have the noexec option! You have to
reboot the system in order for this to take effect (because of how late
in the boot process coreos-cloudinit starts). Ignition, on the other
hand, doesn't suffer from these problems.

-Alex
signature.asc

baldeynz

unread,
May 9, 2017, 3:41:21 PM5/9/17
to CoreOS User, bal...@gmail.com
Thanks Alex
Reply all
Reply to author
Forward
0 new messages