version 1.8, 2000/04/29 16:06:08 |
version 1.9, 2000/05/02 07:32:44 |
|
|
Session *session_new(void); |
Session *session_new(void); |
void session_set_fds(Session *s, int fdin, int fdout, int fderr); |
void session_set_fds(Session *s, int fdin, int fdout, int fderr); |
void session_pty_cleanup(Session *s); |
void session_pty_cleanup(Session *s); |
|
void session_proctitle(Session *s); |
void do_exec_pty(Session *s, const char *command, struct passwd * pw); |
void do_exec_pty(Session *s, const char *command, struct passwd * pw); |
void do_exec_no_pty(Session *s, const char *command, struct passwd * pw); |
void do_exec_no_pty(Session *s, const char *command, struct passwd * pw); |
|
|
|
|
if (s == NULL) |
if (s == NULL) |
fatal("do_exec_no_pty: no session"); |
fatal("do_exec_no_pty: no session"); |
|
|
setproctitle("%s@notty", pw->pw_name); |
session_proctitle(s); |
|
|
/* Fork the child. */ |
/* Fork the child. */ |
if ((pid = fork()) == 0) { |
if ((pid = fork()) == 0) { |
|
|
last_login_time = get_last_login_time(pw->pw_uid, pw->pw_name, |
last_login_time = get_last_login_time(pw->pw_uid, pw->pw_name, |
buf, sizeof(buf)); |
buf, sizeof(buf)); |
} |
} |
setproctitle("%s@%s", pw->pw_name, strrchr(s->tty, '/') + 1); |
|
|
|
/* Fork the child. */ |
/* Fork the child. */ |
if ((pid = fork()) == 0) { |
if ((pid = fork()) == 0) { |
|
|
/* Get window size from the packet. */ |
/* Get window size from the packet. */ |
pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel); |
pty_change_window_size(s->ptyfd, s->row, s->col, s->xpixel, s->ypixel); |
|
|
|
session_proctitle(s); |
|
|
/* XXX parse and set terminal modes */ |
/* XXX parse and set terminal modes */ |
xfree(term_modes); |
xfree(term_modes); |
return 1; |
return 1; |
|
|
{ |
{ |
session_pty_cleanup(s); |
session_pty_cleanup(s); |
session_free(s); |
session_free(s); |
|
session_proctitle(s); |
} |
} |
|
|
void |
void |
|
|
error("session_close_by_channel: kill %d: %s", |
error("session_close_by_channel: kill %d: %s", |
s->pid, strerror(errno)); |
s->pid, strerror(errno)); |
} |
} |
|
} |
|
|
|
char * |
|
session_tty_list(void) |
|
{ |
|
static char buf[1024]; |
|
int i; |
|
buf[0] = '\0'; |
|
for(i = 0; i < MAX_SESSIONS; i++) { |
|
Session *s = &sessions[i]; |
|
if (s->used && s->ttyfd != -1) { |
|
if (buf[0] != '\0') |
|
strlcat(buf, ",", sizeof buf); |
|
strlcat(buf, strrchr(s->tty, '/') + 1, sizeof buf); |
|
} |
|
} |
|
if (buf[0] == '\0') |
|
strlcpy(buf, "notty", sizeof buf); |
|
return buf; |
|
} |
|
|
|
void |
|
session_proctitle(Session *s) |
|
{ |
|
if (s->pw == NULL) |
|
error("no user for session %d", s->self); |
|
else |
|
setproctitle("%s@%s", s->pw->pw_name, session_tty_list()); |
} |
} |
|
|
void |
void |