summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'session.c')
-rw-r--r--session.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/session.c b/session.c
index d87ea4d44..df7d7cf55 100644
--- a/session.c
+++ b/session.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: session.c,v 1.315 2019/02/22 03:37:11 djm Exp $ */ 1/* $OpenBSD: session.c,v 1.316 2019/06/28 13:35:04 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved 4 * All rights reserved
@@ -399,17 +399,17 @@ do_exec_no_pty(struct ssh *ssh, Session *s, const char *command)
399 fatal("do_exec_no_pty: no session"); 399 fatal("do_exec_no_pty: no session");
400 400
401 /* Allocate pipes for communicating with the program. */ 401 /* Allocate pipes for communicating with the program. */
402 if (pipe(pin) < 0) { 402 if (pipe(pin) == -1) {
403 error("%s: pipe in: %.100s", __func__, strerror(errno)); 403 error("%s: pipe in: %.100s", __func__, strerror(errno));
404 return -1; 404 return -1;
405 } 405 }
406 if (pipe(pout) < 0) { 406 if (pipe(pout) == -1) {
407 error("%s: pipe out: %.100s", __func__, strerror(errno)); 407 error("%s: pipe out: %.100s", __func__, strerror(errno));
408 close(pin[0]); 408 close(pin[0]);
409 close(pin[1]); 409 close(pin[1]);
410 return -1; 410 return -1;
411 } 411 }
412 if (pipe(perr) < 0) { 412 if (pipe(perr) == -1) {
413 error("%s: pipe err: %.100s", __func__, 413 error("%s: pipe err: %.100s", __func__,
414 strerror(errno)); 414 strerror(errno));
415 close(pin[0]); 415 close(pin[0]);
@@ -425,11 +425,11 @@ do_exec_no_pty(struct ssh *ssh, Session *s, const char *command)
425 fatal("do_exec_no_pty: no session"); 425 fatal("do_exec_no_pty: no session");
426 426
427 /* Uses socket pairs to communicate with the program. */ 427 /* Uses socket pairs to communicate with the program. */
428 if (socketpair(AF_UNIX, SOCK_STREAM, 0, inout) < 0) { 428 if (socketpair(AF_UNIX, SOCK_STREAM, 0, inout) == -1) {
429 error("%s: socketpair #1: %.100s", __func__, strerror(errno)); 429 error("%s: socketpair #1: %.100s", __func__, strerror(errno));
430 return -1; 430 return -1;
431 } 431 }
432 if (socketpair(AF_UNIX, SOCK_STREAM, 0, err) < 0) { 432 if (socketpair(AF_UNIX, SOCK_STREAM, 0, err) == -1) {
433 error("%s: socketpair #2: %.100s", __func__, 433 error("%s: socketpair #2: %.100s", __func__,
434 strerror(errno)); 434 strerror(errno));
435 close(inout[0]); 435 close(inout[0]);
@@ -465,7 +465,7 @@ do_exec_no_pty(struct ssh *ssh, Session *s, const char *command)
465 * Create a new session and process group since the 4.4BSD 465 * Create a new session and process group since the 4.4BSD
466 * setlogin() affects the entire process group. 466 * setlogin() affects the entire process group.
467 */ 467 */
468 if (setsid() < 0) 468 if (setsid() == -1)
469 error("setsid failed: %.100s", strerror(errno)); 469 error("setsid failed: %.100s", strerror(errno));
470 470
471#ifdef USE_PIPES 471#ifdef USE_PIPES
@@ -474,19 +474,19 @@ do_exec_no_pty(struct ssh *ssh, Session *s, const char *command)
474 * pair, and make the child side the standard input. 474 * pair, and make the child side the standard input.
475 */ 475 */
476 close(pin[1]); 476 close(pin[1]);
477 if (dup2(pin[0], 0) < 0) 477 if (dup2(pin[0], 0) == -1)
478 perror("dup2 stdin"); 478 perror("dup2 stdin");
479 close(pin[0]); 479 close(pin[0]);
480 480
481 /* Redirect stdout. */ 481 /* Redirect stdout. */
482 close(pout[0]); 482 close(pout[0]);
483 if (dup2(pout[1], 1) < 0) 483 if (dup2(pout[1], 1) == -1)
484 perror("dup2 stdout"); 484 perror("dup2 stdout");
485 close(pout[1]); 485 close(pout[1]);
486 486
487 /* Redirect stderr. */ 487 /* Redirect stderr. */
488 close(perr[0]); 488 close(perr[0]);
489 if (dup2(perr[1], 2) < 0) 489 if (dup2(perr[1], 2) == -1)
490 perror("dup2 stderr"); 490 perror("dup2 stderr");
491 close(perr[1]); 491 close(perr[1]);
492#else 492#else
@@ -497,12 +497,12 @@ do_exec_no_pty(struct ssh *ssh, Session *s, const char *command)
497 */ 497 */
498 close(inout[1]); 498 close(inout[1]);
499 close(err[1]); 499 close(err[1]);
500 if (dup2(inout[0], 0) < 0) /* stdin */ 500 if (dup2(inout[0], 0) == -1) /* stdin */
501 perror("dup2 stdin"); 501 perror("dup2 stdin");
502 if (dup2(inout[0], 1) < 0) /* stdout (same as stdin) */ 502 if (dup2(inout[0], 1) == -1) /* stdout (same as stdin) */
503 perror("dup2 stdout"); 503 perror("dup2 stdout");
504 close(inout[0]); 504 close(inout[0]);
505 if (dup2(err[0], 2) < 0) /* stderr */ 505 if (dup2(err[0], 2) == -1) /* stderr */
506 perror("dup2 stderr"); 506 perror("dup2 stderr");
507 close(err[0]); 507 close(err[0]);
508#endif 508#endif
@@ -577,14 +577,14 @@ do_exec_pty(struct ssh *ssh, Session *s, const char *command)
577 * Do this before forking (and cleanup in the child) so as to 577 * Do this before forking (and cleanup in the child) so as to
578 * detect and gracefully fail out-of-fd conditions. 578 * detect and gracefully fail out-of-fd conditions.
579 */ 579 */
580 if ((fdout = dup(ptyfd)) < 0) { 580 if ((fdout = dup(ptyfd)) == -1) {
581 error("%s: dup #1: %s", __func__, strerror(errno)); 581 error("%s: dup #1: %s", __func__, strerror(errno));
582 close(ttyfd); 582 close(ttyfd);
583 close(ptyfd); 583 close(ptyfd);
584 return -1; 584 return -1;
585 } 585 }
586 /* we keep a reference to the pty master */ 586 /* we keep a reference to the pty master */
587 if ((ptymaster = dup(ptyfd)) < 0) { 587 if ((ptymaster = dup(ptyfd)) == -1) {
588 error("%s: dup #2: %s", __func__, strerror(errno)); 588 error("%s: dup #2: %s", __func__, strerror(errno));
589 close(ttyfd); 589 close(ttyfd);
590 close(ptyfd); 590 close(ptyfd);
@@ -614,11 +614,11 @@ do_exec_pty(struct ssh *ssh, Session *s, const char *command)
614 pty_make_controlling_tty(&ttyfd, s->tty); 614 pty_make_controlling_tty(&ttyfd, s->tty);
615 615
616 /* Redirect stdin/stdout/stderr from the pseudo tty. */ 616 /* Redirect stdin/stdout/stderr from the pseudo tty. */
617 if (dup2(ttyfd, 0) < 0) 617 if (dup2(ttyfd, 0) == -1)
618 error("dup2 stdin: %s", strerror(errno)); 618 error("dup2 stdin: %s", strerror(errno));
619 if (dup2(ttyfd, 1) < 0) 619 if (dup2(ttyfd, 1) == -1)
620 error("dup2 stdout: %s", strerror(errno)); 620 error("dup2 stdout: %s", strerror(errno));
621 if (dup2(ttyfd, 2) < 0) 621 if (dup2(ttyfd, 2) == -1)
622 error("dup2 stderr: %s", strerror(errno)); 622 error("dup2 stderr: %s", strerror(errno));
623 623
624 /* Close the extra descriptor for the pseudo tty. */ 624 /* Close the extra descriptor for the pseudo tty. */
@@ -755,7 +755,7 @@ do_login(struct ssh *ssh, Session *s, const char *command)
755 fromlen = sizeof(from); 755 fromlen = sizeof(from);
756 if (ssh_packet_connection_is_on_socket(ssh)) { 756 if (ssh_packet_connection_is_on_socket(ssh)) {
757 if (getpeername(ssh_packet_get_connection_in(ssh), 757 if (getpeername(ssh_packet_get_connection_in(ssh),
758 (struct sockaddr *)&from, &fromlen) < 0) { 758 (struct sockaddr *)&from, &fromlen) == -1) {
759 debug("getpeername: %.100s", strerror(errno)); 759 debug("getpeername: %.100s", strerror(errno));
760 cleanup_exit(255); 760 cleanup_exit(255);
761 } 761 }
@@ -1619,7 +1619,7 @@ do_child(struct ssh *ssh, Session *s, const char *command)
1619#endif 1619#endif
1620 1620
1621 /* Change current directory to the user's home directory. */ 1621 /* Change current directory to the user's home directory. */
1622 if (chdir(pw->pw_dir) < 0) { 1622 if (chdir(pw->pw_dir) == -1) {
1623 /* Suppress missing homedir warning for chroot case */ 1623 /* Suppress missing homedir warning for chroot case */
1624#ifdef HAVE_LOGIN_CAP 1624#ifdef HAVE_LOGIN_CAP
1625 r = login_getcapbool(lc, "requirehome", 0); 1625 r = login_getcapbool(lc, "requirehome", 0);
@@ -1973,7 +1973,7 @@ session_subsystem_req(struct ssh *ssh, Session *s)
1973 s->is_subsystem = SUBSYSTEM_INT_SFTP; 1973 s->is_subsystem = SUBSYSTEM_INT_SFTP;
1974 debug("subsystem: %s", prog); 1974 debug("subsystem: %s", prog);
1975 } else { 1975 } else {
1976 if (stat(prog, &st) < 0) 1976 if (stat(prog, &st) == -1)
1977 debug("subsystem: cannot stat %s: %s", 1977 debug("subsystem: cannot stat %s: %s",
1978 prog, strerror(errno)); 1978 prog, strerror(errno));
1979 s->is_subsystem = SUBSYSTEM_EXT; 1979 s->is_subsystem = SUBSYSTEM_EXT;
@@ -2062,7 +2062,7 @@ session_break_req(struct ssh *ssh, Session *s)
2062 (r = sshpkt_get_end(ssh)) != 0) 2062 (r = sshpkt_get_end(ssh)) != 0)
2063 sshpkt_fatal(ssh, r, "%s: parse packet", __func__); 2063 sshpkt_fatal(ssh, r, "%s: parse packet", __func__);
2064 2064
2065 if (s->ptymaster == -1 || tcsendbreak(s->ptymaster, 0) < 0) 2065 if (s->ptymaster == -1 || tcsendbreak(s->ptymaster, 0) == -1)
2066 return 0; 2066 return 0;
2067 return 1; 2067 return 1;
2068} 2068}
@@ -2286,7 +2286,7 @@ session_pty_cleanup2(Session *s)
2286 * the pty cleanup, so that another process doesn't get this pty 2286 * the pty cleanup, so that another process doesn't get this pty
2287 * while we're still cleaning up. 2287 * while we're still cleaning up.
2288 */ 2288 */
2289 if (s->ptymaster != -1 && close(s->ptymaster) < 0) 2289 if (s->ptymaster != -1 && close(s->ptymaster) == -1)
2290 error("close(s->ptymaster/%d): %s", 2290 error("close(s->ptymaster/%d): %s",
2291 s->ptymaster, strerror(errno)); 2291 s->ptymaster, strerror(errno));
2292 2292
@@ -2598,7 +2598,7 @@ session_setup_x11fwd(struct ssh *ssh, Session *s)
2598 } 2598 }
2599 2599
2600 /* Set up a suitable value for the DISPLAY variable. */ 2600 /* Set up a suitable value for the DISPLAY variable. */
2601 if (gethostname(hostname, sizeof(hostname)) < 0) 2601 if (gethostname(hostname, sizeof(hostname)) == -1)
2602 fatal("gethostname: %.100s", strerror(errno)); 2602 fatal("gethostname: %.100s", strerror(errno));
2603 /* 2603 /*
2604 * auth_display must be used as the displayname when the 2604 * auth_display must be used as the displayname when the