In OpenSSH one can declare a subsystem in the configuration file (/etc/ssh/sshd_config) or force a command such as svnserve to be executed by including this in the authorized_keys line for a particular key like this:
command="svnserve -t --tunnel-user=alice" ssh-dss AAAA...
command="svnserve -t --tunnel-user=bob" ssh-dss AAAA...
thus allowing the same system user to be reused for different "identities" within the Subversion (svnserve) context.
How would I go about to write a service like svnserve myself, allowing to specify the use of the tunnel and how exactly is the data transmitted in these cases? In particular how does the svnserve instance "know" by which means to output the data or read input? Does this all happen via stdout and stdin in such a case and if so, will there be a way to distinguish stderr as well?
I imagine the subsystem and the command= are using the same mechanism, but please correct me if I'm wrong.
(I left no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty out for brevity, but I am aware of them and their use for the scenario.)