[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] (#!)^2 problem



Peter Makholm <sslug@sslug> writes:

> Mon pointen er at glibc/linuxkernen kun vil lave et lag af
> shebang-udfoldning?

Den korte konklusion:
Det Carsten forsøger er umuligt. Kernen vil kun udføre et lag af '#!'.

Den lange fortsættelse:
Det ser ret med vilje ud. Kernen fortolker '#!' i fs/binfmt_script.c:

static int load_script(struct linux_binprm *bprm,struct pt_regs *regs)
{
        char *cp, *i_name, *i_arg;
        struct file *file;
        char interp[BINPRM_BUF_SIZE];
        int retval;

        if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!') ||
        (bprm->sh_bang)) 
                return -ENOEXEC;
        /*
         * This section does the #! interpretation.
         * Sorta complicated, but hopefully it will work.  -TYT
         */

        bprm->sh_bang++;
        allow_write_access(bprm->file);
        fput(bprm->file);
        bprm->file = NULL;
[...]

bprm er en struktur der bliver kastet lidt frem og tilbage. bprm->sh_bang++
sørger for at load_script kun bliver kaldt en gang. Hvis man ser lidt
længere ned i funktionen kan man se at scripts bliver implementeret
ved at ændre lidt i bprm-strukturen og så starte forfra i søgningen
efter en funktion der kan udføre filen. Der er simpelthen ikke plads
til at gemme flere lag af indirektioner.

Interessant...

-- 
 Peter Makholm     |        One thing you do is prevent good software from
 sslug@sslug |      being written. Who can afford to do professional
 http://hacking.dk |                                     work for nothing?
                   |                                         -- Bill Gates


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *