chrootした後にexecができません
chrootをしなければ、pythonのprint文が出力されますが、
chrootをすると、execエラーになってしまいます。
どうしたらこの問題を解決できるのでしょうか?
lang
1#include <stdio.h> 2#include <stdlib.h> 3#include <string.h> 4#include <unistd.h> 5#include <errno.h> 6 7int main(void) 8{ 9 int rc = 0; 10 11 rc = chroot("./tmp"); 12 if(rc < 0){ 13 printf("Error: chroot(%d) %s\n", errno, strerror(errno)); 14 return(-1); 15 } 16 17 rc = chdir("./tmp"); 18 if(rc < 0){ 19 printf("Error: chdir(%d) %s\n", errno, strerror(errno)); 20 return(-1); 21 } 22 23/* 24 if ( execl("/usr/bin/python", "python", "hello.py", NULL) < 0 ) 25 { 26 fprintf(stderr, "error: execl() failed\n"); 27 exit(1); 28 } 29 */ 30 31 if ( execl("python", "python", "hello.py", "", NULL) < 0 ) 32 { 33 fprintf(stderr, "error: execl() failed\n"); 34 exit(1); 35 } 36 37 return(0); 38}
lang
1#!/usr/bin/python 2# -*- coding: utf-8 -*- 3 4print "Content-type: text/html" 5print 6print "<html>" 7print "Hello,World!" 8print "</html>"
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/06/03 08:27
2015/06/03 09:19
2015/06/03 10:19
2015/06/04 08:05
2015/06/05 05:04