Lines Matching +full:- +full:- +full:fail +full:- +full:env +full:- +full:changed
66 #include "openbsd-compat/sys-queue.h"
80 #include "ssh-gss.h"
84 #include "auth-options.h"
107 (!strncmp(c, INTERNAL_SFTP_NAME, sizeof(INTERNAL_SFTP_NAME) - 1) && \
108 (c[sizeof(INTERNAL_SFTP_NAME) - 1] == '\0' || \
109 c[sizeof(INTERNAL_SFTP_NAME) - 1] == ' ' || \
110 c[sizeof(INTERNAL_SFTP_NAME) - 1] == '\t'))
148 static int sessions_first_unused = -1;
186 int sock = -1; in auth_input_request_forwarding()
197 auth_sock_dir = xstrdup("/tmp/ssh-XXXXXXXXXX"); in auth_input_request_forwarding()
224 SSH_CHANNEL_AUTH_SOCKET, sock, sock, -1, in auth_input_request_forwarding()
227 nc->path = xstrdup(auth_sock_name); in auth_input_request_forwarding()
236 if (sock != -1) in auth_input_request_forwarding()
256 setproctitle("%s", authctxt->pw->pw_name); in do_authenticated()
259 /* XXX - streamlocal? */ in do_authenticated()
281 s[i] != '-' && s[i] != '_') in xauth_valid_string()
307 return -1; in do_exec_no_pty()
313 return -1; in do_exec_no_pty()
322 return -1; in do_exec_no_pty()
333 return -1; in do_exec_no_pty()
340 return -1; in do_exec_no_pty()
348 case -1: in do_exec_no_pty()
363 return -1; in do_exec_no_pty()
367 /* Child. Reinitialize the log since the pid has changed. */ in do_exec_no_pty()
419 cray_init_job(s->pw); /* set up cray jid and tmpdir */ in do_exec_no_pty()
436 s->pid = pid; in do_exec_no_pty()
437 /* Set interactive/non-interactive mode. */ in do_exec_no_pty()
438 packet_set_interactive(s->display != NULL, in do_exec_no_pty()
455 s->is_subsystem, 0); in do_exec_no_pty()
466 s->is_subsystem, 0); in do_exec_no_pty()
485 ptyfd = s->ptyfd; in do_exec_pty()
486 ttyfd = s->ttyfd; in do_exec_pty()
493 * detect and gracefully fail out-of-fd conditions. in do_exec_pty()
499 return -1; in do_exec_pty()
507 return -1; in do_exec_pty()
512 case -1: in do_exec_pty()
518 return -1; in do_exec_pty()
525 /* Child. Reinitialize the log because the pid has changed. */ in do_exec_pty()
532 pty_make_controlling_tty(&ttyfd, s->tty); in do_exec_pty()
547 cray_init_job(s->pw); /* set up cray jid and tmpdir */ in do_exec_pty()
569 s->pid = pid; in do_exec_pty()
575 s->ptymaster = ptymaster; in do_exec_pty()
578 session_set_fds(s, ptyfd, fdout, -1, 1, 1); in do_exec_pty()
605 record_utmp_only(pid, s->tty, s->pw->pw_name, in do_pre_login()
630 forced = "(key-option)"; in do_exec()
634 s->is_subsystem = s->is_subsystem ? in do_exec()
636 } else if (s->is_subsystem) in do_exec()
637 s->is_subsystem = SUBSYSTEM_EXT; in do_exec()
639 "forced-command %s '%.900s'", forced, command); in do_exec()
640 } else if (s->is_subsystem) { in do_exec()
642 "subsystem '%.900s'", s->subsys); in do_exec()
650 if (s->ttyfd != -1) { in do_exec()
651 tty = s->tty; in do_exec()
660 s->pw->pw_name, in do_exec()
663 s->self); in do_exec()
668 else if (s->ttyfd == -1) { in do_exec()
669 char *shell = s->pw->pw_shell; in do_exec()
676 if (s->ttyfd != -1) in do_exec()
693 /* administrative, login(1)-like work */
700 struct passwd * pw = s->pw; in do_login()
719 record_login(pid, s->tty, pw->pw_name, pw->pw_uid, in do_login()
729 if (options.use_pam && !use_privsep && s->authctxt->force_pwchange) { in do_login()
732 s->authctxt->force_pwchange = 0; in do_login()
733 /* XXX - signal [net] parent to enable forwardings */ in do_login()
777 struct passwd *pw = s->pw; in check_quietlogin()
783 snprintf(buf, sizeof(buf), "%.200s/.hushlogin", pw->pw_dir); in check_quietlogin()
802 char **env; in child_set_env() local
826 env = *envp; in child_set_env()
828 for (i = 0; env[i]; i++) in child_set_env()
829 if (strncmp(env[i], name, namelen) == 0 && env[i][namelen] == '=') in child_set_env()
831 if (env[i]) { in child_set_env()
833 free(env[i]); in child_set_env()
837 if (i >= envsize - 1) { in child_set_env()
839 fatal("child_set_env: too many env vars"); in child_set_env()
841 env = (*envp) = xreallocarray(env, envsize, sizeof(char *)); in child_set_env()
845 env[i + 1] = NULL; in child_set_env()
849 env[i] = xmalloc(strlen(name) + 1 + strlen(value) + 1); in child_set_env()
850 snprintf(env[i], strlen(name) + 1 + strlen(value) + 1, "%s=%s", name, value); in child_set_env()
860 read_environment_file(char ***env, u_int *envsize, in read_environment_file() argument
894 child_set_env(env, envsize, cp, value); in read_environment_file()
904 child_get_env(char **env, const char *name) in child_get_env() argument
910 for (i=0; env[i] != NULL; i++) in child_get_env()
911 if (strncmp(name, env[i], len) == 0 && env[i][len] == '=') in child_get_env()
912 return(env[i] + len + 1); in child_get_env()
921 read_etc_default_login(char ***env, u_int *envsize, uid_t uid) in read_etc_default_login() argument
942 child_set_env(env, envsize, "PATH", var); in read_etc_default_login()
955 copy_environment(char **source, char ***env, u_int *envsize) in copy_environment() argument
972 child_set_env(env, envsize, var_name, var_val); in copy_environment()
984 char **env, *laddr; in do_setup_env() local
985 struct passwd *pw = s->pw; in do_setup_env()
992 env = xcalloc(envsize, sizeof(char *)); in do_setup_env()
993 env[0] = NULL; in do_setup_env()
1004 copy_environment(p, &env, &envsize); in do_setup_env()
1013 ssh_gssapi_do_child(&env, &envsize); in do_setup_env()
1017 for (i = 0; i < s->num_env; i++) in do_setup_env()
1018 child_set_env(&env, &envsize, s->env[i].name, s->env[i].val); in do_setup_env()
1020 child_set_env(&env, &envsize, "USER", pw->pw_name); in do_setup_env()
1021 child_set_env(&env, &envsize, "LOGNAME", pw->pw_name); in do_setup_env()
1023 child_set_env(&env, &envsize, "LOGIN", pw->pw_name); in do_setup_env()
1025 child_set_env(&env, &envsize, "HOME", pw->pw_dir); in do_setup_env()
1027 if (setusercontext(lc, pw, pw->pw_uid, LOGIN_SETPATH) < 0) in do_setup_env()
1028 child_set_env(&env, &envsize, "PATH", _PATH_STDPATH); in do_setup_env()
1030 child_set_env(&env, &envsize, "PATH", getenv("PATH")); in do_setup_env()
1040 read_etc_default_login(&env, &envsize, pw->pw_uid); in do_setup_env()
1041 path = child_get_env(env, "PATH"); in do_setup_env()
1044 child_set_env(&env, &envsize, "PATH", in do_setup_env()
1045 s->pw->pw_uid == 0 ? SUPERUSER_PATH : _PATH_STDPATH); in do_setup_env()
1051 snprintf(buf, sizeof buf, "%.200s/%.50s", _PATH_MAILDIR, pw->pw_name); in do_setup_env()
1052 child_set_env(&env, &envsize, "MAIL", buf); in do_setup_env()
1055 child_set_env(&env, &envsize, "SHELL", shell); in do_setup_env()
1059 child_set_env(&env, &envsize, "TZ", getenv("TZ")); in do_setup_env()
1064 char *str = ce->s; in do_setup_env()
1070 child_set_env(&env, &envsize, str, str + i + 1); in do_setup_env()
1072 custom_environment = ce->next; in do_setup_env()
1073 free(ce->s); in do_setup_env()
1081 child_set_env(&env, &envsize, "SSH_CLIENT", buf); in do_setup_env()
1088 child_set_env(&env, &envsize, "SSH_CONNECTION", buf); in do_setup_env()
1090 if (s->ttyfd != -1) in do_setup_env()
1091 child_set_env(&env, &envsize, "SSH_TTY", s->tty); in do_setup_env()
1092 if (s->term) in do_setup_env()
1093 child_set_env(&env, &envsize, "TERM", s->term); in do_setup_env()
1094 if (s->display) in do_setup_env()
1095 child_set_env(&env, &envsize, "DISPLAY", s->display); in do_setup_env()
1097 child_set_env(&env, &envsize, "SSH_ORIGINAL_COMMAND", in do_setup_env()
1102 child_set_env(&env, &envsize, "TMPDIR", cray_tmpdir); in do_setup_env()
1114 child_set_env(&env, &envsize, "KRB5CCNAME", cp); in do_setup_env()
1122 child_set_env(&env, &envsize, "AUTHSTATE", cp); in do_setup_env()
1123 read_environment_file(&env, &envsize, "/etc/environment"); in do_setup_env()
1127 if (s->authctxt->krb5_ccname) in do_setup_env()
1128 child_set_env(&env, &envsize, "KRB5CCNAME", in do_setup_env()
1129 s->authctxt->krb5_ccname); in do_setup_env()
1140 copy_environment(p, &env, &envsize); in do_setup_env()
1144 copy_environment(p, &env, &envsize); in do_setup_env()
1150 child_set_env(&env, &envsize, SSH_AUTHSOCKET_ENV_NAME, in do_setup_env()
1156 strcmp(pw->pw_dir, "/") ? pw->pw_dir : ""); in do_setup_env()
1157 read_environment_file(&env, &envsize, buf); in do_setup_env()
1162 for (i = 0; env[i]; i++) in do_setup_env()
1163 fprintf(stderr, " %.200s\n", env[i]); in do_setup_env()
1165 return env; in do_setup_env()
1181 s->display != NULL && s->auth_proto != NULL && s->auth_data != NULL; in do_rc_files()
1184 if (!s->is_subsystem && options.adm_forced_command == NULL && in do_rc_files()
1187 snprintf(cmd, sizeof cmd, "%s -c '%s %s'", in do_rc_files()
1194 fprintf(f, "%s %s\n", s->auth_proto, in do_rc_files()
1195 s->auth_data); in do_rc_files()
1205 /* _PATH_BSHELL is not a compile-time constant on Android. */ in do_rc_files()
1214 fprintf(f, "%s %s\n", s->auth_proto, in do_rc_files()
1215 s->auth_data); in do_rc_files()
1225 options.xauth_location, s->auth_display); in do_rc_files()
1228 options.xauth_location, s->auth_display, in do_rc_files()
1229 s->auth_proto, s->auth_data); in do_rc_files()
1231 snprintf(cmd, sizeof cmd, "%s -q -", in do_rc_files()
1236 s->auth_display); in do_rc_files()
1238 s->auth_display, s->auth_proto, in do_rc_files()
1239 s->auth_data); in do_rc_files()
1256 if (login_getcapbool(lc, "ignorenologin", 0) || pw->pw_uid == 0) in do_nologin()
1260 if (pw->pw_uid == 0) in do_nologin()
1264 if (stat(nl, &sb) == -1) { in do_nologin()
1271 logit("User %.100s not allowed because %s exists", pw->pw_name, nl); in do_nologin()
1282 * must be root-owned directories with strict permissions.
1298 * root-owned directory with strict permissions. in safely_chroot()
1305 memcpy(component, path, cp - path); in safely_chroot()
1306 component[cp - path] = '\0'; in safely_chroot()
1324 if (chdir(path) == -1) in safely_chroot()
1327 if (chroot(path) == -1) in safely_chroot()
1329 if (chdir("/") == -1) in safely_chroot()
1332 verbose("Changed root directory to \"%s\"", path); in safely_chroot()
1345 if (setusercontext(lc, pw, pw->pw_uid, in do_setusercontext()
1351 if (setlogin(pw->pw_name) < 0) in do_setusercontext()
1353 if (setgid(pw->pw_gid) < 0) { in do_setusercontext()
1358 if (initgroups(pw->pw_name, pw->pw_gid) < 0) { in do_setusercontext()
1372 pw->pw_uid); in do_setusercontext()
1373 chroot_path = percent_expand(tmp, "h", pw->pw_dir, in do_setusercontext()
1374 "u", pw->pw_name, (char *)NULL); in do_setusercontext()
1375 safely_chroot(chroot_path, pw->pw_uid); in do_setusercontext()
1385 if (setusercontext(lc, pw, pw->pw_uid, LOGIN_SETUSER) < 0) { in do_setusercontext()
1393 (void) setusercontext(lc, pw, pw->pw_uid, LOGIN_SETUMASK); in do_setusercontext()
1397 * In a chroot environment, the set_id() will always fail; in do_setusercontext()
1404 if (!in_chroot && set_id(pw->pw_name) != 0) in do_setusercontext()
1405 fatal("set_id(%s) Failed", pw->pw_name); in do_setusercontext()
1415 if (getuid() != pw->pw_uid || geteuid() != pw->pw_uid) in do_setusercontext()
1416 fatal("Failed to set uids to %u.", (u_int) pw->pw_uid); in do_setusercontext()
1424 if (s->ttyfd != -1) { in do_pwchange()
1431 execl(_PATH_PASSWD_PROG, "passwd", s->pw->pw_name, in do_pwchange()
1449 if (auth_sock != -1) { in child_close_fds()
1451 auth_sock = -1; in child_close_fds()
1464 /* XXX better use close-on-exec? -markus */ in child_close_fds()
1494 char **env; in do_child() local
1497 struct passwd *pw = s->pw; in do_child()
1504 if (s->authctxt->force_pwchange) { in do_child()
1512 cray_setup(pw->pw_uid, pw->pw_name, command); in do_child()
1516 * Login(1) does this as well, and it needs uid 0 for the "-h" in do_child()
1520 session_setup_sia(pw, s->ttyfd == -1 ? NULL : s->tty); in do_child()
1549 shell = (pw->pw_shell[0] == '\0') ? _PATH_BSHELL : pw->pw_shell; in do_child()
1555 env = do_setup_env(s, shell); in do_child()
1574 environ = env; in do_child()
1582 * home directory is in AFS and it's not world-readable. in do_child()
1586 (s->authctxt->krb5_ctx != NULL)) { in do_child()
1593 if (k_afs_cell_of_file(pw->pw_dir, cell, sizeof(cell)) == 0) in do_child()
1594 krb5_afslog(s->authctxt->krb5_ctx, in do_child()
1595 s->authctxt->krb5_fwd_ccache, cell, NULL); in do_child()
1597 krb5_afslog_home(s->authctxt->krb5_ctx, in do_child()
1598 s->authctxt->krb5_fwd_ccache, NULL, NULL, pw->pw_dir); in do_child()
1603 if (chdir(pw->pw_dir) < 0) { in do_child()
1610 "directory %s: %s\n", pw->pw_dir, in do_child()
1624 if (s->is_subsystem == SUBSYSTEM_INT_SFTP_ERROR) { in do_child()
1628 } else if (s->is_subsystem == SUBSYSTEM_INT_SFTP) { in do_child()
1633 setproctitle("%s@%s", s->pw->pw_name, INTERNAL_SFTP_NAME); in do_child()
1634 args = xstrdup(command ? command : "sftp-server"); in do_child()
1636 if (i < ARGV_MAX - 1) in do_child()
1644 exit(sftp_server_main(i, argv, s->pw)); in do_child()
1657 * name to be passed in argv[0] is preceded by '-' to indicate that in do_child()
1663 /* Start the shell. Set initial character to '-'. */ in do_child()
1664 argv0[0] = '-'; in do_child()
1666 if (strlcpy(argv0 + 1, shell0, sizeof(argv0) - 1) in do_child()
1667 >= sizeof(argv0) - 1) { in do_child()
1676 execve(shell, argv, env); in do_child()
1683 * Execute the command using the user's shell. This uses the -c in do_child()
1687 argv[1] = "-c"; in do_child()
1690 execve(shell, argv, env); in do_child()
1707 sessions[id].chanid = -1; in session_unused()
1708 sessions[id].ptyfd = -1; in session_unused()
1709 sessions[id].ttyfd = -1; in session_unused()
1710 sessions[id].ptymaster = -1; in session_unused()
1721 if (sessions_first_unused == -1) { in session_new()
1745 if (s->used) { in session_new()
1749 sessions_first_unused = s->next_unused; in session_new()
1750 s->used = 1; in session_new()
1751 s->next_unused = -1; in session_new()
1752 debug("session_new: session %d", s->self); in session_new()
1766 s->used, in session_dump()
1767 s->next_unused, in session_dump()
1768 s->self, in session_dump()
1770 s->chanid, in session_dump()
1771 (long)s->pid); in session_dump()
1784 s->authctxt = authctxt; in session_open()
1785 s->pw = authctxt->pw; in session_open()
1786 if (s->pw == NULL || !authctxt->valid) in session_open()
1787 fatal("no user for session %d", s->self); in session_open()
1788 debug("session_open: session %d: link with channel %d", s->self, chanid); in session_open()
1789 s->chanid = chanid; in session_open()
1799 if (s->used && s->ttyfd != -1 && strcmp(s->tty, tty) == 0) { in session_by_tty()
1815 if (s->used && s->chanid == id) { in session_by_channel()
1834 if (s->x11_chanids == NULL || !s->used) in session_by_x11_channel()
1836 for (j = 0; s->x11_chanids[j] != -1; j++) { in session_by_x11_channel()
1837 if (s->x11_chanids[j] == id) { in session_by_x11_channel()
1839 "channel %d", s->self, id); in session_by_x11_channel()
1856 if (s->used && s->pid == pid) in session_by_pid()
1867 s->col = packet_get_int(); in session_window_change_req()
1868 s->row = packet_get_int(); in session_window_change_req()
1869 s->xpixel = packet_get_int(); in session_window_change_req()
1870 s->ypixel = packet_get_int(); in session_window_change_req()
1872 pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel); in session_window_change_req()
1886 if (s->ttyfd != -1) { in session_pty_req()
1891 s->term = packet_get_string(&len); in session_pty_req()
1892 s->col = packet_get_int(); in session_pty_req()
1893 s->row = packet_get_int(); in session_pty_req()
1894 s->xpixel = packet_get_int(); in session_pty_req()
1895 s->ypixel = packet_get_int(); in session_pty_req()
1897 if (strcmp(s->term, "") == 0) { in session_pty_req()
1898 free(s->term); in session_pty_req()
1899 s->term = NULL; in session_pty_req()
1904 if (!PRIVSEP(pty_allocate(&s->ptyfd, &s->ttyfd, s->tty, in session_pty_req()
1905 sizeof(s->tty)))) { in session_pty_req()
1906 free(s->term); in session_pty_req()
1907 s->term = NULL; in session_pty_req()
1908 s->ptyfd = -1; in session_pty_req()
1909 s->ttyfd = -1; in session_pty_req()
1910 error("session_pty_req: session %d alloc failed", s->self); in session_pty_req()
1913 debug("session_pty_req: session %d alloc %s", s->self, s->tty); in session_pty_req()
1916 tty_parse_modes(s->ttyfd, &n_bytes); in session_pty_req()
1919 pty_setowner(s->pw, s->tty); in session_pty_req()
1922 pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel); in session_pty_req()
1938 s->subsys = packet_get_string(&len); in session_subsystem_req()
1940 debug2("subsystem request for %.100s by user %s", s->subsys, in session_subsystem_req()
1941 s->pw->pw_name); in session_subsystem_req()
1944 if (strcmp(s->subsys, options.subsystem_name[i]) == 0) { in session_subsystem_req()
1948 s->is_subsystem = SUBSYSTEM_INT_SFTP; in session_subsystem_req()
1954 s->is_subsystem = SUBSYSTEM_EXT; in session_subsystem_req()
1964 "subsystem not found", s->subsys, s->pw->pw_name); in session_subsystem_req()
1974 if (s->auth_proto != NULL || s->auth_data != NULL) { in session_x11_req()
1976 "x11 forwarding already active", s->self); in session_x11_req()
1979 s->single_connection = packet_get_char(); in session_x11_req()
1980 s->auth_proto = packet_get_string(NULL); in session_x11_req()
1981 s->auth_data = packet_get_string(NULL); in session_x11_req()
1982 s->screen = packet_get_int(); in session_x11_req()
1985 if (xauth_valid_string(s->auth_proto) && in session_x11_req()
1986 xauth_valid_string(s->auth_data)) in session_x11_req()
1993 free(s->auth_proto); in session_x11_req()
1994 free(s->auth_data); in session_x11_req()
1995 s->auth_proto = NULL; in session_x11_req()
1996 s->auth_data = NULL; in session_x11_req()
2027 if (s->ptymaster == -1 || tcsendbreak(s->ptymaster, 0) < 0) in session_break_req()
2043 if (s->num_env > 128) { in session_env_req()
2044 debug2("Ignoring env request %s: too many env vars", name); in session_env_req()
2045 goto fail; in session_env_req()
2050 debug2("Setting env %d: %s=%s", s->num_env, name, val); in session_env_req()
2051 s->env = xreallocarray(s->env, s->num_env + 1, in session_env_req()
2052 sizeof(*s->env)); in session_env_req()
2053 s->env[s->num_env].name = name; in session_env_req()
2054 s->env[s->num_env].val = val; in session_env_req()
2055 s->num_env++; in session_env_req()
2059 debug2("Ignoring env request %s: disallowed name", name); in session_env_req()
2061 fail: in session_env_req()
2080 return auth_input_request_forwarding(s->pw); in session_auth_agent_req()
2090 if ((s = session_by_channel(c->self)) == NULL) { in session_input_channel_req()
2092 c->self, rtype); in session_input_channel_req()
2095 debug("session_input_channel_req: session %d req %s", s->self, rtype); in session_input_channel_req()
2101 if (c->type == SSH_CHANNEL_LARVAL) { in session_input_channel_req()
2106 } else if (strcmp(rtype, "pty-req") == 0) { in session_input_channel_req()
2108 } else if (strcmp(rtype, "x11-req") == 0) { in session_input_channel_req()
2110 } else if (strcmp(rtype, "auth-agent-req@openssh.com") == 0) { in session_input_channel_req()
2114 } else if (strcmp(rtype, "env") == 0) { in session_input_channel_req()
2118 if (strcmp(rtype, "window-change") == 0) { in session_input_channel_req()
2135 if (s->chanid == -1) in session_set_fds()
2136 fatal("no channel for session %d", s->self); in session_set_fds()
2137 channel_set_fds(s->chanid, in session_set_fds()
2154 if (s->ttyfd == -1) in session_pty_cleanup2()
2157 debug("session_pty_cleanup: session %d release %s", s->self, s->tty); in session_pty_cleanup2()
2160 if (s->pid != 0) in session_pty_cleanup2()
2161 record_logout(s->pid, s->tty, s->pw->pw_name); in session_pty_cleanup2()
2163 /* Release the pseudo-tty. */ in session_pty_cleanup2()
2165 pty_release(s->tty); in session_pty_cleanup2()
2172 if (s->ptymaster != -1 && close(s->ptymaster) < 0) in session_pty_cleanup2()
2173 error("close(s->ptymaster/%d): %s", in session_pty_cleanup2()
2174 s->ptymaster, strerror(errno)); in session_pty_cleanup2()
2177 s->ttyfd = -1; in session_pty_cleanup2()
2218 if (c->ostate != CHAN_OUTPUT_CLOSED) in session_close_x11()
2233 for (i = 0; s->x11_chanids[i] != -1; i++) { in session_close_single_x11()
2235 "closing channel %d", s->self, s->x11_chanids[i]); in session_close_single_x11()
2240 if (s->x11_chanids[i] != id) in session_close_single_x11()
2241 session_close_x11(s->x11_chanids[i]); in session_close_single_x11()
2243 free(s->x11_chanids); in session_close_single_x11()
2244 s->x11_chanids = NULL; in session_close_single_x11()
2245 free(s->display); in session_close_single_x11()
2246 s->display = NULL; in session_close_single_x11()
2247 free(s->auth_proto); in session_close_single_x11()
2248 s->auth_proto = NULL; in session_close_single_x11()
2249 free(s->auth_data); in session_close_single_x11()
2250 s->auth_data = NULL; in session_close_single_x11()
2251 free(s->auth_display); in session_close_single_x11()
2252 s->auth_display = NULL; in session_close_single_x11()
2260 if ((c = channel_lookup(s->chanid)) == NULL) in session_exit_message()
2262 s->self, s->chanid); in session_exit_message()
2264 s->self, s->chanid, (long)s->pid); in session_exit_message()
2267 channel_request_start(s->chanid, "exit-status", 0); in session_exit_message()
2271 channel_request_start(s->chanid, "exit-signal", 0); in session_exit_message()
2287 debug("session_exit_message: release channel %d", s->chanid); in session_exit_message()
2294 channel_register_cleanup(c->self, session_close_by_channel, 1); in session_exit_message()
2302 if (c->ostate != CHAN_OUTPUT_CLOSED) in session_exit_message()
2313 s->pw->pw_name, in session_close()
2316 s->self); in session_close()
2318 if (s->ttyfd != -1) in session_close()
2320 free(s->term); in session_close()
2321 free(s->display); in session_close()
2322 free(s->x11_chanids); in session_close()
2323 free(s->auth_display); in session_close()
2324 free(s->auth_data); in session_close()
2325 free(s->auth_proto); in session_close()
2326 free(s->subsys); in session_close()
2327 if (s->env != NULL) { in session_close()
2328 for (i = 0; i < s->num_env; i++) { in session_close()
2329 free(s->env[i].name); in session_close()
2330 free(s->env[i].val); in session_close()
2332 free(s->env); in session_close()
2335 session_unused(s->self); in session_close()
2347 if (s->chanid != -1) in session_close_by_pid()
2349 if (s->ttyfd != -1) in session_close_by_pid()
2351 s->pid = 0; in session_close_by_pid()
2369 id, (long)s->pid); in session_close_by_channel()
2370 if (s->pid != 0) { in session_close_by_channel()
2376 if (s->ttyfd != -1) in session_close_by_channel()
2381 channel_cancel_cleanup(s->chanid); in session_close_by_channel()
2384 if (s->x11_chanids != NULL) { in session_close_by_channel()
2385 for (i = 0; s->x11_chanids[i] != -1; i++) { in session_close_by_channel()
2386 session_close_x11(s->x11_chanids[i]); in session_close_by_channel()
2387 s->x11_chanids[i] = -1; in session_close_by_channel()
2391 s->chanid = -1; in session_close_by_channel()
2401 if (s->used) { in session_destroy_all()
2420 if (s->used && s->ttyfd != -1) { in session_tty_list()
2422 if (strncmp(s->tty, "/dev/", 5) != 0) { in session_tty_list()
2423 cp = strrchr(s->tty, '/'); in session_tty_list()
2424 cp = (cp == NULL) ? s->tty : cp + 1; in session_tty_list()
2426 cp = s->tty + 5; in session_tty_list()
2441 if (s->pw == NULL) in session_proctitle()
2442 error("no user for session %d", s->self); in session_proctitle()
2444 setproctitle("%s@%s", s->pw->pw_name, session_tty_list()); in session_proctitle()
2464 (stat(options.xauth_location, &st) == -1)) { in session_setup_x11fwd()
2468 if (s->display != NULL) { in session_setup_x11fwd()
2473 options.x11_use_localhost, s->single_connection, in session_setup_x11fwd()
2474 &s->display_number, &s->x11_chanids) == -1) { in session_setup_x11fwd()
2478 for (i = 0; s->x11_chanids[i] != -1; i++) { in session_setup_x11fwd()
2479 channel_register_cleanup(s->x11_chanids[i], in session_setup_x11fwd()
2493 s->display_number, s->screen); in session_setup_x11fwd()
2495 s->display_number, s->screen); in session_setup_x11fwd()
2496 s->display = xstrdup(display); in session_setup_x11fwd()
2497 s->auth_display = xstrdup(auth_display); in session_setup_x11fwd()
2509 memcpy(&my_addr, he->h_addr_list[0], sizeof(struct in_addr)); in session_setup_x11fwd()
2511 s->display_number, s->screen); in session_setup_x11fwd()
2514 s->display_number, s->screen); in session_setup_x11fwd()
2516 s->display = xstrdup(display); in session_setup_x11fwd()
2517 s->auth_display = xstrdup(display); in session_setup_x11fwd()
2555 if (!authctxt->authenticated) in do_cleanup()
2560 authctxt->krb5_ctx) in do_cleanup()
2570 auth_sock_cleanup_proc(authctxt->pw); in do_cleanup()