]> git.proxmox.com Git - mirror_lxcfs.git/log
mirror_lxcfs.git
7 years agobindings: increase reserved buffer size a little
Christian Brauner [Sat, 11 Mar 2017 16:19:12 +0000 (17:19 +0100)]
bindings: increase reserved buffer size a little

So far, only proc_stat_read() is fully using BUF_RESERVE_SIZE so it doesn't
actually benefit from the additional memory assigned to it like all the other
files in proc do. So double the size and have proc_stat_read() only use half of
it.

Supposedly fixes #176.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agobindings: implement guest nice
Christian Brauner [Sat, 11 Mar 2017 13:51:58 +0000 (14:51 +0100)]
bindings: implement guest nice

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agopam_cgfs: remove dead assignment
Christian Brauner [Sat, 11 Mar 2017 13:04:47 +0000 (14:04 +0100)]
pam_cgfs: remove dead assignment

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agopam_cgfs: error out on failure in cgv2_init()
Christian Brauner [Sat, 11 Mar 2017 12:58:10 +0000 (13:58 +0100)]
pam_cgfs: error out on failure in cgv2_init()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #178 from brauner/2017-03-03/fix_trim
Serge Hallyn [Fri, 3 Mar 2017 00:16:04 +0000 (18:16 -0600)]
Merge pull request #178 from brauner/2017-03-03/fix_trim

pam_cgfs: make trim() safer

7 years agopam_cgfs: make trim() safer
Christian Brauner [Thu, 2 Mar 2017 23:35:07 +0000 (00:35 +0100)]
pam_cgfs: make trim() safer

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #174 from brauner/2017-02-09/bugfixes
Serge Hallyn [Thu, 9 Feb 2017 21:03:38 +0000 (15:03 -0600)]
Merge pull request #174 from brauner/2017-02-09/bugfixes

2017 02 09/bugfixes

7 years agobindings: Want space for ints? Call sizeof(int)!
Christian Brauner [Thu, 9 Feb 2017 10:49:04 +0000 (11:49 +0100)]
bindings: Want space for ints? Call sizeof(int)!

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agopam_cgfs: make sure that **p is not NULL
Christian Brauner [Thu, 9 Feb 2017 10:36:47 +0000 (11:36 +0100)]
pam_cgfs: make sure that **p is not NULL

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agopam_cgfs: return created directly
Christian Brauner [Thu, 9 Feb 2017 10:25:30 +0000 (11:25 +0100)]
pam_cgfs: return created directly

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agopam_cgfs: remove dead assignment
Christian Brauner [Thu, 9 Feb 2017 10:22:50 +0000 (11:22 +0100)]
pam_cgfs: remove dead assignment

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoMerge pull request #169 from almostivan/btime
Serge Hallyn [Fri, 3 Feb 2017 06:00:12 +0000 (00:00 -0600)]
Merge pull request #169 from almostivan/btime

virtualize the 'btime' field of /proc/stat

7 years agoMerge pull request #172 from Blub/queue
Serge Hallyn [Thu, 2 Feb 2017 16:21:08 +0000 (10:21 -0600)]
Merge pull request #172 from Blub/queue

Limit memswlimit by TotalSwap

7 years agoMerge pull request #171 from Blub/trivial/false-vs-NULL
Serge Hallyn [Thu, 2 Feb 2017 16:16:38 +0000 (10:16 -0600)]
Merge pull request #171 from Blub/trivial/false-vs-NULL

cleanup: return false instead of NULL as bool

7 years agoLimit memswlimit by TotalSwap
Wolfgang Bumiller [Thu, 2 Feb 2017 08:36:46 +0000 (09:36 +0100)]
Limit memswlimit by TotalSwap

We do this for the memlimit when hitting MemTotal which
means if neither is limited we end up subtracting the
hosts's total memory from the 'unlimited' swap value in the
SwapTotal and SwapFree lines.

Fixes #170

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
7 years agocleanup: return false instead of NULL as bool
Wolfgang Bumiller [Wed, 1 Feb 2017 14:19:24 +0000 (15:19 +0100)]
cleanup: return false instead of NULL as bool

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
7 years agovirtualize the 'btime' field of /proc/stat
Jason Baron [Fri, 27 Jan 2017 21:57:54 +0000 (16:57 -0500)]
virtualize the 'btime' field of /proc/stat

Currently, the 'btime' of /proc/stat reflects the boot time of the host.
We would like it to reflect when the guest boots, so use the start time of
init.

