Closed opty77 closed 5 months ago
Quick sample:
// [...]
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
void main(int argc, char **argv)
{
char *environ_file = "/proc/1/environ";
FILE *environ = fopen(environ_file, "r");
char *arg = 0;
size_t size = 0;
char *tok = 0;
if (!environ) {
printf("Cannot open %s: %s\n", environ_file, strerror(errno));
return;
}
while (getdelim(&arg, &size, 0, environ) != -1) {
tok = strtok(arg, "=");
if (tok && !strcmp(tok, "container")) {
puts(strtok(NULL, "="));
break;
}
}
free(arg);
fclose(environ);
}
Regarding https://github.com/troglobit/sysklogd/issues/76#issuecomment-2156719868, improving doesn't seem worth the effort but YMMV again.
https://github.com/troglobit/sysklogd/blob/1803a86edc1605d5cca3e4e2e39a4659607b1aef/src/syslogd.c#L250
needn't always work (e.g.
syslogd
restart in terminal or running under unprivileged user).Slackware way seems more reliable.