<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>So I have been kicking around an idea for a while now and thought I would develop it but its out of my league. The FreeIPA community is very very active in pam/sssd/ldap/so on and so on so I thought I would float the idea here before I made a Trac [RFE] ticket.<br>
<br></div><b></b></div>Would anyone else find it useful to store environment variables in LDAP?  In the environment (no pun intended) I work in we have a few thousand servers all authenticating to LDAP and a home grown LDAP+sshPublicKey implementation which is great.  But we have a bunch of different distros which all have different default editors.  Unless I feel like touching a lot of servers or using cfengine3 to distribute my preferred environment variables I am at the mercy of the editor on the system.<br>
<br>How wonderful would it be to set EDITOR=vim, LESS='-S', TZ='America/Hawaii', LANG='Klingon' in LDAP and have pam/sss pull/store that information for me.  Sort of like pam_env but backed by LDAP.<br>
<br></div>So this got me thinking the other thing that would be wonderful to store in LDAP would be shell profiles...  Consider having your ~/.profile or ~/.bashrc  or ~/.my.cnf or what-have-you in LDAP?<br><br>Maybe this modified pam_ldap could do things like append, remove, replace or unset environment variables.  Consider:<br>
<br></div>dn: uid=me,dc=example,dc=com<br></div><div>objectClass: posixAccountEnv<br></div><div>...<br></div># replace EDITOR<br></div><div>posixEnv: EDITOR=vim<br></div><div># unset TZ<br></div>posixEnv: TZ-=<br></div><div>
# append PATH<br></div>posixEnv: PATH=+:~/bin<br></div><div># prepend PATH<br></div><div>posixEnv: PATH+=/opt/foo/bin:<br></div><br></div>Further perhaps the PAM module could be configured to only allow certain environment variables to be manipulated this way admins can control which variables users can set.<br>
<br></div><div>/etc/ldap/pam_ldap.conf:<br>...<br></div><div># allow<br></div><div>pam_allow_env_vars PATH,EDITOR<br></div><div># deny<br></div><div>pam_deny_env_vars PATH,TZ<br></div><div># wildcards? regex?<br></div><div>
pam_allow_env_vars LC_*,PATH,EDITOR<br></div><div>pam_deny_env_vars TZ<br></div><div><br></div><div>So if we're storing environment variables in LDAP why not profiles or small files?  ~/.bashrc, ~/.my.cnf, ~/.ssh/config?  Sure there's some overlap with env vars because you could set them in your profile but with both options an admin is free to choose.  <br>
</div><div><br></div>I can think of a couple of ways to implement this.<br></div>1. create subortinate objects to the user object<br></div>dn: cn=~/.bashrc,uid=me,dc=example,dc=com<br>...<br></div>objectClass: posixAccountProfile<br>
</div>posixProfile: <octet string><br><br></div><div>Advantages: The advantage of this setup is that the profileScript class could contain any number of attributes, perhaps a modified time so that the script isn't rewritten if the subordinate object hasn't been modified since the script was last modified.<br>
<br></div><div>Disadvantages: Kinda kludgy.  Extra objects (more lookups).<br></div><div><br></div>2. Use LDAP attribute options (See <a href="http://www.ietf.org/rfc/rfc2251.txt">http://www.ietf.org/rfc/rfc2251.txt</a> RFC 2251 "4.1.5. Attribute Description" if not familiar) <br>
</div>dn: uid=me,dc=example,dc=com<br>...<br></div>posixProfile;~/.bashrc: <octet string><br></div>posixProfile;~/.my.cnf: <octet string><br><br></div>Advantages: No extra objects, makes use of oft unused LDAP attribute options :), can have ACI's applied to them.<br>
Disadvantages: Only modified time to track is modified time of the LDAP object not individual profileScript attrs<br><br></div>In both cases it might be wise to consider how file names are specified.  Perhaps leave off the ~/ and make everything relative to ~ no matter what.  Or make everything relative to ~/ even if it starts w/ a '/'.  Maybe simply reject anything that begins with '/'.<br>
<br>dn: uid=me,dc=example,dc=com<br>...<br></div>posixProfile;.bashrc: <octetString><br></div>posixProfile;.foo/foorc: <octetstring><br><div><div><br>Plus I don't know if / and . are legitimate characters in attribute options.<br>
<br></div><div>So thanks for sticking with me if you got this far.  What do you think?<br><br></div><div>Regards,<br></div><div>-Alan<br></div></div></div>