* segfault message supressed with su -c
@ 2012-09-11 15:01 Ondrej Oprala
2012-09-11 16:19 ` Voelker, Bernhard
2012-09-11 17:19 ` Pádraig Brady
0 siblings, 2 replies; 6+ messages in thread
From: Ondrej Oprala @ 2012-09-11 15:01 UTC (permalink / raw)
To: util-linux
[-- Attachment #1: Type: text/plain, Size: 400 bytes --]
Hi,
I've written a tiny patch that should fix this issue with su:
https://bugzilla.redhat.com/show_bug.cgi?id=747592.
None of the shells' output propagates back
to the shell where su was called (except TCSH, which reports segfault
to stdout; I've tested this with sh,ksh,zsh,bash).
So, with this patch, su should print a warning if
WIFSIGNALED(status) && WCOREDUMP(status) is true.
Cheers,
Ondrej
[-- Attachment #2: DIFF --]
[-- Type: text/plain, Size: 994 bytes --]
>From d4776f487e283649d65be3f3865141a0171a80e7 Mon Sep 17 00:00:00 2001
From: Ondrej Oprala <ooprala@redhat.com>
Date: Tue, 11 Sep 2012 16:39:17 +0200
Subject: [PATCH] su: add segmentation fault reporting of the child process
Child processes that ended with segmentation fault previously
indicated this with return status only. The report is now more
verbose if core dump is allowed.
---
login-utils/su-common.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/login-utils/su-common.c b/login-utils/su-common.c
index 23ad57d..b0dbed2 100644
--- a/login-utils/su-common.c
+++ b/login-utils/su-common.c
@@ -300,7 +300,11 @@ create_watching_parent (void)
}
if (pid != (pid_t)-1)
if (WIFSIGNALED (status))
- status = WTERMSIG (status) + 128;
+ {
+ status = WTERMSIG (status) + 128;
+ if (WCOREDUMP (status))
+ fprintf (stderr, _("Segmentation fault (core dumped)\n"));
+ }
else
status = WEXITSTATUS (status);
else
--
1.7.11.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: segfault message supressed with su -c
2012-09-11 15:01 segfault message supressed with su -c Ondrej Oprala
@ 2012-09-11 16:19 ` Voelker, Bernhard
2012-09-11 18:02 ` Pádraig Brady
2012-09-11 17:19 ` Pádraig Brady
1 sibling, 1 reply; 6+ messages in thread
From: Voelker, Bernhard @ 2012-09-11 16:19 UTC (permalink / raw)
To: Ondrej Oprala, util-linux@vger.kernel.org
Ondrej Oprala wrote:
> Hi,
> I've written a tiny patch that should fix this issue with su:
> https://bugzilla.redhat.com/show_bug.cgi?id=747592.
> None of the shells' output propagates back
> to the shell where su was called (except TCSH, which reports segfault
> to stdout; I've tested this with sh,ksh,zsh,bash).
> So, with this patch, su should print a warning if
> WIFSIGNALED(status) && WCOREDUMP(status) is true.
Good catch!
> + fprintf (stderr, _("Segmentation fault (core dumped)\n"));
Maybe the error message should point out that it
was not su which dumped core ... ;-)
Have a nice day,
Berny
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: segfault message supressed with su -c
2012-09-11 15:01 segfault message supressed with su -c Ondrej Oprala
2012-09-11 16:19 ` Voelker, Bernhard
@ 2012-09-11 17:19 ` Pádraig Brady
2012-09-12 10:22 ` Ondrej Oprala
1 sibling, 1 reply; 6+ messages in thread
From: Pádraig Brady @ 2012-09-11 17:19 UTC (permalink / raw)
To: Ondrej Oprala; +Cc: util-linux
On 09/11/2012 04:01 PM, Ondrej Oprala wrote:
> Hi,
> I've written a tiny patch that should fix this issue with su:
> https://bugzilla.redhat.com/show_bug.cgi?id=747592.
> None of the shells' output propagates back
> to the shell where su was called (except TCSH, which reports segfault
> to stdout; I've tested this with sh,ksh,zsh,bash).
> So, with this patch, su should print a warning if
> WIFSIGNALED(status) && WCOREDUMP(status) is true.
>
> Cheers,
> Ondrej
>
> DIFF
>
>
>> From d4776f487e283649d65be3f3865141a0171a80e7 Mon Sep 17 00:00:00 2001
> From: Ondrej Oprala<ooprala@redhat.com>
> Date: Tue, 11 Sep 2012 16:39:17 +0200
> Subject: [PATCH] su: add segmentation fault reporting of the child process
>
> Child processes that ended with segmentation fault previously
> indicated this with return status only. The report is now more
> verbose if core dump is allowed.
> ---
> login-utils/su-common.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/login-utils/su-common.c b/login-utils/su-common.c
> index 23ad57d..b0dbed2 100644
> --- a/login-utils/su-common.c
> +++ b/login-utils/su-common.c
> @@ -300,7 +300,11 @@ create_watching_parent (void)
> }
> if (pid != (pid_t)-1)
> if (WIFSIGNALED (status))
> - status = WTERMSIG (status) + 128;
> + {
> + status = WTERMSIG (status) + 128;
> + if (WCOREDUMP (status))
> + fprintf (stderr, _("Segmentation fault (core dumped)\n"));
> + }
> else
> status = WEXITSTATUS (status);
> else
> -- 1.7.11.4
You'll need to key on WTERMSIG (status).
"Segmentation fault" will not always be appropriate.
You'll get a core just with Ctrl-\ (SIGQUIT) too for example.
Something along the lines of:
"%s (core dumped)", strsignal (WTERMSIG (status))
cheers,
Pádraig.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: segfault message supressed with su -c
2012-09-11 16:19 ` Voelker, Bernhard
@ 2012-09-11 18:02 ` Pádraig Brady
0 siblings, 0 replies; 6+ messages in thread
From: Pádraig Brady @ 2012-09-11 18:02 UTC (permalink / raw)
To: Voelker, Bernhard; +Cc: Ondrej Oprala, util-linux@vger.kernel.org
On 09/11/2012 05:19 PM, Voelker, Bernhard wrote:
> Ondrej Oprala wrote:
>> Hi,
>> I've written a tiny patch that should fix this issue with su:
>> https://bugzilla.redhat.com/show_bug.cgi?id=747592.
>> None of the shells' output propagates back
>> to the shell where su was called (except TCSH, which reports segfault
>> to stdout; I've tested this with sh,ksh,zsh,bash).
>> So, with this patch, su should print a warning if
>> WIFSIGNALED(status)&& WCOREDUMP(status) is true.
>
> Good catch!
>
>> + fprintf (stderr, _("Segmentation fault (core dumped)\n"));
>
> Maybe the error message should point out that it
> was not su which dumped core ... ;-)
Maybe not. Consider:
monitor_1 timeout 2 'su -c command'
You might as well just say "core dumped",
and leave the investigation as to what
cored exactly to inspection of the core file.
cheers,
Pádraig.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: segfault message supressed with su -c
2012-09-11 17:19 ` Pádraig Brady
@ 2012-09-12 10:22 ` Ondrej Oprala
2012-09-21 10:39 ` Karel Zak
0 siblings, 1 reply; 6+ messages in thread
From: Ondrej Oprala @ 2012-09-12 10:22 UTC (permalink / raw)
To: Pádraig Brady; +Cc: util-linux
[-- Attachment #1: Type: text/plain, Size: 347 bytes --]
> You'll need to key on WTERMSIG (status).
> "Segmentation fault" will not always be appropriate.
> You'll get a core just with Ctrl-\ (SIGQUIT) too for example.
> Something along the lines of:
>
> "%s (core dumped)", strsignal (WTERMSIG (status))
>
> cheers,
> Pádraig.
I've redone the patch to reflect your proposition :) .
Cheers,
Ondrej.
[-- Attachment #2: DIFF --]
[-- Type: text/plain, Size: 1147 bytes --]
From 65e73591fce2fa961bf6de1cbc934f6aa7a22745 Mon Sep 17 00:00:00 2001
From: Ondrej Oprala <ooprala@redhat.com>
Date: Tue, 11 Sep 2012 16:39:17 +0200
Subject: [PATCH] su: add segmentation fault reporting of the child process
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Child processes that ended with segmentation fault previously
indicated this with return status only. The report is now more
verbose if core dump is allowed.
Improved-by: Pádraig Brady.
---
login-utils/su-common.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/login-utils/su-common.c b/login-utils/su-common.c
index 23ad57d..2749303 100644
--- a/login-utils/su-common.c
+++ b/login-utils/su-common.c
@@ -300,7 +300,12 @@ create_watching_parent (void)
}
if (pid != (pid_t)-1)
if (WIFSIGNALED (status))
- status = WTERMSIG (status) + 128;
+ {
+ status = WTERMSIG (status) + 128;
+ if (WCOREDUMP (status))
+ fprintf (stderr, _("%s (core dumped)\n"),
+ strsignal (WTERMSIG (status)));
+ }
else
status = WEXITSTATUS (status);
else
--
1.7.11.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: segfault message supressed with su -c
2012-09-12 10:22 ` Ondrej Oprala
@ 2012-09-21 10:39 ` Karel Zak
0 siblings, 0 replies; 6+ messages in thread
From: Karel Zak @ 2012-09-21 10:39 UTC (permalink / raw)
To: Ondrej Oprala; +Cc: Pádraig Brady, util-linux
On Wed, Sep 12, 2012 at 12:22:50PM +0200, Ondrej Oprala wrote:
> login-utils/su-common.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Applied, thanks.
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-09-21 10:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-11 15:01 segfault message supressed with su -c Ondrej Oprala
2012-09-11 16:19 ` Voelker, Bernhard
2012-09-11 18:02 ` Pádraig Brady
2012-09-11 17:19 ` Pádraig Brady
2012-09-12 10:22 ` Ondrej Oprala
2012-09-21 10:39 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).