Signed-off-by: Jason Baron <jbaron@akamai.com>
7 years agoMerge pull request #168 from Xeno22/master
Stéphane Graber [Fri, 27 Jan 2017 21:49:40 +0000 (16:49 -0500)]
Merge pull request #168 from Xeno22/master

Also check next variable for NULL on cg_rmdir

7 years agoAlso check next variable for NULL on cg_rmdir
Xeno [Fri, 27 Jan 2017 18:06:39 +0000 (19:06 +0100)]
Also check next variable for NULL on cg_rmdir

Signed-off-by: Martin Zwickel <martin.zwickel@googlemail.com>
7 years agoMerge pull request #166 from stgraber/master
Serge Hallyn [Wed, 25 Jan 2017 03:22:21 +0000 (21:22 -0600)]
Merge pull request #166 from stgraber/master

Remove unused variable

7 years agoRemove unused variable
Stéphane Graber [Wed, 25 Jan 2017 03:15:11 +0000 (22:15 -0500)]
Remove unused variable

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
7 years agoMerge pull request #162 from Fabian-Gruenbichler/swapfix
Serge Hallyn [Sat, 31 Dec 2016 23:19:54 +0000 (17:19 -0600)]
Merge pull request #162 from Fabian-Gruenbichler/swapfix

fix swap values with nested cgroups

7 years agofix swap values with nested cgroups
Fabian Grünbichler [Thu, 22 Dec 2016 12:12:04 +0000 (13:12 +0100)]
fix swap values with nested cgroups

the memory limit was already correctly set by looking at the
whole cgroup hierarchy and using the minimum value, refactor
that code to support arbitrary files in the memory cgroup
and reuse it for the memsw limit as well.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
7 years agoMerge pull request #161 from stgraber/master
Serge Hallyn [Sat, 3 Dec 2016 00:54:19 +0000 (18:54 -0600)]
Merge pull request #161 from stgraber/master

tests: Fix run on ppc64el

7 years agotests: Fix run on ppc64el
Stéphane Graber [Sat, 3 Dec 2016 00:45:18 +0000 (19:45 -0500)]
tests: Fix run on ppc64el

Turns out a MB of memory isn't quite enough to run things like cat on
some architectures, so lets bump to a more comfortable 64MB.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
7 years agoMerge pull request #147 from albatross0/fix_scanning_of_memstat
Serge Hallyn [Wed, 23 Nov 2016 19:37:10 +0000 (13:37 -0600)]
Merge pull request #147 from albatross0/fix_scanning_of_memstat

Fix wrong scanning of memory.stat

7 years agoMerge pull request #160 from brauner/2016-11-21/cgfsng_improve_isolcpus_handling
Serge Hallyn [Tue, 22 Nov 2016 01:05:40 +0000 (19:05 -0600)]
Merge pull request #160 from brauner/2016-11-21/cgfsng_improve_isolcpus_handling

cgfsng improve isolcpus handling

7 years agocgroups: handle non-existent isolcpus file
Christian Brauner [Tue, 22 Nov 2016 00:20:01 +0000 (01:20 +0100)]
cgroups: handle non-existent isolcpus file

If the file "/sys/devices/system/cpu/isolated" doesn't exist, we can't just
simply bail. We still need to check whether we need to copy the parents cpu
settings.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
7 years agopam_cgfs: improve cg_filter_and_set_cpus()
Christian Brauner [Tue, 22 Nov 2016 00:18:41 +0000 (01:18 +0100)]
pam_cgfs: improve cg_filter_and_set_cpus()

- add debugg logging
- simplify logic

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
7 years agoMerge pull request #159 from brauner/2016-11-19/pam_cgfs_handle_cpuset_v1
Serge Hallyn [Mon, 21 Nov 2016 16:05:47 +0000 (10:05 -0600)]
Merge pull request #159 from brauner/2016-11-19/pam_cgfs_handle_cpuset_v1

pam_cgfs: handle cgroupfs v1 cpuset controller

7 years agopam_cgfs: bugfixes
Christian Brauner [Mon, 21 Nov 2016 15:47:59 +0000 (16:47 +0100)]
pam_cgfs: bugfixes

- add missing free()s
- simplify logic
- add a comment to point out that most helpers stem from LXC

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
7 years agopam_cgfs: improve logging
Christian Brauner [Sat, 19 Nov 2016 14:38:55 +0000 (15:38 +0100)]
pam_cgfs: improve logging

