Thursday, December 4, 2014

am i slob or am i lazy? let's find -exec chown

 le sigh. LE SIGH. sometimes people like to do things on their own out of expediency or   
 because their local sysadmin is a lazy lazy lazy slob.
  
 i'm not a slob.  

 the issue was that someonenotme updated ubuntu and nfs was broke. or rather,   
 their home dir wasn't mounted.  

 this had been the case for months.   

 sure, i could put this line in /etc/fstab and go my merry way:  

 slobberserver:/home     /home     nfs   rsize=8192,wsize=8192,soft,_netdev   0 0  

 but, i'm not a slob.  

 see that _netdev? that's an awesome directive that says, "hey linuxbox  
 do not mount me till the network stack it up". awesome.  

 here's what you do:  

 record someonenotme's local system uid & gid  
 # id someonenotme  
 uid=1000(someonenotme) gid=1000(someonenotme)  

 kill all someonenotme processes  
 # kill -9 `ps -ef|grep someonenotme| awk '{print $2}'`  

 really really?  
 # lsof |grep someonenotme  
 ... nada ...  

 ldap & nfs-ize the system  
 # apt-get install nscd autofs ldap-client  

 put all your specially conf'd ldap conf files in /etc  

 refresh the name service  
 # /etc/init.d/nscd restart  

 # id someonenotme  
 uid=15288(someonenotme) gid=101(someonenotme) groups=100(users)  

 edit passwd and change someonenotme's uid and gid to that in ldap.  

 oh, and make sure the homedir matches, too.  
 # vipasswd  

 now we change all the uids and gids so that someonenotme matches what we have in ldap.  
 to prevent an unfun time, first umount all nfs mounts of interest.  
 # umount /home  

 now we look and change:  
 # find / -uid 1000 -gid 1000 -exec chown 15288:101 {} \;   

 after this is complete, mount -a and go about your business.  

 but wait! you cd'd into their dir, didn't you?  you saw they've done stuff as root 
 in the past.  crud.  why did you ls -la?
 # find /home/someonenotme -uid 0 -gid 0 -exec chown 15288:101 {} \;

 still not a slob.  

No comments: