fixed: [patch] fix to ForceCommand to support additional arguments tointernal-sftp - openssh

This is a discussion on fixed: [patch] fix to ForceCommand to support additional arguments tointernal-sftp - openssh ; The previous version broke the case of internal-sftp without arguments. This is a fixed version. --- /var/tmp/session.c 2008-08-18 21:07:10.000000000 -0700 +++ session.c 2008-08-19 11:28:29.000000000 -0700 @@ -781,7 +781,7 @@ if (options.adm_forced_command) { original_command = command; command = options.adm_forced_command; - if ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: fixed: [patch] fix to ForceCommand to support additional arguments tointernal-sftp

  1. fixed: [patch] fix to ForceCommand to support additional arguments tointernal-sftp

    The previous version broke the case of internal-sftp without arguments. This
    is a fixed version.

    --- /var/tmp/session.c 2008-08-18 21:07:10.000000000 -0700
    +++ session.c 2008-08-19 11:28:29.000000000 -0700
    @@ -781,7 +781,7 @@
    if (options.adm_forced_command) {
    original_command = command;
    command = options.adm_forced_command;
    - if (strcmp(INTERNAL_SFTP_NAME, command) == 0)
    + if (strcmp(INTERNAL_SFTP_NAME, command) == 0 ||
    strncmp(INTERNAL_SFTP_NAME, command, strlen(INTERNAL_SFTP_NAME)) == 0 &&
    isspace(command[strlen(INTERNAL_SFTP_NAME)]))
    s->is_subsystem = SUBSYSTEM_INT_SFTP;
    else if (s->is_subsystem)
    s->is_subsystem = SUBSYSTEM_EXT;
    @@ -789,7 +789,7 @@
    } else if (forced_command) {
    original_command = command;
    command = forced_command;
    - if (strcmp(INTERNAL_SFTP_NAME, command) == 0)
    + if (strcmp(INTERNAL_SFTP_NAME, command) == 0 ||
    strncmp(INTERNAL_SFTP_NAME, command, strlen(INTERNAL_SFTP_NAME)) == 0 &&
    isspace(command[strlen(INTERNAL_SFTP_NAME)]))
    s->is_subsystem = SUBSYSTEM_INT_SFTP;
    else if (s->is_subsystem)
    s->is_subsystem = SUBSYSTEM_EXT;
    _______________________________________________
    openssh-unix-dev mailing list
    openssh-unix-dev@mindrot.org
    https://lists.mindrot.org/mailman/li...enssh-unix-dev


  2. Re: fixed: [patch] fix to ForceCommand to support additional argumentsto internal-sftp

    On Tue, 19 Aug 2008, Michael Barabanov wrote:

    > The previous version broke the case of internal-sftp without arguments. This
    > is a fixed version.


    How about this:

    Index: session.c
    ================================================== =================
    RCS file: /cvs/src/usr.bin/ssh/session.c,v
    retrieving revision 1.241
    diff -u -p -r1.241 session.c
    --- session.c 16 Jun 2008 13:22:53 -0000 1.241
    +++ session.c 20 Aug 2008 00:32:11 -0000
    @@ -87,6 +87,12 @@
    #include
    #endif

    +#define IS_INTERNAL_SFTP(c) \
    + (!strncmp(c, INTERNAL_SFTP_NAME, sizeof(INTERNAL_SFTP_NAME) - 1) && \
    + (c[sizeof(INTERNAL_SFTP_NAME) - 1] == '\0' || \
    + c[sizeof(INTERNAL_SFTP_NAME) - 1] == ' ' || \
    + c[sizeof(INTERNAL_SFTP_NAME) - 1] == '\t'))
    +
    /* func */

    Session *session_new(void);
    @@ -701,7 +707,7 @@ do_exec(Session *s, const char *command)
    if (options.adm_forced_command) {
    original_command = command;
    command = options.adm_forced_command;
    - if (strcmp(INTERNAL_SFTP_NAME, command) == 0)
    + if (IS_INTERNAL_SFTP(command))
    s->is_subsystem = SUBSYSTEM_INT_SFTP;
    else if (s->is_subsystem)
    s->is_subsystem = SUBSYSTEM_EXT;
    @@ -709,7 +715,7 @@ do_exec(Session *s, const char *command)
    } else if (forced_command) {
    original_command = command;
    command = forced_command;
    - if (strcmp(INTERNAL_SFTP_NAME, command) == 0)
    + if (IS_INTERNAL_SFTP(command))
    s->is_subsystem = SUBSYSTEM_INT_SFTP;
    else if (s->is_subsystem)
    s->is_subsystem = SUBSYSTEM_EXT;
    _______________________________________________
    openssh-unix-dev mailing list
    openssh-unix-dev@mindrot.org
    https://lists.mindrot.org/mailman/li...enssh-unix-dev


  3. Re: fixed: [patch] fix to ForceCommand to support additionalarguments to internal-sftp

    This should work as well.

    On Tue, Aug 19, 2008 at 5:32 PM, Damien Miller wrote:

    > On Tue, 19 Aug 2008, Michael Barabanov wrote:
    >
    > > The previous version broke the case of internal-sftp without arguments.

    > This
    > > is a fixed version.

    >
    > How about this:
    >
    > Index: session.c
    > ================================================== =================
    > RCS file: /cvs/src/usr.bin/ssh/session.c,v
    > retrieving revision 1.241
    > diff -u -p -r1.241 session.c
    > --- session.c 16 Jun 2008 13:22:53 -0000 1.241
    > +++ session.c 20 Aug 2008 00:32:11 -0000
    > @@ -87,6 +87,12 @@
    > #include
    > #endif
    >
    > +#define IS_INTERNAL_SFTP(c) \
    > + (!strncmp(c, INTERNAL_SFTP_NAME, sizeof(INTERNAL_SFTP_NAME) - 1) &&
    > \
    > + (c[sizeof(INTERNAL_SFTP_NAME) - 1] == '\0' || \
    > + c[sizeof(INTERNAL_SFTP_NAME) - 1] == ' ' || \
    > + c[sizeof(INTERNAL_SFTP_NAME) - 1] == '\t'))
    > +
    > /* func */
    >
    > Session *session_new(void);
    > @@ -701,7 +707,7 @@ do_exec(Session *s, const char *command)
    > if (options.adm_forced_command) {
    > original_command = command;
    > command = options.adm_forced_command;
    > - if (strcmp(INTERNAL_SFTP_NAME, command) == 0)
    > + if (IS_INTERNAL_SFTP(command))
    > s->is_subsystem = SUBSYSTEM_INT_SFTP;
    > else if (s->is_subsystem)
    > s->is_subsystem = SUBSYSTEM_EXT;
    > @@ -709,7 +715,7 @@ do_exec(Session *s, const char *command)
    > } else if (forced_command) {
    > original_command = command;
    > command = forced_command;
    > - if (strcmp(INTERNAL_SFTP_NAME, command) == 0)
    > + if (IS_INTERNAL_SFTP(command))
    > s->is_subsystem = SUBSYSTEM_INT_SFTP;
    > else if (s->is_subsystem)
    > s->is_subsystem = SUBSYSTEM_EXT;
    >

    _______________________________________________
    openssh-unix-dev mailing list
    openssh-unix-dev@mindrot.org
    https://lists.mindrot.org/mailman/li...enssh-unix-dev


  4. Re: fixed: [patch] fix to ForceCommand to support additional argumentsto internal-sftp

    On Tue, 19 Aug 2008, Michael Barabanov wrote:

    > This should work as well.


    Applied - thanks. It will be in 5.2.

    -d
    _______________________________________________
    openssh-unix-dev mailing list
    openssh-unix-dev@mindrot.org
    https://lists.mindrot.org/mailman/li...enssh-unix-dev


+ Reply to Thread