- remove GNU specific %m specifier
- add more lxcfs_debug() calls

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
7 years agopam_cgfs: handle cgroupfs v1 cpuset controller
Christian Brauner [Sat, 19 Nov 2016 13:38:57 +0000 (14:38 +0100)]
pam_cgfs: handle cgroupfs v1 cpuset controller

If init has not placed us into our own cgroup on login we will reside in the
root cgroup. In this case cgroup.clone_children will not have been initialized
and so we need to do it. Otherwise users will not be able to start containers
with cpuset limits set.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
7 years agoMerge pull request #156 from brauner/2016-11-11/cgroupv2_support
Serge Hallyn [Fri, 18 Nov 2016 03:37:13 +0000 (21:37 -0600)]
Merge pull request #156 from brauner/2016-11-11/cgroupv2_support

pam_cgfs: reimplement and add cgroupfs v2 support

7 years agopam_cgfs: re-use cgroups that already belong to us
Christian Brauner [Thu, 17 Nov 2016 23:18:45 +0000 (00:18 +0100)]
pam_cgfs: re-use cgroups that already belong to us

When we detect an already existing cgroup that belongs to our uid and gid, we
simply re-use it. This allows us to avoid creating useless additional cgroups
when e.g. running multiple sudo commands in a script or when we login from
different ttys.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
7 years agopam_cgfs: bugfixes
Christian Brauner [Thu, 17 Nov 2016 23:00:54 +0000 (00:00 +0100)]
pam_cgfs: bugfixes

When we are placed in a systemd user slice, do not try to re-enter the cgroup
again.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
7 years agopam_cgfs: bugfixes
Christian Brauner [Thu, 17 Nov 2016 19:32:15 +0000 (20:32 +0100)]
pam_cgfs: bugfixes

- free(basecginfo) on failure
- correct check when parsing /proc/<pid>/mountinfo
- check for NULL when retrieving init cgroup

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
7 years agopam_cgfs: reimplement and add cgroupfs v2 support
Christian Brauner [Sun, 13 Nov 2016 05:07:58 +0000 (06:07 +0100)]
pam_cgfs: reimplement and add cgroupfs v2 support

This is a rewrite of pam_cgfs which leans on LXC's cgfsng.c. Various codepaths
have been adapted and made more appropriate.

The strategy of pam_cgfs v2 is to support cgroupfs v1, cgroupfs v2, and mixed
mounts where some controllers are mounted into a standard cgroupfs v1 hierarchy
location (/sys/fs/cgroup/<controller>) and other controllers are mounted into
the cgroupfs v2 hierarchy.

The functions and types for cgroupfs v1 and cgroupfs v2 have nearly all been
kept separately even if they do nearly the exact same job. This is on purpose!
Although marked non-experimental, cgroupfs v2 is too much of a moving target.
Extrapolating from currentl cgroupfs v2 standard behaviour seems risky and error
prone. Even more so when those assumptions complexify or simplify cgroupfs v1
assumptions when trying to handle both, cgroupfs v1 and cgroupfs v2, in one
function. In short, code duplication currently is on purpose so that we can
easily adapt to changes in cgroupfs v2 behaviour without having to touch any of
the functions or types that deal with the basically standardized cgroupfs v1
behaviour.

A quick run-through of what current pam_cgfs does (The same wording can be found
in the preamble/license to pam_cgfs.c.):

When a user logs in, this pam module will create cgroups which the user may
administer. It handles both pure cgroupfs v1 and pure cgroupfs v2, as well as
mixed mounts, where some controllers are mounted in a standard cgroupfs v1
hierarchy location (/sys/fs/cgroup/<controller>) and others are in the cgroupfs
v2 hierarchy.
Writeable cgroups are either created for all controllers or, if specified, for
any controllers listed on the command line.
The cgroup created will be "user/$user/0" for the first session, "user/$user/1"
for the second, etc.

Systems with a systemd init system are treated specially, both with respect to
cgroupfs v1 and cgroupfs v2. For both, cgroupfs v1 and cgroupfs v2, we check
whether systemd already placed us in a cgroup it created, e.g.

     user.slice/user-uid.slice/session-n.scope

by checking whether uid == our uid. If it did, we simply chown the last
part (session-n.scope). If it did not we create a cgroup as outlined above
(user/$user/n) and chown it to our uid.
The same holds for cgroupfs v2 where checking this assumption becomes crucial:
If we systemd already created and placed us in a cgroups, we __have to__ be
placed our under it on login, otherwise things like starting an xserver or
similar will not work.

All requested cgroups must be mounted under /sys/fs/cgroup/$controller,
no messing around with finding mountpoints.

