I would like to mount a CIFS network filesystem with samba on my Arch Linux system. I would like to mount this filesystem whenever I log in (either through ssh, a TTY, or through KDM). I can get pretty close to what I want by adding the network share to /etc/fstab. The biggest problem is that this requires either hard coding my password into /etc/fstab or creating a credentials file with my username and password. It seems unsafe to me to keep my username and password in a plain text file even if I set the permissions to 600. Is there a proper way to securely automount a network share? Can I do this with PAM (my username and password are the same on both machines) and if so how? 
Proper way to mount samba share
samba
It turns out that pam_mount is the way to go. You add the network share to /etc/security/pam_mount.conf.xml<volume user=yourUserName fstype=auto path=//path/to/the/network/share mountpoint=/path/to/the/mount/point options=username=yourUserName /><mkmountpoint enable=1 remove=true />It should be theoretically possible to use the %(USER), %(USERUID), and %(USERGID) variables to make it a general mount, but I couldn't get that part to work on Arch Linux. You also need to configure your system to use pam_mount. You need to modify both /etc/pam.d/system-auth and your corresponding login-manager. For KDM it is /etc/pam.d/kde. The modifications basically involve adding optional  pam_mount.so to every section of both files, but the exact details are tricky since the ordering matters. I followed the Arch Wiki.With this setup and the same username/password on the server and my machine I can auto mount without saving a credentials file anywhere.