You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: deployment/linux-capability.md
+24-22Lines changed: 24 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,24 +1,26 @@
1
-
# Linux Capability
1
+
# Using Linux Capabilities
2
2
3
-
This article shows configuration and dependent gem installation instruction for enabling Linux capability module on Fluentd core.
3
+
This article shows configuration and dependent gem installation instructions for enabling [Linux capabilities](https://man7.org/linux/man-pages/man7/capabilities.7.html) on Fluentd core.
4
+
5
+
Linux capabilities grant privileges to processes and executables that are otherwise reserved for the root user (UID 0). You can use these in conjunction with Fluentd plugins to enable the underlying Ruby executable read access to input sources.
4
6
5
7
## Prerequisites
6
8
7
-
* gcc and make etc. for building C extension sources
8
-
* libcap-ng package and its development package
9
-
* libcap-ng-dev on Debian GNU/Linux and Ubuntu
10
-
* libcap-ng-devel on CentOS 7/8, Fedora 33, AmazonLinux 2
11
-
* pkg-config package for linking libcap-ng library
9
+
*`gcc` and `make` etc. for building C extension sources
10
+
*`libcap-ng package` and its development package
11
+
*`libcap-ng-dev` on Debian GNU/Linux and Ubuntu
12
+
*`libcap-ng-devel` on CentOS 7/8, Fedora 33, AmazonLinux 2
13
+
*`pkg-config package` for linking `libcap-ng` library
12
14
* Ruby and its development packages
13
-
* ruby-dev on Debian GNU/Linux and Ubuntu
14
-
* ruby-devel on CentOS 7/8, Fedora 33, AmazonLinux 2
15
+
*`ruby-dev` on Debian GNU/Linux and Ubuntu
16
+
*`ruby-devel` on CentOS 7/8, Fedora 33, AmazonLinux 2
15
17
* Fluentd v1.12 or later
16
18
17
19
## Install capability handling gem
18
20
19
-
Fluentd uses [`capng_c` gem](https://github.com/fluent-plugins-nursery/capng_c) to handle Linux capability.
21
+
Fluentd uses the [`capng_c` gem](https://github.com/fluent-plugins-nursery/capng_c) to handle Linux capabilities.
20
22
21
-
So, Add this line to your Fluentd' or td-agent's Gemfile:
23
+
Add this line to your Fluentd' or td-agent's Gemfile:
22
24
23
25
```ruby
24
26
gem 'capng_c'
@@ -36,22 +38,22 @@ Or install it yourself as for Fluentd:
36
38
$ fluent-gem install capng_c
37
39
```
38
40
39
-
Or install it yourself as for td-agent:
41
+
Or install it yourself as for `td-agent`:
40
42
41
43
```text
42
44
$ td-agent-gem install capng_c
43
45
```
44
46
45
-
**Note:**capng\_c uses `pkg-config` to link libcap-ng library. If you couldn't handle Linux capability with capng\_c installation, please confirm `pgk-config` package is installed on your box.
47
+
**Note:**`capng_c` uses `pkg-config` to link the `libcap-ng` library. If you couldn't handle Linux capability with `capng_c` installation, please confirm `pgk-config` package is installed on your box.
46
48
47
-
## Capability handling on in\_tail
49
+
## Capability handling on `in_tail`
48
50
49
-
Currently, `in_tail` which is the one of the Fluentd core plugin handles the following Linux capabilities:
51
+
The Fluentd core plugin`in_tail` handles the following Linux capabilities:
50
52
51
-
*`CAP_DAC_READ_SEARCH`\(`:dac_read_search` on `in_tail` code.\)
52
-
*`CAP_DAC_OVERRIDE`\(`:dac_override` on `in_tail` code.\)
53
+
*`CAP_DAC_READ_SEARCH`\(`:dac_read_search` on `in_tail` code\)
54
+
*`CAP_DAC_OVERRIDE`\(`:dac_override` on `in_tail` code\)
53
55
54
-
Set up `cap_dac_read_search` or `cap_dac_override` to using Ruby executable:
56
+
Set up `cap_dac_read_search` or `cap_dac_override` to use the Ruby executable:
### Actual Example for Linux capability handling in in\_tail
86
88
87
-
When adding `cap_dac_override`\(partial privileges for rw file\) and `cap_dac_read_search`\(partial privileges for read only\), Fluentd/td-agent can handle to read 640 permission files such as `/var/log/syslog`:
89
+
When adding `cap_dac_override`\(partial privileges for `rw` file\) and `cap_dac_read_search`\(partial privileges for read only\), Fluentd/td-agent can handle to read 640 permission files such as `/var/log/syslog`:
88
90
89
91
```text
90
92
$ ls -lh /var/log/syslog
91
93
-rw-r----- 1 syslog adm 29K Nov 5 14:35 /var/log/syslog
92
94
```
93
95
94
-
This file cannot read form ordinal users:
96
+
This file cannot be read by ordinary users:
95
97
96
98
```text
97
99
$ cat /var/log/syslog
@@ -139,7 +141,7 @@ $ sudo mkdir /var/run/fluentd
139
141
$ sudo chown `whoami` /var/run/fluentd
140
142
```
141
143
142
-
Then, run as ordinal user with `cap_dac_read_search` capability attached Ruby:
144
+
Then, run as an ordinary user with `cap_dac_read_search` capability attached Ruby:
Fluentd which is running on ordinal user does not complain as`Permission denied`. Users can retrieve root files' contents on non-root process, yay!
180
+
Fluentd, which is running by a non-root user, does not complain with`Permission denied`. Users can retrieve root files' contents on a non-root process, yay!
179
181
180
182
If this article is incorrect or outdated, or omits critical information, please [let us know](https://github.com/fluent/fluentd-docs-gitbook/issues?state=open). [Fluentd](http://www.fluentd.org/) is an open-source project under [Cloud Native Computing Foundation \(CNCF\)](https://cncf.io/). All components are available under the Apache 2 License.
0 commit comments