]> git.proxmox.com Git - mirror_lxcfs.git/log
mirror_lxcfs.git
8 years agofix missing dereferencing in must_strcat_pid
Wolfgang Bumiller [Thu, 7 Jan 2016 11:59:51 +0000 (12:59 +0100)]
fix missing dereferencing in must_strcat_pid

Fixes a segfault when reading a /tasks file of a cgroup
containing a large number of pids.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #64 from evgeni/doc-include-fixes
Serge Hallyn [Fri, 1 Jan 2016 18:45:00 +0000 (10:45 -0800)]
Merge pull request #64 from evgeni/doc-include-fixes

update README about the hooks configuration needed

8 years agoupdate README about the hooks configuration needed
Evgeni Golov [Fri, 1 Jan 2016 18:11:42 +0000 (19:11 +0100)]
update README about the hooks configuration needed

- fix the paths for the files and config
- include lxc.mount.auto = cgroup:mixed

Signed-off-by: Evgeni Golov <evgeni@debian.org>
8 years agoDon't assume lxc knows about cgroup namespaces
Serge Hallyn [Fri, 1 Jan 2016 01:47:45 +0000 (17:47 -0800)]
Don't assume lxc knows about cgroup namespaces

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agodon't mount lxcfs cgroups if we have cgroup namespaces
Serge Hallyn [Tue, 10 Nov 2015 15:12:36 +0000 (09:12 -0600)]
don't mount lxcfs cgroups if we have cgroup namespaces

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agouptime: fix pid1 and reaper_busy times
Wolfgang Bumiller [Mon, 14 Dec 2015 08:03:14 +0000 (09:03 +0100)]
uptime: fix pid1 and reaper_busy times

- reaper_busy was off by a factor of 10 (possibly originally
for precision?)
- get_pid1_time was expecting a '1' byte like in
the pid_to/from_ns_wrapper functions instead of reading its
value which is what is actually written

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #57 from tych0/can-see-root-cgroup
Serge Hallyn [Mon, 7 Dec 2015 18:08:04 +0000 (12:08 -0600)]
Merge pull request #57 from tych0/can-see-root-cgroup

caller_may_see_dir: correctly handle tasks in /

8 years agocaller_may_see_dir: correctly handle tasks in /
Tycho Andersen [Mon, 7 Dec 2015 17:13:23 +0000 (10:13 -0700)]
caller_may_see_dir: correctly handle tasks in /

See comment for details.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
8 years agomeminfo: fix report swap usage
Serge Hallyn [Sun, 6 Dec 2015 16:39:55 +0000 (10:39 -0600)]
meminfo: fix report swap usage

when swap controller is enabled but no limits are set, the limits
show up as (unsigned) -1.  This messes up, for instance, 'free -m'.

Closes #56.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agotests/main.sh: support running without having built lxcfs
Serge Hallyn [Thu, 3 Dec 2015 03:02:01 +0000 (21:02 -0600)]
tests/main.sh: support running without having built lxcfs

This is the case in adt.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agomake test_confinement.sh executable
Serge Hallyn [Wed, 25 Nov 2015 18:18:54 +0000 (12:18 -0600)]
make test_confinement.sh executable

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoconfigure.ac: release v0.13 lxcfs-0.13
Serge Hallyn [Wed, 25 Nov 2015 16:25:01 +0000 (10:25 -0600)]
configure.ac: release v0.13

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agocaller_may_see_dir: prune init slice
Serge Hallyn [Mon, 23 Nov 2015 20:41:24 +0000 (14:41 -0600)]
caller_may_see_dir: prune init slice

Otherwise systemd is denied permission to see cgroups in
name=systemd in the container.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoadd check for defunct processes at end
Serge Hallyn [Mon, 23 Nov 2015 01:48:10 +0000 (19:48 -0600)]
add check for defunct processes at end

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agolxcfs.c: minor cleanups
Serge Hallyn [Mon, 23 Nov 2015 01:47:24 +0000 (19:47 -0600)]
lxcfs.c: minor cleanups

