lightdm, the display manager in Ubuntu allows running session setup scripts as root if you add appropriate entry to
/etc/lightdm/lightdm.conf file (Note, that this file doesn't exist as of 14.04, you have to manually create it).
Example of how it might look like
# session-setup-script = Script to run when starting a user session (runs as root)
# session-cleanup-script = Script to run when quitting a user session (runs as root)