Setting tag util-vserver-0.30.216-6
[util-vserver.git] / rev2883to2908.patch
1 Index: python/Makefile-files
2 ===================================================================
3 --- python/Makefile-files       (revision 2883)
4 +++ python/Makefile-files       (revision 2908)
5 @@ -17,6 +17,7 @@
6  ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
7  ## 
8  
9 +AM_INSTALLCHECK_STD_OPTIONS_EXEMPT += python/libvserver.py
10  pyexec_LTLIBRARIES             += python/_libvserver.la
11  pyexec_SCRIPTS                 += python/libvserver.py
12  python__libvserver_la_SOURCES  =  python/_libvserver.c
13 Index: debian/control
14 ===================================================================
15 --- debian/control      (revision 0)
16 +++ debian/control      (revision 2908)
17 @@ -0,0 +1,89 @@
18 +Source: util-vserver
19 +Section: net
20 +Priority: optional
21 +Maintainer: Daniel Hokka Zakrisson <daniel@hozac.com>
22 +Build-Depends: debhelper (>= 7), gawk, dietlibc-dev, net-tools, vlan, iptables, wget, procps, module-init-tools, libnss3-dev, po-debconf, e2fslibs-dev, pkg-config, python2.6-dev
23 +Standards-Version: 3.8.4
24 +Homepage: http://savannah.nongnu.org/projects/util-vserver/
25 +
26 +Package: util-vserver
27 +Architecture: any
28 +Depends: ${shlibs:Depends}, ${misc:Depends}, util-vserver-core, libvserver0, util-vserver-sysv, diffutils
29 +Description: utilities for managing Linux-VServer guests
30 + util-vserver provides the components and a framework to setup virtual
31 + servers.  A virtual server runs inside a Linux server. It is nevertheless
32 + highly independent. As such, you can run various services with normal
33 + configuration. The various vservers can't interact with each other and
34 + can't interact with services in the main server.
35 +
36 +Package: libvserver0
37 +Section: libs
38 +Architecture: any
39 +Depends: ${shlibs:Depends}, ${misc:Depends}
40 +Description: dynamic libraries for util-vserver
41 + util-vserver provides the components and a framework to setup virtual
42 + servers.  A virtual server runs inside a Linux server. It is nevertheless
43 + highly independent. As such, you can run various services with normal
44 + configuration. The various vservers can't interact with each other and
45 + can't interact with services in the main server.
46 +
47 +Package: util-vserver-core
48 +Architecture: any
49 +Depends: ${shlibs:Depends}, ${misc:Depends}
50 +Description: core utilities of util-vserver
51 + util-vserver provides the components and a framework to setup virtual
52 + servers.  A virtual server runs inside a Linux server. It is nevertheless
53 + highly independent. As such, you can run various services with normal
54 + configuration. The various vservers can't interact with each other and
55 + can't interact with services in the main server.
56 +
57 +Package: util-vserver-build
58 +Architecture: any
59 +Depends: ${shlibs:Depends}, ${misc:Depends}, util-vserver, wget, binutils
60 +Description: tools which can be used to build vservers
61 + util-vserver provides the components and a framework to setup virtual
62 + servers.  A virtual server runs inside a Linux server. It is nevertheless
63 + highly independent. As such, you can run various services with normal
64 + configuration. The various vservers can't interact with each other and
65 + can't interact with services in the main server.
66 +
67 +Package: util-vserver-sysv
68 +Architecture: any
69 +Depends: ${shlibs:Depends}, ${misc:Depends}, util-vserver, make, diffutils
70 +Description: initscripts for util-vserver
71 + util-vserver provides the components and a framework to setup virtual
72 + servers.  A virtual server runs inside a Linux server. It is nevertheless
73 + highly independent. As such, you can run various services with normal
74 + configuration. The various vservers can't interact with each other and
75 + can't interact with services in the main server.
76 +
77 +Package: util-vserver-legacy
78 +Architecture: any
79 +Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, util-vserver
80 +Description: legacy scripts for util-vserver
81 + util-vserver provides the components and a framework to setup virtual
82 + servers.  A virtual server runs inside a Linux server. It is nevertheless
83 + highly independent. As such, you can run various services with normal
84 + configuration. The various vservers can't interact with each other and
85 + can't interact with services in the main server.
86 +
87 +Package: libvserver0-dev
88 +Section: libdevel
89 +Architecture: any
90 +Depends: ${shlibs:Depends}, ${misc:Depends}, libvserver0, pkg-config
91 +Description: headers and libraries needed to develop vserver based applications
92 + util-vserver provides the components and a framework to setup virtual
93 + servers.  A virtual server runs inside a Linux server. It is nevertheless
94 + highly independent. As such, you can run various services with normal
95 + configuration. The various vservers can't interact with each other and
96 + can't interact with services in the main server.
97 +
98 +Package: util-vserver-python
99 +Architecture: any
100 +Depends: ${shlibs:Depends}, ${misc:Depends}, libvserver0, ${python:Depends}, ${python:Versions}
101 +Description: python-bindings for util-vserver
102 + util-vserver provides the components and a framework to setup virtual
103 + servers.  A virtual server runs inside a Linux server. It is nevertheless
104 + highly independent. As such, you can run various services with normal
105 + configuration. The various vservers can't interact with each other and
106 + can't interact with services in the main server.
107
108 Property changes on: debian/control
109 ___________________________________________________________________
110 Name: svn:keywords
111    + Id
112
113 Index: debian/compat
114 ===================================================================
115 --- debian/compat       (revision 0)
116 +++ debian/compat       (revision 2908)
117 @@ -0,0 +1 @@
118 +7
119 Index: debian/util-vserver-build.postinst
120 ===================================================================
121 --- debian/util-vserver-build.postinst  (revision 0)
122 +++ debian/util-vserver-build.postinst  (revision 2908)
123 @@ -0,0 +1,8 @@
124 +#!/bin/sh
125 +
126 +test -d /vservers/.hash || mkdir -m0700 /vservers/.hash
127 +
128 +f="/etc/vservers/.defaults/apps/vunify/hash"; test -e "$f"/method -o -e "$f"/00 || \
129 +        ln -s /vservers/.hash "$f"/00
130 +
131 +/usr/sbin/setattr --barrier /vservers/.hash || :
132
133 Property changes on: debian/util-vserver-build.postinst
134 ___________________________________________________________________
135 Name: svn:executable
136    + *
137
138 Index: debian/copyright
139 ===================================================================
140 --- debian/copyright    (revision 0)
141 +++ debian/copyright    (revision 2908)
142 @@ -0,0 +1,41 @@
143 +This work was packaged for Debian by:
144 +
145 +    Daniel Hokka Zakrisson <daniel@hozac.com> on Wed, 14 Jul 2010 22:42:52 +0000
146 +
147 +It was downloaded from:
148 +
149 +    http://svn.linux-vserver.org/svn/util-vserver
150 +
151 +Upstream Author(s):
152 +
153 +    Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
154 +    Daniel Hokka Zakrisson <daniel@hozac.com>
155 +
156 +Copyright:
157 +
158 +    Copyright (C) 2002-2010 Enrico Scholz
159 +    Copyright (C) 2006-2010 Daniel Hokka Zakrisson
160 +
161 +License:
162 +
163 +    This program is free software; you can redistribute it and/or modify it
164 +    under the terms of the GNU General Public License as published by the Free
165 +    Software Foundation; version 2.
166 +
167 +    This program is distributed in the hope that it will be useful, but
168 +    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
169 +    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
170 +    for more details.
171 +
172 +    You should have received a copy of the GNU General Public License with
173 +    your Debian GNU system, in /usr/share/common-licenses/GPL-2, or with the
174 +    Debian GNU source package as the file GNUGPL.TXT.  If not, write to the
175 +    Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
176 +    MA 02110-1301, USA.
177 +
178 +The Debian packaging is:
179 +
180 +    Copyright (C) 2010 Daniel Hokka Zakrisson <daniel@hozac.com>
181 +
182 +and is licensed under the GPL version 2,
183 +see "/usr/share/common-licenses/GPL-2".
184 Index: debian/docs
185 ===================================================================
186 --- debian/docs (revision 0)
187 +++ debian/docs (revision 2908)
188 @@ -0,0 +1,2 @@
189 +NEWS
190 +README
191 Index: debian/util-vserver.postinst
192 ===================================================================
193 --- debian/util-vserver.postinst        (revision 0)
194 +++ debian/util-vserver.postinst        (revision 2908)
195 @@ -0,0 +1,10 @@
196 +#!/bin/sh
197 +
198 +test -d /vservers      || mkdir -m0000 /vservers
199 +test -d /vservers/.pkg || mkdir -m0755 /vservers/.pkg
200 +
201 +f="/etc/vservers/.defaults/vdirbase";  test -L "$f" -o -e "$f" || ln -s /vservers             "$f"
202 +f="/etc/vservers/.defaults/run.rev";   test -L "$f" -o -e "$f" || ln -s /var/run/vservers.rev "$f"
203 +f="/etc/vservers/.defaults/cachebase"; test -L "$f" -o -e "$f" || ln -s /var/cache/vservers   "$f"
204 +
205 +/usr/sbin/setattr --barrier /vservers /vservers/.pkg || :
206
207 Property changes on: debian/util-vserver.postinst
208 ___________________________________________________________________
209 Name: svn:executable
210    + *
211
212 Index: debian/rules
213 ===================================================================
214 --- debian/rules        (revision 0)
215 +++ debian/rules        (revision 2908)
216 @@ -0,0 +1,31 @@
217 +#!/usr/bin/make -f
218 +# -*- makefile -*-
219 +# Sample debian/rules that uses debhelper.
220 +#
221 +# This file was originally written by Joey Hess and Craig Small.
222 +# As a special exception, when this file is copied by dh-make into a
223 +# dh-make output file, you may use that output file without restriction.
224 +# This special exception was added by Craig Small in version 0.37 of dh-make.
225 +#
226 +# Modified to make a template file for a multi-binary package with separated
227 +# build-arch and build-indep targets  by Bill Allombert 2001
228 +
229 +# Uncomment this to turn on verbose mode.
230 +#export DH_VERBOSE=1
231 +
232 +# This has to be exported to make some magic below work.
233 +export DH_OPTIONS
234 +
235 +
236 +%:
237 +       dh $@
238 +
239 +override_dh_auto_configure:
240 +       dh_auto_configure -- --with-initrddir=/etc/init.d --enable-release \
241 +               --enable-apis=NOLEGACY --with-initscripts=sysv
242 +
243 +override_dh_auto_test:
244 +
245 +override_dh_auto_install:
246 +       dh_auto_install
247 +       contrib/make-deb-manifest util-vserver debian contrib/manifest.dat files
248
249 Property changes on: debian/rules
250 ___________________________________________________________________
251 Name: svn:keywords
252    + Id
253 Name: svn:executable
254    + *
255
256 Index: debian/util-vserver.postrm
257 ===================================================================
258 --- debian/util-vserver.postrm  (revision 0)
259 +++ debian/util-vserver.postrm  (revision 2908)
260 @@ -0,0 +1,5 @@
261 +#!/bin/sh
262 +
263 +if test "$1" = purge; then
264 +    rm -rf /var/cache/vservers/* 2>/dev/null || :
265 +fi
266
267 Property changes on: debian/util-vserver.postrm
268 ___________________________________________________________________
269 Name: svn:executable
270    + *
271
272 Index: debian/util-vserver-legacy.postinst
273 ===================================================================
274 --- debian/util-vserver-legacy.postinst (revision 0)
275 +++ debian/util-vserver-legacy.postinst (revision 2908)
276 @@ -0,0 +1,9 @@
277 +#!/bin/sh
278 +
279 +if test "$1" = configure; then
280 +    update-rc.d rebootmgr start 98 2 3 4 5 stop 02 0 1 6 .
281 +    update-rc.d vservers-legacy start 98 2 3 4 5 stop 02 0 1 6 .
282 +    for i in httpd named portmap sendmail smb sshd xinetd gated; do
283 +       update-rc.d v_$i start 98 2 3 4 5 stop 02 0 1 6 .
284 +    done
285 +fi
286
287 Property changes on: debian/util-vserver-legacy.postinst
288 ___________________________________________________________________
289 Name: svn:executable
290    + *
291
292 Index: debian/util-vserver-sysv.postinst
293 ===================================================================
294 --- debian/util-vserver-sysv.postinst   (revision 0)
295 +++ debian/util-vserver-sysv.postinst   (revision 2908)
296 @@ -0,0 +1,7 @@
297 +#!/bin/sh
298 +
299 +if test "$1" = configure; then
300 +    update-rc.d vservers-default start 98 2 3 4 5 stop 02 0 1 6 .
301 +    update-rc.d vprocunhide start 26 2 3 4 5 stop 74 0 1 6 .
302 +    update-rc.d util-vserver start 10 2 3 4 5 stop 90 0 1 6 .
303 +fi
304
305 Property changes on: debian/util-vserver-sysv.postinst
306 ___________________________________________________________________
307 Name: svn:executable
308    + *
309
310 Index: debian/changelog.in
311 ===================================================================
312 --- debian/changelog.in (revision 0)
313 +++ debian/changelog.in (revision 2908)
314 @@ -0,0 +1,5 @@
315 +util-vserver (@PACKAGE_VERSION@-1) unstable; urgency=low
316 +
317 +  * Initial release
318 +
319 + -- Daniel Hokka Zakrisson <daniel@hozac.com>  @DATE@
320 Index: debian/util-vserver-sysv.postrm
321 ===================================================================
322 --- debian/util-vserver-sysv.postrm     (revision 0)
323 +++ debian/util-vserver-sysv.postrm     (revision 2908)
324 @@ -0,0 +1,5 @@
325 +#!/bin/sh
326 +
327 +if test "$1" = upgrade; then
328 +    /etc/init.d/vprocunhide condrestart > /dev/null 2>&1
329 +fi
330
331 Property changes on: debian/util-vserver-sysv.postrm
332 ___________________________________________________________________
333 Name: svn:executable
334    + *
335
336 Index: debian/Makefile-files
337 ===================================================================
338 --- debian/Makefile-files       (revision 0)
339 +++ debian/Makefile-files       (revision 2908)
340 @@ -0,0 +1,33 @@
341 +## $Id$  -*- makefile -*-
342 +
343 +## Copyright (C) 2010 Daniel Hokka Zakrisson <daniel@hozac.com>
344 +##  
345 +## This program is free software; you can redistribute it and/or modify
346 +## it under the terms of the GNU General Public License as published by
347 +## the Free Software Foundation; either version 2, or (at your option)
348 +## any later version.
349 +##  
350 +## This program is distributed in the hope that it will be useful,
351 +## but WITHOUT ANY WARRANTY; without even the implied warranty of
352 +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
353 +## GNU General Public License for more details.
354 +##  
355 +## You should have received a copy of the GNU General Public License
356 +## along with this program; if not, write to the Free Software
357 +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
358 +##  
359 +
360 +
361 +EXTRA_DIST +=  debian/rules \
362 +               debian/control \
363 +               debian/compat \
364 +               debian/copyright \
365 +               debian/docs \
366 +               debian/changelog.in \
367 +               debian/changelog
368 +
369 +#CLEANFILES += debian/changelog
370 +
371 +DEB_CL_DATE = $(shell date '+%a, %d %b %Y %H:%M:%S %z')
372 +debian/changelog: debian/changelog.in
373 +       $(SED) "s/@"PACKAGE_VERSION"@/$(PACKAGE_VERSION)/g;s/@"DATE"@/$(DEB_CL_DATE)/g" $< > $@
374
375 Property changes on: debian/Makefile-files
376 ___________________________________________________________________
377 Name: svn:keywords
378    + Id
379
380 Index: debian/util-vserver-legacy.prerm
381 ===================================================================
382 --- debian/util-vserver-legacy.prerm    (revision 0)
383 +++ debian/util-vserver-legacy.prerm    (revision 2908)
384 @@ -0,0 +1,10 @@
385 +#!/bin/sh
386 +
387 +if test "$1" = remove; then
388 +    /etc/init.d/rebootmgr stop > /dev/null 2>&1
389 +    update-rc.d rebootmgr remove
390 +    update-rc.d vservers-legacy remove
391 +    for i in httpd named portmap sendmail smb sshd xinetd gated; do
392 +       update-rc.d v_$i remove
393 +    done
394 +fi
395
396 Property changes on: debian/util-vserver-legacy.prerm
397 ___________________________________________________________________
398 Name: svn:executable
399    + *
400
401 Index: debian/util-vserver-sysv.prerm
402 ===================================================================
403 --- debian/util-vserver-sysv.prerm      (revision 0)
404 +++ debian/util-vserver-sysv.prerm      (revision 2908)
405 @@ -0,0 +1,8 @@
406 +#!/bin/sh
407 +
408 +if test "$1" = remove; then
409 +    /etc/init.d/vprocunhide stop > /dev/null 2>&1
410 +    update-rc.d vprocunhide remove
411 +    update-rc.d util-vserver remove
412 +    update-rc.d vservers-default remove
413 +fi
414
415 Property changes on: debian/util-vserver-sysv.prerm
416 ___________________________________________________________________
417 Name: svn:executable
418    + *
419
420 Index: src/testsuite/hashcalc-plain.c
421 ===================================================================
422 --- src/testsuite/hashcalc-plain.c      (revision 2883)
423 +++ src/testsuite/hashcalc-plain.c      (revision 2908)
424 @@ -24,6 +24,7 @@
425  #include <stdbool.h>
426  #include <unistd.h>
427  #include <fcntl.h>
428 +#include <sys/stat.h>
429  #include <sys/mman.h>
430  
431  #define ENSC_TESTSUITE
432 Index: src/testsuite/Makefile-files
433 ===================================================================
434 --- src/testsuite/Makefile-files        (revision 2883)
435 +++ src/testsuite/Makefile-files        (revision 2908)
436 @@ -57,19 +57,22 @@
437                                         src/testsuite/hashcalc-plain.sh \
438                                         src/testsuite/vwait-test.sh
439  
440 +DIETPROGS +=                           src/testsuite/vunify-functest \
441 +                                       src/testsuite/chcontext-test \
442 +                                       src/testsuite/chbind-test \
443 +                                       src/testsuite/rpm-fake-test
444 +
445  src_testsuite_rpm_fake_test_SOURCES =  src/testsuite/rpm-fake-test.c
446  
447  src_testsuite_vunify_functest_SOURCES =        src/testsuite/vunify-functest.c
448  src_testsuite_vunify_functest_LDADD =  $(LIBINTERNAL)
449  src_testsuite_vunify_functest_CPPFLAGS=        $(AM_CPPFLAGS) $(src_testsuite_CPPFLAGS)
450  
451 -
452  src_testsuite_chcontext_test_SOURCES = src/testsuite/chcontext-test.c
453 -src_testsuite_chcontext_test_LDADD =   lib/libvserver.la $(LIBINTERNAL)
454 +src_testsuite_chcontext_test_LDADD =   $(VSERVER_LDADDS) $(LIBINTERNAL)
455  
456 -
457  src_testsuite_chbind_test_SOURCES =    src/testsuite/chbind-test.c
458 -src_testsuite_chbind_test_LDADD =      lib/libvserver.la
459 +src_testsuite_chbind_test_LDADD =      $(LIBVSERVER)
460  
461  src_testsuite_hashcalc_SOURCES =       src/testsuite/hashcalc.c
462  src_testsuite_hashcalc_plain_SOURCES = src/testsuite/hashcalc-plain.c
463 @@ -77,6 +80,9 @@
464  src_testsuite_hashcalc_plain_CFLAGS =  $(AM_CFLAGS) $(ENSC_CRYPTO_CFLAGS)
465  
466  if ENSC_CAN_CRYPTO_WITH_DIETLIBC
467 +DIETPROGS +=                           src/testsuite/hashcalc          \
468 +                                       src/testsuite/hashcalc-plain
469 +
470  src_testsuite_hashcalc_LDADD =         $(LIBINTERNAL) $(LIBENSCVECTOR) $(ENSC_CRYPTO_LIB) $(VSERVER_LDADDS)
471  src_testsuite_hashcalc_LDFLAGS =       $(VSERVER_LDFLGS)
472  
473 Index: src/vcontext.c
474 ===================================================================
475 --- src/vcontext.c      (revision 2883)
476 +++ src/vcontext.c      (revision 2908)
477 @@ -21,6 +21,7 @@
478  #endif
479  
480  #include "util.h"
481 +#include "compat-pivot_root.h"
482  #include "lib/internal.h"
483  #include "lib_internal/jail.h"
484  #include "lib_internal/sys_personality.h"
485 Index: src/vserver-stat.c
486 ===================================================================
487 --- src/vserver-stat.c  (revision 2883)
488 +++ src/vserver-stat.c  (revision 2908)
489 @@ -24,6 +24,7 @@
490  #include "vserver.h"
491  #include "util.h"
492  #include "internal.h"
493 +#include "pathconfig.h"
494  
495  #include <ensc_vector/vector.h>
496  
497 @@ -116,7 +117,7 @@
498    WRITE_STR(1, cmd);
499    WRITE_MSG(1,
500             "\n"
501 -           "Show informations about all the active context.\n\n"
502 +           "Show information about all active contexts.\n\n"
503             "   CTX#            Context number\n"
504             "                   #0 = root context\n"
505             "                   #1 = monitoring context\n"
506 @@ -279,6 +280,152 @@
507    }
508  }
509  
510 +static void
511 +registerXidCgroups(struct Vector *vec, struct process_info *process)
512 +{
513 +  xid_t                                xid = (xid_t) process->s_context;
514 +  struct XidData               *res;
515 +
516 +  switch (vc_getXIDType(xid)) {
517 +    case vcTYPE_STATIC:
518 +    case vcTYPE_DYNAMIC:
519 +      break;
520 +    default:
521 +      return;
522 +  }
523 +
524 +  res = Vector_search(vec, &xid, cmpData);
525 +  if (res == 0) {
526 +    struct vc_rlimit_stat      limit;
527 +    struct vc_virt_stat                vstat;
528 +    struct vc_sched_info       sched;
529 +    int                                cpu;
530 +    char                       vhi_name[65],
531 +                               filename[128],
532 +                               cgroup[65],
533 +                               buf[30];
534 +    int                                fd;
535 +    ssize_t                    cgroup_len;
536 +    unsigned long long         rss;
537 +    char                       *endptr;
538 +    size_t                     len;
539 +
540 +    if (vc_virt_stat(xid, &vstat) == -1) {
541 +      perror("vc_virt_stat()");
542 +      return;
543 +    }
544 +    if (vc_rlimit_stat(xid, RLIMIT_NPROC, &limit) == -1) {
545 +      perror("vc_rlimit_stat(RLIMIT_NRPOC)");
546 +      return;
547 +    }
548 +    if (vc_get_vhi_name(xid, vcVHI_CONTEXT, vhi_name, sizeof(vhi_name)) == -1) {
549 +      perror("vc_get_vhi_name(CONTEXT)");
550 +      return;
551 +    }
552 +
553 +    if ((fd = open(DEFAULTCONFDIR "/cgroup/mnt", O_RDONLY)) == -1) {
554 +      strcpy(cgroup, "/dev/cgroup/");
555 +      cgroup_len = sizeof("/dev/cgroup");
556 +    }
557 +    else {
558 +      cgroup_len = read(fd, cgroup, sizeof(cgroup));
559 +      if (cgroup_len == -1) {
560 +        perror("read(cgroup/mnt)");
561 +        return;
562 +      }
563 +      close(fd);
564 +      cgroup[cgroup_len] = '/';
565 +      cgroup_len += 1;
566 +      cgroup[cgroup_len] = 0;
567 +    }
568 +
569 +    len = strlen(vhi_name);
570 +    if ((len + sizeof("/cgroup/name")) >= sizeof(filename)) {
571 +      WRITE_MSG(2, "too long context name: ");
572 +      WRITE_STR(2, vhi_name);
573 +      WRITE_MSG(2, "\n");
574 +      return;
575 +    }
576 +    strcpy(filename, vhi_name);
577 +    strcpy(filename + len, "/cgroup/name");
578 +
579 +    if ((fd = open(filename, O_RDONLY)) == -1) {
580 +      char *dir = strrchr(vhi_name, '/');
581 +      if (dir == NULL) {
582 +        WRITE_MSG(2, "invalid context name: ");
583 +        WRITE_STR(2, dir);
584 +        WRITE_MSG(2, "\n");
585 +        return;
586 +      }
587 +      len = strlen(dir);
588 +      if ((len + cgroup_len) >= sizeof(cgroup)) {
589 +        WRITE_MSG(2, "cgroup name too long: ");
590 +        WRITE_STR(2, dir);
591 +        WRITE_MSG(2, "\n");
592 +        return;
593 +      }
594 +      strcpy(cgroup + cgroup_len, dir);
595 +      cgroup_len += len;
596 +    }
597 +    else {
598 +      ssize_t ret;
599 +      ret = read(fd, cgroup + cgroup_len, sizeof(cgroup) - cgroup_len);
600 +      if (ret == -1) {
601 +        perror("read(cgroup/name)");
602 +        return;
603 +      }
604 +      cgroup_len += ret;
605 +      close(fd);
606 +    }
607 +
608 +    if ((cgroup_len + sizeof("/memory.usage_in_bytes")) > sizeof(filename)) {
609 +      WRITE_MSG(2, "cgroup name too long: ");
610 +      WRITE_STR(2, cgroup);
611 +      WRITE_MSG(2, "\n");
612 +      return;
613 +    }
614 +    strcpy(filename, cgroup);
615 +    strcpy(filename + cgroup_len, "/memory.usage_in_bytes");
616 +
617 +    if ((fd = open(filename, O_RDONLY)) == -1) {
618 +      perror("open(memory.usage_in_bytes)");
619 +      return;
620 +    }
621 +    if (read(fd, buf, sizeof(buf)) == -1) {
622 +      perror("read(memory.usage_in_bytes)");
623 +      return;
624 +    }
625 +    close(fd);
626 +    if ((rss = strtoull(buf, &endptr, 0)) == ULLONG_MAX ||
627 +        (*endptr != '\n' && *endptr != '\0')) {
628 +      perror("strtoull(memory.usage_in_bytes)");
629 +      return;
630 +    }
631 +
632 +    res                        = Vector_insert(vec, &xid, cmpData);
633 +    res->xid           = xid;
634 +
635 +    res->process_count = limit.value;
636 +    res->VmRSS_total   = rss / 4096;
637 +    res->start_time_oldest= getUptime() - vstat.uptime/1000000;
638 +
639 +    res->utime_total   = 0;
640 +    res->stime_total   = 0;
641 +    // XXX: arbitrary CPU limit.
642 +    for (cpu = 0; cpu < 1024; cpu++) {
643 +      sched.cpu_id = cpu;
644 +      sched.bucket_id = 0;
645 +      if (vc_sched_info(xid, &sched) == -1)
646 +        break;
647 +
648 +      res->utime_total += sched.user_msec;
649 +      res->stime_total += sched.sys_msec;
650 +    }
651 +  }
652 +  
653 +  res->VmSize_total    += process->VmSize;
654 +}
655 +
656  static inline uint64_t
657  toMsec(uint64_t v)
658  {
659 @@ -615,7 +762,7 @@
660    
661    Vector_init(&xid_data, sizeof(struct XidData));
662  
663 -  if (vc_isSupported(vcFEATURE_VSTAT)) {
664 +  if (vc_isSupported(vcFEATURE_VSTAT) && !vc_isSupported(vcFEATURE_MEMCG)) {
665      unsigned long xid;
666      Echdir(PROC_VIRT_DIR_NAME);
667      proc_dir = Eopendir(".");
668 @@ -628,6 +775,8 @@
669      closedir(proc_dir);
670    }
671    else {
672 +    void (*handler)(struct Vector *vec, struct process_info *process);
673 +
674      my_pid = getpid();
675  
676      if (!switchToWatchXid(&errptr)) {
677 @@ -641,6 +790,11 @@
678               "         procfs-security. Please read the FAQ for more details\n"
679               "         http://linux-vserver.org/Proc-Security\n");
680  
681 +    if (vc_isSupported(vcFEATURE_MEMCG))
682 +      handler = registerXidCgroups;
683 +    else
684 +      handler = registerXid;
685 +
686      Echdir(PROC_DIR_NAME);
687      proc_dir = Eopendir(".");
688      while ((dir_entry = readdir(proc_dir)) != NULL)
689 @@ -652,7 +806,7 @@
690        if (atoi(dir_entry->d_name) != my_pid) {
691         struct process_info *   info = get_process_info(dir_entry->d_name);
692         if (info)
693 -         registerXid(&xid_data, info);
694 +         handler(&xid_data, info);
695        }
696      }
697      closedir(proc_dir);
698 Index: scripts/vserver.suexec
699 ===================================================================
700 --- scripts/vserver.suexec      (revision 2883)
701 +++ scripts/vserver.suexec      (revision 2908)
702 @@ -40,7 +40,7 @@
703         "${CHBIND_CMD[@]}" \
704         $_EXEC_ULIMIT "$VSERVER_DIR/ulimits" \
705         ${USE_VNAMESPACE:+$_VNAMESPACE --enter "$S_CONTEXT" -- } \
706 -       $_VSPACE --enter "$S_CONTEXT" "${OPTS_VSPACE[@]}" -- \
707 +       $_VSPACE --enter "$S_CONTEXT" "${OPTS_VSPACE[@]}" "${OPTS_VSPACE_SHARED[@]}" -- \
708         $_VTAG --migrate "${OPTS_VTAG_ENTER[@]}" --silent -- \
709         $_VCONTEXT $SILENT_OPT --migrate $OPT_VCONTEXT_CHROOT \
710           --xid "$S_CONTEXT" --uid "$user" "${OPTS_VCONTEXT_ENTER[@]}" -- \
711 Index: scripts/vserver.stop
712 ===================================================================
713 --- scripts/vserver.stop        (revision 2883)
714 +++ scripts/vserver.stop        (revision 2908)
715 @@ -83,7 +83,7 @@
716      "${IONICE_CMD[@]}" \
717      "${NICE_CMD[@]}" \
718      "${CHBIND_CMD[@]}" \
719 -    "$_VSPACE" --enter "$S_CONTEXT" "${OPTS_VSPACE[@]}" -- \
720 +    "$_VSPACE" --enter "$S_CONTEXT" "${OPTS_VSPACE[@]}" "${OPTS_VSPACE_SHARED[@]}" -- \
721      "$_VTAG" --migrate "${OPTS_VTAG_ENTER[@]}" --silent -- \
722      $_VCONTEXT $SILENT_OPT --migrate $OPT_VCONTEXT_CHROOT --xid "$S_CONTEXT" -- \
723      "${INITCMD_STOP[@]}" || fail=1
724 Index: scripts/vserver.start
725 ===================================================================
726 --- scripts/vserver.start       (revision 2883)
727 +++ scripts/vserver.start       (revision 2908)
728 @@ -136,6 +136,7 @@
729  if $_VSERVER_INFO - FEATURE migrate; then
730      ${IONICE_CMD[@]} \
731      ${NICE_CMD[@]} \
732 +    "${VSPACE_SHARED_CMD[@]}" \
733      "${CHBIND_CMD[@]}" \
734      $_EXEC_ULIMIT "$VSERVER_DIR"/ulimits \
735      $_VTAG       --create "${OPTS_VTAG_CREATE[@]}" --silent -- \
736 @@ -143,7 +144,7 @@
737      $_VCONTEXT   --create "${OPTS_VCONTEXT_CREATE[@]}" -- \
738      ${OPTION_STRACE:+$_STRACE -fF -o /tmp/vserver-start.$$} \
739      ${USE_VNAMESPACE:+$_VNAMESPACE --set -- } \
740 -    $_VSPACE     --set "${OPTS_VSPACE[@]}" -- \
741 +    $_VSPACE     --set "${OPTS_VSPACE[@]}" "${OPTS_VSPACE_SHARED[@]}" -- \
742      $_EXEC_REMOUNT /proc /sys -- \
743      $_VLIMIT     --dir "$VSERVER_DIR"/rlimits --missingok -- \
744      $_VSCHED     --xid self --force "${OPTS_VSCHED[@]}" -- \
745 Index: scripts/vserver.functions
746 ===================================================================
747 --- scripts/vserver.functions   (revision 2883)
748 +++ scripts/vserver.functions   (revision 2908)
749 @@ -49,6 +49,8 @@
750  declare -a OPTS_VTAG_ENTER=()
751  declare -a OPTS_VMEMCTRL=()
752  declare -a OPTS_VSPACE=( --default )
753 +declare -a OPTS_VSPACE_SHARED=()
754 +declare -a VSPACE_SHARED_CMD=()
755  
756  declare -a STOPCMD_PREPARE=()
757  
758 @@ -110,6 +112,12 @@
759  
760      test -n "$_HAVE_INTERFACE_OPTIONS" || _generateInterfaceOptions "$vdir"
761  
762 +    if test -e "$vdir"/noncontext -o \
763 +           \( -e "$vdir"/spaces/net -a ! -e "$vdir"/ncontext \); then
764 +       _HAVE_CHBIND_OPTIONS=1
765 +       return 0
766 +    fi
767 +
768      local f="$vdir"/interfaces/bcast
769      getFileValue bcast "$f"
770      f="$vdir"/interfaces/lback
771 @@ -787,17 +795,23 @@
772  {
773      local vdir="$1"
774      local d="$vdir"/spaces
775 +    local shared
776 +    local space
777  
778 -    ( test ! -e "$d"/pid ) || \
779 -       OPTS_VSPACE=( "${OPTS_VSPACE[@]}" --pid )
780 +    for space in pid net; do
781 +       if test -e "$d"/$space; then
782 +           getFileValue shared "$d"/$space || shared=""
783 +           if test -z "$shared"; then
784 +               OPTS_VSPACE=( "${OPTS_VSPACE[@]}" --$space )
785 +           elif test "$shared" = "0"; then
786 +               : # Do nothing
787 +           else
788 +               OPTS_VSPACE_SHARED=( "${OPTS_VSPACE_SHARED[@]}" --$space )
789 +               VSPACE_SHARED_CMD=( "${VSPACE_SHARED_CMD[@]}" $_VSPACE --enter "$shared" --$space -- )
790 +           fi
791 +       fi
792 +    done
793  
794 -    test ! -e "$d"/net || {
795 -       OPTS_VSPACE=( "${OPTS_VSPACE[@]}" --net )
796 -       # network context and namespace don't make much sense
797 -       _HAVE_CHBIND_OPTIONS=1
798 -       CHBIND_CMD=()
799 -    }
800 -
801      local mask
802      getFileValue mask "$d"/mask || \
803        OPTS_VSPACE=( "${OPTS_VSPACE[@]}" --mask "$mask" )
804 @@ -1461,8 +1475,12 @@
805  {
806      hasCgroup || return 1
807      test -d "$CGROUP_MNT" || return 1
808 +    memcg=""
809 +    if $_VSERVER_INFO - FEATURE memcg; then
810 +       memcg=1
811 +    fi
812      test -d "$1/cgroup" -o \
813 -       \( -d "$__CONFDIR/.defaults/cgroup" -a \
814 +       \( \( -d "$__CONFDIR/.defaults/cgroup" -o -n "$memcg" \) -a \
815            ! -e "$1/nocgroup" \)
816  }
817  
818 Index: configure.ac
819 ===================================================================
820 --- configure.ac        (revision 2883)
821 +++ configure.ac        (revision 2908)
822 @@ -27,6 +27,7 @@
823  AC_INIT(util-vserver, 0.30.215, vserver@list.linux-vserver.org)
824  AC_CONFIG_SRCDIR([src/capchroot.c])
825  AC_CONFIG_HEADER([config.h])
826 +AC_CONFIG_MACRO_DIR([m4])
827  
828  AM_INIT_AUTOMAKE([1.9 gnits dist-bzip2 subdir-objects])
829  AM_MAINTAINER_MODE
830 Index: lib/syscall_setiattr-fscompat.hc
831 ===================================================================
832 --- lib/syscall_setiattr-fscompat.hc    (revision 2883)
833 +++ lib/syscall_setiattr-fscompat.hc    (revision 2908)
834 @@ -26,6 +26,7 @@
835  #include "ioctl-getxflg.hc"
836  
837  #include <fcntl.h>
838 +#include <sys/stat.h>
839  
840  static inline ALWAYSINLINE int
841  vc_set_iattr_fscompat(char const *filename,
842 Index: lib/vserver.h
843 ===================================================================
844 --- lib/vserver.h       (revision 2883)
845 +++ lib/vserver.h       (revision 2908)
846 @@ -281,8 +281,18 @@
847  
848  // the VCI bit values
849  #define VC_VCI_NO_DYNAMIC              (1 << 0)
850 +#define VC_VCI_PROC_SECURE             (1 << 4)
851 +#define VC_VCI_HARDCPU                 (1 << 5)
852 +#define VC_VCI_IDLELIMIT               (1 << 6)
853 +#define VC_VCI_IDLETIME                        (1 << 7)
854 +#define VC_VCI_COWBL                   (1 << 8)
855 +#define VC_VCI_FULLCOWBL               (1 << 9)
856  #define VC_VCI_SPACES                  (1 << 10)
857  #define VC_VCI_NETV2                   (1 << 11)
858 +#define VC_VCI_MEMCG                   (1 << 12)
859 +#define VC_VCI_DEBUG                   (1 << 16)
860 +#define VC_VCI_HISTORY                 (1 << 20)
861 +#define VC_VCI_TAGGED                  (1 << 24)
862  #define VC_VCI_PPTAG                   (1 << 28)
863  
864  
865 @@ -980,7 +990,7 @@
866                   vcFEATURE_VSHELPER0, vcFEATURE_VSHELPER, vcFEATURE_VWAIT,
867                  vcFEATURE_VNET,   vcFEATURE_VSTAT,   vcFEATURE_PPTAG,
868                  vcFEATURE_PIDSPACE, vcFEATURE_SPACES, vcFEATURE_PERSISTENT,
869 -                vcFEATURE_PIVOT_ROOT,
870 +                vcFEATURE_PIVOT_ROOT, vcFEATURE_MEMCG,
871                  }
872      vcFeatureSet;
873  
874 Index: lib/issupported.c
875 ===================================================================
876 --- lib/issupported.c   (revision 2883)
877 +++ lib/issupported.c   (revision 2908)
878 @@ -50,7 +50,8 @@
879      case vcFEATURE_PPTAG       :  return conf & VC_VCI_PPTAG;
880      case vcFEATURE_SPACES      :  return conf & VC_VCI_SPACES;
881      case vcFEATURE_PIVOT_ROOT  :  return ver >= 0x00020304;
882 -    case vcFEATURE_PIDSPACE    :  return ver >= 0x00020305;
883 +    case vcFEATURE_PIDSPACE    :  return false;
884 +    case vcFEATURE_MEMCG       :  return ver >= 0x00020306 && conf & VC_VCI_MEMCG;
885      default                    :  assert(false); 
886    }
887  
888 Index: lib/syscall_getiattr-fscompat.hc
889 ===================================================================
890 --- lib/syscall_getiattr-fscompat.hc    (revision 2883)
891 +++ lib/syscall_getiattr-fscompat.hc    (revision 2908)
892 @@ -25,6 +25,9 @@
893  #include "ioctl-getxflg.hc"
894  
895  #include <fcntl.h>
896 +#include <unistd.h>
897 +#include <sys/stat.h>
898 +
899  static inline ALWAYSINLINE int
900  vc_get_iattr_fscompat(char const *filename,
901                       xid_t    * /*@null@*/ xid,
902 Index: lib/issupportedstring.c
903 ===================================================================
904 --- lib/issupportedstring.c     (revision 2883)
905 +++ lib/issupportedstring.c     (revision 2908)
906 @@ -35,7 +35,7 @@
907    DECL(MIGRATE), DECL(NAMESPACE), DECL(SCHED),    DECL(VINFO),
908    DECL(VHI),     DECL(VSHELPER0), DECL(VSHELPER), DECL(VWAIT),
909    DECL(VNET),    DECL(VSTAT),     DECL(PPTAG),    DECL(PIDSPACE),
910 -  DECL(SPACES),  DECL(PERSISTENT),DECL(PIVOT_ROOT),
911 +  DECL(SPACES),  DECL(PERSISTENT),DECL(PIVOT_ROOT),DECL(MEMCG),
912  };
913  
914  bool
915 Index: pathconfig.h.pathsubst
916 ===================================================================
917 --- pathconfig.h.pathsubst      (revision 2883)
918 +++ pathconfig.h.pathsubst      (revision 2908)
919 @@ -25,6 +25,7 @@
920  #define SYSCONFDIR             "@SYSCONFDIR@"
921  #define LOCKDIR                        "/var/lock"
922  #define PKGLIBDEFAULTDIR       PKGLIBDIR "/defaults"
923 +#define DEFAULTCONFDIR         "@CONFDIR@/.defaults"
924  
925  #define DEFAULT_VSERVERDIR     "@VSERVERDIR@"
926  #define DEFAULT_VSERVERPKGDIR  "@VSERVERPKGDIR@"
927 Index: contrib/make-manifest
928 ===================================================================
929 --- contrib/make-manifest       (revision 2883)
930 +++ contrib/make-manifest       (revision 2908)
931 @@ -21,7 +21,7 @@
932  dest=$2
933  data=$3
934  
935 -for i in $name-{core,devel,base,build,legacy,lib,sysv}.list; do
936 +for i in $name-{core,devel,base,build,legacy,lib,sysv,python}.list; do
937      echo '%defattr(-,root,root,-)' >$i
938  done
939  
940 Index: contrib/manifest.dat.pathsubst
941 ===================================================================
942 --- contrib/manifest.dat.pathsubst      (revision 2883)
943 +++ contrib/manifest.dat.pathsubst      (revision 2908)
944 @@ -159,3 +159,4 @@
945  legacy @CONFIG@ @INITRDDIR@/vservers-legacy
946  legacy @CONFIG_NOREPLACE@ @SYSCONFDIR@/vservers.conf
947  build  @CONFIG_NOREPLACE@ @CONFDIR@/.distributions/*/apt/sources.list
948 +@HAVE_PYTHON_TRUE@python @PYEXECDIR@/*
949 Index: contrib/make-deb-manifest
950 ===================================================================
951 --- contrib/make-deb-manifest   (revision 0)
952 +++ contrib/make-deb-manifest   (revision 2908)
953 @@ -0,0 +1,63 @@
954 +#!/bin/bash
955 +
956 +# Copyright (C) 2010 Daniel Hokka Zakrisson <daniel@hozac.com>
957 +#  
958 +# This program is free software; you can redistribute it and/or modify
959 +# it under the terms of the GNU General Public License as published by
960 +# the Free Software Foundation; version 2 of the License.
961 +#  
962 +# This program is distributed in the hope that it will be useful,
963 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
964 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
965 +# GNU General Public License for more details.
966 +#  
967 +# You should have received a copy of the GNU General Public License
968 +# along with this program; if not, write to the Free Software
969 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
970 +
971 +## Usage: make-deb-manifest <basename> <destdir> <datfile>
972 +
973 +name=$2/$1
974 +dest=$2
975 +data=$3
976 +
977 +getname() {
978 +    if test $1 = "lib"; then
979 +       fullname="$dest/libvserver0"
980 +    elif test $1 = "devel"; then
981 +       fullname="$dest/libvserver0-dev"
982 +    elif test $1 = "base"; then
983 +       fullname="$name"
984 +    else
985 +       fullname="$name-$1"
986 +    fi
987 +}
988 +
989 +for i in {core,build,legacy,sysv,lib,devel,base,python}; do
990 +    getname $i
991 +    echo -n >${fullname}.install
992 +    rm -f ${fullname}.conffiles
993 +done
994 +
995 +DESTDIR=debian/tmp
996 +while read style file; do
997 +    test "$file" || continue
998 +    case "$style" in
999 +       (\#*)   continue;;
1000 +    esac
1001 +    getname $style
1002 +    set -o noglob
1003 +    set -- $file
1004 +    set +o noglob
1005 +    if test "$2"; then
1006 +       file="$2"
1007 +       for i in ${DESTDIR}$file; do
1008 +           test "${file#/etc/}" != "$file" && continue
1009 +           echo "${i#${DESTDIR}}" >>${fullname}.conffiles
1010 +       done
1011 +    fi
1012 +    for i in ${DESTDIR}$file; do
1013 +       i=${i#${DESTDIR}}
1014 +        echo "$i ${i%/*}" >>${fullname}.install
1015 +    done
1016 +done < $data
1017
1018 Property changes on: contrib/make-deb-manifest
1019 ___________________________________________________________________
1020 Name: svn:executable
1021    + *
1022
1023 Index: contrib/Makefile-files
1024 ===================================================================
1025 --- contrib/Makefile-files      (revision 2883)
1026 +++ contrib/Makefile-files      (revision 2908)
1027 @@ -37,6 +37,7 @@
1028                                         contrib/yum-3.2.0-chroot.patch \
1029                                         contrib/yum-3.2.1-chroot.patch \
1030                                         contrib/yum-3.2.4-chroot.patch \
1031 -                                       contrib/make-manifest
1032 +                                       contrib/make-manifest \
1033 +                                       contrib/make-deb-manifest
1034  
1035  contrib/manifest.dat:                  contrib/.manifest.dat.pathsubst.stamp
1036 Index: lib_internal/matchlist-initrefserverlist.c
1037 ===================================================================
1038 --- lib_internal/matchlist-initrefserverlist.c  (revision 2883)
1039 +++ lib_internal/matchlist-initrefserverlist.c  (revision 2908)
1040 @@ -26,6 +26,7 @@
1041  #include <dirent.h>
1042  #include <string.h>
1043  #include <fcntl.h>
1044 +#include <sys/stat.h>
1045  
1046  #define ENSC_WRAPPERS_FCNTL    1
1047  #define ENSC_WRAPPERS_UNISTD   1
1048 Index: util-vserver.spec.in
1049 ===================================================================
1050 --- util-vserver.spec.in        (revision 2883)
1051 +++ util-vserver.spec.in        (revision 2908)
1052 @@ -395,9 +395,10 @@
1053  %{!?_without_doc:%doc lib/apidoc/html}
1054  
1055  
1056 -%files python
1057 +%if 0%{!?_without_python:1}
1058 +%files python -f %name-python.list
1059  %defattr(-,root,root,-)
1060 -%{!?_without_python:%{python_sitearch}/*}
1061 +%endif
1062  
1063  
1064  %changelog
1065 Index: Makefile.am
1066 ===================================================================
1067 --- Makefile.am (revision 2883)
1068 +++ Makefile.am (revision 2908)
1069 @@ -143,6 +143,9 @@
1070                         s!@'ENSC_HAVE_C99_COMPILER_FALSE'@!\@ENSC_HAVE_C99_COMPILER_FALSE@ !g; \
1071                         s!@'ENSC_HAVE_CXX_COMPILER_TRUE'@!\@ENSC_HAVE_CXX_COMPILER_TRUE@ !g; \
1072                         s!@'ENSC_HAVE_CXX_COMPILER_FALSE'@!\@ENSC_HAVE_CXX_COMPILER_FALSE@ !g; \
1073 +                       s!@'HAVE_PYTHON_TRUE'@!\@HAVE_PYTHON_TRUE@ !g; \
1074 +                       s!@'HAVE_PYTHON_FALSE'@!\@HAVE_PYTHON_FALSE@ !g; \
1075 +                       s!@'PYEXECDIR'@!$(pyexecdir)!g; \
1076                         $(ENSC_PATHPROG_SED)
1077  
1078  pathconfig.h:          .pathconfig.h.pathsubst.stamp
1079 @@ -233,6 +236,7 @@
1080  if HAVE_PYTHON
1081  include $(top_srcdir)/python/Makefile-files
1082  endif
1083 +include $(top_srcdir)/debian/Makefile-files
1084  
1085  include $(top_srcdir)/m4/gpgsig.am
1086  include $(top_srcdir)/m4/validate.am
1087 Index: ensc_vector/testsuite/Makefile-files
1088 ===================================================================
1089 --- ensc_vector/testsuite/Makefile-files        (revision 2883)
1090 +++ ensc_vector/testsuite/Makefile-files        (revision 2908)
1091 @@ -21,6 +21,9 @@
1092  TESTS +=                       ensc_vector/testsuite/test1 \
1093                                 ensc_vector/testsuite/test2
1094  
1095 +DIETPROGS +=                   ensc_vector/testsuite/test1 \
1096 +                               ensc_vector/testsuite/test2
1097 +
1098  ensc_vector_testsuite_test1_SOURCES =  ensc_vector/testsuite/test1.c
1099  ensc_vector_testsuite_test1_LDADD =    $(LIBENSCVECTOR)
1100