chroot

å称
     chroot — ã«ã¼ããã£ã¬ã¯ããªãå¤æ´ãã

ã©ã¤ãã©ãª
     Standard C Library (libc, -lc)

æ¸å¼
     <unistd.h> int chroot(const char *dirname)

解説
     dirname å¼æ°ã¯ãASCII ã®ãã«æåã§çµäºãããã£ã¬ã¯ããªã®ãã¹åã®ã¢ãã¬ã¹ã§ãã
     chroot() ã·ã¹ãã ã³ã¼ã«ã¯ã dirname ãã«ã¼ããã£ã¬ã¯ããªãããªãã¡ã ‘/’
     ã§éå§ãããã¹åã®ãã¹æ¤ç´¢ã® éå§ç¹ã«ãã¾ãã

     ãã£ã¬ã¯ããªãã«ã¼ããã£ã¬ã¯ããªã«ãªãããã«ã¯ã ããã»ã¹ã«ãã®ãã£ã¬ã¯ããªã¸ã®å®è¡
     (æ¤ç´¢) 許å¯ããªããã°ãªãã¾ããã

     chroot() ã¯ããã»ã¹ã®ç¾å¨ã®ãã£ã¬ã¯ããªã«å½±é¿ããªããã¨ã«æ³¨æããå¿è¦ãããã¾ãã

     ãã®é¢æ°ãå¼ã³åºããã®ã¯ã¹ã¼ãã¦ã¼ã¶ã®ã¿ã§ãã

     ãã£ã¬ã¯ããªãåç§ãããªã¼ãã³ãã¡ã¤ã«è¨è¿°åãåå¨ããå ´åã chroot() å¼ã³åºã㯠sysctl
     å¤æ° ‘kern.chroot_allow_open_directories’ ã®è¨å®ã«å¾ãã次ã®ããã«å¤±æãã¾ã:

     ‘kern.chroot_allow_open_directories’ ã 0 ã«è¨‐
     å®ããã¦ããå ´åããã£ã¬ã¯ããªããªã¼ãã³ããã¦ããã° chroot() ã¯å¸¸ã« EPERM
     ã§å¤±æãã¾ãã

     ‘kern.chroot_allow_open_directories’ ã 1 ã«è¨å®ããã¦ããå ´å (ããã©ã«ã)ã
     ãã£ã¬ã¯ããªããªã¼ãã³ããã¦ãã¦ããã®ããã»ã¹ã chroot() ã·ã¹ãã ã³ã¼ã«ã®å½±é¿ãåããæã
     chroot() 㯠EPERM ã§å¤±æãã¾ãã

     ‘kern.chroot_allow_open_directories’
     ãä»ã®å¤ã®å ´åããªã¼ãã³ãã£ã¬ã¯ããªã®ãã§ãã¯ã¯ããã¾ããã

     æ£å¸¸ã«å®äºããã¨ãå¤ 0 ãè¿ããã¾ãã ããã§ãªãå ´åã¯ãå¤ -1 ãè¿ãããã¨ã©ã¼ã示ãããã«
     errno ãè¨å®ããã¾ãã

ã¨ã©ã¼
     chroot() ã·ã¹ãã ã³ã¼ã«ã¯ã次ã®å ´åå¦çã«å¤±æããã«ã¼ããã£ã¬ã¯ããªã¯å¤æ´ããã¾ãã:

     [ENOTDIR]          ãã¹ã®æ§æè¦ç´ ä¸ã«ãã£ã¬ã¯ããªä»¥å¤ã®ãã®ãå«ã¾ãã¦ãã¾ãã

     [EPERM]            å®å¹ã¦ã¼ã¶ ID ãã¹ã¼ãã¦ã¼ã¶ã§ã¯ããã¾ããã ã¾ãã¯ãã£ã¬ã¯ããªã
                        1 ã¤ä»¥ä¸ã®ãã¡ã¤ã«è¨è¿°åã«ãã£ã¦ãªã¼ãã³ããã¦ãã¾ãã

     [ENAMETOOLONG]     ãã¹åã®æ§æè¦ç´ ã 255 æåãè¶ãã¦ãããã ã¾ãã¯ãã¹åå¨ä½ã 1023
                        æåãè¶ãã¦ãã¾ãã

     [ENOENT]           æå®ã®ãã£ã¬ã¯ããªãåå¨ãã¾ããã

     [EACCES]           æå®ããããã¹ã«ã¯ãæ¤ç´¢ã許å¯ããã¦ããªããã£ã¬ã¯ããªãå«ã¾ãã¦ãã¾ãã

     [ELOOP]            ãã¹åãå¤æããã¨ãã«æ¤åºãããã·ã³ããªãã¯ãªã³ã¯ãå¤ããã¾ãã

     [EFAULT]           dirname å¼æ°ãããã‐
                        ã»ã¹ã«å²ãå½ã¦ãããã¢ãã¬ã¹ç©ºéã®ç¯å²å¤ãæãã¦ãã¾ãã

     [EIO]              ãã¡ã¤ã«ã·ã¹ãã ã«èªã¿æ¸ããã¦ããéã«å¥åºåã¨ã©ã¼ãçºçãã¾ããã

é¢é£é ç®
     chdir(2), jail(2)

æ´å²
     chroot() ã·ã¹ãã ã³ã¼ã«ã¯ 4.2BSD ã§ç»å ´ãã¾ããã

ãã°
     ããã»ã¹ããã®ä½æ¥ãã£ã¬ã¯ããªãç®çã®ãã£ã¬ã¯ããªã«å¤æ´å¯è½ã§ãããã
     (ãã£ã¬ã¯ããªã®ãªã¼ãã³ãã§ãã¯ãã¾ã㯠MAC ãã§ãã¯ã®ãããª) ä»ã®
     ã¢ã¯ã»ã¹å¶å¾¡ãã§ãã¯ã§å¤±æããå ´åã«ã¯ããã®ããã»ã¹ã®ä½æ¥ãã£ã¬ã¯ããªã
     å¤æ´ãããã¾ã¾ããã®ã·ã¹ãã ã³ã¼ã«ãã¨ã©ã¼ãè¿ãããããã¾ããã