Note, as of now, we currently do not yet necessarily deal correctly with weird
corner cases like not mounting the name=systemd cgroupfs v1 controller at
/sys/fs/cgroup/systemd but rather mounting an empty cgroupfs v2 hierarchy at the
same location which is used by systemd to track processes. This is left for
future commits.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
7 years agomacro: add header for shared macros
Christian Brauner [Sun, 13 Nov 2016 05:06:54 +0000 (06:06 +0100)]
macro: add header for shared macros

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
7 years agoMerge pull request #153 from Fabian-Gruenbichler/memactivefix
Serge Hallyn [Thu, 20 Oct 2016 00:32:21 +0000 (19:32 -0500)]
Merge pull request #153 from Fabian-Gruenbichler/memactivefix

fix Active/Inactive /proc/meminfo

7 years agofix Active/Inactive /proc/meminfo
Fabian Grünbichler [Wed, 19 Oct 2016 07:16:36 +0000 (09:16 +0200)]
fix Active/Inactive /proc/meminfo

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
7 years agoMerge pull request #151 from brauner/2016-10-08/getattr_from_wronly_files
Serge Hallyn [Sun, 9 Oct 2016 04:25:56 +0000 (23:25 -0500)]
Merge pull request #151 from brauner/2016-10-08/getattr_from_wronly_files

bindings: remove noop check

7 years agobindings: remove noop check
Christian Brauner [Sat, 8 Oct 2016 08:15:10 +0000 (10:15 +0200)]
bindings: remove noop check

Unless the file was created with chmod 000 the current check for
!O_RDONLY && !O_WRONLY will always be successful, making the current check
basically a noop. And even in the case where a file has chmod 000 we still want
the user to see that it has no permissions. So let's remove the check entirely.
Whether a user sees a file will be determined by a prior check for O_RDONLY on
the directory anyway.

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
7 years agoMerge pull request #150 from brauner/2016-10-07/getattr_from_wronly_files
Stéphane Graber [Fri, 7 Oct 2016 06:19:31 +0000 (08:19 +0200)]
Merge pull request #150 from brauner/2016-10-07/getattr_from_wronly_files

bindings: allow getattr on O_WRONLY files

7 years agobindings: allow getattr on O_WRONLY files
Christian Brauner [Thu, 6 Oct 2016 22:59:53 +0000 (00:59 +0200)]
bindings: allow getattr on O_WRONLY files

We should only deny getting the attributes of a file if it neither contains
O_RDONLY permission nor O_WRONLY permissions. Otherwise ls -al will not show
attributes on O_WRONLY files. Such files are quite common under /proc or /sys.

BEFORE:
root@conventiont:~# ls -al /var/lib/lxcfs/cgroup/devices/
ls: cannot access '/var/lib/lxcfs/cgroup/devices/devices.allow': Permission denied
ls: cannot access '/var/lib/lxcfs/cgroup/devices/devices.deny': Permission denied
total 0
drwxr-xr-x 2 root root 0 Oct  7 01:00 .
drwxr-xr-x 2 root root 0 Oct  7 01:00 ..
-rw-r--r-- 1 root root 0 Oct  7 01:00 cgroup.clone_children
-rw-r--r-- 1 root root 0 Oct  7 01:00 cgroup.procs
-r--r--r-- 1 root root 0 Oct  7 01:00 cgroup.sane_behavior
?????????? ? ?    ?    ?            ? devices.allow
?????????? ? ?    ?    ?            ? devices.deny
-r--r--r-- 1 root root 0 Oct  7 01:00 devices.list
drwxr-xr-x 2 root root 0 Oct  7 01:00 init.scope
drwxr-xr-x 2 root root 0 Oct  7 01:00 lxc
-rw-r--r-- 1 root root 0 Oct  7 01:00 notify_on_release
-rw-r--r-- 1 root root 0 Oct  7 01:00 release_agent
drwxr-xr-x 2 root root 0 Oct  7 01:00 system.slice
-rw-r--r-- 1 root root 0 Oct  7 01:00 tasks
drwxr-xr-x 2 root root 0 Oct  7 01:00 user.slice

