diff options
author | Damien Miller <djm@mindrot.org> | 2013-04-23 15:22:40 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2013-04-23 15:22:40 +1000 |
commit | 9303e6527bb5ca7630c765f28624702c212bfd6c (patch) | |
tree | 2ab20f483ec614db9ac99156bd4f2c2932e271be | |
parent | f1a02aea35504e8bef2ed9eef6f9ddeab12bacb3 (diff) |
- djm@cvs.openbsd.org 2013/04/18 02:16:07
[sftp.c]
make "sftp -q" do what it says on the sticker: hush everything but errors;
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | sftp.c | 34 |
2 files changed, 27 insertions, 10 deletions
@@ -53,6 +53,9 @@ | |||
53 | - dtucker@cvs.openbsd.org 2013/04/17 09:04:09 | 53 | - dtucker@cvs.openbsd.org 2013/04/17 09:04:09 |
54 | [session.c] | 54 | [session.c] |
55 | revert rev 1.262; it fails because uid is already set here. ok djm@ | 55 | revert rev 1.262; it fails because uid is already set here. ok djm@ |
56 | - djm@cvs.openbsd.org 2013/04/18 02:16:07 | ||
57 | [sftp.c] | ||
58 | make "sftp -q" do what it says on the sticker: hush everything but errors; | ||
56 | 59 | ||
57 | 20130418 | 60 | 20130418 |
58 | - (djm) [config.guess config.sub] Update to last versions before they switch | 61 | - (djm) [config.guess config.sub] Update to last versions before they switch |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sftp.c,v 1.142 2013/02/08 00:41:12 djm Exp $ */ | 1 | /* $OpenBSD: sftp.c,v 1.143 2013/04/18 02:16:07 djm 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 | * |
@@ -76,6 +76,9 @@ int batchmode = 0; | |||
76 | /* PID of ssh transport process */ | 76 | /* PID of ssh transport process */ |
77 | static pid_t sshpid = -1; | 77 | static pid_t sshpid = -1; |
78 | 78 | ||
79 | /* Suppress diagnositic messages */ | ||
80 | int quiet = 0; | ||
81 | |||
79 | /* This is set to 0 if the progressmeter is not desired. */ | 82 | /* This is set to 0 if the progressmeter is not desired. */ |
80 | int showprogress = 1; | 83 | int showprogress = 1; |
81 | 84 | ||
@@ -565,7 +568,8 @@ process_get(struct sftp_conn *conn, char *src, char *dst, char *pwd, | |||
565 | } | 568 | } |
566 | xfree(tmp); | 569 | xfree(tmp); |
567 | 570 | ||
568 | printf("Fetching %s to %s\n", g.gl_pathv[i], abs_dst); | 571 | if (!quiet) |
572 | printf("Fetching %s to %s\n", g.gl_pathv[i], abs_dst); | ||
569 | if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) { | 573 | if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) { |
570 | if (download_dir(conn, g.gl_pathv[i], abs_dst, NULL, | 574 | if (download_dir(conn, g.gl_pathv[i], abs_dst, NULL, |
571 | pflag || global_pflag, 1) == -1) | 575 | pflag || global_pflag, 1) == -1) |
@@ -650,7 +654,8 @@ process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd, | |||
650 | } | 654 | } |
651 | xfree(tmp); | 655 | xfree(tmp); |
652 | 656 | ||
653 | printf("Uploading %s to %s\n", g.gl_pathv[i], abs_dst); | 657 | if (!quiet) |
658 | printf("Uploading %s to %s\n", g.gl_pathv[i], abs_dst); | ||
654 | if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) { | 659 | if (pathname_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) { |
655 | if (upload_dir(conn, g.gl_pathv[i], abs_dst, | 660 | if (upload_dir(conn, g.gl_pathv[i], abs_dst, |
656 | pflag || global_pflag, 1) == -1) | 661 | pflag || global_pflag, 1) == -1) |
@@ -1335,7 +1340,8 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd, | |||
1335 | path1 = make_absolute(path1, *pwd); | 1340 | path1 = make_absolute(path1, *pwd); |
1336 | remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g); | 1341 | remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g); |
1337 | for (i = 0; g.gl_pathv[i] && !interrupted; i++) { | 1342 | for (i = 0; g.gl_pathv[i] && !interrupted; i++) { |
1338 | printf("Removing %s\n", g.gl_pathv[i]); | 1343 | if (!quiet) |
1344 | printf("Removing %s\n", g.gl_pathv[i]); | ||
1339 | err = do_rm(conn, g.gl_pathv[i]); | 1345 | err = do_rm(conn, g.gl_pathv[i]); |
1340 | if (err != 0 && err_abort) | 1346 | if (err != 0 && err_abort) |
1341 | break; | 1347 | break; |
@@ -1431,7 +1437,8 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd, | |||
1431 | a.perm = n_arg; | 1437 | a.perm = n_arg; |
1432 | remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g); | 1438 | remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g); |
1433 | for (i = 0; g.gl_pathv[i] && !interrupted; i++) { | 1439 | for (i = 0; g.gl_pathv[i] && !interrupted; i++) { |
1434 | printf("Changing mode on %s\n", g.gl_pathv[i]); | 1440 | if (!quiet) |
1441 | printf("Changing mode on %s\n", g.gl_pathv[i]); | ||
1435 | err = do_setstat(conn, g.gl_pathv[i], &a); | 1442 | err = do_setstat(conn, g.gl_pathv[i], &a); |
1436 | if (err != 0 && err_abort) | 1443 | if (err != 0 && err_abort) |
1437 | break; | 1444 | break; |
@@ -1460,10 +1467,14 @@ parse_dispatch_command(struct sftp_conn *conn, const char *cmd, char **pwd, | |||
1460 | } | 1467 | } |
1461 | aa->flags &= SSH2_FILEXFER_ATTR_UIDGID; | 1468 | aa->flags &= SSH2_FILEXFER_ATTR_UIDGID; |
1462 | if (cmdnum == I_CHOWN) { | 1469 | if (cmdnum == I_CHOWN) { |
1463 | printf("Changing owner on %s\n", g.gl_pathv[i]); | 1470 | if (!quiet) |
1471 | printf("Changing owner on %s\n", | ||
1472 | g.gl_pathv[i]); | ||
1464 | aa->uid = n_arg; | 1473 | aa->uid = n_arg; |
1465 | } else { | 1474 | } else { |
1466 | printf("Changing group on %s\n", g.gl_pathv[i]); | 1475 | if (!quiet) |
1476 | printf("Changing group on %s\n", | ||
1477 | g.gl_pathv[i]); | ||
1467 | aa->gid = n_arg; | 1478 | aa->gid = n_arg; |
1468 | } | 1479 | } |
1469 | err = do_setstat(conn, g.gl_pathv[i], aa); | 1480 | err = do_setstat(conn, g.gl_pathv[i], aa); |
@@ -1922,7 +1933,8 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2) | |||
1922 | dir = make_absolute(dir, remote_path); | 1933 | dir = make_absolute(dir, remote_path); |
1923 | 1934 | ||
1924 | if (remote_is_dir(conn, dir) && file2 == NULL) { | 1935 | if (remote_is_dir(conn, dir) && file2 == NULL) { |
1925 | printf("Changing to: %s\n", dir); | 1936 | if (!quiet) |
1937 | printf("Changing to: %s\n", dir); | ||
1926 | snprintf(cmd, sizeof cmd, "cd \"%s\"", dir); | 1938 | snprintf(cmd, sizeof cmd, "cd \"%s\"", dir); |
1927 | if (parse_dispatch_command(conn, cmd, | 1939 | if (parse_dispatch_command(conn, cmd, |
1928 | &remote_path, 1) != 0) { | 1940 | &remote_path, 1) != 0) { |
@@ -2143,6 +2155,8 @@ main(int argc, char **argv) | |||
2143 | addargs(&args, "%s", optarg); | 2155 | addargs(&args, "%s", optarg); |
2144 | break; | 2156 | break; |
2145 | case 'q': | 2157 | case 'q': |
2158 | ll = SYSLOG_LEVEL_ERROR; | ||
2159 | quiet = 1; | ||
2146 | showprogress = 0; | 2160 | showprogress = 0; |
2147 | addargs(&args, "-%c", ch); | 2161 | addargs(&args, "-%c", ch); |
2148 | break; | 2162 | break; |
@@ -2178,7 +2192,7 @@ main(int argc, char **argv) | |||
2178 | (infile = fopen(optarg, "r")) == NULL) | 2192 | (infile = fopen(optarg, "r")) == NULL) |
2179 | fatal("%s (%s).", strerror(errno), optarg); | 2193 | fatal("%s (%s).", strerror(errno), optarg); |
2180 | showprogress = 0; | 2194 | showprogress = 0; |
2181 | batchmode = 1; | 2195 | quiet = batchmode = 1; |
2182 | addargs(&args, "-obatchmode yes"); | 2196 | addargs(&args, "-obatchmode yes"); |
2183 | break; | 2197 | break; |
2184 | case 'p': | 2198 | case 'p': |
@@ -2275,7 +2289,7 @@ main(int argc, char **argv) | |||
2275 | if (conn == NULL) | 2289 | if (conn == NULL) |
2276 | fatal("Couldn't initialise connection to server"); | 2290 | fatal("Couldn't initialise connection to server"); |
2277 | 2291 | ||
2278 | if (!batchmode) { | 2292 | if (!quiet) { |
2279 | if (sftp_direct == NULL) | 2293 | if (sftp_direct == NULL) |
2280 | fprintf(stderr, "Connected to %s.\n", host); | 2294 | fprintf(stderr, "Connected to %s.\n", host); |
2281 | else | 2295 | else |