All of lore.kernel.org
 help / color / mirror / Atom feed
* core_pattern piping strangeness
@ 2008-04-15 21:09 Michael Kerrisk
       [not found] ` <cfd18e0f0804151411x62080f10y833493db7f1b8cfd@mail.gmail.com>
  0 siblings, 1 reply; 25+ messages in thread
From: Michael Kerrisk @ 2008-04-15 21:09 UTC (permalink / raw)
  To: ak; +Cc: Linux Kernel Mailing List, Petr Gajdos, michael.kerrisk

Hi Andi,

In 2.6.19 you added the pipiing syntax
(http://lwn.net/Articles/195310/) to core_pattern.  Petr pointed out
that this is not yet documented in core(5), so I set to testing it.

The change log has the text:

    The core dump proces will run with the privileges and in the name space
    of the process that caused the core dump.

This appears not to be true (as tested on 2.6.25-rc8).  Instead the
pipe program is run as root.  I'm not sure what "in the name space of
the process that caused the core dump" means -- I wondered if it might
mean that the current working directory of the program would be the
same as that of the process that caused the core dump.  However that
is not so: the current directory for the pipe program is the root
directory.

Can you comment?  Am I misunderstanding something?

Test program and shell session shown below.

Cheers,

Michael


$ cat core_pattern_test.c
/* core_pattern_test.c */

#define _GNU_SOURCE
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define BUF_SIZE 1024

int
main(int argc, char *argv[])
{
    int fd, tot;
    ssize_t numRead;
    char buf[BUF_SIZE];
    FILE *fp;

    fd = open(argv[1], O_CREAT | O_WRONLY | O_TRUNC, 0666);

    fp = fdopen(fd, "a");
    fprintf(fp, "PID=%ld\n", (long) getpid());
    fprintf(fp, "cwd=%s\n", get_current_dir_name());
    fprintf(fp, "UID=%ld; EUID=%ld\n", (long) getuid(), (long) geteuid());

    /* Count bytes in standard input */

    tot = 0;
    while ((numRead = read(STDIN_FILENO, buf, BUF_SIZE)) > 0)
        tot += numRead;
    fprintf(fp, "Total bytes in core dump: %d\n", tot);

    exit(EXIT_SUCCESS);
}

$ cc core_pattern_test.c
$ su
Password:
# echo "|$PWD/a.out $PWD/core.log" > /proc/sys/kernel/core_pattern
# exit
$ sleep 100 &
[1] 5637
$ kill -QUIT %1
[1]+  Quit                    (core dumped) sleep 100
$ cat core.log
PID=5638
cwd=/
UID=0; EUID=0
Total bytes in core dump: 282624

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2008-05-05 11:29 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-15 21:09 core_pattern piping strangeness Michael Kerrisk
     [not found] ` <cfd18e0f0804151411x62080f10y833493db7f1b8cfd@mail.gmail.com>
     [not found]   ` <48051FBA.60503@firstfloor.org>
2008-04-18 16:53     ` core_pattern pipe documentation Michael Kerrisk
     [not found]       ` <4808D1F4.7050705-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-04-23 12:09         ` Michael Kerrisk
2008-04-23 12:09           ` Michael Kerrisk
     [not found]           ` <cfd18e0f0804230509g4e7456ecgd40c0bfee874a82c-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-23 14:59             ` Neil Horman
2008-04-23 14:59               ` Neil Horman
     [not found]               ` <20080423145933.GA26228-D2DSsfbTpT2dRepn21IEfvXAX3CI6PSWQQ4Iyu8u01E@public.gmane.org>
2008-04-25 13:18                 ` Michael Kerrisk
2008-04-25 13:18                   ` Michael Kerrisk
     [not found]                   ` <cfd18e0f0804250618ic6dfd09gf68573256be3ff-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-25 16:22                     ` Neil Horman
2008-04-25 16:22                       ` Neil Horman
     [not found]                       ` <20080425162225.GA9833-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2008-04-25 18:13                         ` Michael Kerrisk
2008-04-25 18:13                           ` Michael Kerrisk
     [not found]                           ` <cfd18e0f0804251113w4ef2dea3t6727009aa67e6e09-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-25 18:54                             ` Neil Horman
2008-04-25 18:54                               ` Neil Horman
     [not found]                               ` <20080425185442.GC9833-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2008-04-25 19:50                                 ` Michael Kerrisk
2008-04-25 19:50                                   ` Michael Kerrisk
2008-04-25 20:05                                 ` Michael Kerrisk
2008-04-25 20:05                                   ` Michael Kerrisk
     [not found]                                   ` <cfd18e0f0804251305u4edb2bb1k290553965291c4fa-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-25 20:18                                     ` Neil Horman
2008-04-25 20:18                                       ` Neil Horman
     [not found]                                       ` <20080425201800.GD9833-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2008-04-25 20:39                                         ` Michael Kerrisk
2008-04-25 20:39                                           ` Michael Kerrisk
2008-05-05  7:19                                           ` core_pattern pipe documentation - draft 2 Michael Kerrisk
     [not found]                                             ` <481EB4F4.8050901-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-05-05 11:29                                               ` Neil Horman
2008-05-05 11:29                                                 ` Neil Horman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.