diff options
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | doc/index.html | 2 | ||||
-rw-r--r-- | doc/libstddjb/djbunix.html | 8 | ||||
-rw-r--r-- | doc/license.html | 2 | ||||
-rw-r--r-- | doc/upgrade.html | 4 | ||||
-rw-r--r-- | package/deps.mak | 7 | ||||
-rw-r--r-- | package/info | 2 | ||||
-rw-r--r-- | src/include/skalibs/posixplz.h | 1 | ||||
-rw-r--r-- | src/libposixplz/execvep.c | 33 | ||||
-rw-r--r-- | src/libposixplz/execvep_internal.c | 37 | ||||
-rw-r--r-- | src/libposixplz/execvep_loose.c | 13 | ||||
-rw-r--r-- | src/libposixplz/posixplz-internal.h | 8 |
12 files changed, 84 insertions, 37 deletions
diff --git a/NEWS b/NEWS index 33290dc..c8832b9 100644 --- a/NEWS +++ b/NEWS @@ -1,9 +1,11 @@ Changelog for skalibs. -In 2.6.3.2 +In 2.6.4.0 ---------- - Bugfixes. + - New function: execvep_loose() + In 2.6.3.1 ---------- diff --git a/doc/index.html b/doc/index.html index 7eb9ed8..2115be4 100644 --- a/doc/index.html +++ b/doc/index.html @@ -60,7 +60,7 @@ with a standard C development environment </li> <h3> Download </h3> <ul> - <li> The current released version of skalibs is <a href="skalibs-2.6.3.2.tar.gz">2.6.3.2</a>. </li> + <li> The current released version of skalibs is <a href="skalibs-2.6.4.0.tar.gz">2.6.4.0</a>. </li> <li> Alternatively, you can checkout a copy of the <a href="//git.skarnet.org/cgi-bin/cgit.cgi/skalibs/">skalibs git repository</a>: diff --git a/doc/libstddjb/djbunix.html b/doc/libstddjb/djbunix.html index da8ed23..05515aa 100644 --- a/doc/libstddjb/djbunix.html +++ b/doc/libstddjb/djbunix.html @@ -328,7 +328,7 @@ Returns -1 and sets errno if it fails; returns 0 if it succeeds. <h3> Executable search and execution, and environment </h3> <p> -<code> void execvep (char const *file, char const *const *argv, char const *const *envp, char const *path) </code> <br /> +<code> void execvep_loose (char const *file, char const *const *argv, char const *const *envp, char const *path) </code> <br /> Executes into the executable file at <em>file</em>, with the command line set to <em>argv</em> and the environment set to <em>envp</em>. If <em>file</em> is not an absolute path, it is searched in the @@ -339,6 +339,12 @@ error that happened. </p> <p> +<code> void execvep (char const *file, char const *const *argv, char const *const *envp, char const *path) </code> <br /> +Like <tt>execvep_loose()</tt>, but if <em>file</em> contains a slash, +it is treated as an absolute path. +</p> + +<p> <code> void pathexec_run (char const *file, char const *const *argv, char const *const *envp) </code> <br /> Performs <tt>execvep(file, argv, envp, path)</tt>, <em>path</em> being the contents of the PATH environment variable. If PATH is not set, <em>path</em> diff --git a/doc/license.html b/doc/license.html index 30d7bee..1afdc4d 100644 --- a/doc/license.html +++ b/doc/license.html @@ -74,7 +74,7 @@ color, or different text font. </li> <p> <em>I am aware that the previous restrictions sound completely ridiculous while the official skalibs documentation is incomplete. -As of 2.6.3.2, I'm not going to enforce those restrictions, but if you're +As of 2.6.4.0, I'm not going to enforce those restrictions, but if you're going to provide documentation for skalibs, don't keep it to yourself, please send it to me instead. :-) </em> </p> diff --git a/doc/upgrade.html b/doc/upgrade.html index 6568ca7..7f95df7 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -16,10 +16,10 @@ <a href="//skarnet.org/">skarnet.org</a> </p> -<h2> in 2.6.3.2 </h2> +<h2> in 2.6.4.0 </h2> <ul> - <li> No functional changes. </li> + <li> New function: <a href="libstddjb/djbunix.html">execvep_loose()</a>. </li> </ul> <h2> in 2.6.3.1 </h2> diff --git a/package/deps.mak b/package/deps.mak index 4120c48..ea62f01 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -22,6 +22,7 @@ src/include/skalibs/djbunix.h: src/include/skalibs/env.h src/include/skalibs/env src/include/skalibs/env.h: src/include/skalibs/gccattributes.h src/include/skalibs/stralloc.h src/include/skalibs/envalloc.h: src/include/skalibs/genalloc.h src/include/skalibs/environ.h: src/include/skalibs/posixplz.h +src/include/skalibs/error.h: src/include/skalibs/gccattributes.h src/include/skalibs/fmtscan.h: src/include/skalibs/gccattributes.h src/include/skalibs/genalloc.h: src/include/skalibs/functypes.h src/include/skalibs/stralloc.h src/include/skalibs/genqdyn.h: src/include/skalibs/stralloc.h @@ -30,6 +31,7 @@ src/include/skalibs/gensetdyn.h: src/include/skalibs/functypes.h src/include/ska src/include/skalibs/getpeereid.h: src/include/skalibs/posixplz.h src/include/skalibs/iobuffer.h: src/include/skalibs/buffer.h src/include/skalibs/djbunix.h src/include/skalibs/iopause.h: src/include/skalibs/tai.h +src/include/skalibs/ip46.h: src/include/skalibs/fmtscan.h src/include/skalibs/socket.h src/include/skalibs/kolbak.h: src/include/skalibs/unixmessage.h src/include/skalibs/lolstdio.h: src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/strerr2.h src/include/skalibs/mininetstring.h: src/include/skalibs/stralloc.h @@ -51,6 +53,7 @@ src/include/skalibs/strerr2.h: src/include/skalibs/strerr.h src/include/skalibs/tai.h: src/include/skalibs/gccattributes.h src/include/skalibs/uint64.h src/include/skalibs/textclient.h: src/include/skalibs/allreadwrite.h src/include/skalibs/tai.h src/include/skalibs/textmessage.h src/include/skalibs/textmessage.h: src/include/skalibs/allreadwrite.h src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/gccattributes.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h +src/include/skalibs/types.h: src/include/skalibs/uint16.h src/include/skalibs/uint32.h src/include/skalibs/uint64.h src/include/skalibs/unix-timed.h: src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h src/include/skalibs/unix-transactional.h: src/include/skalibs/stralloc.h src/include/skalibs/uint64.h src/include/skalibs/unixconnection.h: src/include/skalibs/unixmessage.h @@ -137,7 +140,9 @@ src/libdatastruct/gensetdyn_new.o src/libdatastruct/gensetdyn_new.lo: src/libdat src/libdatastruct/gensetdyn_ready.o src/libdatastruct/gensetdyn_ready.lo: src/libdatastruct/gensetdyn_ready.c src/include/skalibs/genalloc.h src/include/skalibs/gensetdyn.h src/include/skalibs/stralloc.h src/libdatastruct/gensetdyn_zero.o src/libdatastruct/gensetdyn_zero.lo: src/libdatastruct/gensetdyn_zero.c src/include/skalibs/gensetdyn.h src/libposixplz/doublefork.o src/libposixplz/doublefork.lo: src/libposixplz/doublefork.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h src/include/skalibs/uint64.h -src/libposixplz/execvep.o src/libposixplz/execvep.lo: src/libposixplz/execvep.c src/include/skalibs/bytestr.h src/include/skalibs/posixplz.h +src/libposixplz/execvep.o src/libposixplz/execvep.lo: src/libposixplz/execvep.c src/libposixplz/posixplz-internal.h src/include/skalibs/posixplz.h +src/libposixplz/execvep_internal.o src/libposixplz/execvep_internal.lo: src/libposixplz/execvep_internal.c src/include/skalibs/bytestr.h src/include/skalibs/posixplz.h +src/libposixplz/execvep_loose.o src/libposixplz/execvep_loose.lo: src/libposixplz/execvep_loose.c src/libposixplz/posixplz-internal.h src/include/skalibs/posixplz.h src/libposixplz/getpeereid.o src/libposixplz/getpeereid.lo: src/libposixplz/getpeereid.c src/include/skalibs/nonposix.h src/include/skalibs/posixplz.h src/include/skalibs/sysdeps.h src/libposixplz/memmem.o src/libposixplz/memmem.lo: src/libposixplz/memmem.c src/include/skalibs/posixplz.h src/include/skalibs/sysdeps.h src/libposixplz/setgroups.o src/libposixplz/setgroups.lo: src/libposixplz/setgroups.c src/include/skalibs/nonposix.h src/include/skalibs/setgroups.h src/include/skalibs/sysdeps.h diff --git a/package/info b/package/info index 6f4b721..40de272 100644 --- a/package/info +++ b/package/info @@ -1,4 +1,4 @@ package=skalibs -version=2.6.3.2 +version=2.6.4.0 category=prog package_macro_name=SKALIBS diff --git a/src/include/skalibs/posixplz.h b/src/include/skalibs/posixplz.h index 72cffee..1e7692d 100644 --- a/src/include/skalibs/posixplz.h +++ b/src/include/skalibs/posixplz.h @@ -39,6 +39,7 @@ extern int getpeereid (int, uid_t *, gid_t *) ; */ extern void execvep (char const *, char const *const *, char const *const *, char const *) ; +extern void execvep_loose (char const *, char const *const *, char const *const *, char const *) ; extern pid_t doublefork (void) ; extern int touch (char const *) ; diff --git a/src/libposixplz/execvep.c b/src/libposixplz/execvep.c index acdf11f..461f238 100644 --- a/src/libposixplz/execvep.c +++ b/src/libposixplz/execvep.c @@ -2,38 +2,13 @@ #include <unistd.h> #include <string.h> -#include <errno.h> -#include <skalibs/bytestr.h> #include <skalibs/posixplz.h> +#include "posixplz-internal.h" void execvep (char const *file, char const *const *argv, char const *const *envp, char const *path) { - if (!path) errno = EINVAL ; - else if (file[str_chr(file, '/')]) - execve(file, (char *const *)argv, (char *const *)envp) ; /* execve prototype sucks */ + if (strchr(file, '/')) + execve(file, (char *const *)argv, (char *const *)envp) ; else - { - size_t pathlen = strlen(path) + 1 ; - size_t filelen = strlen(file) ; - int savederrno = 0 ; - while (pathlen) - { - size_t split = byte_chr(path, pathlen - 1, ':') ; - if (split) - { - char tmp[split + 2 + filelen] ; - memcpy(tmp, path, split) ; - tmp[split] = '/' ; - memcpy(tmp + split + 1, file, filelen + 1) ; - execve(tmp, (char *const *)argv, (char *const *)envp) ; - if (errno != ENOENT) - { - savederrno = errno ; - if ((errno != EACCES) && (errno != EPERM) && (errno != EISDIR)) break ; - } - } - path += split+1 ; pathlen -= split+1 ; - } - if (savederrno) errno = savederrno ; - } + execvep_internal(file, argv, envp, path) ; } diff --git a/src/libposixplz/execvep_internal.c b/src/libposixplz/execvep_internal.c new file mode 100644 index 0000000..17858f0 --- /dev/null +++ b/src/libposixplz/execvep_internal.c @@ -0,0 +1,37 @@ +/* ISC license. */ + +#include <unistd.h> +#include <string.h> +#include <errno.h> +#include <skalibs/bytestr.h> +#include <skalibs/posixplz.h> + +void execvep_internal (char const *file, char const *const *argv, char const *const *envp, char const *path) +{ + if (!path) errno = EINVAL ; + else + { + size_t pathlen = strlen(path) + 1 ; + size_t filelen = strlen(file) ; + int savederrno = 0 ; + while (pathlen) + { + size_t split = byte_chr(path, pathlen - 1, ':') ; + if (split) + { + char tmp[split + 2 + filelen] ; + memcpy(tmp, path, split) ; + tmp[split] = '/' ; + memcpy(tmp + split + 1, file, filelen + 1) ; + execve(tmp, (char *const *)argv, (char *const *)envp) ; + if (errno != ENOENT) + { + savederrno = errno ; + if ((errno != EACCES) && (errno != EPERM) && (errno != EISDIR)) break ; + } + } + path += split+1 ; pathlen -= split+1 ; + } + if (savederrno) errno = savederrno ; + } +} diff --git a/src/libposixplz/execvep_loose.c b/src/libposixplz/execvep_loose.c new file mode 100644 index 0000000..7506362 --- /dev/null +++ b/src/libposixplz/execvep_loose.c @@ -0,0 +1,13 @@ +/* ISC license. */ + +#include <unistd.h> +#include <skalibs/posixplz.h> +#include "posixplz-internal.h" + +void execvep_loose (char const *file, char const *const *argv, char const *const *envp, char const *path) +{ + if (file[0] == '/') + execve(file, (char *const *)argv, (char *const *)envp) ; + else + execvep_internal(file, argv, envp, path) ; +} diff --git a/src/libposixplz/posixplz-internal.h b/src/libposixplz/posixplz-internal.h new file mode 100644 index 0000000..c3da73a --- /dev/null +++ b/src/libposixplz/posixplz-internal.h @@ -0,0 +1,8 @@ +/* ISC license. */ + +#ifndef POSIXPLZ_INTERNAL_H +#define POSIXPLZ_INTERNAL_H + +extern void execvep_internal (char const *, char const *const *, char const *const *, char const *) ; + +#endif |