Commit Graph

7643 Commits

Author SHA1 Message Date
Christian Brauner
db2d1af171
utils: improve lxc_switch_uid_gid()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-11 00:44:57 +02:00
Christian Brauner
b962868f4c
utils: improve get_ns_uid() and add get_ns_gid()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-11 00:44:56 +02:00
Christian Brauner
0b26d75e62
Merge pull request #2589 from 2xsec/bugfix
lxccontainer: fix dereferenced pointer
2018-09-07 13:54:09 +01:00
2xsec
5106ecd032
lxccontainer: fix dereferenced pointer
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
2018-09-06 16:55:10 +09:00
Wolfgang Bumiller
a21ed5555d
Merge pull request #2584 from brauner/2018-09-03/bugfixes
commands: switch to setting errno and returning -1
2018-09-04 14:45:55 +02:00
Christian Brauner
a9d4137983
log: log_append_logfile() add new error path
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-04 14:05:28 +02:00
Christian Brauner
bfcedc7ea0
nl: save errno on lxc_netns_set_nsid()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-04 14:05:28 +02:00
Christian Brauner
7fbb15ec9c
tree-wide: s/send()/lxc_send_nointr()/g
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-04 14:05:28 +02:00
Christian Brauner
28143f8862
file_utils: add lxc_send_nointr()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-04 13:59:13 +02:00
Christian Brauner
e3233f26ce
tree-wide: s/recv()/lxc_recv_nointr()/g
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-04 13:59:13 +02:00
Christian Brauner
a285b30814
log: save errno on strerror_r()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-04 13:57:35 +02:00
Christian Brauner
b7051eb7e6
log: do not clobber errno
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-04 13:57:19 +02:00
Christian Brauner
2a850b2ca6
commands: switch to setting errno and returning -1
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-09-04 10:35:30 +02:00
Christian Brauner
de69edd15e
file_utils: add lxc_recv_nointr()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-04 10:35:30 +02:00
Christian Brauner
a8007512f7
commands: better error message
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-04 10:35:25 +02:00
Christian Brauner
593010238b
Merge pull request #2585 from 2xsec/bugfix
caps: fix illegal access to array bound
2018-09-04 10:34:46 +02:00
2xsec
b8bcbe9b06
syntax error: mismatch brace
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
2018-09-04 14:58:59 +09:00
2xsec
aa599d1f48
nl: remove duplicated define
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
2018-09-04 14:24:22 +09:00
2xsec
91d9cab6de
utils: defensive programming
If caller passed the size of array not string length, it is possible to be accessed out of bounds.

Reorder conditions can prevent access invalid index of array.

Signed-off-by: 2xsec <dh48.jeong@samsung.com>
2018-09-04 11:10:18 +09:00
2xsec
22b67bfa96
caps: fix illegal access to array bound
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
2018-09-03 15:10:35 +09:00
Wolfgang Bumiller
d3aba1db25
Merge pull request #2581 from brauner/2018-09-02/macro
macro: move MS_* macros
2018-09-02 10:03:16 +02:00
Christian Brauner
6e5655e0db
macro: move MS_* macros
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-02 07:32:23 +02:00
Wolfgang Bumiller
04a49be674
Merge pull request #2580 from brauner/2018-09-01/revert_blub_revert
Revert "Revert "tree-wide: use sizeof on static arrays""
2018-09-01 20:53:32 +02:00
Christian Brauner
979a0d9354
Revert "Revert "tree-wide: use sizeof on static arrays""
This reverts commit 2fb7cf0b32.

The problem wasn't caused by the reverted commit and was fixed in

commit 0c9b1f826d ("macro: calculate buffer lengths correctly")

The full explanation can be taken from the following irc excerpt from
the #lxc-dev channel:

│19:54:47 brauner | there was a bug in one of the standard macros we used
│19:55:01 brauner | and the changes by INTTYPE_TO_STRLEN() caused the issue to surface
│19:55:03 brauner | which is good
│19:55:16 brauner | i sent a branch and stgraber merged it that fixes it
│19:57:56  Blub\0 | so...
│19:58:31  Blub\0 | still doesn't explain how it was the sizeof() patch
│20:07:14 brauner | Blub\0: so here's the long explanation
│20:07:35 brauner | Blub\0: stgraber bumped pid_max on our jenkins test builders
│20:07:53 brauner | Blub\0: because we're running *a lot* of containers
│20:07:56 brauner | in any case
│20:08:06 brauner | there was a buffer
│20:08:12 brauner | LXC_LSMATTRLEN
│20:08:59 brauner | it used to be
│20:09:03 brauner | -/* /proc/pid-to-str/attr/current = (5 + INTTYPE_TO_STRLEN(pid_t) + 7 + 1) */
│20:09:03 brauner | -#define LXC_LSMATTRLEN (5 + INTTYPE_TO_STRLEN(pid_t) + 7 + 1)
│20:09:14 brauner | which one can see is wrong
│20:09:21 brauner | before the INTTYPE patchset
│20:09:40 brauner | INTTYPE_TO_STRLEN(pid_t) was LXC_NUMSTRLEN64
│20:09:45 brauner | which gave you 21 chars
│20:09:57 brauner | so it accounted for the missing parts
│20:10:03 brauner | because the correct macro should've been
│20:10:17 brauner | +/* /proc/        = 6
│20:10:17 brauner | + *               +
│20:10:17 brauner | + * <pid-as-str>  = INTTYPE_TO_STRLEN(pid_t)
│20:10:17 brauner | + *               +
│20:10:17 brauner | + * /attr/        = 6
│20:10:17 brauner | + *               +
│20:10:17 brauner | + * /current      = 8
│20:10:17 brauner | + *               +
│20:10:17 brauner | + * \0            = 1
│20:10:17 brauner | + */
│20:10:17 brauner | +#define LXC_LSMATTRLEN (6 + INTTYPE_TO_STRLEN(pid_t) + 6 + 8 + 1)
│20:10:24  Blub\0 | still
│20:10:31 brauner | the issue was only seen
│20:10:39 brauner | when the pid number hit a specific maximum
│20:10:50  Blub\0 | the sizeof patch only changed instances of actual char buf[A_FIXED_NUMBER] + snprintf(buf, A_FIXED_NUMBER, ...)
│20:10:54 brauner | aka exceeded the newly shortened buffer
│20:11:42 brauner | your patch was a red herring
│20:12:03  Blub\0 | I guess
│20:12:06 brauner | it didn't cause it
│20:12:14 brauner | it just surfaced at the same time it was merged
│20:12:25  Blub\0 | so we can revert the revert then? :)
│20:12:35 brauner | yes, that was th eplan all along

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-01 20:25:07 +02:00
Stéphane Graber
b0f3050884
Merge pull request #2579 from brauner/2018-08-31/int64_t_pids
macro: calculate buffer lengths correctly
2018-08-31 16:52:23 -07:00
Christian Brauner
0c9b1f826d
macro: calculate buffer lengths correctly
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-01 01:08:30 +02:00
Christian Brauner
54dcfd8160
commands: assign before converting to pointer
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-09-01 00:29:30 +02:00
Stéphane Graber
f8db64b867
Merge pull request #2578 from brauner/2018-08-31/int64_t_pids
commands: pass around intmax_t
2018-08-31 14:30:21 -07:00
Christian Brauner
9234406bb1
commands: pass around intmax_t
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-31 21:44:49 +02:00
Stéphane Graber
2fb7cf0b32
Revert "tree-wide: use sizeof on static arrays"
This reverts commit 81a3bb64b4.

This commit broke all builders running with pid_max > 32768.

Reverting for now so we can bring the build farm back online.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2018-08-31 11:58:17 -07:00
Wolfgang Bumiller
6b28940591
Merge pull request #2435 from brauner/2018-06-27/storage_managed
[RFC] conf: introduce lxc.rootfs.managed
2018-08-30 08:28:08 +02:00
Christian Brauner
7cba1a2729
Merge pull request #2577 from Blub/inttype-lengths
tree-wide: use sizeof on static arrays
2018-08-29 22:26:46 +02:00
Wolfgang Bumiller
81a3bb64b4 tree-wide: use sizeof on static arrays
Instead of duplicating their lengths in read/snprintf/...
calls.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-08-29 21:46:39 +02:00
Wolfgang Bumiller
f288e10a59
Merge pull request #2572 from brauner/2018-08-24/musl_fixes
build: fix musl + add compiler.h
2018-08-29 21:39:05 +02:00
Stéphane Graber
de2c63143a
Merge pull request #2576 from brauner/2018-08-28/command_init_id
commands: always return -1 on lxc_cmd_get_init_pid() err
2018-08-28 11:29:02 -07:00
Christian Brauner
62fc84030b
string_utils: use UINT64_MAX macro
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:22:24 +02:00
Christian Brauner
1f207a5cd9
caps: move macros to macro header
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:22:24 +02:00
Christian Brauner
3ef9b3d30f
start: remove duplicate macros
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:22:24 +02:00
Christian Brauner
9978b4d342
Makefile: correctly add ifaddrs to noinst_HEADERS
Before this we only added ifaddrs.h to noinst_HEADERS when we were running on
Android's bionic. That obviously doesn't make sense since it is possible that
ifaddrs.h is not defined and we're also not running on Android's bionic.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:22:24 +02:00
Christian Brauner
ba2b6354b2
macro: coding style fixes
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:22:24 +02:00
Christian Brauner
0c5ea884e8
macro: final INTTYPE_TO_STRLEN() related cleanups
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:22:24 +02:00
Christian Brauner
84226232fb
tests: s/LXC_NUMSTRLEN64/INTTYPE_TO_STRLEN()/
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:22:24 +02:00
Christian Brauner
d33968ade3
conf: s/LXC_NUMSTRLEN64/INTTYPE_TO_STRLEN()/
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:22:24 +02:00
Christian Brauner
9d6ade4ace
tools: s/LXC_NUMSTRLEN64/INTTYPE_TO_STRLEN()/
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:22:24 +02:00
Christian Brauner
40464e8ac6
utils: s/LXC_NUMSTRLEN64/INTTYPE_TO_STRLEN()/
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:22:24 +02:00
Christian Brauner
f1eacafbc8
string_utils: s/LXC_NUMSTRLEN64/INTTYPE_TO_STRLEN()/
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:22:24 +02:00
Christian Brauner
8335fd40ef
network: s/LXC_NUMSTRLEN64/INTTYPE_TO_STRLEN()/
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:22:24 +02:00
Christian Brauner
397a8d30a8
monitor: s/LXC_NUMSTRLEN64/INTTYPE_TO_STRLEN()/
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:14:52 +02:00
Christian Brauner
da07fe61fc
lxccontainer: s/LXC_NUMSTRLEN64/INTTYPE_TO_STRLEN()/
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:14:52 +02:00
Christian Brauner
2955a58ab4
macro: s/LXC_NUMSTRLEN64/INTTYPE_TO_STRLEN()/
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-08-28 20:14:52 +02:00