AFTER:
root@conventiont:~# ls -al /var/lib/lxcfs/cgroup/devices/
total 0
drwxr-xr-x 2 root root 0 Oct  7 01:01 .
drwxr-xr-x 2 root root 0 Oct  7 01:01 ..
-rw-r--r-- 1 root root 0 Oct  7 01:01 cgroup.clone_children
-rw-r--r-- 1 root root 0 Oct  7 01:01 cgroup.procs
-r--r--r-- 1 root root 0 Oct  7 01:01 cgroup.sane_behavior
--w------- 1 root root 0 Oct  7 01:01 devices.allow
--w------- 1 root root 0 Oct  7 01:01 devices.deny
-r--r--r-- 1 root root 0 Oct  7 01:01 devices.list
drwxr-xr-x 2 root root 0 Oct  7 01:01 init.scope
drwxr-xr-x 2 root root 0 Oct  7 01:01 lxc
-rw-r--r-- 1 root root 0 Oct  7 01:01 notify_on_release
-rw-r--r-- 1 root root 0 Oct  7 01:01 release_agent
drwxr-xr-x 2 root root 0 Oct  7 01:01 system.slice
-rw-r--r-- 1 root root 0 Oct  7 01:01 tasks
drwxr-xr-x 2 root root 0 Oct  7 01:01 user.slice

Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
7 years agoAdd Documentation key to systemd unit
Stéphane Graber [Wed, 5 Oct 2016 12:39:45 +0000 (14:39 +0200)]
Add Documentation key to systemd unit

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
7 years agoFix wrong scanning of memory.stat
albatross0 [Thu, 29 Sep 2016 11:23:27 +0000 (20:23 +0900)]
Fix wrong scanning of memory.stat

Signed-off-by: KUWAZAWA Takuya <albatross0@gmail.com>
7 years agoMerge pull request #145 from brauner/2016-09-04/lxcfs_on_ramfs
Serge Hallyn [Tue, 6 Sep 2016 14:59:18 +0000 (09:59 -0500)]
Merge pull request #145 from brauner/2016-09-04/lxcfs_on_ramfs

lxcfs on ramfs

7 years agobindings: make pivot_enter() contain all its code
Christian Brauner [Mon, 5 Sep 2016 14:13:12 +0000 (16:13 +0200)]
bindings: make pivot_enter() contain all its code

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
7 years agobindings: fix type weirdness with statfs f_type
Christian Brauner [Sun, 4 Sep 2016 16:49:23 +0000 (18:49 +0200)]
bindings: fix type weirdness with statfs f_type

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
7 years agobindings: use chroot() on ramfs
Christian Brauner [Sun, 4 Sep 2016 16:07:01 +0000 (18:07 +0200)]
bindings: use chroot() on ramfs

- Detect whether we are on a ramfs. We first try via statfs and check for
  RAMFS_MAGIC. This may report TMPFS_MAGIC although it should better report
  RAMFS_MAGIC. In this case, parse /proc/self/mountinfo and check for
        - rootfs rootfs
  like we do in LXC.
- When we are on ramfs use chroot(), otherwise use pivot_root().

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
7 years agobindings: agnostic naming
Christian Brauner [Sun, 4 Sep 2016 15:42:22 +0000 (17:42 +0200)]
bindings: agnostic naming

- non-functional changes

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
7 years agobindings: add function to check fs type
Christian Brauner [Sun, 4 Sep 2016 15:33:09 +0000 (17:33 +0200)]
bindings: add function to check fs type

We use statfs directly because statvfs proved unreliable in my testing. It's
f_fsid field does not seem to work correctly with linux/magic.h macros.

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
7 years agoMerge pull request #140 from brauner/2016-08-30/add_avoid_version
Serge Hallyn [Wed, 31 Aug 2016 14:03:53 +0000 (09:03 -0500)]
Merge pull request #140 from brauner/2016-08-30/add_avoid_version

autotools: add -avoid-version

7 years agoMerge pull request #141 from brauner/2016-08-31/restore_cwd
Serge Hallyn [Wed, 31 Aug 2016 03:36:14 +0000 (22:36 -0500)]
Merge pull request #141 from brauner/2016-08-31/restore_cwd

bindings: restore original working directory

7 years agobindings: restore original working directory
Christian Brauner [Wed, 31 Aug 2016 00:20:09 +0000 (02:20 +0200)]
bindings: restore original working directory

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agoautotools: add -avoid-version
Christian Brauner [Tue, 30 Aug 2016 20:54:30 +0000 (22:54 +0200)]
autotools: add -avoid-version

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agoMerge pull request #139 from brauner/2016-08-30/fix_debug_macros
Serge Hallyn [Tue, 30 Aug 2016 19:21:25 +0000 (14:21 -0500)]
Merge pull request #139 from brauner/2016-08-30/fix_debug_macros