Make some of these fns easier to read.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoget_task_reaper_pid: clean up forked child
Serge Hallyn [Mon, 23 Nov 2015 01:31:28 +0000 (19:31 -0600)]
get_task_reaper_pid: clean up forked child

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #54 from hallyn/2015-11-20/glibc
Serge Hallyn [Fri, 20 Nov 2015 21:17:59 +0000 (15:17 -0600)]
Merge pull request #54 from hallyn/2015-11-20/glibc

work around weird glibc assert

8 years agowork around weird glibc assert
Serge Hallyn [Fri, 20 Nov 2015 18:29:11 +0000 (12:29 -0600)]
work around weird glibc assert

tl;dr realloc only in BATCH_SIZE increments.

longer version
I can't reproduce it separately yet, but on i386 xenial, lxcfs
is failing on reading meminfo, hitting a glibc assertion in malloc.c:

lxcfs: malloc.c:2373: sysmalloc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 *(sizeof(size_t))) - 1)) & ~((2 *(sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long) old_end & pagemask) == 0)' failed.

The relevant glibc code:

  /*
     If not the first time through, we require old_size to be
     at least MINSIZE and to have prev_inuse set.
   */
  assert ((old_top == initial_top (av) && old_size == 0) ||
          ((unsigned long) (old_size) >= MINSIZE &&
           prev_inuse (old_top) &&
           ((unsigned long) old_end & pagemask) == 0));

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agotravis: install libattr1-dev to fix building of tests
Serge Hallyn [Thu, 19 Nov 2015 19:53:39 +0000 (13:53 -0600)]
travis: install libattr1-dev to fix building of tests

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoprint_subsystems: print to stderr
Serge Hallyn [Thu, 19 Nov 2015 19:35:43 +0000 (13:35 -0600)]
print_subsystems: print to stderr

Dietmar pointed out that printing to stdout seems to mess up
systemd logging.

Reported-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoAdd files needed to build tests to EXTRA_DIST
Serge Hallyn [Tue, 17 Nov 2015 22:53:29 +0000 (16:53 -0600)]
Add files needed to build tests to EXTRA_DIST

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoconfigure.ac: release v0.12
Serge Hallyn [Tue, 17 Nov 2015 21:21:42 +0000 (15:21 -0600)]
configure.ac: release v0.12

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoremove stray debug statement lxcfs-0.12
Serge Hallyn [Tue, 17 Nov 2015 00:45:49 +0000 (18:45 -0600)]
remove stray debug statement

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoImplement privilege check when moving tasks
Serge Hallyn [Fri, 13 Nov 2015 23:18:55 +0000 (17:18 -0600)]
Implement privilege check when moving tasks

When writing pids to a tasks file in lxcfs, lxcfs was checking
for privilege over the tasks file but not over the pid being
moved.  Since the cgm_movepid request is done as root on the host,
not with the requestor's credentials, we must copy the check which
cgmanager was doing to ensure that the requesting task is allowed
to change the victim task's cgroup membership.

This is CVE-2015-1344
https://bugs.launchpad.net/ubuntu/+source/lxcfs/+bug/1512854

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoFix checking of parent directories
Serge Hallyn [Fri, 13 Nov 2015 23:07:36 +0000 (17:07 -0600)]
Fix checking of parent directories

Taken from the justification in the launchpad bug:

To a task in freezer cgroup /a/b/c/d, it should appear that there are no
cgroups other than its descendents. Since this is a filesystem, we must have
the parent directories, but each parent cgroup should only contain the child
which the task can see.

So, when this task looks at /a/b, it should see only directory 'c' and no
files. Attempt to create /a/b/x should result in -EPERM, whether /a/b/x already
exists or not. Attempts to query /a/b/x should result in -ENOENT whether /a/b/x
exists or not. Opening /a/b/tasks should result in -ENOENT.

The caller_may_see_dir checks specifically whether a task may see a cgroup
directory - i.e. /a/b/x if opening /a/b/x/tasks, and /a/b/c/d if doing
opendir('/a/b/c/d').

caller_is_in_ancestor() will return true if the caller in /a/b/c/d looks at
/a/b/c/d/e. If the caller is in a child cgroup of the queried one - i.e. if the
task in /a/b/c/d queries /a/b, then *nextcg will container the next (the only)
directory which he can see in the path - 'c'.

