diff options
author | JANAK DESAI <janak@us.ibm.com> | 2006-02-07 15:59:00 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-02-07 19:12:34 -0500 |
commit | 741a295130606143edbf9fc740f633dbc1e6225f (patch) | |
tree | 3679047dd44e94ba94ee1487880a94def93a06f9 /kernel/fork.c | |
parent | 99d1419d96d7df9cfa56bc977810be831bd5ef64 (diff) |
[PATCH] unshare system call -v5: unshare namespace
If the namespace structure is being shared, allocate a new one and copy
information from the current, shared, structure.
Signed-off-by: Janak Desai <janak@us.ibm.com>
Cc: Al Viro <viro@ftp.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Michael Kerrisk <mtk-manpages@gmx.net>
Cc: Andi Kleen <ak@muc.de>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 598e5c27242c..07dd241aa1e0 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -1388,16 +1388,21 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp) | |||
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | /* | 1390 | /* |
1391 | * Unsharing of namespace for tasks created without CLONE_NEWNS is not | 1391 | * Unshare the namespace structure if it is being shared |
1392 | * supported yet | ||
1393 | */ | 1392 | */ |
1394 | static int unshare_namespace(unsigned long unshare_flags, struct namespace **new_nsp) | 1393 | static int unshare_namespace(unsigned long unshare_flags, struct namespace **new_nsp, struct fs_struct *new_fs) |
1395 | { | 1394 | { |
1396 | struct namespace *ns = current->namespace; | 1395 | struct namespace *ns = current->namespace; |
1397 | 1396 | ||
1398 | if ((unshare_flags & CLONE_NEWNS) && | 1397 | if ((unshare_flags & CLONE_NEWNS) && |
1399 | (ns && atomic_read(&ns->count) > 1)) | 1398 | (ns && atomic_read(&ns->count) > 1)) { |
1400 | return -EINVAL; | 1399 | if (!capable(CAP_SYS_ADMIN)) |
1400 | return -EPERM; | ||
1401 | |||
1402 | *new_nsp = dup_namespace(current, new_fs ? new_fs : current->fs); | ||
1403 | if (!*new_nsp) | ||
1404 | return -ENOMEM; | ||
1405 | } | ||
1401 | 1406 | ||
1402 | return 0; | 1407 | return 0; |
1403 | } | 1408 | } |
@@ -1482,7 +1487,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags) | |||
1482 | goto bad_unshare_out; | 1487 | goto bad_unshare_out; |
1483 | if ((err = unshare_fs(unshare_flags, &new_fs))) | 1488 | if ((err = unshare_fs(unshare_flags, &new_fs))) |
1484 | goto bad_unshare_cleanup_thread; | 1489 | goto bad_unshare_cleanup_thread; |
1485 | if ((err = unshare_namespace(unshare_flags, &new_ns))) | 1490 | if ((err = unshare_namespace(unshare_flags, &new_ns, new_fs))) |
1486 | goto bad_unshare_cleanup_fs; | 1491 | goto bad_unshare_cleanup_fs; |
1487 | if ((err = unshare_sighand(unshare_flags, &new_sigh))) | 1492 | if ((err = unshare_sighand(unshare_flags, &new_sigh))) |
1488 | goto bad_unshare_cleanup_ns; | 1493 | goto bad_unshare_cleanup_ns; |