mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-23 05:55:41 +02:00
Handle parameters and some output messages.
This commit is contained in:
parent
0b55122f42
commit
e3ad6f1c65
74
scp.c
74
scp.c
@ -251,6 +251,9 @@ char *port = NULL;
|
|||||||
/* This is set password if given on the command line. */
|
/* This is set password if given on the command line. */
|
||||||
char *password = NULL;
|
char *password = NULL;
|
||||||
|
|
||||||
|
/* This is set ssh_config if given on the command line. */
|
||||||
|
char *ssh_config = NULL;
|
||||||
|
|
||||||
int ipv_restrict = 0;
|
int ipv_restrict = 0;
|
||||||
|
|
||||||
#define ONLY_IPV4 1
|
#define ONLY_IPV4 1
|
||||||
@ -811,6 +814,10 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
|
|||||||
args[i++] = "-p";
|
args[i++] = "-p";
|
||||||
args[i++] = port;
|
args[i++] = port;
|
||||||
}
|
}
|
||||||
|
if (ssh_config) {
|
||||||
|
args[i++] = "-F";
|
||||||
|
args[i++] = ssh_config;
|
||||||
|
}
|
||||||
if (remuser != NULL) {
|
if (remuser != NULL) {
|
||||||
args[i++] = "-l";
|
args[i++] = "-l";
|
||||||
args[i++] = remuser;
|
args[i++] = remuser;
|
||||||
@ -893,6 +900,18 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
|
|||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (port)
|
||||||
|
free(port);
|
||||||
|
|
||||||
|
if (cipher)
|
||||||
|
free(cipher);
|
||||||
|
|
||||||
|
if (identity)
|
||||||
|
free(identity);
|
||||||
|
|
||||||
|
if (ssh_config)
|
||||||
|
free(ssh_config);
|
||||||
|
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
printf("%s could not be started\n", ssh_program);
|
printf("%s could not be started\n", ssh_program);
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -1100,32 +1119,67 @@ main(int argc, char **argv)
|
|||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
case '4':
|
case '4':
|
||||||
|
ipv_restrict = ONLY_IPV4;
|
||||||
|
break;
|
||||||
case '6':
|
case '6':
|
||||||
|
ipv_restrict = ONLY_IPV6;
|
||||||
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
addargs(&args, "-%c", ch);
|
addargs(&args, "-%c", ch);
|
||||||
addargs(&remote_remote_args, "-%c", ch);
|
addargs(&remote_remote_args, "-%c", ch);
|
||||||
|
|
||||||
|
compress = ch;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case '3':
|
case '3':
|
||||||
throughlocal = 1;
|
throughlocal = 1;
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
case 'c':
|
case 'c':
|
||||||
|
addargs(&remote_remote_args, "-%c", ch);
|
||||||
|
addargs(&remote_remote_args, "%s", optarg);
|
||||||
|
addargs(&args, "-%c", ch);
|
||||||
|
addargs(&args, "%s", optarg);
|
||||||
|
|
||||||
|
cipher = malloc(strlen(optarg) + 1);
|
||||||
|
if (cipher)
|
||||||
|
strcpy(cipher, optarg);
|
||||||
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
|
addargs(&remote_remote_args, "-%c", ch);
|
||||||
|
addargs(&remote_remote_args, "%s", optarg);
|
||||||
|
addargs(&args, "-%c", ch);
|
||||||
|
addargs(&args, "%s", optarg);
|
||||||
|
|
||||||
|
identity = malloc(strlen(optarg) + 1);
|
||||||
|
if (identity)
|
||||||
|
strcpy(identity, optarg);
|
||||||
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
addargs(&remote_remote_args, "-%c", ch);
|
addargs(&remote_remote_args, "-%c", ch);
|
||||||
addargs(&remote_remote_args, "%s", optarg);
|
addargs(&remote_remote_args, "%s", optarg);
|
||||||
addargs(&args, "-%c", ch);
|
addargs(&args, "-%c", ch);
|
||||||
addargs(&args, "%s", optarg);
|
addargs(&args, "%s", optarg);
|
||||||
|
|
||||||
|
ssh_config = malloc(strlen(optarg) + 1);
|
||||||
|
if (ssh_config)
|
||||||
|
strcpy(ssh_config, optarg);
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
addargs(&remote_remote_args, "-p");
|
addargs(&remote_remote_args, "-p");
|
||||||
addargs(&remote_remote_args, "%s", optarg);
|
addargs(&remote_remote_args, "%s", optarg);
|
||||||
addargs(&args, "-p");
|
addargs(&args, "-p");
|
||||||
addargs(&args, "%s", optarg);
|
addargs(&args, "%s", optarg);
|
||||||
|
|
||||||
|
port = malloc(strlen(optarg) + 1);
|
||||||
|
if (port)
|
||||||
|
strcpy(port, optarg);
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
addargs(&remote_remote_args, "\"-oBatchmode yes\"");
|
addargs(&remote_remote_args, "\"-oBatchmode yes\"");
|
||||||
addargs(&args, "\"-oBatchmode yes\"");
|
addargs(&args, "\"-oBatchmode yes\"");
|
||||||
|
|
||||||
|
batchmode = 1;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
limit_kbps = strtonum(optarg, 1, 100 * 1024 * 1024,
|
limit_kbps = strtonum(optarg, 1, 100 * 1024 * 1024,
|
||||||
@ -1590,7 +1644,17 @@ rsource(char *name, struct stat *statp)
|
|||||||
(void) snprintf(path, sizeof path, "D%04o %d %.1024s\n",
|
(void) snprintf(path, sizeof path, "D%04o %d %.1024s\n",
|
||||||
(u_int) (statp->st_mode & FILEMODEMASK), 0, last);
|
(u_int) (statp->st_mode & FILEMODEMASK), 0, last);
|
||||||
if (verbose_mode)
|
if (verbose_mode)
|
||||||
|
#ifdef WINDOWS
|
||||||
|
{
|
||||||
|
printf("Entering directory: ");
|
||||||
|
wchar_t* wtmp = utf8_to_utf16(path);
|
||||||
|
WriteConsoleW(GetStdHandle(STD_ERROR_HANDLE), wtmp, wcslen(wtmp), 0, 0);
|
||||||
|
free(wtmp);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf(stderr, "Entering directory: %s", path);
|
fprintf(stderr, "Entering directory: %s", path);
|
||||||
|
#endif
|
||||||
|
|
||||||
(void) atomicio(vwrite, remout, path, strlen(path));
|
(void) atomicio(vwrite, remout, path, strlen(path));
|
||||||
if (response() < 0) {
|
if (response() < 0) {
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
@ -1665,8 +1729,16 @@ sink(int argc, char **argv)
|
|||||||
} while (cp < &buf[sizeof(buf) - 1] && ch != '\n');
|
} while (cp < &buf[sizeof(buf) - 1] && ch != '\n');
|
||||||
*cp = 0;
|
*cp = 0;
|
||||||
if (verbose_mode)
|
if (verbose_mode)
|
||||||
|
#ifdef WINDOWS
|
||||||
|
{
|
||||||
|
printf("Sink: ");
|
||||||
|
wchar_t* wtmp = utf8_to_utf16(buf);
|
||||||
|
WriteConsoleW(GetStdHandle(STD_ERROR_HANDLE), wtmp, wcslen(wtmp), 0, 0);
|
||||||
|
free(wtmp);
|
||||||
|
}
|
||||||
|
#else
|
||||||
fprintf(stderr, "Sink: %s", buf);
|
fprintf(stderr, "Sink: %s", buf);
|
||||||
|
#endif
|
||||||
if (buf[0] == '\01' || buf[0] == '\02') {
|
if (buf[0] == '\01' || buf[0] == '\02') {
|
||||||
if (iamremote == 0)
|
if (iamremote == 0)
|
||||||
(void) atomicio(vwrite, STDERR_FILENO,
|
(void) atomicio(vwrite, STDERR_FILENO,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user