-
Notifications
You must be signed in to change notification settings - Fork 66
Ensure unprivileged users have unique tmp and home dirs #1278
base: master
Are you sure you want to change the base?
Conversation
84bf2e1
to
ab088eb
Compare
c86170c
to
13b07cf
Compare
Oh, also to explain; we override |
8045dc3
to
7db2d5b
Compare
# see if user still has any prescence on this machine | ||
pgrep -u "$PAM_USER" && exit 0 | ||
# if no prescense of user, remove all trace of their activity | ||
rm -rf "<%= @polyinstantion_dir %>/home_$PAM_USER" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chris asks please ensure that hardlink traversal isn't a risk here.
cookbooks/bcpc/recipes/pam.rb
Outdated
source 'pam_namespace.conf.erb' | ||
mode 500 | ||
variables(lazy {{ real_home_dir_users: | ||
node['bcpc']['pam_namespace']['real_home_dir_users'].join(','), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ron asks, please .uniq
on node['bcpc']['pam_namespace']['real_home_dir_users']
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly also sort.
cookbooks/bcpc/recipes/pam.rb
Outdated
source 'pam_namespace.conf.erb' | ||
mode 500 | ||
variables(lazy {{ real_home_dir_users: | ||
node['bcpc']['pam_namespace']['real_home_dir_users'].join(','), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this would work, since I haven't tested it: Working. See below comment.
node['bcpc']['pam_namespace']['real_home_dir_users'].join(','), | |
node['bcpc']['pam_namespace']['real_home_dir_users'].uniq.sort.join(','), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems ok
[1] pry(main)> blah = %w(hdfs hdfs yarn hbase mapred hdfs hbase yarn mapred mapred hdfs hbase hadoop)
=> ["hdfs", "hdfs", "yarn", "hbase", "mapred", "hdfs", "hbase", "yarn", "mapred", "mapred", "hdfs", "hbase", "hadoop"]
[2] pry(main)> blah.uniq.sort.join(',')
=> "hadoop,hbase,hdfs,mapred,yarn"
All requested changes made |
Also DRY-up sysctl/pam code repeated in Kafka and Hadoop; should be in BCPC
directory '/inst-dirs' do | ||
user 'root' | ||
group 'root' | ||
mode 0o000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mode 0o000 | |
mode 0o0000 |
|
||
if [ -z "$PAM_TYPE" -o "$PAM_TYPE" == "open_session" ]; then | ||
# need to setup the polyinstantation directory for login | ||
mkdir -pm 000 "/dev/shm/<%= @shm_polyinstantion_dir %>" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this got merged out:
mkdir -pm 000 "/dev/shm/<%= @shm_polyinstantion_dir %>" \ | |
mkdir -pm 0000 "/dev/shm/<%= @shm_polyinstantion_dir %>" \ |
This PR introduces pam_namespaces to ensure that each user gets its own kernel usernamespace for its potential state directories that are managed outside YARN. One further addition is automatic creation and clean-up of directories as needed using pam_exec.
Providing per-user namespaces means we can prevent accidental data sharing and we will prevent many imporoper uses of temporary directories by pro-actively cleaning them up. We have seen many users impact themselves with both anti-patterns and similarly when a user disconnects we will ensure they stop taking up space on our root partition for what should be their ephemeral home directory. We will need to notify users of this change!
The directories affected are listed in `/etc/secuirty/namespaces.conf. Users listed in that file are excluded from that line.
The directories created in
inst_dir.sh.erb
are the necessary directories for pam_namespace to create directories and when the user is no longer running any processes and the user terminations its session the script is called to remove the directories. (If one usesnohup
or such you can hold your directory around I think but I am not too concerned about that right now; we can write clean-up logic if need be later; similarly no quotas are introduced here but use of ZFS or possibly LVM could allow us to easily do that.)The structure under the polyinstantion directory looks like follows; and inside each directory is what the user see: