diff --git a/container-exception-logger.spec b/container-exception-logger.spec index 3a6f1c8..7828667 100644 --- a/container-exception-logger.spec +++ b/container-exception-logger.spec @@ -35,7 +35,7 @@ mkdir -p %{buildroot}/%{_mandir}/man1 cp man/container-exception-logger.1 %{buildroot}/%{_mandir}/man1/container-exception-logger.1 %files -%{_bindir}/container-exception-logger +%attr(6755, root, root) %{_bindir}/container-exception-logger %{_mandir}/man1/container-exception-logger.1.* %license COPYING diff --git a/src/container-exception-logger.c b/src/container-exception-logger.c index 5f51297..104ef74 100644 --- a/src/container-exception-logger.c +++ b/src/container-exception-logger.c @@ -24,7 +24,7 @@ int main(int argc, char *argv[]) { const char *program_usage_string = - "Usage: container-exception-logger [--no-tag | --tag STRING | --help]" + "Usage: abrt-container-logger [--no-tag | --tag STRING | --help]" "\n" "\nThe tool reads from standard input and writes to '"INIT_PROC_STDERR_FD_PATH"'"; @@ -60,8 +60,25 @@ int main(int argc, char *argv[]) FILE *f = fopen(INIT_PROC_STDERR_FD_PATH, "w"); if (f == NULL) { - perror("Failed to open '"INIT_PROC_STDERR_FD_PATH"'"); - return 2; + perror("Failed to open '"INIT_PROC_STDERR_FD_PATH"' as root"); + + /* Try to open the 'INIT_PROC_STDERR_FD_PATH' as normal user because of + https://github.com/minishift/minishift/issues/2058 + */ + if (seteuid(getuid()) == 0) + { + f = fopen(INIT_PROC_STDERR_FD_PATH, "w"); + if (f == NULL) + { + perror("Failed to open '"INIT_PROC_STDERR_FD_PATH"' as user"); + return 2; + } + } + else + { + perror("Failed to setuid"); + return 3; + } } setvbuf (f, NULL, _IONBF, 0); @@ -82,7 +99,7 @@ int main(int argc, char *argv[]) { perror("Failed to write to '"INIT_PROC_STDERR_FD_PATH"'"); fclose(f); - return 3; + return 4; } } fclose(f);