From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-01.nifty.com (conssluserg-01.nifty.com [210.131.2.80]) by sourceware.org (Postfix) with ESMTPS id 02B453856DE5 for ; Wed, 13 Jul 2022 14:39:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 02B453856DE5 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp Received: from HP-Z230 (ak044095.dynamic.ppp.asahi-net.or.jp [119.150.44.95]) (authenticated) by conssluserg-01.nifty.com with ESMTP id 26DEcXFS007847; Wed, 13 Jul 2022 23:38:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com 26DEcXFS007847 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1657723113; bh=zKeAyDjn6f0eMi4M2fG30FPhgzW8VycuLflIwhpxPJM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=na2olbv+lSODo4oarphjlqRF+k4NFUqiAnmvTDNrBsE0ssFfTT9Wi9Zr7yAadTqJ9 g6u1kGoe/t5RxfPiybnNOMp5DrPzs6Y9USWW9LC9vDHhELSojxBc4ym9dGK7ISqf+N wiSDx6FZ+iYU3orCuRB9m9Mwng1vKZkiOtkdfvT+2jM2/cTbmpVfEb6zlESNNAtdWW gny5K24HX+Zn4ZEKh7rMua8KnY1MmxQv2GxdHkYsmtnqo2nommmCY60uz3VEEDUpq0 M5yOaeMalUXGBHhRCM371jf1s9uw4ergNHsoXOGq9oWqlWpE9V5zYgQ7hj1OYuu/TD lhcJYqQuPsq3g== X-Nifty-SrcIP: [119.150.44.95] Date: Wed, 13 Jul 2022 23:38:33 +0900 From: Takashi Yano To: "'cygwin@cygwin.com'" Cc: "suzuki.masaomi@fujitsu.com" , "'soft-mpop-qqm@ml.css.fujitsu.com'" Subject: Re: scp command fails to transfer file and returns 1. Message-Id: <20220713233833.96744de926432f10ab45bd22@nifty.ne.jp> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_50, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2022 14:39:23 -0000 On Wed, 13 Jul 2022 07:41:25 +0000 > Cygwinサポート ご担当様 > > お世話になっております。 > 沈 テイです。 > > 下記の問題の解決について、ご協力をお願いします。 > > ■環境 > OS: Windows Server 2019 >  Cygwinバージョン: 3.3.5 > > ■問題が起きた背景 >  当方のアプリケーションプログラムでは、リモートシステム(OS: Linux)へ >  SSH通信やファイル転送を行う目的で、Cygwinに含まれるssh, scpコマンドを >  子プロセスとして実行する実装にしています。 >  ※実証内容の詳細は、"■当方のアプリケーションプログラム"を参照 >  ※事前準備として、SSH公開鍵を設定し、パスワードの問い合わせ無しで >   SSH接続できることを確認しています。 > > ■問題の内容 >  URL(https://www.cygwin.com/)からダウンロードした最新バージョン(3.3.5)の >  CygwinをOSに導入した後、当方のアプリケーションプログラムを実行すると、 >  scpコマンドは毎回、戻り値"1"で復帰し、ファイル転送が失敗します。 > >  当方のアプリケーションプログラムをデバックした結果、 >  scpコマンドは下記のメッセージを返却していました。 > >  /usr/bin/scp: dest open ""/tmp/a"": No such file or directory >  /usr/bin/scp: failed to upload file /cygdrive//C/test/a to "/tmp/a" > > ■問題の補足 >  ・scpコマンドを、当方のアプリケーションプログラムから子プロセスとして >   実行するのではなく、コマンドプロンプトやCygwin Bash Shellから直接的に >   実行した場合は、戻り値"0"で復帰し、ファイル転送は成功します。 > >  ・旧バージョン(3.2.0)のCygwinを同じOSに導入した後、 >   当方のアプリケーションプログラムを実行した場合は、scpコマンドは >   戻り値"0"で復帰し、ファイル転送は成功します。 > >  以上のことから、我々は、最新バージョン(3.3.5)と旧バージョン(3.2.0)の >  Cygwinで、scpコマンドの動作仕様に何らかの非互換があるのではないか、と >  推測しています。 > > ■依頼事項 >  上記の問題に対して、考えられる原因および対処方法はありますか? > > <回答先> >   soft-mpop-qqm@ml.css.fujitsu.com > > ■当方のアプリケーションプログラム >  ・子プロセスの実行方法 >   Windows APIのCreateProcess()を以下の様に使用し、子プロセスを実行します。 > >  CreateProcess(NULL, > fullPathCmd,  /* ssh,scpのcommond line */ > NULL, /* process security attributes */ > NULL, /* primary thread security attributes */ > TRUE, /* handles are inherited */ > NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, /* creation flags */ > NULL, /* use parent's environment */ > NULL, /* use parent's current directory */ > &si, /* STARTUPINFO pointer */ > &pi); /* receives PROCESS_INFORMATION */ > >  ・sshコマンドを実行する時のコマンドライン >   上記に示したCreateProcess()の第2パラメタfullPathCmdを、以下の様に >   指定しています。 > >   \bin\ssh.exe -q -l root -p 22 ホスト名 "echo aaa && /bin/sh -c \"/bin/uname -n\"" > >  ・scpコマンドを実行する時のコマンドライン >   上記に示したCreateProcess()の第2パラメタfullPathCmdを、以下の様に >   指定しています。 >    >   \bin\scp.exe "/cygdrive//C/test/a" "root"@ホスト名:""/tmp/a"" > > > 以上、よろしくお願いします。 > > > 以降は英訳文章です。 > ****************************************************************** > Cygwin Support Dear Representatives > > Thank you for your support. > I am Shen Ting. > > We ask for your cooperation in solving the following problem. > > ■Environment > OS: Windows Server 2019 >  Cygwin Version : 3.3.5 > > ■Background of the problem > In our application program, for the purpose of SSH communication and file transfer to a remote system (OS: Linux), > the ssh and scp commands included in Cygwin are executed as child processes. > (*) For details of the demonstration contents, refer to "■Our Application Program" > (*)As a preliminary preparation, we set the SSH public key and > confirm that we can connect to SSH without inquiring about the password. > > ■The problem > In the OS, after installing the latest version (3.3.5) of Cygwin downloaded from the URL(https://www.cygwin.com/), > when we execute our application program, the scp command returns "1" every time, and the file transfer fails. > > As a result of debugging our application program, the scp command returned the following message. > >  /usr/bin/scp: dest open ""/tmp/a"": No such file or directory >  /usr/bin/scp: failed to upload file /cygdrive//C/test/a to "/tmp/a" > > ■Problem supplement > ・If the scp command is executed directly from the command prompt or Cygwin Bash Shell > instead of being executed from our application program as a child process, > "0" will be returned and the file transfer will succeed. > > ・If we execute our application program after introducing the old version Cygwin(3.2.0) to the same OS, > the scp command will return "0" and the file transfer will be successful. > > From the above, we speculate that there may be some incompatibility in the operating specifications of > the scp command in the latest version Cygwin(3.3.5) and the old version Cygwin(3.2.0). > > ■Requests > Are there any possible causes and workarounds for the above problem? > > > soft-mpop-qqm@ml.css.fujitsu.com > > ■Our Application Program > ・How child processes run > Use the Windows API CreateProcess() as follows to execute the child process. > >  CreateProcess(NULL, > fullPathCmd,  /* ssh,scpのcommond line */ > NULL, /* process security attributes */ > NULL, /* primary thread security attributes */ > TRUE, /* handles are inherited */ > NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, /* creation flags */ > NULL, /* use parent's environment */ > NULL, /* use parent's current directory */ > &si, /* STARTUPINFO pointer */ > &pi); /* receives PROCESS_INFORMATION */ > > ・Command line when executing ssh command > The second parameter of CreateProcess() shown above, fullPathCmd, is specified as follows. > > \bin\ssh.exe -q -l root -p 22 ホスト名 "echo aaa && /bin/sh -c \"/bin/uname -n\"" > > ・Command line when executing scp command > The second parameter of CreateProcess() shown above, fullPathCmd, is specified as follows. > > \bin\scp.exe "/cygdrive//C/test/a" "root"@ホスト名:""/tmp/a"" I cannot reproduce your problem. Could you please provide simple test case in C-lang? -- Takashi Yano