usr
Linuxで「chroot」コマンドを使用するには、などのファイルまたはディレクトリが必要であることを知っていますbin
。しかしchroot()
、C で関数を使用する場合、これらのファイルは必要ですか?
これが私のコードです。「hw.out」は「Hello、world」を出力するバイナリファイルです。コンパイルしてルートとして実行しましたが、「Hello, world」の出力に失敗しました。他に何をすべきですか?ありがとうございました!
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int result = chroot(".");
if(result == 0)
printf("Chroot Succese.\n");
char *arrays[]={"./hw.out",NULL};
execvp("./hw.out", arrays);
return 0;
}