I'm not sure I understand what you're trying to do. If you're just trying to make a login command that lets a process become another user, there already is one. Look at /sys/src/cmd/auth/login.c or man login. Then you can then start a factotum as yourself.