X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=kernel%2Fvserver%2Flegacy.c;h=7ca6700d6994df766d394f599ca091e4e2234ac4;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=a620ae3b5b1bdbd0ed9e3278e10dd3338a9ae1a0;hpb=b76fcd5f0c655b6e3e9bf534594357025421c66a;p=linux-2.6.git diff --git a/kernel/vserver/legacy.c b/kernel/vserver/legacy.c index a620ae3b5..7ca6700d6 100644 --- a/kernel/vserver/legacy.c +++ b/kernel/vserver/legacy.c @@ -4,18 +4,18 @@ * Virtual Server: Legacy Funtions * * Copyright (C) 2001-2003 Jacques Gelinas - * Copyright (C) 2003-2004 Herbert Pötzl + * Copyright (C) 2003-2005 Herbert Pötzl * * V0.01 broken out from vcontext.c V0.05 * */ #include +#include +#include +#include #include -#include #include -#include -#include #include #include @@ -58,9 +58,10 @@ int vc_new_s_context(uint32_t ctx, void __user *data) } return ret; } - - if (!vx_check(0, VX_ADMIN) || - !capable(CAP_SYS_ADMIN) || vx_flags(VX_INFO_LOCK, 0)) + + if (!vx_check(0, VX_ADMIN) || !capable(CAP_SYS_ADMIN) + /* might make sense in the future, or not ... */ + || vx_flags(VX_INFO_LOCK, 0)) return -EPERM; /* ugly hack for Spectator */ @@ -72,16 +73,22 @@ int vc_new_s_context(uint32_t ctx, void __user *data) if (((ctx > MAX_S_CONTEXT) && (ctx != VX_DYNAMIC_ID)) || (ctx == 0)) return -EINVAL; - + if ((ctx == VX_DYNAMIC_ID) || (ctx < MIN_D_CONTEXT)) - new_vxi = find_or_create_vx_info(ctx); + new_vxi = locate_or_create_vx_info(ctx); else - new_vxi = find_vx_info(ctx); + new_vxi = locate_vx_info(ctx); if (!new_vxi) return -EINVAL; + + ret = -EPERM; + if (!vx_info_flags(new_vxi, VXF_STATE_SETUP, 0) && + vx_info_flags(new_vxi, VX_INFO_PRIVATE, 0)) + goto out_put; + new_vxi->vx_flags &= ~(VXF_STATE_SETUP|VXF_STATE_INIT); - + ret = vx_migrate_task(current, new_vxi); if (ret == 0) { current->vx_info->vx_bcaps &= (~vc_data.remove_cap); @@ -94,68 +101,11 @@ int vc_new_s_context(uint32_t ctx, void __user *data) current->namespace, current->fs); if (vc_data.flags & VX_INFO_NPROC) new_vxi->limit.rlim[RLIMIT_NPROC] = - current->rlim[RLIMIT_NPROC].rlim_max; + current->signal->rlim[RLIMIT_NPROC].rlim_max; ret = new_vxi->vx_id; } +out_put: put_vx_info(new_vxi); return ret; } - - -/* set ipv4 root (syscall) */ - -int vc_set_ipv4root(uint32_t nbip, void __user *data) -{ - int i, err = -EPERM; - struct vcmd_set_ipv4root_v3 vc_data; - struct nx_info *new_nxi, *nxi = current->nx_info; - - if (nbip < 0 || nbip > NB_IPV4ROOT) - return -EINVAL; - if (copy_from_user (&vc_data, data, sizeof(vc_data))) - return -EFAULT; - - if (!nxi || nxi->ipv4[0] == 0 || capable(CAP_NET_ADMIN)) - // We are allowed to change everything - err = 0; - else if (nxi) { - int found = 0; - - // We are allowed to select a subset of the currently - // installed IP numbers. No new one allowed - // We can't change the broadcast address though - for (i=0; inbipv4; j++) { - if (nxip == nxi->ipv4[j]) { - found++; - break; - } - } - } - if ((found == nbip) && - (vc_data.broadcast == nxi->v4_bcast)) - err = 0; - } - if (err) - return err; - - new_nxi = create_nx_info(); - if (!new_nxi) - return -EINVAL; - - new_nxi->nbipv4 = nbip; - for (i=0; iipv4[i] = vc_data.nx_mask_pair[i].ip; - new_nxi->mask[i] = vc_data.nx_mask_pair[i].mask; - } - new_nxi->v4_bcast = vc_data.broadcast; - current->nx_info = new_nxi; - current->nid = new_nxi->nx_id; - put_nx_info(nxi); - return 0; -} - -