bindings: fix debug macro

7 years agobindings: fix debug macro
Christian Brauner [Tue, 30 Aug 2016 08:26:44 +0000 (10:26 +0200)]
bindings: fix debug macro

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agoMerge pull request #138 from brauner/2016-08-29/libtool_module
Serge Hallyn [Mon, 29 Aug 2016 18:45:24 +0000 (13:45 -0500)]
Merge pull request #138 from brauner/2016-08-29/libtool_module

2016 08 29/libtool module

7 years agobindings, lxcfs: improve debugging
Christian Brauner [Mon, 29 Aug 2016 08:33:49 +0000 (10:33 +0200)]
bindings, lxcfs: improve debugging

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agolibtool: do not link lxcfs against liblxcfs
Christian Brauner [Mon, 29 Aug 2016 08:12:27 +0000 (10:12 +0200)]
libtool: do not link lxcfs against liblxcfs

Make liblxcfs a libtool module. Also, stop linking lxcfs against liblxcfs. We do
not really need this since we call dlopen() anyway. Furthermore, this allows us
to make sure that functions marked with __attribute__(constructor) are not run
before we call dlopen() in main() in lxcfs. This has the advantage that we can
show help output without __attribute__(constructor) functions being run.

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agoMerge pull request #136 from brauner/2016-08-21/bugfixes
Serge Hallyn [Fri, 26 Aug 2016 14:49:07 +0000 (10:49 -0400)]
Merge pull request #136 from brauner/2016-08-21/bugfixes

bindings: revert cgroup check and improve fs behavior

7 years agobindings: make rmdir behave more consistently
Christian Brauner [Fri, 26 Aug 2016 14:26:27 +0000 (16:26 +0200)]
bindings: make rmdir behave more consistently

We should be able to safely return -EPERM for:

  if (!pick_controller_from_path())
                /* Someone's trying to delete "/cgroup". */

  if (!find_cgroup_in_path())
          /* Someone's trying to delete a controller e.g. "/blkio". */

  if (!get_cgdir_and_path()) {
  /* Someone's trying to delete a cgroup on the same level as the
   * "/lxc" cgroup e.g. rmdir "/cgroup/blkio/lxc" or
   * rmdir "/cgroup/blkio/init.slice".
   */
  }

All other interesting cases are caught further down.

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agobindings: improve returned errnos
Christian Brauner [Fri, 26 Aug 2016 08:32:32 +0000 (10:32 +0200)]
bindings: improve returned errnos

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agobindings: revert cgroup check
Christian Brauner [Thu, 25 Aug 2016 20:33:07 +0000 (22:33 +0200)]
bindings: revert cgroup check

We do not need to check whether mode & W_OK is passed in. Even if the cgroup
root mount is writeable operations like cg_mkdir() et al. will fail with e.g.
EPERM. Basically all operations will fail on the cgroup root mount point because
the first operation they perform is pick_controller_from_path(). That is to say
they try to e.g. pick "blkio" from /var/lib/lxcfs/cgroup/blkio/some/cgroups an
similiar for all other controllers. If pick_controller_from_path() fails they
all return an appropriate errno. For example, cg_mkdir() does:

        controller = pick_controller_from_path(fc, path);
        if (!controller)
                return errno == ENOENT ? -EPERM : -errno;

This means, we do not need to return an errno already in cg_access when
mode & W_OK is passed in. This has the advantage that users are still able to
descend into /var/lib/lxcfs/cgroup via:

        cd /var/lib/lxcfs/cgroup

but are still blocked from doing any write operations.

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agoMerge pull request #134 from evgeni/no-argv0-in-usage
Serge Hallyn [Fri, 26 Aug 2016 10:05:36 +0000 (06:05 -0400)]
Merge pull request #134 from evgeni/no-argv0-in-usage

don't use argv[0] in usage output

7 years agodon't use argv[0] in usage output
Evgeni Golov [Fri, 26 Aug 2016 07:33:09 +0000 (09:33 +0200)]
don't use argv[0] in usage output

otherwise this generates "funny" manpages like
  /home/remote/egolov/Devel/lxcfs/.libs/lt-lxcfs [-p pidfile] mountpoint
  /home/remote/egolov/Devel/lxcfs/.libs/lt-lxcfs -h
or
  /build/lxcfs-8lNGve/lxcfs-2.0/.1/.libs/lt-lxcfs [-p pidfile] mountpoint
  /build/lxcfs-8lNGve/lxcfs-2.0/.1/.libs/lt-lxcfs -h

