ssh host1 -l user1
who am i
$ user1 pts/5
pbrun su - service1
who am i
$ service1 /dev/pts/2
So how can service1 session determine that is was launched by user1?
This worked for me;
w>w.log
# account
grep "$0" w.log | cut -f1 -d " "
# pty
grep "$0" w.log | cut -f2 -d " "