Beyond this, regular DAC permissions should apply, with the
root-in-user-namespace privilege over its mapped uids being respected. The
fc_may_access check does this check for both directories and files.

This is CVE-2015-1342 (LP: #1508481)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoMerge pull request #53 from hallyn/reboot
Serge Hallyn [Mon, 16 Nov 2015 20:18:26 +0000 (14:18 -0600)]
Merge pull request #53 from hallyn/reboot

Add a hook to make reboot sleep 0.5s

8 years agoAdd a hook to make reboot sleep 0.5s (v2)
Serge Hallyn [Thu, 12 Nov 2015 17:15:06 +0000 (11:15 -0600)]
Add a hook to make reboot sleep 0.5s (v2)

To ensure that the new container does not get cached directory entry
information from before we removed the container's cgroup using cgroupfs.

Changelog: make sure lxc.reboot.hook shows up in 'make dist'

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoLimit caching to 0.5s
Serge Hallyn [Thu, 12 Nov 2015 07:41:52 +0000 (01:41 -0600)]
Limit caching to 0.5s

If a cgroup is deleted or chmoded using the underlying cgroupfs, then we
want to minimize the amount of time during which we get stale info.  At the
same time, we don't want to do away with caching in the fuse kernel module
altogether, since calling out to userspace is expensive.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agochown cgroup files after chowning dirs
Serge Hallyn [Wed, 11 Nov 2015 01:38:40 +0000 (19:38 -0600)]
chown cgroup files after chowning dirs

cgmanager used to do this for us.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agomkdir: don't do it as setresid
Serge Hallyn [Wed, 11 Nov 2015 00:42:34 +0000 (18:42 -0600)]
mkdir: don't do it as setresid

First of all the code was wrong anyway.

Secondly, doing mkdir under setres{ug}id won't work because that
won't respect privilege that callers in user namespaces may have.

We check the permissions meticulously anyway, so do the mkdir as
root and then chown the new cgroup.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoImplement SwapTotal and SwapFree support for /proc/meminfo
Teemu Grönqvist [Sat, 31 Oct 2015 19:56:07 +0000 (21:56 +0200)]
Implement SwapTotal and SwapFree support for /proc/meminfo

[ Serge: s/cgm_/cgfs_/ ]

Signed-off-by: Teemu Grönqvist <teemu.gronqvist@net9.fi>
8 years agoMakefile.am: add cgfs.h to lxcfs_SOURCES
Serge Hallyn [Mon, 9 Nov 2015 20:48:10 +0000 (14:48 -0600)]
Makefile.am: add cgfs.h to lxcfs_SOURCES

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoUse cpuacct info for /proc/uptime idle field
Serge Hallyn [Mon, 9 Nov 2015 05:26:33 +0000 (23:26 -0600)]
Use cpuacct info for /proc/uptime idle field

As future work, the calculation of the reaper pid (to find its cpuacct cgroup)
and its reaper age could be combined into one step.

Closes #50

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agoUse find_mounted_controller in get_pid_cgroup
Serge Hallyn [Mon, 9 Nov 2015 05:13:50 +0000 (23:13 -0600)]
Use find_mounted_controller in get_pid_cgroup

So that get_pid_cgroup("cpu", pid) works when cpu is comounted.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
8 years agofind_mounted_controller: support comounted controllers
Serge Hallyn [Mon, 9 Nov 2015 05:12:30 +0000 (23:12 -0600)]
find_mounted_controller: support comounted controllers

So that when an internal fn asks for a cgroup value in 'cpu',
it finds it under 'cpu,cpuacct'.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoconvert to using cgfs instead of cgmanager
Serge Hallyn [Mon, 2 Nov 2015 22:56:36 +0000 (16:56 -0600)]
convert to using cgfs instead of cgmanager

remove lxcfs_mkdir - it is not needed since we don't need a clean dbus connection

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agodrop support for precise's glib
Serge Hallyn [Sat, 31 Oct 2015 04:33:16 +0000 (23:33 -0500)]
drop support for precise's glib

since we can't run in travis anyway

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agook, don't run the tests after all bc we'd need to modprobe fuse
Serge Hallyn [Sat, 31 Oct 2015 04:32:25 +0000 (23:32 -0500)]
ok, don't run the tests after all bc we'd need to modprobe fuse

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agotravis: satisfy older glib by calling g_type_init
Serge Hallyn [Sat, 31 Oct 2015 04:27:12 +0000 (23:27 -0500)]
travis: satisfy older glib by calling g_type_init

Sad, really.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agotravis: forget it for now
Serge Hallyn [Sat, 31 Oct 2015 04:21:49 +0000 (23:21 -0500)]
travis: forget it for now

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agotravis: no really
Serge Hallyn [Sat, 31 Oct 2015 02:42:33 +0000 (21:42 -0500)]
travis: no really

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agotravis: noninteractive upgrade
Serge Hallyn [Sat, 31 Oct 2015 02:37:28 +0000 (21:37 -0500)]
travis: noninteractive upgrade

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agotravis: do a dist-upgrade...?
Serge Hallyn [Sat, 31 Oct 2015 02:21:45 +0000 (21:21 -0500)]
travis: do a dist-upgrade...?

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agofinal travis fixes (i hope)
Serge Hallyn [Sat, 31 Oct 2015 02:15:45 +0000 (21:15 -0500)]
final travis fixes (i hope)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agouse LXCFSDIR in meminfo hierarchy test
Serge Hallyn [Sat, 31 Oct 2015 02:15:26 +0000 (21:15 -0500)]
use LXCFSDIR in meminfo hierarchy test

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoadd more travis (trusty) requirements
Serge Hallyn [Sat, 31 Oct 2015 01:57:53 +0000 (20:57 -0500)]
add more travis (trusty) requirements

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agotravis: install coreutils
Serge Hallyn [Sat, 31 Oct 2015 01:52:44 +0000 (20:52 -0500)]
travis: install coreutils

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agorun tests as root
Serge Hallyn [Sat, 31 Oct 2015 01:26:42 +0000 (20:26 -0500)]
run tests as root

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years ago/proc/meminfo: show the lowest limit amongst our ancestors
Serge Hallyn [Fri, 30 Oct 2015 23:30:56 +0000 (18:30 -0500)]
/proc/meminfo: show the lowest limit amongst our ancestors

If we are in /a/b/c, and b is limited to 500k, then c's limit_in_bytes
will not reflect the 500k, although that will be enforced for us.  So
check our lineage for the lowest limit.

Closes #44

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoactually run tests from travis
Serge Hallyn [Fri, 30 Oct 2015 18:03:34 +0000 (13:03 -0500)]
actually run tests from travis

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agosupport running tests from travis
Serge Hallyn [Fri, 30 Oct 2015 17:58:12 +0000 (12:58 -0500)]
support running tests from travis

Add a main.sh which can run a self-confined testsuite.

Note that without having lxcfs_mkdir installed, we cannot mkdir as
non-root user.

Update the test scripts to support using a lxcfs mountpoint other
than /var/lib/lxcfs

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoenable travis
Serge Hallyn [Fri, 30 Oct 2015 17:57:50 +0000 (12:57 -0500)]
enable travis

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agodon't let idletime be > reaperage
Serge Hallyn [Fri, 30 Oct 2015 17:29:18 +0000 (12:29 -0500)]
don't let idletime be > reaperage

This is not a good way to do this.  We should decide on a proper
heuristic.  We could take something like reaperage * (idletime/total_uptime),
but that doesn't scale for how much our own container used the cpu nor
for time.

I will open a github issue to fix this.

However as it currently stands the test_proc testcase was failing, this
at least lets it pass.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoMerge pull request #49 from hallyn/offset1
Stéphane Graber [Wed, 28 Oct 2015 22:32:54 +0000 (18:32 -0400)]
Merge pull request #49 from hallyn/offset1

fix corner cases in uptime and diskstat read

9 years agofix corner cases in uptime and diskstat read
Serge Hallyn [Wed, 28 Oct 2015 20:41:45 +0000 (20:41 +0000)]
fix corner cases in uptime and diskstat read

Closes #33

The code for these (a shortcut version of the other proc_*_read ones) was
doing snprintf(buf, size, ...).  If the user only requests one byte, we
just served them a trailing 0.  Fix that.

We weren't handling reads with offset in these cases either.  Fix that.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoMerge pull request #48 from bmiklautz/uptime_format
Serge Hallyn [Wed, 28 Oct 2015 18:36:18 +0000 (13:36 -0500)]
Merge pull request #48 from bmiklautz/uptime_format

Change uptime format

9 years agoupdate .gitignore
Serge Hallyn [Tue, 27 Oct 2015 20:49:05 +0000 (15:49 -0500)]
update .gitignore

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agomove lxcfs_mkdir under libexecdir
Serge Hallyn [Tue, 27 Oct 2015 20:48:46 +0000 (15:48 -0500)]
move lxcfs_mkdir under libexecdir

Note, this will require us to add

       dh_auto_configure -- --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
               --libexecdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH)

