Changing usernames

From Netsoc Wiki
Revision as of 01:10, 23 October 2012 by Stesh (talk | contribs)
Jump to: navigation, search

Now and again users will ask that their netsoc username be changed to something other than what they signed up with originally. This isn't too hard, but it's just a little fiddly to get right. You should not try to accomplish this by just creating a new account with that name, then chown -R'ing their files or whatever. There are far too many things to clean up once a single user corresponds to several UID numbers.

As far as I can remember, you need to do the following (the order shouldn't matter too much, but doing it in this order minimizes broken things:

Redirect their mail

Add a redirect in /etc/aliases on spoon so that mail to the old username will still arrive in the user's mail spool:

# oldusername changed username to newusername on $date
oldusername: newusername

Don't run newaliases just yet, so that the user continues to receive mail while you work.

Now, rename their local mail spool on spoon to reflect the new username, and temporarily link to the old username:

# mv /var/spool/mail/{oldusername, newusername}
# ln -s /var/spool/mail{newusername, oldusername}

Change their credentials in LDAP

Log into the LDAP directory by vzctl enter'ing the container on cuberoot.

You need to grab the relevant User object, and change a few things:

u = User('oldusername')
g = u.get_personal_group()

u.uid = 'newusername' # change their UID
g.cn = 'newusername' # change their personal group's GID
User.forbid_username('old_username') # prevent people from signing up with the old username in the future
u.comment('changed username from "oldusername" to "newusername"') # Record the fact that you just did this

Flip their mail over to the new account

# rm /var/spool/mail/oldusername
# newaliases

rename their homedirs

Log into cuberoot, and move their homedir and webspace to the new username:

# mv /srv/userhome/{oldusername,newusername}
# mv /srv/userweb/{oldusername,newusername}

Log into spoon and do likewise:

# mv /home/{oldusername,newusername}

Fix their webspace

At this point apache on userweb still thinks their webspace is in the old location, so you need to reload:

# invoke-rc.d apache2 reload

Redirect their old webspace to their new webspace

This is accomplished by adding regex config magic to /etc/lighttpd/sites/somethingorother on cubewww. Some day I'll give an example.

Fix their MySQL account

I've never actually had to do this, but you may have to log in as root on MySQL on user web and rename the user's database from "u_oldusername" to "u_newusername" . It might be necessary to change their MySQL username in the Users table, but I have a feeling that the update_ldap_mysql script takes care of this in due course once LDAP changes.


Fix o-lines, etc. in IRC

You're unlikely to have to do this, unless you're changing your own user account (most users don't have o-lines).

Edit the username in /etc/ircd-hybrid/ircd.conf on cubeirc to reflect the new username. Also rehash the config in your IRC client using /REHASH


Anything else?

Am I missing anything?