Signed-off-by: Evgeni Golov <evgeni@debian.org>
7 years agoMerge pull request #127 from brauner/2016-08-21/bugfixes
Serge Hallyn [Fri, 26 Aug 2016 07:11:06 +0000 (03:11 -0400)]
Merge pull request #127 from brauner/2016-08-21/bugfixes

2016 08 21/bugfixes

7 years agoMerge pull request #133 from glensc/pld
Serge Hallyn [Fri, 26 Aug 2016 07:06:52 +0000 (03:06 -0400)]
Merge pull request #133 from glensc/pld

add pld linux support

7 years agoadd pld linux support
Elan Ruusamäe [Thu, 25 Aug 2016 21:18:46 +0000 (00:18 +0300)]
add pld linux support

Signed-off-by: Elan Ruusamäe <glen@delfi.ee>
7 years agobindings: more consistent fs behavior
Christian Brauner [Mon, 22 Aug 2016 10:20:10 +0000 (12:20 +0200)]
bindings: more consistent fs behavior

- e.g. let cg_mkdir() return EPERM

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agobindings: set errno in pick_controller_from_path()
Christian Brauner [Mon, 22 Aug 2016 10:00:25 +0000 (12:00 +0200)]
bindings: set errno in pick_controller_from_path()

This will allow us to provide better standard fs behavior.

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agobindings: non functional changes
Christian Brauner [Mon, 22 Aug 2016 09:56:46 +0000 (11:56 +0200)]
bindings: non functional changes

- whitespace fixes for pick_controller_from_path()

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agolxcfs: better fs behavior on /var/lib/lxcfs
Christian Brauner [Mon, 22 Aug 2016 09:36:02 +0000 (11:36 +0200)]
lxcfs: better fs behavior on /var/lib/lxcfs

return -EPERM for mkdir(), rmdir(), chown(), chmod() on top directory
/var/lib/lxcfs.

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agolxcfs, bindings: show "." and ".." dir entries
Christian Brauner [Sun, 21 Aug 2016 11:53:27 +0000 (13:53 +0200)]
lxcfs, bindings: show "." and ".." dir entries

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agobindings: allow access to /var/lib/lxcfs/proc
Christian Brauner [Sat, 20 Aug 2016 22:11:13 +0000 (00:11 +0200)]
bindings: allow access to /var/lib/lxcfs/proc

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agobindings: enable access to /var/lib/lxcfs/cgroup
Christian Brauner [Sat, 20 Aug 2016 22:02:32 +0000 (00:02 +0200)]
bindings: enable access to /var/lib/lxcfs/cgroup

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agobindings: grant access to /var/lib/lxcfs
Christian Brauner [Sat, 20 Aug 2016 22:22:38 +0000 (00:22 +0200)]
bindings: grant access to /var/lib/lxcfs

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agoMerge pull request #129 from brauner/2016-08-22/fix_cgfs_remove
Serge Hallyn [Thu, 25 Aug 2016 12:17:31 +0000 (08:17 -0400)]
Merge pull request #129 from brauner/2016-08-22/fix_cgfs_remove

bindings: use openat fd for fstatat(), unlinkat()

7 years agobindings: close open fds on error
Christian Brauner [Mon, 22 Aug 2016 15:48:12 +0000 (17:48 +0200)]
bindings: close open fds on error

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agobindings: use openat fd for fstatat(), unlinkat()
Christian Brauner [Mon, 22 Aug 2016 00:47:27 +0000 (02:47 +0200)]
bindings: use openat fd for fstatat(), unlinkat()

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agoMerge pull request #132 from brauner/2016-08-24/better_debugging
Serge Hallyn [Wed, 24 Aug 2016 18:40:58 +0000 (13:40 -0500)]
Merge pull request #132 from brauner/2016-08-24/better_debugging

bindings: improve debugging

7 years agobindings: improve debugging
Christian Brauner [Wed, 24 Aug 2016 13:43:49 +0000 (15:43 +0200)]
bindings: improve debugging

- replace multiple DEBUG ifdefines with a single ifdefine at the top
- ifdefine lxcfs_debug() macro function that expands to nothing when -DDEBUG is
  not given

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agoMerge pull request #130 from hallyn/2016-08-21/fixrace
Serge Hallyn [Mon, 22 Aug 2016 14:04:54 +0000 (09:04 -0500)]
Merge pull request #130 from hallyn/2016-08-21/fixrace

2016 08 21/fixrace