to debian/rules.

Closes #46

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoChange "uptime" format
Bernhard Miklautz [Wed, 28 Oct 2015 13:07:28 +0000 (14:07 +0100)]
Change "uptime" format

/proc/uptime has the format %lu.%02lu %lu.%02lu. The format used by
lxcfs doesn't consider the nano second portion of the uptime which might
cause programs that rely on that format to fail.

This commit adapts the uptime format to match the kernels by adding
trailing dummy values (.0) to the uptime and idle time values.
The parsing of /proc/uptime was updated.

Signed-off-by: Bernhard Miklautz <bernhard.miklautz@shacknet.at>
9 years agoconfigure.ac: drop libcgmanager dependency
Serge Hallyn [Tue, 27 Oct 2015 20:43:30 +0000 (15:43 -0500)]
configure.ac: drop libcgmanager dependency

Closes #45

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoconfigure.ac: v0.11 lxcfs-0.11
Serge Hallyn [Mon, 26 Oct 2015 20:59:25 +0000 (15:59 -0500)]
configure.ac: v0.11

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoRemove a memory leak from getattr
Serge Hallyn [Mon, 26 Oct 2015 19:37:31 +0000 (14:37 -0500)]
Remove a memory leak from getattr

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoremove stale comments, update some
Serge Hallyn [Thu, 22 Oct 2015 23:30:57 +0000 (18:30 -0500)]
remove stale comments, update some

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agofix memory leak
Serge Hallyn [Thu, 22 Oct 2015 23:01:07 +0000 (18:01 -0500)]
fix memory leak

