* Implemented support for chroot:

- Added a "root" vnode to the io_context. It is used for resolving
    paths and converting nodes to paths instead of sRoot. Some more
    passing around of io_context structures was necessary.
  - Introduced a new lock sIOContextRootLock to protect
    io_context::root. The current uses of io_context::io_mutex
    (put_vnode(), remove_vnode() while holding it) looked too suspicious
    to use that mutex in vnode_path_to_vnode().
  - Added _kern_change_root() syscall and chroot() libroot function.
  - Added chroot coreutils program to the image. Funnily it seems to be
    much easier to set up a little jail than under Linux (just copy
    bash and libroot.so into respective subdirs; mount another pipefs
    if you want pipe support).
    With Haiku allowing direct access to directories via inode IDs
    jailing is obviously not very secure at the moment.
  - Added /var/empty to the image. It will be the chroot target for ssh.
* Changed vfs.cpp:get_cwd() so that the io_context::io_mutex is no
  longer held when calling dir_vnode_to_path().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24673 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-03-30 05:59:54 +00:00
parent 2df0ed7856
commit 360be1fc45
10 changed files with 325 additions and 101 deletions
+3 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2007, Haiku Inc. All Rights Reserved.
* Copyright 2004-2008, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _UNISTD_H_
@@ -155,6 +155,8 @@ extern pid_t setsid(void);
extern int setpgid(pid_t pid, pid_t pgid);
extern pid_t setpgrp(void);
extern int chroot(const char *path);
/* access permissions */
extern gid_t getegid(void);
extern uid_t geteuid(void);
+4 -1
View File
@@ -16,6 +16,7 @@ extern "C" {
#endif
struct file_descriptor;
struct io_context;
struct selectsync;
struct select_info;
@@ -28,7 +29,9 @@ struct fd_ops {
struct selectsync *sync);
status_t (*fd_deselect)(struct file_descriptor *, uint8 event,
struct selectsync *sync);
status_t (*fd_read_dir)(struct file_descriptor *, struct dirent *buffer, size_t bufferSize, uint32 *_count);
status_t (*fd_read_dir)(struct io_context* ioContext,
struct file_descriptor *, struct dirent *buffer,
size_t bufferSize, uint32 *_count);
status_t (*fd_rewind_dir)(struct file_descriptor *);
status_t (*fd_read_stat)(struct file_descriptor *, struct stat *);
status_t (*fd_write_stat)(struct file_descriptor *, const struct stat *, int statMask);
+1
View File
@@ -90,6 +90,7 @@ extern thread_id _kern_fork(void);
extern pid_t _kern_process_info(pid_t process, int32 which);
extern pid_t _kern_setpgid(pid_t process, pid_t group);
extern pid_t _kern_setsid(void);
extern status_t _kern_change_root(const char *path);
extern thread_id _kern_spawn_thread(int32 (*func)(thread_func, void *),
const char *name, int32 priority, void *data1, void *data2);
+2
View File
@@ -39,6 +39,7 @@ struct vnode;
/** The I/O context of a process/team, holds the fd array among others */
typedef struct io_context {
struct vnode *root;
struct vnode *cwd;
mutex io_mutex;
uint32 table_size;
@@ -184,6 +185,7 @@ status_t _user_read_index_stat(dev_t device, const char *name, struct stat *stat
status_t _user_remove_index(dev_t device, const char *name);
status_t _user_getcwd(char *buffer, size_t size);
status_t _user_setcwd(int fd, const char *path);
status_t _user_change_root(const char *path);
int _user_open_query(dev_t device, const char *query, size_t queryLength, uint32 flags,
port_id port, int32 token);