What magic did openssh do to handle programs like VIM?

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



Hi,

I'm trying to write my own remote shell program,

It simply connects to a remote server then copy the sock fd to stdin,
stdout and stderr. And it works.

But I found several problems:
1. It doesn't handle characters like ^A ^E or tab (any bash/readline stuff)
    -> openssh itself doesn't seem to incorporate readline, so the
magic is not on           readline
2. If I run command like VIM, it doesn't run.
    And buttons like "<ESC>:q" won't work

Can someone enlighten me about what SSH did, so it all works perfectly?

Attached the prototype:

    int sockfd = socket(PF_INET, SOCK_STREAM, 0);
    struct sockaddr_in remaddr = { 0 };

    remaddr.sin_family = AF_INET;
    remaddr.sin_port = htons(9999);
    remaddr.sin_addr.s_addr = inet_addr("192.168.56.1");

    if (connect(sockfd, (struct sockaddr *)&remaddr, sizeof(struct sockaddr)))
        ERR_QUIT("connect");

    for (int i = 0; i < 2; ++i )
        dup2 (sockfd, i);
    execl("/bin/bash", "/bin/bash", "-i", NULL);



-- 
Best Regards,
Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/
Finger Print:   9F67 391B B770 8FF6 99DC  D92D 87F6 2602 1371 4D33
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev




[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux