• [^] # Re: Et ?

    Posté par . En réponse au journal Juste un bug idiot.. Évalué à 10.

    D'après "man 5 core":

    Piping core dumps to a program
     Since kernel 2.6.19, Linux supports an alternate syntax for the
     /proc/sys/kernel/core_pattern file. If the first character of this
     file is a pipe symbol (|), then the remainder of the line is inter‐
     preted as a program to be executed. Instead of being written to a disk
     file, the core dump is given as standard input to the program. Note
     the following points:
     * The program must be specified using an absolute pathname (or a path‐
     name relative to the root directory, /), and must immediately follow
     the '|' character.
     * The process created to run the program runs as user and group root.
     * Command-line arguments can be supplied to the program (since kernel
     2.6.24), delimited by white space (up to a total line length of 128
     bytes).
     * The command-line arguments can include any of the % specifiers
     listed above. For example, to pass the PID of the process that is
     being dumped, specify %p in an argument.
    
    

    Il n'est pas dit qu'il est possible d'utiliser des pipes comme si c'était un shell. Le pipe en début de ligne est juste là pour montrer que c'est un programme à exécuter.

    Du coup mon interprétation serait la suivante, le programme tee va se lancer avec les argv suivants:

    argv[0]="/usr/bin/tee"
    argv[1]="/tmp/core.%e.%p" (enfin avec le contenu correct de %e et %p)
    argv[2]="|"
    argv[3]="/usr/libexec/abrt-hook-ccpp"
    argv[4]="%s"
    argv[5]="%c"
    argv[6]="%p"
    argv[7]="%u"
    argv[8]="%g"
    argv[9]="%t"
    argv[10]="e"
    
    

    Du coup, on aurait bien le core dans /tmp/code.%e.%p, par contre, tee écrirait aussi le contenu dans un fichier "|", "e", "%c", etc.

    Et surtout dans /usr/libexec/abrt-hook-ccpp, qui serait donc également écrasé par le core dump… Et qui ne marcherait donc plus !

    Il me semble que le core file est enregistré dans le "current working directory" (cwd) du process qui crashe, donc si cwd="/", on se retrouve avec tous le fichiers mentionnés ci-dessus directement dans /, et c'est un beau bordel.

    J'ai bon?