diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-07-14 07:21:59 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:23:05 -0500 |
commit | 0e5907d57cdfb0c1ce3f151161a9260c14466bd0 (patch) | |
tree | aa522b01632adbe40b01b362f9ee9d13bb77e02a | |
parent | fa2b97a20a518708e4534e8aa2cce12024228488 (diff) | |
download | samba-0e5907d57cdfb0c1ce3f151161a9260c14466bd0.tar.gz samba-0e5907d57cdfb0c1ce3f151161a9260c14466bd0.tar.bz2 samba-0e5907d57cdfb0c1ce3f151161a9260c14466bd0.zip |
r8452: allow for the ugly hack:
#!/bin/sh
exec smbscript "$0" ${1+"$@"}
which is needed because bloody solaris puts 'env' in /bin instead of /usr/bin
also neaten up the #! handling code.
(This used to be commit 778bcd3738e42d8adfd4529f790c898f0d904363)
-rw-r--r-- | source4/scripting/ejs/smbscript.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index dec9592c46..d71d084779 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -83,15 +83,15 @@ void ejs_exception(const char *reason) /* load the script and advance past interpreter line*/ script = file_load(fname, &script_size, mem_ctx); - if ((script_size > 2) && script[0] == '#' && script[1] == '!') { - script += 2; - script_size -= 2; - while (script_size) { - if (*script == '\r' || *script == '\n') - break; - script++; - script_size--; - } + /* allow scriptable js */ + if (strncmp(script, "#!", 2) == 0) { + script += strcspn(script, "\r\n"); + script += strspn(script, "\r\n"); + } + /* and this copes with the ugly exec hack */ + if (strncmp(script, "exec ", 5) == 0) { + script += strcspn(script, "\r\n"); + script += strspn(script, "\r\n"); } /* run the script */ |