each key also has an allocated char*, so use list_key to free the key.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agolxc mount hook: whitespace fixup
Wolfgang Bumiller [Wed, 21 Oct 2015 09:37:08 +0000 (11:37 +0200)]
lxc mount hook: whitespace fixup

Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agolxc mount hook: add missing space before ]
Wolfgang Bumiller [Wed, 21 Oct 2015 09:37:07 +0000 (11:37 +0200)]
lxc mount hook: add missing space before ]

Otherwise [ interprets the ] as part of the path and also
errors about a missing ']'

Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoswap out libnih and libnih-dbus for glib
Serge Hallyn [Fri, 16 Oct 2015 19:44:29 +0000 (14:44 -0500)]
swap out libnih and libnih-dbus for glib

The motivation is to make threading possible, to hopefully greatly
speed up systemd startup inside containers.

This required converting all the nih-ified memory tracking.  (Some
of this can probably be done smarter in a more glib-friendly way, i.e.
avoiding doing a glib string alloc followed by strdup followed by
freeing the glib string)

We open a single dbus connection for all threads to use.  If that
connection is closed (i.e. cgmanager exits / restarts) the first
task to find it so takes a mutex and attempts to reconnect, once
per second, until it is reconnected.

When creating a directory for non-root user, execute a new binary
to get a clean dbus session as that user.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoallow systemd to escape its init.scope cgroup
Serge Hallyn [Thu, 15 Oct 2015 13:29:56 +0000 (08:29 -0500)]
allow systemd to escape its init.scope cgroup

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoMerge pull request #38 from sn-x/master
Serge Hallyn [Tue, 13 Oct 2015 20:34:41 +0000 (15:34 -0500)]
Merge pull request #38 from sn-x/master

Fixed issue #37

9 years agoFixed issue #37
Aljaz Meznaric [Fri, 9 Oct 2015 09:54:12 +0000 (11:54 +0200)]
Fixed issue #37

