Bug#922642: possible implementation
[2019-08-13 10:43] Shengjing Zhu > > [2019-08-11 22:54] Shengjing Zhu > > > This C patch works for me. But I have another approach now. > > > > > > Add following script as /usr/bin/execlineb > > > > > > #!/usr/lib/execline/bin/execlineb -S0 > > > /usr/lib/execline/bin/importas -D > > > /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PATH PATH > > > /usr/lib/execline/bin/export PATH /usr/lib/execline/bin:${PATH} > > > /usr/lib/execline/bin/exec -a $0 /usr/lib/execline/bin/execlineb $@ > > > > > > What do you think? > > > > Good, very good. But it will only work on Linux. kFreeBSD does not > > permit scripts (not ELF binaries) to be used as interpreters. > > The first time to know that. But execline currently is only > (successfully) built on linux. Okay. Probably you want set 'arch: linux-any' then or re-write /usr/bin/execlineb script in C, like this: int main(int argc, char **argv) { char *new_argv[argc + 20]; new_argv[0] = "/usr/lib/execline/bin/importas"; new_argv[1] = "/usr/lib/execline/bin/importas"; new_argv[2] = "-D"; // etc. memcpy(new_argv + ?, argv, argc * sizeof(char*)); execv(new_argv[0], new_argv); } I do not have strong opinion, I only use Linux kernel. -- Note, that I send and fetch email in batch, once in a few days. Please, mention in body of your reply when you add or remove recepients.
Bug#922642: possible implementation
On Tue, Aug 13, 2019 at 3:30 AM Dmitry Bogatov wrote: > > > [2019-08-11 22:54] Shengjing Zhu > > This C patch works for me. But I have another approach now. > > > > Add following script as /usr/bin/execlineb > > > > #!/usr/lib/execline/bin/execlineb -S0 > > /usr/lib/execline/bin/importas -D > > /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PATH PATH > > /usr/lib/execline/bin/export PATH /usr/lib/execline/bin:${PATH} > > /usr/lib/execline/bin/exec -a $0 /usr/lib/execline/bin/execlineb $@ > > > > What do you think? > > Good, very good. But it will only work on Linux. kFreeBSD does not > permit scripts (not ELF binaries) to be used as interpreters. The first time to know that. But execline currently is only (successfully) built on linux. -- Shengjing Zhu
Bug#922642: possible implementation
[2019-08-11 22:54] Shengjing Zhu > This C patch works for me. But I have another approach now. > > Add following script as /usr/bin/execlineb > > #!/usr/lib/execline/bin/execlineb -S0 > /usr/lib/execline/bin/importas -D > /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PATH PATH > /usr/lib/execline/bin/export PATH /usr/lib/execline/bin:${PATH} > /usr/lib/execline/bin/exec -a $0 /usr/lib/execline/bin/execlineb $@ > > What do you think? Good, very good. But it will only work on Linux. kFreeBSD does not permit scripts (not ELF binaries) to be used as interpreters. -- Note, that I send and fetch email in batch, once in a few days. Please, mention in body of your reply when you add or remove recepients.
Bug#922642: possible implementation
> > diff -Nru execline-2.5.0.1/debian/patches/move-execlineb-to-usr.patch > > execline-2.5.0.1/debian/patches/move-execlineb-to-usr.patch > > --- execline-2.5.0.1/debian/patches/move-execlineb-to-usr.patch 1970-01-01 > > 00:00:00.0 + > > +++ execline-2.5.0.1/debian/patches/move-execlineb-to-usr.patch 2019-03-06 > > 17:53:53.0 + > > @@ -0,0 +1,48 @@ > > +--- a/src/execline/execlineb.c > > b/src/execline/execlineb.c > > +@@ -12,6 +12,7 @@ > > + #include > > + #include > > + #include > > ++#include > > + #include "exlsn.h" > > + > > + #define USAGE "execlineb [ -p | -P | -S nmin | -s nmin ] [ -q | -w | -W ] > > [ -c commandline ] script args" > > +@@ -64,6 +65,27 @@ static int myexlp (stralloc *sa, char co > > + return -1 ; > > + } > > + > > ++/* Add /usr/lib/execline/bin into PATH. See #922642. */ > > ++static int adjust_path(const char *const *envp, stralloc *modif) > > ++{ > > ++ size_t oldlen = modif->len; > > ++ const char *old = env_get2(envp, "PATH"); > > ++ stralloc new = STRALLOC_ZERO; > > ++ > > ++ if (!old) return 1 ; > > ++ > > ++ if (!stralloc_cats(, "/usr/lib/execline/bin:") > > ++ || !stralloc_cats(, old) > > ++ || !env_addmodif(modif, "PATH", new.s) > > ++ || setenv("PATH", new.s, 1) == -1) > > ++ { > > ++stralloc_free(); > > ++modif->len = oldlen; > > ++return 0; > > ++ } > > ++ return 1; > > ++} > > ++ > > + int main (int argc, char const *const *argv, char const *const *envp) > > + { > > + stralloc sa = STRALLOC_ZERO ; > > +@@ -133,6 +155,9 @@ int main (int argc, char const *const *a > > + goto errenv ; > > + } > > + > > ++ if (!adjust_path(envp, )) > > ++goto errenv ; > > ++ > > + if (flagpushenv == 3 || flagpushenv == 4) > > + { > > + if (flagstrict && ((unsigned int)argc < nmin)) This C patch works for me. But I have another approach now. Add following script as /usr/bin/execlineb #!/usr/lib/execline/bin/execlineb -S0 /usr/lib/execline/bin/importas -D /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PATH PATH /usr/lib/execline/bin/export PATH /usr/lib/execline/bin:${PATH} /usr/lib/execline/bin/exec -a $0 /usr/lib/execline/bin/execlineb $@ What do you think? -- Shengjing Zhu
Bug#922642: possible implementation
On Fri, Mar 8, 2019 at 2:09 AM Christoph Biedl wrote: > > Control: 922624 -patch > Control: 922642 +patch > > Beware, this should go to #922642 not #922624. Changelog (below) still > needs to be adjusted. > > Christoph > > Dmitry Bogatov wrote... > > control: tags -1 +patch > > Hello! Here is debdiff with implementation of proposal -- `execlineb' is > moved to /usr/bin and it includes /usr/lib/execline/bin into PATH. Every > binary in /usr/bin needs a manual, so I conjured one with `help2man', > but it definitely need polishing. > > Thank you for packaging and maintaining `execline'. > > diff -Nru execline-2.5.0.1/debian/changelog execline-2.5.0.1/debian/changelog > --- execline-2.5.0.1/debian/changelog 2019-02-08 14:36:23.0 + > +++ execline-2.5.0.1/debian/changelog 2019-03-06 17:53:53.0 + > @@ -1,3 +1,11 @@ > +execline (2.5.0.1-4) UNRELEASED; urgency=medium > + > + * Add `/usr/lib/execline/bin' into PATH for scripts, invoked by > `execlineb'. > +(Closes: #922624) > + * Move execlineb into `/usr/bin'. > + > + -- Dmitry Bogatov Wed, 06 Mar 2019 17:53:53 + > + > execline (2.5.0.1-3) unstable; urgency=medium > >* Add dep8 autopkgtest script > diff -Nru execline-2.5.0.1/debian/execlineb.1 > execline-2.5.0.1/debian/execlineb.1 > --- execline-2.5.0.1/debian/execlineb.1 1970-01-01 00:00:00.0 + > +++ execline-2.5.0.1/debian/execlineb.1 2019-03-06 17:53:53.0 + > @@ -0,0 +1,401 @@ > +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8. > +.TH EXECLINEB "1" "March 2019" "Debian" "User Commands" > +.SH NAME > +execlineb \- manual page for execlineb execline > +.SH DESCRIPTION > +execline > +Software > +skarnet.org > +.PP > +The execlineb program > +.PP > +execlineb reads and executes a script. > +.PP > +Interface > +.IP > +execlineb [ \fB\-q\fR | \fB\-w\fR | \fB\-W\fR ] [ \fB\-p\fR | \fB\-P\fR | > \fB\-S\fR nmin | \fB\-s\fR nmin ] \fB\-c\fR script [ args... ] > +.PP > +or > +.IP > +execlineb [ \fB\-q\fR | \fB\-w\fR | \fB\-W\fR ] [ \fB\-p\fR | \fB\-P\fR | > \fB\-S\fR nmin | \fB\-s\fR nmin ] scriptfile [ args... ] > +.PP > +or in an executable file: > +.PP > +#!/command/execlineb [ \fB\-qwWpPSnmin\fR ] > +script > +.PP > +Parsing phase. > +.IP > +* execlineb reads and parses the script it is given. It exits 100 on a > +.IP > +syntax error and 111 on a temporary error. It makes an argv, i.e. a > +system command line, with the parsed script. If the argv is empty, > +execlineb exits 0. > +.PP > +Environment management phase. > +.IP > +* Pushing the current stack frame. If none of the \fB\-p\fR, \fB\-P\fR, > \fB\-S\fR or \fB\-s\fR > +.IP > +options is set: execlineb pushes the current positional parameters, > +i.e. environment variables that start with #, 0, 1, ..., 9. To get the > +previous values back, use emptyenv \fB\-P\fR. > +.IP > +* Setting the new stack frame. If none of the \fB\-P\fR, \fB\-S\fR or > \fB\-s\fR options is > +.IP > +set: > +.IP > ++ execlineb sets the # environment variable to the number n of args > +.IP > +it is given. > +.IP > ++ It sets the 0 environment variable to the name of the script \- or > +.IP > +to the execlineb invocation name if the \fB\-c\fR option is used. > +.IP > ++ It sets the 1, 2, ... n environment variables to the different > +.IP > +args. > +.PP > +Execution phase. > +.IP > +* execlineb executes into the argv it has built from the script. There > +.IP > +is only one command line for the whole script: the execlineb binary is > +a launcher, whose sole purpose is to execute into that command line. > +It does not stay in memory like a traditional interpreter would. > +.PP > +Options > +.IP > +* \fB\-c\fR script : execute script, do not look for a file. > +.PP > +See below for the other options. > +.PP > +Syntax of scripts > +.PP > +An execlineb script is a string that must not contain the null character. > +execlineb parses it and divides it into words. The parser recognizes the > +following components: > +.IP > +* whitespace is defined as spaces, tabs, newlines and carriage returns. > +.IP > +Words are always separated by whitespace. > +.IP > +* A quoted string begins with a doublequote (") and ends with another > +.IP > +doublequote. Quoted doublequotes must be prefixed by a backslash (\e). > +Quoted strings always evaluate to exactly one word. For instance, "" > +evaluates to the empty word. > +.IP > +* The \ea, \eb, \et, \en, \ev, \ef, and \er sequences are recognized in > quoted > +.IP > +strings, and are converted to the ASCII numbers 7, 8, 9, 10, 11, 12 > +and 13 respectively. > +.IP > +* Inside a quoted string, backslashed newlines disappear completely. > +* \e0xab sequences are recognized in quoted strings and evaluate to ASCII > +.IP > +hexadecimal number ab. > +.IP > +* \e0abc sequences are recognized in quoted strings and evaluate to ASCII > +.IP > +octal number abc. > +.IP > +* \eabc sequences are recognized in quoted strings and evaluate to ASCII > +.IP > +decimal number
Bug#922624: Bug#922642: possible implementation
Control: 922624 -patch Control: 922642 +patch Beware, this should go to #922642 not #922624. Changelog (below) still needs to be adjusted. Christoph Dmitry Bogatov wrote... control: tags -1 +patch Hello! Here is debdiff with implementation of proposal -- `execlineb' is moved to /usr/bin and it includes /usr/lib/execline/bin into PATH. Every binary in /usr/bin needs a manual, so I conjured one with `help2man', but it definitely need polishing. Thank you for packaging and maintaining `execline'. diff -Nru execline-2.5.0.1/debian/changelog execline-2.5.0.1/debian/changelog --- execline-2.5.0.1/debian/changelog 2019-02-08 14:36:23.0 + +++ execline-2.5.0.1/debian/changelog 2019-03-06 17:53:53.0 + @@ -1,3 +1,11 @@ +execline (2.5.0.1-4) UNRELEASED; urgency=medium + + * Add `/usr/lib/execline/bin' into PATH for scripts, invoked by `execlineb'. +(Closes: #922624) + * Move execlineb into `/usr/bin'. + + -- Dmitry Bogatov Wed, 06 Mar 2019 17:53:53 + + execline (2.5.0.1-3) unstable; urgency=medium * Add dep8 autopkgtest script diff -Nru execline-2.5.0.1/debian/execlineb.1 execline-2.5.0.1/debian/execlineb.1 --- execline-2.5.0.1/debian/execlineb.1 1970-01-01 00:00:00.0 + +++ execline-2.5.0.1/debian/execlineb.1 2019-03-06 17:53:53.0 + @@ -0,0 +1,401 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8. +.TH EXECLINEB "1" "March 2019" "Debian" "User Commands" +.SH NAME +execlineb \- manual page for execlineb execline +.SH DESCRIPTION +execline +Software +skarnet.org +.PP +The execlineb program +.PP +execlineb reads and executes a script. +.PP +Interface +.IP +execlineb [ \fB\-q\fR | \fB\-w\fR | \fB\-W\fR ] [ \fB\-p\fR | \fB\-P\fR | \fB\-S\fR nmin | \fB\-s\fR nmin ] \fB\-c\fR script [ args... ] +.PP +or +.IP +execlineb [ \fB\-q\fR | \fB\-w\fR | \fB\-W\fR ] [ \fB\-p\fR | \fB\-P\fR | \fB\-S\fR nmin | \fB\-s\fR nmin ] scriptfile [ args... ] +.PP +or in an executable file: +.PP +#!/command/execlineb [ \fB\-qwWpPSnmin\fR ] +script +.PP +Parsing phase. +.IP +* execlineb reads and parses the script it is given. It exits 100 on a +.IP +syntax error and 111 on a temporary error. It makes an argv, i.e. a +system command line, with the parsed script. If the argv is empty, +execlineb exits 0. +.PP +Environment management phase. +.IP +* Pushing the current stack frame. If none of the \fB\-p\fR, \fB\-P\fR, \fB\-S\fR or \fB\-s\fR +.IP +options is set: execlineb pushes the current positional parameters, +i.e. environment variables that start with #, 0, 1, ..., 9. To get the +previous values back, use emptyenv \fB\-P\fR. +.IP +* Setting the new stack frame. If none of the \fB\-P\fR, \fB\-S\fR or \fB\-s\fR options is +.IP +set: +.IP ++ execlineb sets the # environment variable to the number n of args +.IP +it is given. +.IP ++ It sets the 0 environment variable to the name of the script \- or +.IP +to the execlineb invocation name if the \fB\-c\fR option is used. +.IP ++ It sets the 1, 2, ... n environment variables to the different +.IP +args. +.PP +Execution phase. +.IP +* execlineb executes into the argv it has built from the script. There +.IP +is only one command line for the whole script: the execlineb binary is +a launcher, whose sole purpose is to execute into that command line. +It does not stay in memory like a traditional interpreter would. +.PP +Options +.IP +* \fB\-c\fR script : execute script, do not look for a file. +.PP +See below for the other options. +.PP +Syntax of scripts +.PP +An execlineb script is a string that must not contain the null character. +execlineb parses it and divides it into words. The parser recognizes the +following components: +.IP +* whitespace is defined as spaces, tabs, newlines and carriage returns. +.IP +Words are always separated by whitespace. +.IP +* A quoted string begins with a doublequote (") and ends with another +.IP +doublequote. Quoted doublequotes must be prefixed by a backslash (\e). +Quoted strings always evaluate to exactly one word. For instance, "" +evaluates to the empty word. +.IP +* The \ea, \eb, \et, \en, \ev, \ef, and \er sequences are recognized in quoted +.IP +strings, and are converted to the ASCII numbers 7, 8, 9, 10, 11, 12 +and 13 respectively. +.IP +* Inside a quoted string, backslashed newlines disappear completely. +* \e0xab sequences are recognized in quoted strings and evaluate to ASCII +.IP +hexadecimal number ab. +.IP +* \e0abc sequences are recognized in quoted strings and evaluate to ASCII +.IP +octal number abc. +.IP +* \eabc sequences are recognized in quoted strings and evaluate to ASCII +.IP +decimal number abc. a must not be zero. +.IP +* A comment starts with a # and ends with the line. Comments are not +.IP +recognized inside quoted strings. +.IP +* Anything else is an unquoted string, that can evaluate to zero or more +.IP +words. +.IP +* Any character can be escaped in unquoted strings by prepending it with +.IP +a backslash. It works the same way