Machines being duped in Amon Server due to Agent inability to access "/etc/opt/amonagent/machine-id"
eliezerlp opened this issue · comments
When running as a user without appropriate permissions to write / access that path the following happens:
$ runuser -l eliezerlp -c 'amonagent -debug'
open /etc/opt/amonagent/machine-id: permission deniedinvalid argumentINFO[0000] Starting Amon Agent (Version: 0.7-1-g6f1eeeb)
INFO[0000] Agent Config: Interval:1m0s
open /etc/opt/amonagent/machine-id: permission deniedinvalid argumentINFO[0003] Metrics collected (Interval:1m0s)
{
"system": {
"cpu": {
[...]
"host": {
"host": "XXXXXXXX",
"machineid": "feb35e201XXXXXXXXXXXb6669919",
"server_key": "",
"distro": {
"version": "20",
"name": "fedora"
},
"ip_address": "XXXXXXXX",
"instance_id": ""
},
"plugins": {},
"checks": null
}INFO[0003] Sending data to http://amon.XXXXX/api/system/v2/?api_key=XXXXXXXXXXXXXXXXXXXXXXXX
open /etc/opt/amonagent/machine-id: permission deniedinvalid argumentINFO[0063] Metrics collected (Interval:1m0s)
{
"system": {
"cpu": {
"user": 0,
[...]
],
"host": {
"host": "XXXXXXX",
"machineid": "1b3da610XXXXXXX96646ebbd",
"server_key": "",
"distro": {
"version": "20",
"name": "fedora"
},
"ip_address": "XXXXXX",
"instance_id": ""
},
"plugins": {},
"checks": null
}INFO[0063] Sending data to http://amon.XXXXXX/api/system/v2/?api_key=XXXXXXXXXXXXXX
open /etc/opt/amonagent/machine-id: permission deniedinvalid argumentINFO[0123] Metrics collected (Interval:1m0s)
From an strace
:
openat(AT_FDCWD, "/proc/sys/kernel/hostname", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "direct131ca\n", 512) = 12
close(3) = 0
stat64("/etc/opt/amonagent/machine-id", 0x18845b24) = -1 ENOENT (No such file or directory)
getrandom("\342\353P\372\361\364{\370*\345DQ\312\327w\344", 16, 0) = 16
openat(AT_FDCWD, "/etc/opt/amonagent/machine-id", O_RDWR|O_CREAT|O_TRUNC|O_LARGEFILE|O_CLOEXEC, 0666) = -1 EACCES (Permission denied)
write(1, "open /etc/opt/amonagent/machine-"..., 53open /etc/opt/amonagent/machine-id: permission denied) = 53
write(1, "invalid argument", 16invalid argument) = 16
openat(AT_FDCWD, "/etc/opt/amonagent/amonagent.conf", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "{\n \"api_key\":\"cxfsAQT4LXQPljW"..., 512) = 112
stat64("/etc/opt/amonagent/plugins-enabled", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0