9 years agoMerge pull request #34 from ralt/patch-1
Stéphane Graber [Mon, 14 Sep 2015 14:56:02 +0000 (10:56 -0400)]
Merge pull request #34 from ralt/patch-1

Better explain what lxcfs does

9 years agoBetter explain what lxcfs does
Florian Margaine [Mon, 14 Sep 2015 10:22:29 +0000 (12:22 +0200)]
Better explain what lxcfs does

At first glance, I thought this project was a custom fs for the hosts, not for the containers themselves.

Hopefully this line will clear up the misunderstanding for future
readers, and show that this project is *really* useful!

Signed-off-by: Florian Margaine <florian@margaine.com>
9 years agoconfigure.ac: v0.10 lxcfs-0.10
Stéphane Graber [Thu, 3 Sep 2015 22:55:54 +0000 (18:55 -0400)]
configure.ac: v0.10

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
9 years agofix symlink
Serge Hallyn [Thu, 3 Sep 2015 13:46:52 +0000 (08:46 -0500)]
fix symlink

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agolxc mount hook: implement stgraber's suggestions
Serge Hallyn [Thu, 3 Sep 2015 04:00:11 +0000 (23:00 -0500)]
lxc mount hook: implement stgraber's suggestions

revert to using sh and use symlinks instead of extra mounts.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoUpdate lxc mount hook to ovver a mount per co-mounted controller
Serge Hallyn [Thu, 3 Sep 2015 03:28:59 +0000 (22:28 -0500)]
Update lxc mount hook to ovver a mount per co-mounted controller

If cpu,cpuacct are comounted, then in addition to cpu,cpuacct make
mounts for 'cpu' and 'cpuacct'.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agolxc mount hook: don't mount lxcfs fs for any controller already setup
Serge Hallyn [Wed, 24 Jun 2015 23:26:06 +0000 (18:26 -0500)]
lxc mount hook: don't mount lxcfs fs for any controller already setup

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agodon't thread
Serge Hallyn [Wed, 24 Jun 2015 23:15:34 +0000 (18:15 -0500)]
don't thread

The pieces are there, but for now it's still not safe with libdbus

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoReturn host's meminfo file if no memory cgroup
Serge Hallyn [Fri, 5 Jun 2015 04:18:20 +0000 (23:18 -0500)]
Return host's meminfo file if no memory cgroup

If memory cgroup is not available (that is, we can't find a
memory cgroup for the reading task), then just return the
contents of the host's /proc/meminfo.  (Same for all proc file
reads)

Closes #30

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agofix two threading issues
Serge Hallyn [Wed, 20 May 2015 15:56:46 +0000 (08:56 -0700)]
fix two threading issues

Make sure to prep dbus for threading before we start.

And use _exit() any time we are exiting from a forked child.  This is
to avoid calling the at_exit() functions.  Once a thread in the main
program has called nih_error_init(), this registers an at_exit fn which
asserts that the nih_context not be null - but after we fork, if libnih
is built with --enable-threading, then the nih_context is in fact null.
The only way to clear the atexit fns would be to exec().  So call
_exit() instead of exit(), because _exit() avoids calling the atexit
fns.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agouse threads when safe
Serge Hallyn [Tue, 19 May 2015 21:27:05 +0000 (14:27 -0700)]
use threads when safe

libnih, when not built with --enable-threading, cannot be safely
used by a threaded application.  Detect whether it is built to be
threadsafe using a new libnih helper, and, if so, run threaded by
(a) not passing '-s' to fuse, and (b) making the dbus connection
and detected api version thread-local.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoconfigure.ac: v0.9 lxcfs-0.9
Serge Hallyn [Sat, 9 May 2015 00:52:28 +0000 (19:52 -0500)]
configure.ac: v0.9

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoMerge pull request #26 from mikemccracken/maybe-fix-24
Stéphane Graber [Fri, 8 May 2015 21:09:38 +0000 (21:09 +0000)]
Merge pull request #26 from mikemccracken/maybe-fix-24

Add error handling for snprintf calls inside *_read() funcs

9 years agoinside *_read() funcs, return 0 for snprintf errors and truncations
Michael McCracken [Fri, 8 May 2015 20:24:03 +0000 (16:24 -0400)]
inside *_read() funcs, return 0 for snprintf errors and truncations

