タイトルについてはお詫びしますが、それ以外の説明は見つかりませんでした。私の会社では、最新の LTS Ubuntu+Apache2+suPHP で開発サーバーを実行しています。それを処理するために、Zend2 と Lazarus アプリケーションを作成しています。Zend を使用した Web パーツは正常に動作します。問題は、Lazarus で書かれたコンソール アプリケーションです。データベースとユーザーを作成し、フレームワークなどをダウンロードするために、いくつかのクラスを実行します。また、管理目的で (root 権限を使用して) いくつかのシェル コマンドを実行する必要があります。権利を取得するために、私はかなり醜いソリューションを使用してecho mymagicpassword | sudo -S mymagiccommandいます. ここにスニペットがあります:
constructor TRootProcess.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Options:=[poUsePipes,poWaitOnExit];
Executable:='/bin/sh';
Parameters.Add('-c');
Parameters.Add('echo %pwd% | sudo -S ');
end;
function TRootProcess.ExecuteCommand(command: String): String;
var
str: TStringList;
begin
str:=TStringList.Create;
command:=Copy(Parameters.GetText, 0, Length(Parameters.GetText)-1)+command;
command:=StringReplace(command,'%pwd%','mymagicpassword',[rfReplaceAll]);
Parameters.SetText(PChar(command));
Execute;
str.Clear;
str.LoadFromStream(Output);
Result:=str.Text;
end;
このアプリケーションを手動で実行すると、すべてがうまく動作します。しかし、PHP Applicaiton を使用して実行するとshell_exec、他のシェル アプリケーション (ls、cp mkdir、useradd、chmod など) を起動して、アプリケーション全体が (最後のログ エントリも) 実行されます。は、もう。stdout/stderr、suPHP ログ、さらには Apache2 ログにもエラーはありません。また、PHP からの実行は約 1 週間うまくいき、明らかに動作を停止しました。
前もって感謝します