Hello,

on Wednesday 09 May 2012 at 11:26, Lluís Batlle i Rossell wrote:
> On Tue, May 08, 2012 at 10:06:15PM -0400, Martin Gagnon wrote:
> > On Wed, May 09, 2012 at 12:09:36AM +0200, Lluís Batlle i Rossell wrote:
> > > On Tue, May 08, 2012 at 05:55:38PM -0400, Leo Razoumov wrote:
> > > >            9.   Runs user's shell or command.
> > > But I don't know why the sshd man page does not say that though. :)
> > 
> > This is for bash... But for ksh (default on OpenBSD and QNX for
> > instance) any echo on .kshrc or on .profile will *not* appear when
> > doing: "ssh host command" neither with "ssh -T host command".
> > 
> > There's a chance that sshd manpage expect ksh behavior since openssh is
> > developped by OpenBSD crowd and their system use ksh by default..
> 
> Ah very interesting.
> And can you run: ssh host "cat < ~/.kshrc"
> ?
> 
> If so, it would mean the command is run by ksh, and not by sshd.

Why resort to dubious experimentation when code source is available?
Truth lies in the source code. I gather the relevant code is at the end
of do_child() from session.c

    /*
     * If we have no command, execute the shell.  In this case, the shell
     * name to be passed in argv[0] is preceded by '-' to indicate that
     * this is a login shell.
     */
     if (!command) {
[...]
         execve(shell, argv, env);
[...]
         perror(shell);
         exit(1);
     }
     /*
      * Execute the command using the user's shell.  This uses the -c
      * option to execute the command.
      */
     argv[0] = (char *) shell0;
     argv[1] = "-c";
     argv[2] = (char *) command;
     argv[3] = NULL;
     execve(shell, argv, env);
     perrror(shell);
     exit(1);
}


Greping across the source for `exec[a-z ]*(` provides with few enough
results to check them all; but the code flow for `ssh host command` is
quite simple, jumping from client code to server code through a
grep '"exec"'.


So I admit I was wrong, as far as I can tell `ssh host command` does
spawn a shell. I guess I was misled by my own dubious experimentation:
`ssh host pstree` showed pstree as a direct child of sshd, but it seems
my shell (zsh) uses exec() to run pstree, while sh and tcsh don't (and
so appear between sshd and pstree).

However I have no idea about the behavior of bash or ksh with regard to
banners or startup scripts.


Hoping this helps,
Natacha

Attachment: pgpSjG0lssfIV.pgp
Description: PGP signature

_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to