/* Ce programme permet de multiplexer plusieurs commandes sur son canal 0 et 1 Il est appele par cfshell_local, qui etablie une relation unique avec lui. Normalement cfshell_remote execute sur un vserver en tant qu'un usager. On a donc cfshell_cmd(s) qui parle a cfshell_local qui parle a cfshell_remote, qui execute des commandes. Pour chaque commande, cfshell_remote fait un fork(). */ #include #include #include #include #include #include #include #include #include "cfshell.h" using namespace std; struct CLIINFO: public ARRAY_OBJ{ bool is_task; int channel; STREAMP_BUF buf; CLIINFO(){ is_task = false; channel = 0; } }; struct CHANNELS{ int fd0,fd1,fd2; // stdout ... stderr }; int main (int argc, char *argv[]) { glocal int ret = -1; glocal.ret = (argc,argv); int ret = -1; signal (SIGPIPE,SIG_IGN); signal (SIGCHLD,SIG_IGN); glocal vector chans; (); glocal int no = no; glocal CLIINFO *cli = (CLIINFO*)info.data; (glocal.cli->buf,line,info.linelen); int ret = 0; unsigned ulen = len; if (glocal.no == 0){ if (ulen >= sizeof(CFSHELL_MULTI)){ CFSHELL_MULTI *m = (CFSHELL_MULTI*)buf; if (ulen >= sizeof(CFSHELL_MULTI)+sizeof(CFSHELL_PROTOCOL)){ CFSHELL_PROTOCOL *proto = (CFSHELL_PROTOCOL*)((char*)buf+sizeof(CFSHELL_MULTI)); int need_len = sizeof(CFSHELL_PROTOCOL)+sizeof(CFSHELL_MULTI)+proto->len; if (len >= need_len){ ret = need_len; //if ( } } } }else if (ulen >= sizeof(CFSHELL_MULTI)+sizeof(CFSHELL_PROTOCOL)){ CFSHELL_PROTOCOL *proto = (CFSHELL_PROTOCOL*)buf; unsigned need_len = sizeof(CFSHELL_PROTOCOL)+proto->len; if (ulen >= need_len){ ret = need_len; CFSHELL_MULTI multi; multi.channel = glocal.cli->channel; glocal.TCPSERVER.send (&multi,sizeof(multi)); glocal.TCPSERVER.send (buf,need_len); } } return ret; o.setrawmode (true); o.inject (0,new CLIINFO); o.loop(); ret = 0; return ret; return glocal.ret; }