7 years agomeminfo: don't show negative swapfree
Serge Hallyn [Sun, 21 Aug 2016 20:05:31 +0000 (15:05 -0500)]
meminfo: don't show negative swapfree

Also commonize some of the mem{,sw} free/used calculations.

Closes #115

7 years agopam: fix race in cgroup creation
Serge Hallyn [Sun, 21 Aug 2016 18:26:42 +0000 (13:26 -0500)]
pam: fix race in cgroup creation

If we find that a cgroup already exists, we should

1. remove all the cgroups which we've created so far
2. set existed to true
3. return failure

The caller should then detect that existed == true,
and re-try with the next index.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
7 years agoMerge pull request #126 from hallyn/2016-08-18/meminfo.more
Serge Hallyn [Thu, 18 Aug 2016 05:34:38 +0000 (00:34 -0500)]
Merge pull request #126 from hallyn/2016-08-18/meminfo.more

Virtualize more of the meminfo fields

7 years agoVirtualize more of the meminfo fields
Serge Hallyn [Thu, 18 Aug 2016 05:03:51 +0000 (00:03 -0500)]
Virtualize more of the meminfo fields

The worst remaining offending line appears to be VmallocTotal.
Suggestions for how to calculate that would be appreciated.

Closes #119

Signed-off-by: Serge Hallyn <serge@hallyn.com>
7 years agoFix test_reload for lxcfs chroot
Stéphane Graber [Tue, 16 Aug 2016 16:36:01 +0000 (12:36 -0400)]
Fix test_reload for lxcfs chroot

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
7 years agoMerge pull request #124 from brauner/2016-07-27/move_lxcfs_to_minimal_chroot
Serge Hallyn [Wed, 10 Aug 2016 14:47:38 +0000 (09:47 -0500)]
Merge pull request #124 from brauner/2016-07-27/move_lxcfs_to_minimal_chroot

move lxcfs to minimal chroot

7 years agobindings: avoid using additional process
Christian Brauner [Mon, 8 Aug 2016 17:00:13 +0000 (19:00 +0200)]
bindings: avoid using additional process

Instead of clone(..., CLONE_NEWNS | CLONE_FILES, ...) simply use
unshare(CLONE_NEWNS) and setns().

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agobindings: use strchr(), strrchr()
Christian Brauner [Sun, 7 Aug 2016 20:04:41 +0000 (22:04 +0200)]
bindings: use strchr(), strrchr()

index(), rindex() are deprecated.

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agolxcfs, bindings: set fd_hierarchies in constructor
Christian Brauner [Sat, 6 Aug 2016 13:28:44 +0000 (15:28 +0200)]
lxcfs, bindings: set fd_hierarchies in constructor

We need to initialize fd_hierarchies in the __constructor__ to guarantee a
consistent view across users of the shared library. Note well that hierarchies
and fd_hierarchies are considered read-only after the __constructor__ has run.

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agobindings: document new code
Christian Brauner [Sat, 6 Aug 2016 09:19:02 +0000 (11:19 +0200)]
bindings: document new code

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agolxcfs: document new code
Christian Brauner [Sat, 6 Aug 2016 09:09:17 +0000 (11:09 +0200)]
lxcfs: document new code

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agolxcfs, bindings: cleanup and fix exit logic
Christian Brauner [Sat, 6 Aug 2016 00:00:01 +0000 (02:00 +0200)]
lxcfs, bindings: cleanup and fix exit logic

- close open file descriptors referring to cgroup hierarchies mounted in private
  lxcfs mount namespace
- fix exit logic in main()

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agobindings: open_pids_file()
Christian Brauner [Fri, 5 Aug 2016 23:47:23 +0000 (01:47 +0200)]
bindings: open_pids_file()

Enable open_pids_file() to be used with *at() family of functions.

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agobindings: is_dir(), chown_tasks_files(), cgfs_chown_file()
Christian Brauner [Fri, 5 Aug 2016 23:40:41 +0000 (01:40 +0200)]
bindings: is_dir(), chown_tasks_files(), cgfs_chown_file()

Enable is_dir(), chown_tasks_files(), cgfs_chown_file() to be used with *at()
family of functions.

Signed-off-by: Christian Brauner <cbrauner@suse.de>
7 years agobindings: cgfs_chmod_file()
Christian Brauner [Fri, 5 Aug 2016 23:34:21 +0000 (01:34 +0200)]
bindings: cgfs_chmod_file()

Enable cgfs_chmod_file() to be used with *at() family of functions.

Signed-off-by: Christian Brauner <cbrauner@suse.de>