#!/usr/sbin/cfagent -f

control:
   any::
   actionsequence = ( editfiles )
   EditFileSize = ( 30000 )

editfiles:
   any::
     	{ ${target}/etc/fuse.conf
          SetCommentStart "#"
          UnCommentLinesMatching "#user_allow_other"
	}

	{ ${target}/etc/security/pam_mount.conf.xml
          # We need to first mount sshfs to some location other than $HOME, because of a deadlock fuse/ssh
          # when mounting directly to $HOME. (Perhaps related to ~/.ssh in the home directory).
          BeginGroupIfNoSuchLine '<!-- Debian-LAN -->'
            LocateLineMatching '\s*<!-- Volume definitions -->'
            InsertLine '<!-- Debian-LAN -->'
            InsertLine '<volume fstype="fuse" path="sshfs#%(USER)@mainserver:" mountpoint="/home/%(USER)"'
            InsertLine '        options="GSSAPIAuthentication=yes,StrictHostKeyChecking=no,allow_root" />'
            InsertLine '<volume path="/home/%(USER)" mountpoint="~" options="bind" />'
          EndGroup
	}