Signed-off-by: Michael McCracken <mike.mccracken@canonical.com>
9 years agocheck return value from snprintf to avoid FUSE errors. Potentially fixes #24.
Michael McCracken [Fri, 8 May 2015 08:46:02 +0000 (04:46 -0400)]
check return value from snprintf to avoid FUSE errors. Potentially fixes #24.

Signed-off-by: Michael McCracken <mike.mccracken@canonical.com>
9 years agoconfigure.ac: release 0.8 lxcfs-0.8
Serge Hallyn [Thu, 7 May 2015 19:39:34 +0000 (14:39 -0500)]
configure.ac: release 0.8

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoimplement --version
Serge Hallyn [Thu, 7 May 2015 16:25:52 +0000 (11:25 -0500)]
implement --version

Because this is needed for help2man to determine the program name.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoFix the check for cpu being in cpuset range
Serge Hallyn [Thu, 30 Apr 2015 11:07:34 +0000 (13:07 +0200)]
Fix the check for cpu being in cpuset range

Also add a testcase to make sure that the new function is correct.
In order to share the cpuset range checking code with with the
test, move it into cpuset.c.  Not sure whether we want that in a
utils.c instead.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoAdd some more sanity checks
Serge Hallyn [Mon, 20 Apr 2015 13:40:39 +0000 (08:40 -0500)]
Add some more sanity checks

Limit string size in sscanf, convert some sprintfs to snprintfs
(to make them future-proof), and free d in case of error.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agofree d at program end
Serge Hallyn [Sun, 19 Apr 2015 04:51:03 +0000 (23:51 -0500)]
free d at program end

to silence warnings from memory checkers

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoMake sure that that '/cgroup' and the controller are sep'd by /
Serge Hallyn [Sun, 19 Apr 2015 04:03:45 +0000 (23:03 -0500)]
Make sure that that '/cgroup' and the controller are sep'd by /

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agocg_read: add ending newline
Serge Hallyn [Fri, 17 Apr 2015 21:13:33 +0000 (16:13 -0500)]
cg_read: add ending newline

Closes #23

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agouse direct_io
Serge Hallyn [Fri, 17 Apr 2015 20:39:35 +0000 (15:39 -0500)]
use direct_io

This will prevent a file read for over getattr.

File sizes show up as 0, but they do so in cgroupfs and procfs as well.

Closes #20.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoProvide the fuse options we want ourselves
Serge Hallyn [Fri, 17 Apr 2015 20:28:04 +0000 (15:28 -0500)]
Provide the fuse options we want ourselves

continue to allow the options which in the past we basically required
callers to provide ("-s -f -o allow_other"), exit on anything else.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoCleanup whitespace
Serge Hallyn [Fri, 10 Apr 2015 18:54:46 +0000 (13:54 -0500)]
Cleanup whitespace

and remove commented out debug statement

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
9 years agoMerge pull request #22 from hustcat/cache.1
Serge Hallyn [Fri, 10 Apr 2015 18:52:02 +0000 (13:52 -0500)]
Merge pull request #22 from hustcat/cache.1

cache for proc file

9 years agoinfo as parent when malloc memory for file buf
Ye Yin [Fri, 10 Apr 2015 07:19:44 +0000 (15:19 +0800)]
info as parent when malloc memory for file buf
reduce one blank for /proc/stat

Signed-off-by: Ye Yin <eyniy@qq.com>
9 years agoMerge pull request #19 from hallyn/cache.1
Serge Hallyn [Thu, 9 Apr 2015 21:18:06 +0000 (16:18 -0500)]
Merge pull request #19 from hallyn/cache.1

Cache.1

9 years agoadd cache for proc file, for support multiple read
Ye Yin [Thu, 9 Apr 2015 11:01:10 +0000 (19:01 +0800)]
add cache for proc file, for support multiple read

Signed-off-by: Ye Yin <eyniy@qq.com>
9 years agoLXC hook fixes
Stéphane Graber [Tue, 7 Apr 2015 20:17:40 +0000 (16:17 -0400)]
LXC hook fixes

 - Detects whether cgroups are enabled in the container's config
 - Don't mount a second tmpfs on /sys/fs/cgroup

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>