static PyObject *
vserver_chcontext(PyObject *self, PyObject *args)
{
- int result;
+ int ctx_is_new;
xid_t ctx;
- uint32_t flags = 0;
- uint32_t bcaps = ~vc_get_insecurebcaps();
+ uint_least64_t bcaps = ~vc_get_insecurebcaps();
- if (!PyArg_ParseTuple(args, "I|K", &ctx, &flags))
+ if (!PyArg_ParseTuple(args, "I", &ctx))
return NULL;
- if ((result = pl_chcontext(ctx, flags, bcaps, 0)) < 0)
+ if ((ctx_is_new = pl_chcontext(ctx, bcaps, 0)) < 0)
return PyErr_SetFromErrno(PyExc_OSError);
- return PyBool_FromLong(result);
+ return PyBool_FromLong(ctx_is_new);
}
static PyObject *
sprintf(fname,"/proc/virtual/%d", ctx);
if(stat(&fname[0],&statbuf)==0)
- ret = Py_BuildValue("i",1);
+ ret = PyBool_FromLong(1);
else
- ret = Py_BuildValue("i",0);
+ ret = PyBool_FromLong(0);
return ret;
}
struct vc_rlimit limits;
PyObject *ret;
+ errno = 0;
if (vc_get_rlimit(xid, resource, &limits)==-1)
ret = PyErr_SetFromErrno(PyExc_OSError);
else
static PyObject *
vserver_set_rlimit(PyObject *self, PyObject *args) {
struct vc_rlimit limits;
- struct rlimit olim, nlim;
+ struct rlimit lim;
xid_t xid;
int resource, lresource;
PyObject *ret;
goto do_vc_set_rlimit;
case VLIMIT_OPENFD:
lresource = RLIMIT_NOFILE;
+ break;
default:
break;
}
- getrlimit(lresource,&olim);
- if ((limits.min != VC_LIM_KEEP) && (limits.min > olim.rlim_cur)) {
- nlim.rlim_cur = limits.min;
- if (limits.min > olim.rlim_max) {
- nlim.rlim_max = limits.min;
- } else {
- nlim.rlim_max = olim.rlim_max;
- }
- setrlimit(lresource, &nlim);
+ getrlimit(lresource,&lim);
+ if (adjust_lim(&limits,&lim)) {
+ setrlimit(lresource, &lim);
}
do_vc_set_rlimit:
- if (vc_set_rlimit(xid, resource, &limits))
+ errno = 0;
+ if (vc_set_rlimit(xid, resource, &limits)==-1)
ret = PyErr_SetFromErrno(PyExc_OSError);
else
ret = __vserver_get_rlimit(xid, resource);