Skip to content

Commit

Permalink
Using the 64-bit Linux capability mode when available.
Browse files Browse the repository at this point in the history
For backward compatibility, the Linux capabilities macros exposes v1 semantics
(32-bit) by default.  We probe the version at runtime (because of pre-compiled
binaries) but the kernel syscall API is conservative and it doesn't return a
64-bit capability version if the input version is v1.

This patch suppress the kernel > 5.0 dmesg log below:

  capability: warning: 'unitd' uses 32-bit capabilities (legacy support in use)
  • Loading branch information
i4ki committed Dec 16, 2019
1 parent 96a9a79 commit eced72b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/nxt_capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
#include <linux/capability.h>
#include <sys/syscall.h>


#if (_LINUX_CAPABILITY_VERSION_3)
#define NXT_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_3
#elif (_LINUX_CAPABILITY_VERSION_2)
#define NXT_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_2
#else
#define NXT_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION
#endif


#define nxt_capget(hdrp, datap) \
syscall(SYS_capget, hdrp, datap)
#define nxt_capset(hdrp, datap) \
Expand Down Expand Up @@ -43,7 +53,7 @@ nxt_capability_linux_get_version()
{
struct __user_cap_header_struct hdr;

hdr.version = _LINUX_CAPABILITY_VERSION;
hdr.version = NXT_CAPABILITY_VERSION;
hdr.pid = nxt_pid;

nxt_capget(&hdr, NULL);
Expand Down

0 comments on commit eced72b

Please sign in to comment.