summaryrefslogtreecommitdiff
path: root/sftp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sftp.c')
-rw-r--r--sftp.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/sftp.c b/sftp.c
index 08e13a733..2b8fdabfb 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp.c,v 1.175 2016/07/22 03:47:36 djm Exp $ */ 1/* $OpenBSD: sftp.c,v 1.177 2016/10/18 12:41:22 millert Exp $ */
2/* 2/*
3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -17,7 +17,6 @@
17 17
18#include "includes.h" 18#include "includes.h"
19 19
20#include <sys/param.h> /* MIN MAX */
21#include <sys/types.h> 20#include <sys/types.h>
22#include <sys/ioctl.h> 21#include <sys/ioctl.h>
23#ifdef HAVE_SYS_STAT_H 22#ifdef HAVE_SYS_STAT_H
@@ -233,6 +232,18 @@ killchild(int signo)
233 232
234/* ARGSUSED */ 233/* ARGSUSED */
235static void 234static void
235suspchild(int signo)
236{
237 if (sshpid > 1) {
238 kill(sshpid, signo);
239 while (waitpid(sshpid, NULL, WUNTRACED) == -1 && errno == EINTR)
240 continue;
241 }
242 kill(getpid(), SIGSTOP);
243}
244
245/* ARGSUSED */
246static void
236cmd_interrupt(int signo) 247cmd_interrupt(int signo)
237{ 248{
238 const char msg[] = "\rInterrupt \n"; 249 const char msg[] = "\rInterrupt \n";
@@ -802,7 +813,7 @@ do_ls_dir(struct sftp_conn *conn, const char *path,
802 /* Count entries for sort and find longest filename */ 813 /* Count entries for sort and find longest filename */
803 for (n = 0; d[n] != NULL; n++) { 814 for (n = 0; d[n] != NULL; n++) {
804 if (d[n]->filename[0] != '.' || (lflag & LS_SHOW_ALL)) 815 if (d[n]->filename[0] != '.' || (lflag & LS_SHOW_ALL))
805 m = MAX(m, strlen(d[n]->filename)); 816 m = MAXIMUM(m, strlen(d[n]->filename));
806 } 817 }
807 818
808 /* Add any subpath that also needs to be counted */ 819 /* Add any subpath that also needs to be counted */
@@ -814,9 +825,9 @@ do_ls_dir(struct sftp_conn *conn, const char *path,
814 width = ws.ws_col; 825 width = ws.ws_col;
815 826
816 columns = width / (m + 2); 827 columns = width / (m + 2);
817 columns = MAX(columns, 1); 828 columns = MAXIMUM(columns, 1);
818 colspace = width / columns; 829 colspace = width / columns;
819 colspace = MIN(colspace, width); 830 colspace = MINIMUM(colspace, width);
820 } 831 }
821 832
822 if (lflag & SORT_FLAGS) { 833 if (lflag & SORT_FLAGS) {
@@ -915,10 +926,10 @@ do_globbed_ls(struct sftp_conn *conn, const char *path,
915 if (!(lflag & LS_SHORT_VIEW)) { 926 if (!(lflag & LS_SHORT_VIEW)) {
916 /* Count entries for sort and find longest filename */ 927 /* Count entries for sort and find longest filename */
917 for (i = 0; g.gl_pathv[i]; i++) 928 for (i = 0; g.gl_pathv[i]; i++)
918 m = MAX(m, strlen(g.gl_pathv[i])); 929 m = MAXIMUM(m, strlen(g.gl_pathv[i]));
919 930
920 columns = width / (m + 2); 931 columns = width / (m + 2);
921 columns = MAX(columns, 1); 932 columns = MAXIMUM(columns, 1);
922 colspace = width / columns; 933 colspace = width / columns;
923 } 934 }
924 935
@@ -1669,16 +1680,16 @@ complete_display(char **list, u_int len)
1669 1680
1670 /* Count entries for sort and find longest */ 1681 /* Count entries for sort and find longest */
1671 for (y = 0; list[y]; y++) 1682 for (y = 0; list[y]; y++)
1672 m = MAX(m, strlen(list[y])); 1683 m = MAXIMUM(m, strlen(list[y]));
1673 1684
1674 if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1) 1685 if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)
1675 width = ws.ws_col; 1686 width = ws.ws_col;
1676 1687
1677 m = m > len ? m - len : 0; 1688 m = m > len ? m - len : 0;
1678 columns = width / (m + 2); 1689 columns = width / (m + 2);
1679 columns = MAX(columns, 1); 1690 columns = MAXIMUM(columns, 1);
1680 colspace = width / columns; 1691 colspace = width / columns;
1681 colspace = MIN(colspace, width); 1692 colspace = MINIMUM(colspace, width);
1682 1693
1683 printf("\n"); 1694 printf("\n");
1684 m = 1; 1695 m = 1;
@@ -2214,6 +2225,9 @@ connect_to_server(char *path, char **args, int *in, int *out)
2214 signal(SIGTERM, killchild); 2225 signal(SIGTERM, killchild);
2215 signal(SIGINT, killchild); 2226 signal(SIGINT, killchild);
2216 signal(SIGHUP, killchild); 2227 signal(SIGHUP, killchild);
2228 signal(SIGTSTP, suspchild);
2229 signal(SIGTTIN, suspchild);
2230 signal(SIGTTOU, suspchild);
2217 close(c_in); 2231 close(c_in);
2218 close(c_out); 2232 close(c_out);
2219} 2233}
@@ -2258,7 +2272,7 @@ main(int argc, char **argv)
2258 ssh_malloc_init(); /* must be called before any mallocs */ 2272 ssh_malloc_init(); /* must be called before any mallocs */
2259 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 2273 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
2260 sanitise_stdfd(); 2274 sanitise_stdfd();
2261 setlocale(LC_CTYPE, ""); 2275 msetlocale();
2262 2276
2263 __progname = ssh_get_progname(argv[0]); 2277 __progname = ssh_get_progname(argv[0]);
2264 memset(&args, '\0', sizeof(args)); 2278 memset(&args, '\0', sizeof(args));