comparison svr-chansession.c @ 594:a98a2138364a

Improve capitalisation for all logged strings
author Matt Johnston <matt@ucc.asn.au>
date Wed, 23 Feb 2011 15:50:30 +0000
parents 6cb1bd7be8b3
children 810dfc792ca9
comparison
equal deleted inserted replaced
593:ea103e4476ce 594:a98a2138364a
453 453
454 len = buf_getint(ses.payload); 454 len = buf_getint(ses.payload);
455 TRACE(("term mode str %d p->l %d p->p %d", 455 TRACE(("term mode str %d p->l %d p->p %d",
456 len, ses.payload->len , ses.payload->pos)); 456 len, ses.payload->len , ses.payload->pos));
457 if (len != ses.payload->len - ses.payload->pos) { 457 if (len != ses.payload->len - ses.payload->pos) {
458 dropbear_exit("bad term mode string"); 458 dropbear_exit("Bad term mode string");
459 } 459 }
460 460
461 if (len == 0) { 461 if (len == 0) {
462 TRACE(("leave get_termmodes: empty terminal modes string")) 462 TRACE(("leave get_termmodes: empty terminal modes string"))
463 return; 463 return;
518 break; 518 break;
519 519
520 } 520 }
521 } 521 }
522 if (tcsetattr(chansess->master, TCSANOW, &termio) < 0) { 522 if (tcsetattr(chansess->master, TCSANOW, &termio) < 0) {
523 dropbear_log(LOG_INFO, "error setting terminal attributes"); 523 dropbear_log(LOG_INFO, "Error setting terminal attributes");
524 } 524 }
525 TRACE(("leave get_termmodes")) 525 TRACE(("leave get_termmodes"))
526 } 526 }
527 527
528 /* Set up a session pty which will be used to execute the shell or program. 528 /* Set up a session pty which will be used to execute the shell or program.
548 return DROPBEAR_FAILURE; 548 return DROPBEAR_FAILURE;
549 } 549 }
550 550
551 /* allocate the pty */ 551 /* allocate the pty */
552 if (chansess->master != -1) { 552 if (chansess->master != -1) {
553 dropbear_exit("multiple pty requests"); 553 dropbear_exit("Multiple pty requests");
554 } 554 }
555 if (pty_allocate(&chansess->master, &chansess->slave, namebuf, 64) == 0) { 555 if (pty_allocate(&chansess->master, &chansess->slave, namebuf, 64) == 0) {
556 TRACE(("leave sessionpty: failed to allocate pty")) 556 TRACE(("leave sessionpty: failed to allocate pty"))
557 return DROPBEAR_FAILURE; 557 return DROPBEAR_FAILURE;
558 } 558 }
559 559
560 chansess->tty = (char*)m_strdup(namebuf); 560 chansess->tty = (char*)m_strdup(namebuf);
561 if (!chansess->tty) { 561 if (!chansess->tty) {
562 dropbear_exit("out of memory"); /* TODO disconnect */ 562 dropbear_exit("Out of memory"); /* TODO disconnect */
563 } 563 }
564 564
565 pw = getpwnam(ses.authstate.pw_name); 565 pw = getpwnam(ses.authstate.pw_name);
566 if (!pw) 566 if (!pw)
567 dropbear_exit("getpwnam failed after succeeding previously"); 567 dropbear_exit("getpwnam failed after succeeding previously");
639 /* take public key option 'command' into account */ 639 /* take public key option 'command' into account */
640 svr_pubkey_set_forced_command(chansess); 640 svr_pubkey_set_forced_command(chansess);
641 641
642 #ifdef LOG_COMMANDS 642 #ifdef LOG_COMMANDS
643 if (chansess->cmd) { 643 if (chansess->cmd) {
644 dropbear_log(LOG_INFO, "user %s executing '%s'", 644 dropbear_log(LOG_INFO, "User %s executing '%s'",
645 ses.authstate.pw_name, chansess->cmd); 645 ses.authstate.pw_name, chansess->cmd);
646 } else { 646 } else {
647 dropbear_log(LOG_INFO, "user %s executing login shell", 647 dropbear_log(LOG_INFO, "User %s executing login shell",
648 ses.authstate.pw_name); 648 ses.authstate.pw_name);
649 } 649 }
650 #endif 650 #endif
651 651
652 /* uClinux will vfork(), so there'll be a race as 652 /* uClinux will vfork(), so there'll be a race as
729 729
730 TRACE(("enter ptycommand")) 730 TRACE(("enter ptycommand"))
731 731
732 /* we need to have a pty allocated */ 732 /* we need to have a pty allocated */
733 if (chansess->master == -1 || chansess->tty == NULL) { 733 if (chansess->master == -1 || chansess->tty == NULL) {
734 dropbear_log(LOG_WARNING, "no pty was allocated, couldn't execute"); 734 dropbear_log(LOG_WARNING, "No pty was allocated, couldn't execute");
735 return DROPBEAR_FAILURE; 735 return DROPBEAR_FAILURE;
736 } 736 }
737 737
738 #ifdef __uClinux__ 738 #ifdef __uClinux__
739 pid = vfork(); 739 pid = vfork();
882 if (getuid() == 0) { 882 if (getuid() == 0) {
883 883
884 if ((setgid(ses.authstate.pw_gid) < 0) || 884 if ((setgid(ses.authstate.pw_gid) < 0) ||
885 (initgroups(ses.authstate.pw_name, 885 (initgroups(ses.authstate.pw_name,
886 ses.authstate.pw_gid) < 0)) { 886 ses.authstate.pw_gid) < 0)) {
887 dropbear_exit("error changing user group"); 887 dropbear_exit("Error changing user group");
888 } 888 }
889 if (setuid(ses.authstate.pw_uid) < 0) { 889 if (setuid(ses.authstate.pw_uid) < 0) {
890 dropbear_exit("error changing user"); 890 dropbear_exit("Error changing user");
891 } 891 }
892 } else { 892 } else {
893 /* ... but if the daemon is the same uid as the requested uid, we don't 893 /* ... but if the daemon is the same uid as the requested uid, we don't
894 * need to */ 894 * need to */
895 895
896 /* XXX - there is a minor issue here, in that if there are multiple 896 /* XXX - there is a minor issue here, in that if there are multiple
897 * usernames with the same uid, but differing groups, then the 897 * usernames with the same uid, but differing groups, then the
898 * differing groups won't be set (as with initgroups()). The solution 898 * differing groups won't be set (as with initgroups()). The solution
899 * is for the sysadmin not to give out the UID twice */ 899 * is for the sysadmin not to give out the UID twice */
900 if (getuid() != ses.authstate.pw_uid) { 900 if (getuid() != ses.authstate.pw_uid) {
901 dropbear_exit("couldn't change user as non-root"); 901 dropbear_exit("Couldn't change user as non-root");
902 } 902 }
903 } 903 }
904 904
905 /* set env vars */ 905 /* set env vars */
906 addnewvar("USER", ses.authstate.pw_name); 906 addnewvar("USER", ses.authstate.pw_name);
928 } 928 }
929 #endif 929 #endif
930 930
931 /* change directory */ 931 /* change directory */
932 if (chdir(ses.authstate.pw_dir) < 0) { 932 if (chdir(ses.authstate.pw_dir) < 0) {
933 dropbear_exit("error changing directory"); 933 dropbear_exit("Error changing directory");
934 } 934 }
935 935
936 #ifndef DISABLE_X11FWD 936 #ifndef DISABLE_X11FWD
937 /* set up X11 forwarding if enabled */ 937 /* set up X11 forwarding if enabled */
938 x11setauth(chansess); 938 x11setauth(chansess);
944 944
945 usershell = m_strdup(get_user_shell()); 945 usershell = m_strdup(get_user_shell());
946 run_shell_command(chansess->cmd, ses.maxfd, usershell); 946 run_shell_command(chansess->cmd, ses.maxfd, usershell);
947 947
948 /* only reached on error */ 948 /* only reached on error */
949 dropbear_exit("child failed"); 949 dropbear_exit("Child failed");
950 } 950 }
951 951
952 const struct ChanType svrchansess = { 952 const struct ChanType svrchansess = {
953 0, /* sepfds */ 953 0, /* sepfds */
954 "session", /* name */ 954 "session", /* name */