=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/sftp-client.c,v retrieving revision 1.104 retrieving revision 1.105 diff -u -r1.104 -r1.105 --- src/usr.bin/ssh/sftp-client.c 2013/09/19 00:49:12 1.104 +++ src/usr.bin/ssh/sftp-client.c 2013/10/11 02:45:36 1.105 @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-client.c,v 1.104 2013/09/19 00:49:12 djm Exp $ */ +/* $OpenBSD: sftp-client.c,v 1.105 2013/10/11 02:45:36 djm Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -441,7 +441,7 @@ static int -do_lsreaddir(struct sftp_conn *conn, char *path, int printflag, +do_lsreaddir(struct sftp_conn *conn, char *path, int print_flag, SFTP_DIRENT ***dir) { Buffer msg; @@ -523,7 +523,7 @@ longname = buffer_get_string(&msg, NULL); a = decode_attrib(&msg); - if (printflag) + if (print_flag) printf("%s\n", longname); /* @@ -599,7 +599,7 @@ } int -do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int printflag) +do_mkdir(struct sftp_conn *conn, char *path, Attrib *a, int print_flag) { u_int status, id; @@ -608,7 +608,7 @@ strlen(path), a); status = get_status(conn, id); - if (status != SSH2_FX_OK && printflag) + if (status != SSH2_FX_OK && print_flag) error("Couldn't create directory: %s", fx2txt(status)); return(status); @@ -984,7 +984,7 @@ int do_download(struct sftp_conn *conn, char *remote_path, char *local_path, - Attrib *a, int pflag, int resume) + Attrib *a, int preserve_flag, int resume_flag) { Attrib junk; Buffer msg; @@ -1047,15 +1047,15 @@ return(-1); } - local_fd = open(local_path, O_WRONLY | O_CREAT | (resume ? : O_TRUNC), - mode | S_IWUSR); + local_fd = open(local_path, + O_WRONLY | O_CREAT | (resume_flag ? 0 : O_TRUNC), mode | S_IWUSR); if (local_fd == -1) { error("Couldn't open local file \"%s\" for writing: %s", local_path, strerror(errno)); goto fail; } offset = highwater = 0; - if (resume) { + if (resume_flag) { if (fstat(local_fd, &st) == -1) { error("Unable to stat local file \"%s\": %s", local_path, strerror(errno)); @@ -1205,7 +1205,7 @@ fatal("Transfer complete, but requests still in queue"); /* Truncate at highest contiguous point to avoid holes on interrupt */ if (read_error || write_error || interrupted) { - if (reordered && resume) { + if (reordered && resume_flag) { error("Unable to resume download of \"%s\": " "server reordered requests", local_path); } @@ -1227,10 +1227,11 @@ if (interrupted || status != SSH2_FX_OK) status = -1; /* Override umask and utimes if asked */ - if (pflag && fchmod(local_fd, mode) == -1) + if (preserve_flag && fchmod(local_fd, mode) == -1) error("Couldn't set mode on \"%s\": %s", local_path, strerror(errno)); - if (pflag && (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME)) { + if (preserve_flag && + (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME)) { struct timeval tv[2]; tv[0].tv_sec = a->atime; tv[1].tv_sec = a->mtime; @@ -1248,8 +1249,8 @@ } static int -download_dir_internal(struct sftp_conn *conn, char *src, char *dst, - Attrib *dirattrib, int pflag, int printflag, int depth, int resume) +download_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth, + Attrib *dirattrib, int preserve_flag, int print_flag, int resume_flag) { int i, ret = 0; SFTP_DIRENT **dir_entries; @@ -1270,7 +1271,7 @@ error("\"%s\" is not a directory", src); return -1; } - if (printflag) + if (print_flag) printf("Retrieving %s\n", src); if (dirattrib->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) @@ -1301,12 +1302,12 @@ strcmp(filename, "..") == 0) continue; if (download_dir_internal(conn, new_src, new_dst, - &(dir_entries[i]->a), pflag, printflag, - depth + 1, resume) == -1) + depth + 1, &(dir_entries[i]->a), preserve_flag, + print_flag, resume_flag) == -1) ret = -1; } else if (S_ISREG(dir_entries[i]->a.perm) ) { if (do_download(conn, new_src, new_dst, - &(dir_entries[i]->a), pflag, resume) == -1) { + &(dir_entries[i]->a), preserve_flag, resume_flag) == -1) { error("Download of file %s to %s failed", new_src, new_dst); ret = -1; @@ -1318,7 +1319,7 @@ free(new_src); } - if (pflag) { + if (preserve_flag) { if (dirattrib->flags & SSH2_FILEXFER_ATTR_ACMODTIME) { struct timeval tv[2]; tv[0].tv_sec = dirattrib->atime; @@ -1339,7 +1340,7 @@ int download_dir(struct sftp_conn *conn, char *src, char *dst, - Attrib *dirattrib, int pflag, int printflag, int resume) + Attrib *dirattrib, int preserve_flag, int print_flag, int resume_flag) { char *src_canon; int ret; @@ -1349,15 +1350,15 @@ return -1; } - ret = download_dir_internal(conn, src_canon, dst, - dirattrib, pflag, printflag, 0, resume); + ret = download_dir_internal(conn, src_canon, dst, 0, + dirattrib, preserve_flag, print_flag, resume_flag); free(src_canon); return ret; } int do_upload(struct sftp_conn *conn, char *local_path, char *remote_path, - int pflag) + int preserve_flag) { int local_fd; int status = SSH2_FX_OK; @@ -1401,7 +1402,7 @@ a.flags &= ~SSH2_FILEXFER_ATTR_SIZE; a.flags &= ~SSH2_FILEXFER_ATTR_UIDGID; a.perm &= 0777; - if (!pflag) + if (!preserve_flag) a.flags &= ~SSH2_FILEXFER_ATTR_ACMODTIME; buffer_init(&msg); @@ -1529,7 +1530,7 @@ } /* Override umask and utimes if asked */ - if (pflag) + if (preserve_flag) do_fsetstat(conn, handle, handle_len, &a); if (do_close(conn, handle, handle_len) != SSH2_FX_OK) @@ -1540,8 +1541,8 @@ } static int -upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, - int pflag, int printflag, int depth) +upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, int depth, + int preserve_flag, int print_flag) { int ret = 0, status; DIR *dirp; @@ -1564,7 +1565,7 @@ error("\"%s\" is not a directory", src); return -1; } - if (printflag) + if (print_flag) printf("Entering %s\n", src); attrib_clear(&a); @@ -1572,7 +1573,7 @@ a.flags &= ~SSH2_FILEXFER_ATTR_SIZE; a.flags &= ~SSH2_FILEXFER_ATTR_UIDGID; a.perm &= 01777; - if (!pflag) + if (!preserve_flag) a.flags &= ~SSH2_FILEXFER_ATTR_ACMODTIME; status = do_mkdir(conn, dst, &a, 0); @@ -1610,10 +1611,11 @@ continue; if (upload_dir_internal(conn, new_src, new_dst, - pflag, printflag, depth + 1) == -1) + depth + 1, preserve_flag, print_flag) == -1) ret = -1; } else if (S_ISREG(sb.st_mode)) { - if (do_upload(conn, new_src, new_dst, pflag) == -1) { + if (do_upload(conn, new_src, new_dst, + preserve_flag) == -1) { error("Uploading of file %s to %s failed!", new_src, new_dst); ret = -1; @@ -1631,8 +1633,8 @@ } int -upload_dir(struct sftp_conn *conn, char *src, char *dst, int pflag, - int printflag) +upload_dir(struct sftp_conn *conn, char *src, char *dst, int preserve_flag, + int print_flag) { char *dst_canon; int ret; @@ -1642,7 +1644,8 @@ return -1; } - ret = upload_dir_internal(conn, src, dst_canon, pflag, printflag, 0); + ret = upload_dir_internal(conn, src, dst_canon, preserve_flag, + print_flag, 0); free(dst_canon); return ret; }