lkml.org 
[lkml]   [1996]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectOOPS Re: Patch to binfmt_script to support arbitrary interpreters

Ooops. My previous patch didn't iput the inode when executing a non-script.
I only found out when I shut the system down.

The attached patch is corrected.

My apologies.

Dr. Bradley Broom,
School of Data Communications, Email: broom@fit.qut.edu.au
Queensland University of Technology, Bus. : +61 7 3864 2769
GPO Box 2434, Brisbane, 4001, Australia. Fax : +61 7 3221 2384
--- linux/fs/exec.c.old Wed May 15 23:08:00 1996
+++ linux/fs/exec.c Wed May 15 23:08:06 1996
@@ -63,19 +63,24 @@

void binfmt_setup(void)
{
-#ifdef CONFIG_BINFMT_ELF
- init_elf_binfmt();
-#endif
+ /* This cannot be configured out of the kernel */
+ /* Formats are actually tried in the reverse order of
+ * registration, and script format must be the last one
+ * tried.
+ */
+ init_script_binfmt();

#ifdef CONFIG_BINFMT_AOUT
init_aout_binfmt();
#endif

+#ifdef CONFIG_BINFMT_ELF
+ init_elf_binfmt();
+#endif
+
#ifdef CONFIG_BINFMT_JAVA
init_java_binfmt();
#endif
- /* This cannot be configured out of the kernel */
- init_script_binfmt();
}

int register_binfmt(struct linux_binfmt * fmt)
--- linux/fs/binfmt_script.c.old Wed May 15 22:45:51 1996
+++ linux/fs/binfmt_script.c Thu May 16 00:36:42 1996
@@ -11,45 +11,63 @@
#include <linux/malloc.h>
#include <linux/binfmts.h>

+#define _PATH_USREXEC "/bin/usrexec"
+
static int do_load_script(struct linux_binprm *bprm,struct pt_regs *regs)
{
char *cp, *interp, *i_name, *i_arg;
int retval;
- if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!') || (bprm->sh_bang))
+
+ if (bprm->sh_bang)
return -ENOEXEC;
- /*
- * This section does the #! interpretation.
- * Sorta complicated, but hopefully it will work. -TYT
- */

bprm->sh_bang++;
iput(bprm->inode);
bprm->dont_iput=1;

- bprm->buf[127] = '\0';
- if ((cp = strchr(bprm->buf, '\n')) == NULL)
- cp = bprm->buf+127;
- *cp = '\0';
- while (cp > bprm->buf) {
- cp--;
- if ((*cp == ' ') || (*cp == '\t'))
- *cp = '\0';
+ /* Determine interp, i_name, and i_arg.
+ */
+ if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!')) {
+ strcpy (bprm->buf, _PATH_USREXEC);
+ interp = bprm->buf;
+ if ((i_name = strrchr (bprm->buf, '/')) != NULL)
+ i_name++;
else
- break;
+ i_name = bprm->buf;
+ i_arg = 0;
}
- for (cp = bprm->buf+2; (*cp == ' ') || (*cp == '\t'); cp++);
- if (!cp || *cp == '\0')
- return -ENOEXEC; /* No interpreter name found */
- interp = i_name = cp;
- i_arg = 0;
- for ( ; *cp && (*cp != ' ') && (*cp != '\t'); cp++) {
- if (*cp == '/')
- i_name = cp+1;
+ else {
+ /*
+ * This section does the #! interpretation.
+ * Sorta complicated, but hopefully it will work. -TYT
+ */
+
+ bprm->buf[127] = '\0';
+ if ((cp = strchr(bprm->buf, '\n')) == NULL)
+ cp = bprm->buf+127;
+ *cp = '\0';
+ while (cp > bprm->buf) {
+ cp--;
+ if ((*cp == ' ') || (*cp == '\t'))
+ *cp = '\0';
+ else
+ break;
+ }
+ for (cp = bprm->buf+2; (*cp == ' ') || (*cp == '\t'); cp++);
+ if (!cp || *cp == '\0')
+ return -ENOEXEC; /* No interpreter name found */
+ interp = i_name = cp;
+ i_arg = 0;
+ for ( ; *cp && (*cp != ' ') && (*cp != '\t'); cp++) {
+ if (*cp == '/')
+ i_name = cp+1;
+ }
+ while ((*cp == ' ') || (*cp == '\t'))
+ *cp++ = '\0';
+ if (*cp)
+ i_arg = cp;
}
- while ((*cp == ' ') || (*cp == '\t'))
- *cp++ = '\0';
- if (*cp)
- i_arg = cp;
+
/*
* OK, we've parsed out the interpreter name and
* (optional) argument.
\
 
 \ /
  Last update: 2005-03-22 13:37    [from the cache]
©2003-2011 Jasper Spaans