comparison svr-chansession.c @ 496:9f583f4d59a6

propagate from branch 'au.asn.ucc.matt.dropbear.pubkey-options' (head 537a6ebebb46424b967ffe787f0f8560e5f447e8) to branch 'au.asn.ucc.matt.dropbear' (head 10b2f286b9886364db39dfbb4f8f46e49e345d87)
author Matt Johnston <matt@ucc.asn.au>
date Tue, 23 Sep 2008 13:16:22 +0000
parents 7ad49f34a122 52a644e7b8e1
children 43bbe17d6ba0
comparison
equal deleted inserted replaced
495:cd02449b709c 496:9f583f4d59a6
35 #include "random.h" 35 #include "random.h"
36 #include "utmp.h" 36 #include "utmp.h"
37 #include "x11fwd.h" 37 #include "x11fwd.h"
38 #include "agentfwd.h" 38 #include "agentfwd.h"
39 #include "runopts.h" 39 #include "runopts.h"
40 #include "auth.h"
40 41
41 /* Handles sessions (either shells or programs) requested by the client */ 42 /* Handles sessions (either shells or programs) requested by the client */
42 43
43 static int sessioncommand(struct Channel *channel, struct ChanSess *chansess, 44 static int sessioncommand(struct Channel *channel, struct ChanSess *chansess,
44 int iscmd, int issubsys); 45 int iscmd, int issubsys);
525 unsigned int termlen; 526 unsigned int termlen;
526 unsigned char namebuf[65]; 527 unsigned char namebuf[65];
527 struct passwd * pw = NULL; 528 struct passwd * pw = NULL;
528 529
529 TRACE(("enter sessionpty")) 530 TRACE(("enter sessionpty"))
531
532 if (!svr_pubkey_allows_pty()) {
533 TRACE(("leave sessionpty : pty forbidden by public key option"))
534 return DROPBEAR_FAILURE;
535 }
536
530 chansess->term = buf_getstring(ses.payload, &termlen); 537 chansess->term = buf_getstring(ses.payload, &termlen);
531 if (termlen > MAX_TERM_LEN) { 538 if (termlen > MAX_TERM_LEN) {
532 /* TODO send disconnect ? */ 539 /* TODO send disconnect ? */
533 TRACE(("leave sessionpty: term len too long")) 540 TRACE(("leave sessionpty: term len too long"))
534 return DROPBEAR_FAILURE; 541 return DROPBEAR_FAILURE;
580 * one command (which fails), then try another. Ie fallback 587 * one command (which fails), then try another. Ie fallback
581 * from sftp to scp */ 588 * from sftp to scp */
582 return DROPBEAR_FAILURE; 589 return DROPBEAR_FAILURE;
583 } 590 }
584 591
592 /* take public key option 'command' into account */
593 svr_pubkey_set_forced_command(chansess);
594
585 if (iscmd) { 595 if (iscmd) {
586 /* "exec" */ 596 /* "exec" */
587 chansess->cmd = buf_getstring(ses.payload, &cmdlen); 597 if (chansess->cmd == NULL) {
588 598 chansess->cmd = buf_getstring(ses.payload, &cmdlen);
589 if (cmdlen > MAX_CMD_LEN) { 599
590 m_free(chansess->cmd); 600 if (cmdlen > MAX_CMD_LEN) {
591 /* TODO - send error - too long ? */ 601 m_free(chansess->cmd);
592 return DROPBEAR_FAILURE; 602 /* TODO - send error - too long ? */
603 return DROPBEAR_FAILURE;
604 }
593 } 605 }
594 if (issubsys) { 606 if (issubsys) {
595 #ifdef SFTPSERVER_PATH 607 #ifdef SFTPSERVER_PATH
596 if ((cmdlen == 4) && strncmp(chansess->cmd, "sftp", 4) == 0) { 608 if ((cmdlen == 4) && strncmp(chansess->cmd, "sftp", 4) == 0) {
597 m_free(chansess->cmd); 609 m_free(chansess->cmd);