[Automatic Bug Reporting Tool - ABRT] #951: libreport can't open /etc/system-release
by fedora-badges
#951: libreport can't open /etc/system-release
-----------------------+------------------------------
Reporter: jfilak | Owner: crash-catcher@…
Type: defect | Status: new
Priority: critical | Milestone:
Component: libreport | Version:
Keywords: | Blocked By:
Blocking: |
-----------------------+------------------------------
''/var/log/message''
{{{
Jan 17 17:18:52 f18-x8664 abrt[30090]: Can't open file '/etc/system-
release': Too many levels of symbolic links
Jan 17 17:18:52 f18-x8664 abrt[30090]: Can't open file '/etc/redhat-
release': Too many levels of symbolic links
Jan 17 17:19:17 f18-x8664 abrt[30090]: Saved core dump of pid 30053
(/usr/libexec/gnome-shell-calendar-server) to
/var/tmp/abrt/ccpp-2013-01-17-17:18:51-30053 (36159488 bytes)
}}}
''File system''
{{{
[root@f18-x8664 ~]# ls -al /etc/system-release
lrwxrwxrwx. 1 root root 14 Jan 2 13:02 /etc/system-release -> fedora-
release
}}}
''libreport/src/lib/dump_dir.c:709''
{{{
static char *load_text_file(const char *path, unsigned flags)
{
int fd = open(path, O_RDONLY | O_NOFOLLOW);
if (fd == -1)
{
if (!(flags & DD_FAIL_QUIETLY_ENOENT))
perror_msg("Can't open file '%s'", path);
return (flags & DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE ? NULL :
xstrdup(""));
}
...
}}}
''libreport/src/lib/dump_dir.c:554''
{{{
if (!release)
{
release = load_text_file("/etc/system-release",
DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
if (!release)
release = load_text_file("/etc/redhat-release", /*flags:*/ 0);
dd_save_text(dd, FILENAME_OS_RELEASE, release);
if (chroot_dir)
{
free(release);
char *chrooted_name = concat_path_file(chroot_dir, "/etc
/system-release");
release = load_text_file(chrooted_name, /*flags:*/ 0);
free(chrooted_name);
if (release[0])
dd_save_text(dd, FILENAME_OS_RELEASE_IN_ROOTDIR, release);
}
}
}}}
Cause by commit:
{{{
commit 3bbf961b1884dd32654dd39b360dd78ef294b10a
Author: Jiri Moskovcak <jmoskovc(a)redhat.com>
Date: Tue Jan 15 16:07:13 2013 +0100
never follow symlinks rhbz#887866
- use lchown instead chown and O_NOFOLLOW where we use open
}}}
--
Ticket URL: <https://fedorahosted.org/abrt/ticket/951>
Automatic Bug Reporting Tool - ABRT <http://fedorahoted.org/abrt/>
Automatic bug reporting tool
11 years, 3 months
[Automatic Bug Reporting Tool - ABRT] #949: abrt-cli can't run $EDITOR requested for data review
by fedora-badges
#949: abrt-cli can't run $EDITOR requested for data review
-----------------------+------------------------------
Reporter: jfilak | Owner: crash-catcher@…
Type: defect | Status: new
Priority: major | Milestone:
Component: libreport | Version:
Keywords: | Blocked By:
Blocking: |
-----------------------+------------------------------
Steps to reporduce:
{{{
abrt-cli report $DUMP_DIR
}}}
This doesn't help much:
{{{
diff --git a/src/cli/run-command.c b/src/cli/run-command.c
index ee74566..0dacdf4 100644
--- a/src/cli/run-command.c
+++ b/src/cli/run-command.c
@@ -34,6 +34,17 @@ static pid_t start_command(char **argv)
}
if (pid == 0)
{
+ close(0);
+ if (open("/dev/tty", O_RDWR) < 0)
+ _exit(127); /* 127 = DIE */
+ /* do we want that if we're in a script and have no controlling tty?
+ *
+ * YES, they can always call report-cli -y from script and it should
not
+ * try to open an editor
+ */
+ xdup2(0, 1);
+ xdup2(0, 2);
+
/* Child */
execvp(argv[0], argv);
/* Better to use _exit (not exit) after vfork:
}}}
- editor is started on background with the patch
--
Ticket URL: <https://fedorahosted.org/abrt/ticket/949>
Automatic Bug Reporting Tool - ABRT <http://fedorahoted.org/abrt/>
Automatic bug reporting tool
11 years, 3 months
[LIBREPORT PATCH] report-cli: move editor's proc group to foreground group
by Jakub Filak
- closes trac#949
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/cli/run-command.c | 83 +++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 71 insertions(+), 12 deletions(-)
diff --git a/src/cli/run-command.c b/src/cli/run-command.c
index ee74566..1755d19 100644
--- a/src/cli/run-command.c
+++ b/src/cli/run-command.c
@@ -23,40 +23,98 @@
http://git.kernel.org/?p=git/git.git;a=blob;f=run-command.c;hb=HEAD
*/
-static pid_t start_command(char **argv)
+struct command {
+ char **argv;
+ pid_t pid;
+ int tty_fd;
+ pid_t bck_tcgrp; //<< old foreground process group
+ struct termios bck_tmodes; //<< old configuration
+ sighandler_t bck_sigttou; //<< old SIGTTOU handler
+};
+
+static void start_command(struct command *cmd)
{
+ if ((cmd->tty_fd = open("/dev/tty", O_RDWR)) < 0)
+ /* do we want to die if we're in a script and have no controlling tty?
+ *
+ * YES, they can always call 'report-cli -y' from script and it should
+ * not try to open an editor
+ */
+ perror_msg_and_die("open(\"/dev/tty\", O_RDWR)");
+
+ /* save current foreground process group id */
+ if ((cmd->bck_tcgrp = tcgetpgrp(cmd->tty_fd)) < 0 )
+ perror_msg_and_die("tcgetpgrp()");
+
+ /* save current foreground process group attrs */
+ if (tcgetattr(cmd->tty_fd, &(cmd->bck_tmodes)) < 0)
+ perror_msg_and_die("tcsetattr()");
+
+ /* have to ignore the SIGTTOU because of tcsetpgrp() below
+ * otherwise the process will be stopped */
+ cmd->bck_sigttou = signal(SIGTTOU, SIG_IGN);
+
fflush(NULL);
- pid_t pid = vfork();
- if (pid < 0)
+ if ((cmd->pid = vfork()) < 0)
{
perror_msg_and_die("vfork");
}
- if (pid == 0)
+ if (cmd->pid == 0)
{
+ xdup2(cmd->tty_fd, 0);
+ xdup2(cmd->tty_fd, 1);
+ xdup2(cmd->tty_fd, 2);
+
+ pid_t pgrp = getpgrp();
+ if (pgrp < 0) {
+ perror_msg("getpgrp()");
+ _exit(127);
+ }
+
+ /* sends SIGTTOU to process group */
+ if (tcsetpgrp(cmd->tty_fd, pgrp) < 0) {
+ perror_msg("tcsetpgrp()");
+ _exit(127);
+ }
+
+ signal(SIGTTOU, SIG_DFL);
+
/* Child */
- execvp(argv[0], argv);
+ execvp(cmd->argv[0], cmd->argv);
/* Better to use _exit (not exit) after vfork:
* we don't want to mess up parent's memory state
* by running libc cleanup routines.
*/
_exit(127);
}
- return pid;
}
-static int finish_command(pid_t pid, char **argv)
+static int finish_command(struct command *cmd)
{
int status;
- pid_t waiting = safe_waitpid(pid, &status, 0);
+ pid_t waiting = safe_waitpid(cmd->pid, &status, 0);
if (waiting < 0)
perror_msg_and_die("waitpid");
+ /* reset foreground process group */
+ if (tcsetpgrp(cmd->tty_fd, cmd->bck_tcgrp) < 0)
+ perror_msg_and_die("tcsetpgrp()");
+
+ /* restore old foreground process group's attrs */
+ if (tcsetattr(cmd->tty_fd, TCSADRAIN, &(cmd->bck_tmodes)) < 0)
+ perror_msg_and_die("tcsetattr()");
+
+ close(cmd->tty_fd);
+
+ /* SIGTTOU were ignored because of changing foreground process group. */
+ signal(SIGTTOU, cmd->bck_sigttou);
+
int code;
if (WIFSIGNALED(status))
{
code = WTERMSIG(status);
- error_msg("'%s' killed by signal %d", argv[0], code);
+ error_msg("'%s' killed by signal %d", cmd->argv[0], code);
code += 128; /* shells use this convention for deaths by signal */
}
else /* if (WIFEXITED(status)) */
@@ -64,7 +122,7 @@ static int finish_command(pid_t pid, char **argv)
code = WEXITSTATUS(status);
if (code == 127)
{
- error_msg_and_die("Can't run '%s'", argv[0]);
+ error_msg_and_die("Can't run '%s'", cmd->argv[0]);
}
}
@@ -73,6 +131,7 @@ static int finish_command(pid_t pid, char **argv)
int run_command(char **argv)
{
- pid_t pid = start_command(argv);
- return finish_command(pid, argv);
+ struct command cmd = { argv, 0 };
+ start_command(&cmd);
+ return finish_command(&cmd);
}
--
1.7.11.7
11 years, 3 months
[ABRT PATCH] allow default dump directory to be configured from environment
by Jakub Filak
- related to trac#927
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
configure.ac | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 29f961a..33f35e6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -107,9 +107,13 @@ PLUGINS_CONF_DIR='${sysconfdir}/${PACKAGE_NAME}/plugins'
EVENTS_DIR='${sysconfdir}/libreport/events'
EVENTS_CONF_DIR='${sysconfdir}/libreport/events.d'
ENABLE_SOCKET_OR_DBUS='-DENABLE_DBUS=1'
-DEFAULT_DUMP_LOCATION='${localstatedir}/spool/abrt'
DEFAULT_DUMP_DIR_MODE=$($PKG_CONFIG --variable=dd_mode libreport)
+AC_ARG_VAR([DEFAULT_DUMP_LOCATION], [Default dump location ('LOCALSTATEDIR/spool/abrt')])
+if test -z "$DEFAULT_DUMP_LOCATION"; then
+ DEFAULT_DUMP_LOCATION='${localstatedir}/spool/abrt'
+fi
+
AC_SUBST(CONF_DIR)
AC_SUBST(VAR_RUN)
AC_SUBST(PLUGINS_CONF_DIR)
--
1.7.11.7
11 years, 3 months
[LIBREPORT PATCH] dd: open symlinks on request
by Jakub Filak
- /etc/system-release is symlink
- closes trac#951
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/include/dump_dir.h | 4 +++-
src/lib/dump_dir.c | 8 ++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/include/dump_dir.h b/src/include/dump_dir.h
index 4f6a73e..89c7ff7 100644
--- a/src/include/dump_dir.h
+++ b/src/include/dump_dir.h
@@ -32,7 +32,9 @@ extern "C" {
enum {
DD_FAIL_QUIETLY_ENOENT = (1 << 0),
DD_FAIL_QUIETLY_EACCES = (1 << 1),
- DD_OPEN_READONLY = (1 << 2),
+ /* Open symlinks. dd_* funcs don't open symlinks by default */
+ DD_OPEN_FOLLOW = (1 << 2),
+ DD_OPEN_READONLY = (1 << 3),
};
struct dump_dir {
diff --git a/src/lib/dump_dir.c b/src/lib/dump_dir.c
index 5118860..dfa19aa 100644
--- a/src/lib/dump_dir.c
+++ b/src/lib/dump_dir.c
@@ -608,15 +608,15 @@ void dd_create_basic_files(struct dump_dir *dd, uid_t uid, const char *chroot_di
if (!release)
{
release = load_text_file("/etc/system-release",
- DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
+ DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE | DD_OPEN_FOLLOW);
if (!release)
- release = load_text_file("/etc/redhat-release", /*flags:*/ 0);
+ release = load_text_file("/etc/redhat-release", DD_OPEN_FOLLOW);
dd_save_text(dd, FILENAME_OS_RELEASE, release);
if (chroot_dir)
{
free(release);
char *chrooted_name = concat_path_file(chroot_dir, "/etc/system-release");
- release = load_text_file(chrooted_name, /*flags:*/ 0);
+ release = load_text_file(chrooted_name, DD_OPEN_FOLLOW);
free(chrooted_name);
if (release[0])
dd_save_text(dd, FILENAME_OS_RELEASE_IN_ROOTDIR, release);
@@ -762,7 +762,7 @@ int dd_delete(struct dump_dir *dd)
static char *load_text_file(const char *path, unsigned flags)
{
- int fd = open(path, O_RDONLY | O_NOFOLLOW);
+ int fd = open(path, O_RDONLY | ((flags & DD_OPEN_FOLLOW) ? 0 : O_NOFOLLOW));
if (fd == -1)
{
if (!(flags & DD_FAIL_QUIETLY_ENOENT))
--
1.7.11.7
11 years, 3 months