Mercurial > dropbear
comparison svr-chansession.c @ 1121:bb3a03feb31f
Merge pull request #13 from gazoo74/fix-warnings
Fix warnings
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 04 Jun 2015 22:25:28 +0800 |
parents | 367d3800555b |
children | aaf576b27a10 |
comparison
equal
deleted
inserted
replaced
1087:1e486f368ec3 | 1121:bb3a03feb31f |
---|---|
181 | 181 |
182 CHECKCLEARTOWRITE(); | 182 CHECKCLEARTOWRITE(); |
183 | 183 |
184 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_REQUEST); | 184 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_REQUEST); |
185 buf_putint(ses.writepayload, channel->remotechan); | 185 buf_putint(ses.writepayload, channel->remotechan); |
186 buf_putstring(ses.writepayload, "exit-status", 11); | 186 buf_putstring(ses.writepayload, (const unsigned char *) "exit-status", 11); |
187 buf_putbyte(ses.writepayload, 0); /* boolean FALSE */ | 187 buf_putbyte(ses.writepayload, 0); /* boolean FALSE */ |
188 buf_putint(ses.writepayload, chansess->exit.exitstatus); | 188 buf_putint(ses.writepayload, chansess->exit.exitstatus); |
189 | 189 |
190 encrypt_packet(); | 190 encrypt_packet(); |
191 | 191 |
217 return; | 217 return; |
218 } | 218 } |
219 | 219 |
220 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_REQUEST); | 220 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_REQUEST); |
221 buf_putint(ses.writepayload, channel->remotechan); | 221 buf_putint(ses.writepayload, channel->remotechan); |
222 buf_putstring(ses.writepayload, "exit-signal", 11); | 222 buf_putstring(ses.writepayload, (const unsigned char *) "exit-signal", 11); |
223 buf_putbyte(ses.writepayload, 0); /* boolean FALSE */ | 223 buf_putbyte(ses.writepayload, 0); /* boolean FALSE */ |
224 buf_putstring(ses.writepayload, signame, strlen(signame)); | 224 buf_putstring(ses.writepayload, (const unsigned char *) signame, strlen(signame)); |
225 buf_putbyte(ses.writepayload, chansess->exit.exitcore); | 225 buf_putbyte(ses.writepayload, chansess->exit.exitcore); |
226 buf_putstring(ses.writepayload, "", 0); /* error msg */ | 226 buf_putstring(ses.writepayload, (const unsigned char *) "", 0); /* error msg */ |
227 buf_putstring(ses.writepayload, "", 0); /* lang */ | 227 buf_putstring(ses.writepayload, (const unsigned char *) "", 0); /* lang */ |
228 | 228 |
229 encrypt_packet(); | 229 encrypt_packet(); |
230 } | 230 } |
231 | 231 |
232 /* set up a session channel */ | 232 /* set up a session channel */ |
341 | 341 |
342 /* Handle requests for a channel. These can be execution requests, | 342 /* Handle requests for a channel. These can be execution requests, |
343 * or x11/authagent forwarding. These are passed to appropriate handlers */ | 343 * or x11/authagent forwarding. These are passed to appropriate handlers */ |
344 static void chansessionrequest(struct Channel *channel) { | 344 static void chansessionrequest(struct Channel *channel) { |
345 | 345 |
346 unsigned char * type = NULL; | 346 char * type = NULL; |
347 unsigned int typelen; | 347 unsigned int typelen; |
348 unsigned char wantreply; | 348 unsigned char wantreply; |
349 int ret = 1; | 349 int ret = 1; |
350 struct ChanSess *chansess; | 350 struct ChanSess *chansess; |
351 | 351 |
352 TRACE(("enter chansessionrequest")) | 352 TRACE(("enter chansessionrequest")) |
353 | 353 |
354 type = buf_getstring(ses.payload, &typelen); | 354 type = (char *) buf_getstring(ses.payload, &typelen); |
355 wantreply = buf_getbool(ses.payload); | 355 wantreply = buf_getbool(ses.payload); |
356 | 356 |
357 if (typelen > MAX_NAME_LEN) { | 357 if (typelen > MAX_NAME_LEN) { |
358 TRACE(("leave chansessionrequest: type too long")) /* XXX send error?*/ | 358 TRACE(("leave chansessionrequest: type too long")) /* XXX send error?*/ |
359 goto out; | 359 goto out; |
404 | 404 |
405 /* Send a signal to a session's process as requested by the client*/ | 405 /* Send a signal to a session's process as requested by the client*/ |
406 static int sessionsignal(struct ChanSess *chansess) { | 406 static int sessionsignal(struct ChanSess *chansess) { |
407 | 407 |
408 int sig = 0; | 408 int sig = 0; |
409 unsigned char* signame = NULL; | 409 char* signame = NULL; |
410 int i; | 410 int i; |
411 | 411 |
412 if (chansess->pid == 0) { | 412 if (chansess->pid == 0) { |
413 /* haven't got a process pid yet */ | 413 /* haven't got a process pid yet */ |
414 return DROPBEAR_FAILURE; | 414 return DROPBEAR_FAILURE; |
415 } | 415 } |
416 | 416 |
417 signame = buf_getstring(ses.payload, NULL); | 417 signame = (char *) buf_getstring(ses.payload, NULL); |
418 | 418 |
419 i = 0; | 419 i = 0; |
420 while (signames[i].name != 0) { | 420 while (signames[i].name != 0) { |
421 if (strcmp(signames[i].name, signame) == 0) { | 421 if (strcmp(signames[i].name, signame) == 0) { |
422 sig = signames[i].signal; | 422 sig = signames[i].signal; |
555 * The pty is allocated now, and kept for when the shell/program executes. | 555 * The pty is allocated now, and kept for when the shell/program executes. |
556 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ | 556 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ |
557 static int sessionpty(struct ChanSess * chansess) { | 557 static int sessionpty(struct ChanSess * chansess) { |
558 | 558 |
559 unsigned int termlen; | 559 unsigned int termlen; |
560 unsigned char namebuf[65]; | 560 char namebuf[65]; |
561 struct passwd * pw = NULL; | 561 struct passwd * pw = NULL; |
562 | 562 |
563 TRACE(("enter sessionpty")) | 563 TRACE(("enter sessionpty")) |
564 | 564 |
565 if (!svr_pubkey_allows_pty()) { | 565 if (!svr_pubkey_allows_pty()) { |
566 TRACE(("leave sessionpty : pty forbidden by public key option")) | 566 TRACE(("leave sessionpty : pty forbidden by public key option")) |
567 return DROPBEAR_FAILURE; | 567 return DROPBEAR_FAILURE; |
568 } | 568 } |
569 | 569 |
570 chansess->term = buf_getstring(ses.payload, &termlen); | 570 chansess->term = (char *) buf_getstring(ses.payload, &termlen); |
571 if (termlen > MAX_TERM_LEN) { | 571 if (termlen > MAX_TERM_LEN) { |
572 /* TODO send disconnect ? */ | 572 /* TODO send disconnect ? */ |
573 TRACE(("leave sessionpty: term len too long")) | 573 TRACE(("leave sessionpty: term len too long")) |
574 return DROPBEAR_FAILURE; | 574 return DROPBEAR_FAILURE; |
575 } | 575 } |
581 if (pty_allocate(&chansess->master, &chansess->slave, namebuf, 64) == 0) { | 581 if (pty_allocate(&chansess->master, &chansess->slave, namebuf, 64) == 0) { |
582 TRACE(("leave sessionpty: failed to allocate pty")) | 582 TRACE(("leave sessionpty: failed to allocate pty")) |
583 return DROPBEAR_FAILURE; | 583 return DROPBEAR_FAILURE; |
584 } | 584 } |
585 | 585 |
586 chansess->tty = (char*)m_strdup(namebuf); | 586 chansess->tty = m_strdup(namebuf); |
587 if (!chansess->tty) { | 587 if (!chansess->tty) { |
588 dropbear_exit("Out of memory"); /* TODO disconnect */ | 588 dropbear_exit("Out of memory"); /* TODO disconnect */ |
589 } | 589 } |
590 | 590 |
591 pw = getpwnam(ses.authstate.pw_name); | 591 pw = getpwnam(ses.authstate.pw_name); |
601 | 601 |
602 TRACE(("leave sessionpty")) | 602 TRACE(("leave sessionpty")) |
603 return DROPBEAR_SUCCESS; | 603 return DROPBEAR_SUCCESS; |
604 } | 604 } |
605 | 605 |
606 #ifndef USE_VFORK | |
606 static void make_connection_string(struct ChanSess *chansess) { | 607 static void make_connection_string(struct ChanSess *chansess) { |
607 char *local_ip, *local_port, *remote_ip, *remote_port; | 608 char *local_ip, *local_port, *remote_ip, *remote_port; |
608 size_t len; | 609 size_t len; |
609 get_socket_address(ses.sock_in, &local_ip, &local_port, &remote_ip, &remote_port, 0); | 610 get_socket_address(ses.sock_in, &local_ip, &local_port, &remote_ip, &remote_port, 0); |
610 | 611 |
622 m_free(local_ip); | 623 m_free(local_ip); |
623 m_free(local_port); | 624 m_free(local_port); |
624 m_free(remote_ip); | 625 m_free(remote_ip); |
625 m_free(remote_port); | 626 m_free(remote_port); |
626 } | 627 } |
628 #endif | |
627 | 629 |
628 /* Handle a command request from the client. This is used for both shell | 630 /* Handle a command request from the client. This is used for both shell |
629 * and command-execution requests, and passes the command to | 631 * and command-execution requests, and passes the command to |
630 * noptycommand or ptycommand as appropriate. | 632 * noptycommand or ptycommand as appropriate. |
631 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ | 633 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ |
645 } | 647 } |
646 | 648 |
647 if (iscmd) { | 649 if (iscmd) { |
648 /* "exec" */ | 650 /* "exec" */ |
649 if (chansess->cmd == NULL) { | 651 if (chansess->cmd == NULL) { |
650 chansess->cmd = buf_getstring(ses.payload, &cmdlen); | 652 chansess->cmd = (char *) buf_getstring(ses.payload, &cmdlen); |
651 | 653 |
652 if (cmdlen > MAX_CMD_LEN) { | 654 if (cmdlen > MAX_CMD_LEN) { |
653 m_free(chansess->cmd); | 655 m_free(chansess->cmd); |
654 /* TODO - send error - too long ? */ | 656 /* TODO - send error - too long ? */ |
655 return DROPBEAR_FAILURE; | 657 return DROPBEAR_FAILURE; |