##- # Author: Brian Tiffin # Dedicated to the public domain # # Date: September, 2016 # Modified: 2016-10-03/22:39-0400 ##+ # # chroot.icn, Demonstrate chroot, the filesystem root directory function # # Seeing as this program is evaluated during document generation it is # very likely to fail. The book is never built using root permissions. # procedure main() # Change filesystem root to protect outside directories # from unprivileged access. Requires CAP_SYS_CHROOT capabilities. if newroot := chroot("/home/btiffin") then { write(image(newroot)) chdir("/") write(chdir()) d := open(".", "r") while write(read(d)) close(d) } else write("no permission to set new root directory") end