commit 18e43565574b700befc832ed4d25d25e40951f68 parent 265092c55d40f362a521eee97676e0d51ef17800 Author: Laurent Bercot <ska-skaware@skarnet.org> Date: Tue, 24 Nov 2020 21:45:56 +0000 Complete revamp of the pathexec functions - pathexec_run is now called exec_ae a for provided file name (default: argv[0]) e for provided envp (default: environ) - pathexec is now called mexec. m for merge environment. Option letters are: a for provided file name (default: argv[0]) e for provided envp (default: environ) f for provided envp *and* length of the envp m for provided modif string plus its length (the length is always needed because the modifs are null-terminated) n for provided modif string, length *and* number of modifs - functions have a foo0 version for _exit(0) when argv[0] is null - functions have a xfoo version to die if the exec fails - and a xfoo0 - Compatibility #defines and #includes are there until the next major bump Diffstat:
58 files changed, 495 insertions(+), 269 deletions(-)
diff --git a/NEWS b/NEWS @@ -8,6 +8,7 @@ In 2.9.4.0 unconditionally deleting the socket. - ipc_bind_reuse() rewritten to use ipc_bind_reuse_lock(), so it does the right thing instead of clobbering sockets. + - Complete revamping of the pathexec functions, see exec.h In 2.9.3.0 diff --git a/doc/upgrade.html b/doc/upgrade.html @@ -24,6 +24,7 @@ <li> New <tt>ipc_bind_reuse_lock()</tt> function, which takes a lock before deleting a Unix domain socket. The <tt>ipc_bind_reuse()</tt> function now uses it, so it won't unconditionally clobber sockets in the filesystem anymore. </li> + <li> Complete revamping of the pathexec functions, see <tt>exec.h</tt>. </li> </ul> <h2> in 2.9.3.0 </h2> diff --git a/package/deps.mak b/package/deps.mak @@ -19,11 +19,12 @@ src/include/skalibs/cdb.h: src/include/skalibs/gccattributes.h src/include/skalibs/cdb_make.h: src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/diuint32.h src/include/skalibs/genalloc.h src/include/skalibs/datastruct.h: src/include/skalibs/avlnode.h src/include/skalibs/avltree.h src/include/skalibs/avltreen.h src/include/skalibs/bigkv.h src/include/skalibs/genqdyn.h src/include/skalibs/genset.h src/include/skalibs/gensetdyn.h src/include/skalibs/djbtime.h: src/include/skalibs/tai.h src/include/skalibs/uint64.h -src/include/skalibs/djbunix.h: src/include/skalibs/envalloc.h src/include/skalibs/gccattributes.h src/include/skalibs/posixplz.h src/include/skalibs/stralloc.h +src/include/skalibs/djbunix.h: src/include/skalibs/exec.h src/include/skalibs/gccattributes.h src/include/skalibs/stralloc.h 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/exec.h: src/include/skalibs/env.h src/include/skalibs/environ.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 @@ -32,6 +33,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/netstring.h: src/include/skalibs/buffer.h src/include/skalibs/stralloc.h @@ -47,12 +49,15 @@ src/include/skalibs/skalibs.h: src/include/skalibs/biguint.h src/include/skalibs src/include/skalibs/skamisc.h: src/include/skalibs/buffer.h src/include/skalibs/stralloc.h src/include/skalibs/socket.h: src/include/skalibs/djbunix.h src/include/skalibs/gccattributes.h src/include/skalibs/tai.h src/include/skalibs/webipc.h src/include/skalibs/stdcrypto.h: src/include/skalibs/md5.h src/include/skalibs/rc4.h src/include/skalibs/sha1.h src/include/skalibs/sha256.h src/include/skalibs/sha512.h -src/include/skalibs/stddjb.h: src/include/skalibs/alarm.h src/include/skalibs/alloc.h src/include/skalibs/allreadwrite.h src/include/skalibs/bitarray.h src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/bytestr.h src/include/skalibs/cbuffer.h src/include/skalibs/cdb.h src/include/skalibs/cdb_make.h src/include/skalibs/direntry.h src/include/skalibs/disize.h src/include/skalibs/diuint.h src/include/skalibs/diuint32.h src/include/skalibs/djbtime.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/envalloc.h src/include/skalibs/error.h src/include/skalibs/fmtscan.h src/include/skalibs/functypes.h src/include/skalibs/gccattributes.h src/include/skalibs/genalloc.h src/include/skalibs/genwrite.h src/include/skalibs/iobuffer.h src/include/skalibs/iopause.h src/include/skalibs/ip46.h src/include/skalibs/lolstdio.h src/include/skalibs/netstring.h src/include/skalibs/nsig.h src/include/skalibs/segfault.h src/include/skalibs/selfpipe.h src/include/skalibs/setgroups.h src/include/skalibs/sgetopt.h src/include/skalibs/sig.h src/include/skalibs/siovec.h src/include/skalibs/skamisc.h src/include/skalibs/socket.h src/include/skalibs/stralloc.h src/include/skalibs/strerr.h src/include/skalibs/strerr2.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/webipc.h +src/include/skalibs/stddjb.h: src/include/skalibs/alarm.h src/include/skalibs/alloc.h src/include/skalibs/allreadwrite.h src/include/skalibs/bitarray.h src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/bytestr.h src/include/skalibs/cbuffer.h src/include/skalibs/cdb.h src/include/skalibs/cdb_make.h src/include/skalibs/direntry.h src/include/skalibs/disize.h src/include/skalibs/diuint.h src/include/skalibs/diuint32.h src/include/skalibs/djbtime.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/envalloc.h src/include/skalibs/error.h src/include/skalibs/exec.h src/include/skalibs/fmtscan.h src/include/skalibs/functypes.h src/include/skalibs/gccattributes.h src/include/skalibs/genalloc.h src/include/skalibs/genwrite.h src/include/skalibs/iobuffer.h src/include/skalibs/iopause.h src/include/skalibs/ip46.h src/include/skalibs/lolstdio.h src/include/skalibs/netstring.h src/include/skalibs/nsig.h src/include/skalibs/segfault.h src/include/skalibs/selfpipe.h src/include/skalibs/setgroups.h src/include/skalibs/sgetopt.h src/include/skalibs/sig.h src/include/skalibs/siovec.h src/include/skalibs/skamisc.h src/include/skalibs/socket.h src/include/skalibs/stralloc.h src/include/skalibs/strerr.h src/include/skalibs/strerr2.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/webipc.h src/include/skalibs/strerr.h: src/include/skalibs/gccattributes.h 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/uint16.h: src/include/skalibs/uint64.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 @@ -144,6 +149,40 @@ src/libdatastruct/gensetdyn_iter_withcancel.o src/libdatastruct/gensetdyn_iter_w src/libdatastruct/gensetdyn_new.o src/libdatastruct/gensetdyn_new.lo: src/libdatastruct/gensetdyn_new.c src/include/skalibs/genalloc.h src/include/skalibs/gensetdyn.h 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/libenvexec/env_addmodif.o src/libenvexec/env_addmodif.lo: src/libenvexec/env_addmodif.c src/include/skalibs/env.h src/include/skalibs/stralloc.h +src/libenvexec/env_dump.o src/libenvexec/env_dump.lo: src/libenvexec/env_dump.c src/include/skalibs/bytestr.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/nonposix.h src/include/skalibs/unix-transactional.h +src/libenvexec/env_get.o src/libenvexec/env_get.lo: src/libenvexec/env_get.c src/include/skalibs/posixplz.h +src/libenvexec/env_get2.o src/libenvexec/env_get2.lo: src/libenvexec/env_get2.c src/include/skalibs/bytestr.h src/include/skalibs/env.h +src/libenvexec/env_len.o src/libenvexec/env_len.lo: src/libenvexec/env_len.c src/include/skalibs/env.h +src/libenvexec/env_make.o src/libenvexec/env_make.lo: src/libenvexec/env_make.c src/include/skalibs/env.h +src/libenvexec/env_merg.o src/libenvexec/env_merg.lo: src/libenvexec/env_merg.c src/include/skalibs/env.h +src/libenvexec/env_merge.o src/libenvexec/env_merge.lo: src/libenvexec/env_merge.c src/include/skalibs/bytestr.h src/include/skalibs/env.h +src/libenvexec/env_mergen.o src/libenvexec/env_mergen.lo: src/libenvexec/env_mergen.c src/include/skalibs/bytestr.h src/include/skalibs/env.h +src/libenvexec/env_mergn.o src/libenvexec/env_mergn.lo: src/libenvexec/env_mergn.c src/include/skalibs/env.h +src/libenvexec/env_string.o src/libenvexec/env_string.lo: src/libenvexec/env_string.c src/include/skalibs/env.h src/include/skalibs/stralloc.h +src/libenvexec/envalloc_0.o src/libenvexec/envalloc_0.lo: src/libenvexec/envalloc_0.c src/include/skalibs/envalloc.h src/include/skalibs/genalloc.h +src/libenvexec/envalloc_make.o src/libenvexec/envalloc_make.lo: src/libenvexec/envalloc_make.c src/include/skalibs/env.h src/include/skalibs/envalloc.h src/include/skalibs/genalloc.h +src/libenvexec/envalloc_merge.o src/libenvexec/envalloc_merge.lo: src/libenvexec/envalloc_merge.c src/include/skalibs/bytestr.h src/include/skalibs/env.h src/include/skalibs/envalloc.h src/include/skalibs/genalloc.h +src/libenvexec/envalloc_uniq.o src/libenvexec/envalloc_uniq.lo: src/libenvexec/envalloc_uniq.c src/include/skalibs/bytestr.h src/include/skalibs/envalloc.h src/include/skalibs/genalloc.h +src/libenvexec/envdir.o src/libenvexec/envdir.lo: src/libenvexec/envdir.c src/include/skalibs/bytestr.h src/include/skalibs/direntry.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/stralloc.h +src/libenvexec/exec0_ae.o src/libenvexec/exec0_ae.lo: src/libenvexec/exec0_ae.c src/include/skalibs/exec.h +src/libenvexec/exec_ae.o src/libenvexec/exec_ae.lo: src/libenvexec/exec_ae.c src/include/skalibs/config.h src/include/skalibs/exec.h src/include/skalibs/posixplz.h +src/libenvexec/mexec0_af.o src/libenvexec/mexec0_af.lo: src/libenvexec/mexec0_af.c src/include/skalibs/exec.h +src/libenvexec/mexec0_afm.o src/libenvexec/mexec0_afm.lo: src/libenvexec/mexec0_afm.c src/include/skalibs/exec.h +src/libenvexec/mexec0_afn.o src/libenvexec/mexec0_afn.lo: src/libenvexec/mexec0_afn.c src/include/skalibs/exec.h +src/libenvexec/mexec_af.o src/libenvexec/mexec_af.lo: src/libenvexec/mexec_af.c src/include/skalibs/env.h src/include/skalibs/exec.h src/include/skalibs/stralloc.h +src/libenvexec/mexec_afm.o src/libenvexec/mexec_afm.lo: src/libenvexec/mexec_afm.c src/include/skalibs/bytestr.h src/include/skalibs/exec.h +src/libenvexec/mexec_afn.o src/libenvexec/mexec_afn.lo: src/libenvexec/mexec_afn.c src/include/skalibs/env.h src/include/skalibs/exec.h +src/libenvexec/xexec0_ae.o src/libenvexec/xexec0_ae.lo: src/libenvexec/xexec0_ae.c src/include/skalibs/exec.h +src/libenvexec/xexec_ae.o src/libenvexec/xexec_ae.lo: src/libenvexec/xexec_ae.c src/include/skalibs/exec.h src/include/skalibs/strerr2.h +src/libenvexec/xexecvep.o src/libenvexec/xexecvep.lo: src/libenvexec/xexecvep.c src/include/skalibs/exec.h src/include/skalibs/posixplz.h src/include/skalibs/strerr2.h +src/libenvexec/xexecvep_loose.o src/libenvexec/xexecvep_loose.lo: src/libenvexec/xexecvep_loose.c src/include/skalibs/exec.h src/include/skalibs/posixplz.h src/include/skalibs/strerr2.h +src/libenvexec/xmexec0_af.o src/libenvexec/xmexec0_af.lo: src/libenvexec/xmexec0_af.c src/include/skalibs/exec.h src/include/skalibs/strerr2.h +src/libenvexec/xmexec0_afm.o src/libenvexec/xmexec0_afm.lo: src/libenvexec/xmexec0_afm.c src/include/skalibs/exec.h src/include/skalibs/strerr2.h +src/libenvexec/xmexec0_afn.o src/libenvexec/xmexec0_afn.lo: src/libenvexec/xmexec0_afn.c src/include/skalibs/exec.h src/include/skalibs/strerr2.h +src/libenvexec/xmexec_af.o src/libenvexec/xmexec_af.lo: src/libenvexec/xmexec_af.c src/include/skalibs/exec.h src/include/skalibs/strerr2.h +src/libenvexec/xmexec_afm.o src/libenvexec/xmexec_afm.lo: src/libenvexec/xmexec_afm.c src/include/skalibs/exec.h src/include/skalibs/strerr2.h +src/libenvexec/xmexec_afn.o src/libenvexec/xmexec_afn.lo: src/libenvexec/xmexec_afn.c src/include/skalibs/exec.h src/include/skalibs/strerr2.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/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 @@ -303,19 +342,6 @@ src/libstddjb/coe.o src/libstddjb/coe.lo: src/libstddjb/coe.c src/include/skalib src/libstddjb/deepsleepuntil.o src/libstddjb/deepsleepuntil.lo: src/libstddjb/deepsleepuntil.c src/include/skalibs/iopause.h src/include/skalibs/tai.h src/libstddjb/dir_close.o src/libstddjb/dir_close.lo: src/libstddjb/dir_close.c src/include/skalibs/direntry.h src/libstddjb/dir_fd.o src/libstddjb/dir_fd.lo: src/libstddjb/dir_fd.c src/include/skalibs/direntry.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h -src/libstddjb/env_addmodif.o src/libstddjb/env_addmodif.lo: src/libstddjb/env_addmodif.c src/include/skalibs/env.h src/include/skalibs/stralloc.h -src/libstddjb/env_dump.o src/libstddjb/env_dump.lo: src/libstddjb/env_dump.c src/include/skalibs/bytestr.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/nonposix.h src/include/skalibs/unix-transactional.h -src/libstddjb/env_get.o src/libstddjb/env_get.lo: src/libstddjb/env_get.c src/include/skalibs/posixplz.h -src/libstddjb/env_get2.o src/libstddjb/env_get2.lo: src/libstddjb/env_get2.c src/include/skalibs/bytestr.h src/include/skalibs/env.h -src/libstddjb/env_len.o src/libstddjb/env_len.lo: src/libstddjb/env_len.c src/include/skalibs/env.h -src/libstddjb/env_make.o src/libstddjb/env_make.lo: src/libstddjb/env_make.c src/include/skalibs/env.h -src/libstddjb/env_merge.o src/libstddjb/env_merge.lo: src/libstddjb/env_merge.c src/include/skalibs/bytestr.h src/include/skalibs/env.h -src/libstddjb/env_string.o src/libstddjb/env_string.lo: src/libstddjb/env_string.c src/include/skalibs/env.h src/include/skalibs/stralloc.h -src/libstddjb/envalloc_0.o src/libstddjb/envalloc_0.lo: src/libstddjb/envalloc_0.c src/include/skalibs/envalloc.h src/include/skalibs/genalloc.h -src/libstddjb/envalloc_make.o src/libstddjb/envalloc_make.lo: src/libstddjb/envalloc_make.c src/include/skalibs/env.h src/include/skalibs/envalloc.h src/include/skalibs/genalloc.h -src/libstddjb/envalloc_merge.o src/libstddjb/envalloc_merge.lo: src/libstddjb/envalloc_merge.c src/include/skalibs/bytestr.h src/include/skalibs/env.h src/include/skalibs/envalloc.h src/include/skalibs/genalloc.h -src/libstddjb/envalloc_uniq.o src/libstddjb/envalloc_uniq.lo: src/libstddjb/envalloc_uniq.c src/include/skalibs/bytestr.h src/include/skalibs/envalloc.h src/include/skalibs/genalloc.h -src/libstddjb/envdir.o src/libstddjb/envdir.lo: src/libstddjb/envdir.c src/include/skalibs/bytestr.h src/include/skalibs/direntry.h src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/stralloc.h src/libstddjb/error_isalready.o src/libstddjb/error_isalready.lo: src/libstddjb/error_isalready.c src/include/skalibs/bsdsnowflake.h src/include/skalibs/error.h src/libstddjb/error_temp.o src/libstddjb/error_temp.lo: src/libstddjb/error_temp.c src/include/skalibs/error.h src/libstddjb/fd_cat.o src/libstddjb/fd_cat.lo: src/libstddjb/fd_cat.c src/include/skalibs/djbunix.h src/include/skalibs/iobuffer.h @@ -474,13 +500,6 @@ src/libstddjb/openwritevnclose.o src/libstddjb/openwritevnclose.lo: src/libstddj src/libstddjb/openwritevnclose_suffix.o src/libstddjb/openwritevnclose_suffix.lo: src/libstddjb/openwritevnclose_suffix.c src/include/skalibs/djbunix.h src/libstddjb/openwritevnclose_unsafe.o src/libstddjb/openwritevnclose_unsafe.lo: src/libstddjb/openwritevnclose_unsafe.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/libstddjb/path_canonicalize.o src/libstddjb/path_canonicalize.lo: src/libstddjb/path_canonicalize.c src/include/skalibs/djbunix.h -src/libstddjb/pathexec.o src/libstddjb/pathexec.lo: src/libstddjb/pathexec.c src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/posixplz.h -src/libstddjb/pathexec0.o src/libstddjb/pathexec0.lo: src/libstddjb/pathexec0.c src/include/skalibs/djbunix.h -src/libstddjb/pathexec0_run.o src/libstddjb/pathexec0_run.lo: src/libstddjb/pathexec0_run.c src/include/skalibs/djbunix.h -src/libstddjb/pathexec_fromenv.o src/libstddjb/pathexec_fromenv.lo: src/libstddjb/pathexec_fromenv.c src/include/skalibs/djbunix.h src/include/skalibs/env.h src/include/skalibs/stralloc.h -src/libstddjb/pathexec_r.o src/libstddjb/pathexec_r.lo: src/libstddjb/pathexec_r.c src/include/skalibs/djbunix.h -src/libstddjb/pathexec_r_name.o src/libstddjb/pathexec_r_name.lo: src/libstddjb/pathexec_r_name.c src/include/skalibs/bytestr.h src/include/skalibs/djbunix.h src/include/skalibs/env.h -src/libstddjb/pathexec_run.o src/libstddjb/pathexec_run.lo: src/libstddjb/pathexec_run.c src/include/skalibs/config.h src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h src/libstddjb/pipe_internal.o src/libstddjb/pipe_internal.lo: src/libstddjb/pipe_internal.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/libstddjb/prog.o src/libstddjb/prog.lo: src/libstddjb/prog.c src/include/skalibs/strerr2.h src/libstddjb/rm_rf.o src/libstddjb/rm_rf.lo: src/libstddjb/rm_rf.c src/include/skalibs/djbunix.h src/include/skalibs/skamisc.h @@ -734,12 +753,6 @@ src/libstddjb/waitpid_nointr.o src/libstddjb/waitpid_nointr.lo: src/libstddjb/wa src/libstddjb/writenclose_unsafe.o src/libstddjb/writenclose_unsafe.lo: src/libstddjb/writenclose_unsafe.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/libstddjb/writevnclose_unsafe.o src/libstddjb/writevnclose_unsafe.lo: src/libstddjb/writevnclose_unsafe.c src/include/skalibs/allreadwrite.h src/include/skalibs/djbunix.h src/include/skalibs/siovec.h src/libstddjb/xexecvep.o src/libstddjb/xexecvep.lo: src/libstddjb/xexecvep.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h src/include/skalibs/strerr2.h -src/libstddjb/xpathexec.o src/libstddjb/xpathexec.lo: src/libstddjb/xpathexec.c src/include/skalibs/djbunix.h src/include/skalibs/strerr2.h -src/libstddjb/xpathexec0.o src/libstddjb/xpathexec0.lo: src/libstddjb/xpathexec0.c src/include/skalibs/djbunix.h src/include/skalibs/strerr2.h -src/libstddjb/xpathexec0_run.o src/libstddjb/xpathexec0_run.lo: src/libstddjb/xpathexec0_run.c src/include/skalibs/djbunix.h src/include/skalibs/strerr2.h -src/libstddjb/xpathexec_fromenv.o src/libstddjb/xpathexec_fromenv.lo: src/libstddjb/xpathexec_fromenv.c src/include/skalibs/djbunix.h src/include/skalibs/strerr2.h -src/libstddjb/xpathexec_r.o src/libstddjb/xpathexec_r.lo: src/libstddjb/xpathexec_r.c src/include/skalibs/djbunix.h src/include/skalibs/strerr2.h -src/libstddjb/xpathexec_r_name.o src/libstddjb/xpathexec_r_name.lo: src/libstddjb/xpathexec_r_name.c src/include/skalibs/djbunix.h src/include/skalibs/strerr2.h src/libstddjb/xpathexec_run.o src/libstddjb/xpathexec_run.lo: src/libstddjb/xpathexec_run.c src/include/skalibs/djbunix.h src/include/skalibs/strerr2.h src/libunixonacid/access_at.o src/libunixonacid/access_at.lo: src/libunixonacid/access_at.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/include/skalibs/unix-transactional.h src/libunixonacid/ancil_recv_fd.o src/libunixonacid/ancil_recv_fd.lo: src/libunixonacid/ancil_recv_fd.c src/include/skalibs/allreadwrite.h src/include/skalibs/ancil.h src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/posixishard.h src/include/skalibs/sysdeps.h diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h @@ -6,10 +6,10 @@ #include <sys/types.h> #include <sys/uio.h> #include <sys/wait.h> + #include <skalibs/gccattributes.h> #include <skalibs/stralloc.h> -#include <skalibs/envalloc.h> -#include <skalibs/posixplz.h> +#include <skalibs/exec.h> /* compat */ #define DJBUNIX_FLAG_NB 0x01U #define DJBUNIX_FLAG_COE 0x02U @@ -64,24 +64,6 @@ extern int socketpair_internal (int, int, int, unsigned int, int *) ; extern size_t path_canonicalize (char *, char const *, int) ; -extern int pathexec_env (char const *, char const *) ; -extern void pathexec_r (char const *const *, char const *const *, size_t, char const *, size_t) ; -extern void pathexec_r_name (char const *, char const *const *, char const *const *, size_t, char const *, size_t) ; -extern void pathexec_fromenv (char const *const *, char const *const *, size_t) ; -extern void pathexec_run (char const *, char const *const *, char const *const *) ; -extern void pathexec0_run (char const *const *, char const *const *) ; -extern void pathexec (char const *const *) ; -extern void pathexec0 (char const *const *) ; - -extern void xpathexec_r (char const *const *, char const *const *, size_t, char const *, size_t) gccattr_noreturn ; -extern void xpathexec_r_name (char const *, char const *const *, char const *const *, size_t, char const *, size_t) gccattr_noreturn ; -extern void xpathexec_fromenv (char const *const *, char const *const *, size_t) gccattr_noreturn ; -extern void xexecvep (char const *, char const *const *, char const *const *, char const *) gccattr_noreturn ; -extern void xpathexec_run (char const *, char const *const *, char const *const *) gccattr_noreturn ; -extern void xpathexec0_run (char const *const *, char const *const *) gccattr_noreturn ; -extern void xpathexec (char const *const *) gccattr_noreturn ; -extern void xpathexec0 (char const *const *) gccattr_noreturn ; - extern pid_t wait_nointr (int *) ; extern pid_t waitpid_nointr (pid_t, int *, int) ; #define wait_pid(pid, wstat) waitpid_nointr(pid, (wstat), 0) diff --git a/src/include/skalibs/env.h b/src/include/skalibs/env.h @@ -4,6 +4,7 @@ #define SKALIBS_ENV_H #include <sys/types.h> + #include <skalibs/gccattributes.h> #include <skalibs/stralloc.h> @@ -11,11 +12,16 @@ extern size_t env_len (char const *const *) gccattr_pure ; extern char const *env_get (char const *) gccattr_deprecated ; extern char const *env_get2 (char const *const *, char const *) gccattr_pure ; extern char const *ucspi_get (char const *) gccattr_pure ; + extern int env_addmodif (stralloc *, char const *, char const *) ; extern int env_make (char const **, size_t, char const *, size_t) ; -extern size_t env_merge (char const **, size_t, char const *const *, size_t, char const *, size_t) ; extern int env_string (stralloc *, char const *const *, size_t) ; +extern size_t env_mergen (char const **, size_t, char const *const *, size_t, char const *, size_t, size_t) ; +extern size_t env_merge (char const **, size_t, char const *const *, size_t, char const *, size_t) ; +extern size_t env_mergn (char const **, size_t, char const *const *, char const *, size_t, size_t) ; +extern size_t env_merg (char const **, size_t, char const *const *, char const *, size_t) ; + #define SKALIBS_ENVDIR_VERBATIM 0x01 #define SKALIBS_ENVDIR_NOCHOMP 0x02 extern int envdir_internal (char const *, stralloc *, unsigned int, char) ; diff --git a/src/include/skalibs/exec.h b/src/include/skalibs/exec.h @@ -0,0 +1,160 @@ +/* ISC license. */ + +#ifndef SKALIBS_EXEC_H +#define SKALIBS_EXEC_H + +#include <stddef.h> + +#include <skalibs/environ.h> +#include <skalibs/env.h> +#include <skalibs/gccattributes.h> + + + /* Without environment modifications */ + +extern void xexecvep (char const *, char const *const *, char const *const *, char const *) gccattr_noreturn ; +extern void xexecvep_loose (char const *, char const *const *, char const *const *, char const *) gccattr_noreturn ; + +extern void exec_ae (char const *, char const *const *, char const *const *) ; +#define exec_a(file, argv) exec_ae(file, (argv), (char const *const *)environ) +#define exec_e(argv, envp) exec_ae((argv)[0], (argv), envp) +#define exec(argv) exec_a((argv)[0], (argv)) + +extern void xexec_ae (char const *, char const *const *, char const *const *) gccattr_noreturn ; +#define xexec_a(file, argv) xexec_ae(file, (argv), (char const *const *)environ) +#define xexec_e(argv, envp) xexec_ae((argv)[0], (argv), envp) +#define xexec(argv) xexec_a((argv)[0], (argv)) + +extern void exec0_ae (char const *, char const *const *, char const *const *) ; +#define exec0_a(file, argv) exec0_ae(file, (argv), (char const *const *)environ) +#define exec0_e(argv, envp) exec0_ae((argv)[0], (argv), envp) +#define exec0(argv) exec0_a((argv)[0], (argv)) + +extern void xexec0_ae (char const *, char const *const *, char const *const *) gccattr_noreturn ; +#define xexec0_a(file, argv) xexec0_ae(file, (argv), (char const *const *)environ) +#define xexec0_e(argv, envp) xexec0_ae((argv)[0], (argv), envp) +#define xexec0(argv) xexec0_a((argv)[0], (argv)) + + + /* With environment modifications : env_merge and exec */ + +extern int env_mexec (char const *, char const *) ; + +extern void mexec_afn (char const *, char const *const *, char const *const *, size_t, char const *, size_t, size_t) ; +extern void mexec_afm (char const *, char const *const *, char const *const *, size_t, char const *, size_t) ; +extern void mexec_af (char const *, char const *const *, char const *const *, size_t) ; + +#define mexec_aen(file, argv, envp, modif, modiflen, modifn) mexec_afn(file, argv, envp, env_len(envp), modif, modiflen, modifn) +#define mexec_aem(file, argv, envp, modif, modiflen) mexec_afm(file, argv, envp, env_len(envp), modif, modiflen) +#define mexec_ae(file, argv, envp) mexec_af(file, argv, envp, env_len(envp)) + +#define mexec_an(file, argv, modif, modiflen, modifn) mexec_aen(file, argv, (char const *const *)environ, modif, modiflen, modifn) +#define mexec_am(file, argv, modif, modiflen) mexec_aem(file, argv, (char const *const *)environ, modif, modiflen) +#define mexec_a(file, argv) mexec_ae(file, argv, (char const *const *)environ) + +#define mexec_fn(argv, envp, envlen, modif, modiflen, modifn) mexec_afn((argv)[0], (argv), envp, envlen, modif, modiflen, modifn) +#define mexec_fm(argv, envp, envlen, modif, modiflen) mexec_afm((argv)[0], (argv), envp, envlen, modif, modiflen) +#define mexec_f(argv, envp, envlen) mexec_af((argv)[0], (argv), envp, envlen) + +#define mexec_en(argv, envp, modif, modiflen, modifn) mexec_aen((argv)[0], (argv), envp, modif, modiflen, modifn) +#define mexec_em(argv, envp, modif, modiflen) mexec_aem((argv)[0], (argv), envp, modif, modiflen) +#define mexec_e(argv, envp) mexec_a((argv)[0], (argv), envp) + +#define mexec_n(argv, modif, modiflen, modifn) mexec_an((argv)[0], (argv), modif, modiflen, modifn) +#define mexec_m(argv, modif, modiflen) mexec_am((argv)[0], (argv), modif, modiflen) +#define mexec(argv) mexec_a((argv)[0], (argv)) + +extern void mexec0_afn (char const *, char const *const *, char const *const *, size_t, char const *, size_t, size_t) ; +extern void mexec0_afm (char const *, char const *const *, char const *const *, size_t, char const *, size_t) ; +extern void mexec0_af (char const *, char const *const *, char const *const *, size_t) ; + +#define mexec0_aen(file, argv, envp, modif, modiflen, modifn) mexec0_afn(file, argv, envp, env_len(envp), modif, modiflen, modifn) +#define mexec0_aem(file, argv, envp, modif, modiflen) mexec0_afm(file, argv, envp, env_len(envp), modif, modiflen) +#define mexec0_ae(file, argv, envp) mexec0_af(file, argv, envp, env_len(envp)) + +#define mexec0_an(file, argv, modif, modiflen, modifn) mexec0_aen(file, argv, (char const *const *)environ, modif, modiflen, modifn) +#define mexec0_am(file, argv, modif, modiflen) mexec0_aem(file, argv, (char const *const *)environ, modif, modiflen) +#define mexec0_a(file, argv) mexec0_ae(file, argv, (char const *const *)environ) + +#define mexec0_fn(argv, envp, envlen, modif, modiflen, modifn) mexec0_afn((argv)[0], (argv), envp, envlen, modif, modiflen, modifn) +#define mexec0_fm(argv, envp, envlen, modif, modiflen) mexec0_afm((argv)[0], (argv), envp, envlen, modif, modiflen) +#define mexec0_f(argv, envp, envlen) mexec0_af((argv)[0], (argv), envp, envlen) + +#define mexec0_en(argv, envp, modif, modiflen, modifn) mexec0_aen((argv)[0], (argv), envp, modif, modiflen, modifn) +#define mexec0_em(argv, envp, modif, modiflen) mexec0_aem((argv)[0], (argv), envp, modif, modiflen) +#define mexec0_e(argv, envp) mexec0_a((argv)[0], (argv), envp) + +#define mexec0_n(argv, modif, modiflen, modifn) mexec0_an((argv)[0], (argv), modif, modiflen, modifn) +#define mexec0_m(argv, modif, modiflen) mexec0_am((argv)[0], (argv), modif, modiflen) +#define mexec0(argv) mexec0_a((argv)[0], (argv)) + +extern void xmexec_afn (char const *, char const *const *, char const *const *, size_t, char const *, size_t, size_t) gccattr_noreturn ; +extern void xmexec_afm (char const *, char const *const *, char const *const *, size_t, char const *, size_t) gccattr_noreturn ; +extern void xmexec_af (char const *, char const *const *, char const *const *, size_t) gccattr_noreturn ; + +#define xmexec_aen(file, argv, envp, modif, modiflen, modifn) xmexec_afn(file, argv, envp, env_len(envp), modif, modiflen, modifn) +#define xmexec_aem(file, argv, envp, modif, modiflen) xmexec_afm(file, argv, envp, env_len(envp), modif, modiflen) +#define xmexec_ae(file, argv, envp) xmexec_af(file, argv, envp, env_len(envp)) + +#define xmexec_an(file, argv, modif, modiflen, modifn) xmexec_aen(file, argv, (char const *const *)environ, modif, modiflen, modifn) +#define xmexec_am(file, argv, modif, modiflen) xmexec_aem(file, argv, (char const *const *)environ, modif, modiflen) +#define xmexec_a(file, argv) xmexec_ae(file, argv, (char const *const *)environ) + +#define xmexec_fn(argv, envp, envlen, modif, modiflen, modifn) xmexec_afn((argv)[0], (argv), envp, envlen, modif, modiflen, modifn) +#define xmexec_fm(argv, envp, envlen, modif, modiflen) xmexec_afm((argv)[0], (argv), envp, envlen, modif, modiflen) +#define xmexec_f(argv, envp, envlen) xmexec_af((argv)[0], (argv), envp, envlen) + +#define xmexec_en(argv, envp, modif, modiflen, modifn) xmexec_aen((argv)[0], (argv), envp, modif, modiflen, modifn) +#define xmexec_em(argv, envp, modif, modiflen) xmexec_aem((argv)[0], (argv), envp, modif, modiflen) +#define xmexec_e(argv, envp) xmexec_a((argv)[0], (argv), envp) + +#define xmexec_n(argv, modif, modiflen, modifn) xmexec_an((argv)[0], (argv), modif, modiflen, modifn) +#define xmexec_m(argv, modif, modiflen) xmexec_am((argv)[0], (argv), modif, modiflen) +#define xmexec(argv) xmexec_a((argv)[0], (argv)) + +extern void xmexec0_afn (char const *, char const *const *, char const *const *, size_t, char const *, size_t, size_t) ; +extern void xmexec0_afm (char const *, char const *const *, char const *const *, size_t, char const *, size_t) ; +extern void xmexec0_af (char const *, char const *const *, char const *const *, size_t) ; + +#define xmexec0_aen(file, argv, envp, modif, modiflen, modifn) xmexec0_afn(file, argv, envp, env_len(envp), modif, modiflen, modifn) +#define xmexec0_aem(file, argv, envp, modif, modiflen) xmexec0_afm(file, argv, envp, env_len(envp), modif, modiflen) +#define xmexec0_ae(file, argv, envp) xmexec0_af(file, argv, envp, env_len(envp)) + +#define xmexec0_an(file, argv, modif, modiflen, modifn) xmexec0_aen(file, argv, (char const *const *)environ, modif, modiflen, modifn) +#define xmexec0_am(file, argv, modif, modiflen) xmexec0_aem(file, argv, (char const *const *)environ, modif, modiflen) +#define xmexec0_a(file, argv) xmexec0_ae(file, argv, (char const *const *)environ) + +#define xmexec0_fn(argv, envp, envlen, modif, modiflen, modifn) xmexec0_afn((argv)[0], (argv), envp, envlen, modif, modiflen, modifn) +#define xmexec0_fm(argv, envp, envlen, modif, modiflen) xmexec0_afm((argv)[0], (argv), envp, envlen, modif, modiflen) +#define xmexec0_f(argv, envp, envlen) xmexec0_af((argv)[0], (argv), envp, envlen) + +#define xmexec0_en(argv, envp, modif, modiflen, modifn) xmexec0_aen((argv)[0], (argv), envp, modif, modiflen, modifn) +#define xmexec0_em(argv, envp, modif, modiflen) xmexec0_aem((argv)[0], (argv), envp, modif, modiflen) +#define xmexec0_e(argv, envp) xmexec0_a((argv)[0], (argv), envp) + +#define xmexec0_n(argv, modif, modiflen, modifn) xmexec0_an((argv)[0], (argv), modif, modiflen, modifn) +#define xmexec0_m(argv, modif, modiflen) xmexec0_am((argv)[0], (argv), modif, modiflen) +#define xmexec0(argv) xmexec0_a((argv)[0], (argv)) + + + /* Compatibility */ + +#define pathexec_run(file, argv, envp) exec_ae(file, argv, envp) +#define pathexec0_run(file, argv, envp) exec0_ae(file, argv, envp) +#define xpathexec_run(file, argv, envp) xexec_ae(file, argv, envp) +#define xpathexec0_run(file, argv, envp) xexec0_ae(file, argv, envp) + +#define pathexec_env(key, value) env_mexec(key, value) +#define pathexec_fromenv(argv, envp, envlen) mexec_f(argv, envp, envlen) +#define pathexec(argv) mexec(argv) +#define pathexec0(argv) mexec0(argv) +#define xpathexec_fromenv(argv, envp, envlen) xmexec_f(argv, envp, envlen) +#define xpathexec(argv) xmexec(argv) +#define xpathexec0(argv) xmexec0(argv) + +#define pathexec_r_name(file, argv, envp, envlen, modif, modiflen) mexec_afm(file, argv, envp, envlen, modif, modiflen) +#define pathexec_r(argv, envp, envlen, modif, modiflen) mexec_fm(argv, envp, envlen, modif, modiflen) +#define xpathexec_r_name(file, argv, envp, envlen, modif, modiflen) xmexec_afm(file, argv, envp, envlen, modif, modiflen) +#define xpathexec_r(argv, envp, envlen, modif, modiflen) xmexec_fm(argv, envp, envlen, modif, modiflen) + +#endif diff --git a/src/include/skalibs/stddjb.h b/src/include/skalibs/stddjb.h @@ -28,6 +28,7 @@ #include <skalibs/djbunix.h> #include <skalibs/envalloc.h> #include <skalibs/env.h> +#include <skalibs/exec.h> #include <skalibs/fmtscan.h> #include <skalibs/functypes.h> #include <skalibs/gccattributes.h> diff --git a/src/libstddjb/env_addmodif.c b/src/libenvexec/env_addmodif.c diff --git a/src/libstddjb/env_dump.c b/src/libenvexec/env_dump.c diff --git a/src/libstddjb/env_get.c b/src/libenvexec/env_get.c diff --git a/src/libstddjb/env_get2.c b/src/libenvexec/env_get2.c diff --git a/src/libstddjb/env_len.c b/src/libenvexec/env_len.c diff --git a/src/libstddjb/env_make.c b/src/libenvexec/env_make.c diff --git a/src/libenvexec/env_merg.c b/src/libenvexec/env_merg.c @@ -0,0 +1,8 @@ +/* ISC license. */ + +#include <skalibs/env.h> + +size_t env_merg (char const **v, size_t vmax, char const *const *envp, char const *modifs, size_t modiflen) +{ + return env_merge(v, vmax, envp, env_len(envp), modifs, modiflen) ; +} diff --git a/src/libenvexec/env_merge.c b/src/libenvexec/env_merge.c @@ -0,0 +1,9 @@ +/* ISC license. */ + +#include <skalibs/bytestr.h> +#include <skalibs/env.h> + +size_t env_merge (char const **v, size_t vmax, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) +{ + return env_mergen(v, vmax, envp, envlen, modifs, modiflen, byte_count(modifs, modiflen, '\0')) ; +} diff --git a/src/libenvexec/env_mergen.c b/src/libenvexec/env_mergen.c @@ -0,0 +1,26 @@ +/* ISC license. */ + +#include <string.h> +#include <errno.h> + +#include <skalibs/bytestr.h> +#include <skalibs/env.h> + +size_t env_mergen (char const **v, size_t vmax, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen, size_t n) +{ + size_t vlen = envlen ; + size_t i = 0 ; + if (envlen + n + 1 > vmax) return (errno = ENAMETOOLONG, 0) ; + for (; i < envlen ; i++) v[i] = envp[i] ; + for (i = 0 ; i < modiflen ; i += strlen(modifs + i) + 1) + { + size_t split = str_chr(modifs + i, '=') ; + size_t j = 0 ; + for (; j < vlen ; j++) + if (!strncmp(modifs + i, v[j], split) && (v[j][split] == '=')) break ; + if (j < vlen) v[j] = v[--vlen] ; + if (modifs[i + split]) v[vlen++] = modifs + i ; + } + v[vlen++] = 0 ; + return vlen ; +} diff --git a/src/libenvexec/env_mergn.c b/src/libenvexec/env_mergn.c @@ -0,0 +1,8 @@ +/* ISC license. */ + +#include <skalibs/env.h> + +size_t env_mergn (char const **v, size_t vmax, char const *const *envp, char const *modifs, size_t modiflen, size_t modifn) +{ + return env_mergen(v, vmax, envp, env_len(envp), modifs, modiflen, modifn) ; +} diff --git a/src/libstddjb/env_string.c b/src/libenvexec/env_string.c diff --git a/src/libstddjb/envalloc_0.c b/src/libenvexec/envalloc_0.c diff --git a/src/libstddjb/envalloc_make.c b/src/libenvexec/envalloc_make.c diff --git a/src/libenvexec/envalloc_merge.c b/src/libenvexec/envalloc_merge.c @@ -0,0 +1,15 @@ +/* ISC license. */ + +#include <skalibs/bytestr.h> +#include <skalibs/env.h> +#include <skalibs/genalloc.h> +#include <skalibs/envalloc.h> + +int envalloc_merge (genalloc *v, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) +{ + size_t n = envlen + 1 + byte_count(modifs, modiflen, '\0') ; + if (!genalloc_readyplus(char const *, v, n)) return 0 ; + n = env_mergen(genalloc_s(char const *, v) + genalloc_len(char const *, v), n, envp, envlen, modifs, modiflen, n) ; + genalloc_setlen(char const *, v, genalloc_len(char const *, v) + n) ; + return 1 ; +} diff --git a/src/libstddjb/envalloc_uniq.c b/src/libenvexec/envalloc_uniq.c diff --git a/src/libstddjb/envdir.c b/src/libenvexec/envdir.c diff --git a/src/libenvexec/exec0_ae.c b/src/libenvexec/exec0_ae.c @@ -0,0 +1,11 @@ +/* ISC license. */ + +#include <unistd.h> + +#include <skalibs/exec.h> + +void exec0_ae (char const *file, char const *const *argv, char const *const *envp) +{ + if (!argv[0]) _exit(0) ; + exec_ae(file, argv, envp) ; +} diff --git a/src/libenvexec/exec_ae.c b/src/libenvexec/exec_ae.c @@ -0,0 +1,14 @@ +/* ISC license. */ + +#include <stdlib.h> + +#include <skalibs/config.h> +#include <skalibs/posixplz.h> +#include <skalibs/exec.h> + +void exec_ae (char const *file, char const *const *argv, char const *const *envp) +{ + char const *path = getenv("PATH") ; + if (!path) path = SKALIBS_DEFAULTPATH ; + execvep(file, argv, envp, path) ; +} diff --git a/src/libenvexec/mexec0_af.c b/src/libenvexec/mexec0_af.c @@ -0,0 +1,11 @@ +/* ISC license. */ + +#include <unistd.h> + +#include <skalibs/exec.h> + +void mexec0_af (char const *file, char const *const *argv, char const *const *envp, size_t envlen) +{ + if (!argv[0]) _exit(0) ; + mexec_af(file, argv, envp, envlen) ; +} diff --git a/src/libenvexec/mexec0_afm.c b/src/libenvexec/mexec0_afm.c @@ -0,0 +1,11 @@ +/* ISC license. */ + +#include <unistd.h> + +#include <skalibs/exec.h> + +void mexec0_afm (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen) +{ + if (!argv[0]) _exit(0) ; + mexec_afm(file, argv, envp, envlen, modif, modiflen) ; +} diff --git a/src/libenvexec/mexec0_afn.c b/src/libenvexec/mexec0_afn.c @@ -0,0 +1,11 @@ +/* ISC license. */ + +#include <unistd.h> + +#include <skalibs/exec.h> + +void mexec0_afn (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen, size_t modifn) +{ + if (!argv[0]) _exit(0) ; + mexec_afn(file, argv, envp, envlen, modif, modiflen, modifn) ; +} diff --git a/src/libenvexec/mexec_af.c b/src/libenvexec/mexec_af.c @@ -0,0 +1,17 @@ +/* ISC license. */ + +#include <skalibs/stralloc.h> +#include <skalibs/env.h> +#include <skalibs/exec.h> + +static stralloc modifsa = STRALLOC_ZERO ; + +int env_mexec (char const *key, char const *value) +{ + return env_addmodif(&modifsa, key, value) ; +} + +void mexec_af (char const *file, char const *const *argv, char const *const *envp, size_t envlen) +{ + mexec_afm(file, argv, envp, envlen, modifsa.s, modifsa.len) ; +} diff --git a/src/libenvexec/mexec_afm.c b/src/libenvexec/mexec_afm.c @@ -0,0 +1,9 @@ +/* ISC license. */ + +#include <skalibs/bytestr.h> +#include <skalibs/exec.h> + +void mexec_afm (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen) +{ + mexec_afn(file, argv, envp, envlen, modif, modiflen, byte_count(modif, modiflen, '\0')) ; +} diff --git a/src/libenvexec/mexec_afn.c b/src/libenvexec/mexec_afn.c @@ -0,0 +1,11 @@ +/* ISC license. */ + +#include <skalibs/env.h> +#include <skalibs/exec.h> + +void mexec_afn (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen, size_t modifn) +{ + char const *newenvp[envlen + modifn + 1] ; + env_mergen(newenvp, envlen + modifn + 1, envp, envlen, modif, modiflen, modifn) ; + exec_ae(file, argv, newenvp) ; +} diff --git a/src/libenvexec/xexec0_ae.c b/src/libenvexec/xexec0_ae.c @@ -0,0 +1,11 @@ +/* ISC license. */ + +#include <unistd.h> + +#include <skalibs/exec.h> + +void xexec0_ae (char const *file, char const *const *argv, char const *const *envp) +{ + if (!argv[0]) _exit(0) ; + xexec_ae(file, argv, envp) ; +} diff --git a/src/libenvexec/xexec_ae.c b/src/libenvexec/xexec_ae.c @@ -0,0 +1,12 @@ +/* ISC license. */ + +#include <errno.h> + +#include <skalibs/exec.h> +#include <skalibs/strerr2.h> + +void xexec_ae (char const *file, char const *const *argv, char const *const *envp) +{ + exec_ae(file, argv, envp) ; + strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; +} diff --git a/src/libenvexec/xexecvep.c b/src/libenvexec/xexecvep.c @@ -0,0 +1,13 @@ +/* ISC license. */ + +#include <errno.h> + +#include <skalibs/posixplz.h> +#include <skalibs/strerr2.h> +#include <skalibs/exec.h> + +void xexecvep (char const *file, char const *const *argv, char const *const *envp, char const *path) +{ + execvep(file, argv, envp, path) ; + strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; +} diff --git a/src/libenvexec/xexecvep_loose.c b/src/libenvexec/xexecvep_loose.c @@ -0,0 +1,13 @@ +/* ISC license. */ + +#include <errno.h> + +#include <skalibs/posixplz.h> +#include <skalibs/strerr2.h> +#include <skalibs/exec.h> + +void xexecvep_loose (char const *file, char const *const *argv, char const *const *envp, char const *path) +{ + xexecvep_loose(file, argv, envp, path) ; + strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; +} diff --git a/src/libenvexec/xmexec0_af.c b/src/libenvexec/xmexec0_af.c @@ -0,0 +1,12 @@ +/* ISC license. */ + +#include <errno.h> + +#include <skalibs/exec.h> +#include <skalibs/strerr2.h> + +void xmexec0_af (char const *file, char const *const *argv, char const *const *envp, size_t envlen) +{ + xmexec0_af(file, argv, envp, envlen) ; + strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; +} diff --git a/src/libenvexec/xmexec0_afm.c b/src/libenvexec/xmexec0_afm.c @@ -0,0 +1,12 @@ +/* ISC license. */ + +#include <errno.h> + +#include <skalibs/exec.h> +#include <skalibs/strerr2.h> + +void xmexec0_afm (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen) +{ + mexec0_afm(file, argv, envp, envlen, modif, modiflen) ; + strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; +} diff --git a/src/libenvexec/xmexec0_afn.c b/src/libenvexec/xmexec0_afn.c @@ -0,0 +1,12 @@ +/* ISC license. */ + +#include <errno.h> + +#include <skalibs/exec.h> +#include <skalibs/strerr2.h> + +void xmexec0_afn (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen, size_t modifn) +{ + mexec0_afn(file, argv, envp, envlen, modif, modiflen, modifn) ; + strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; +} diff --git a/src/libenvexec/xmexec_af.c b/src/libenvexec/xmexec_af.c @@ -0,0 +1,12 @@ +/* ISC license. */ + +#include <errno.h> + +#include <skalibs/exec.h> +#include <skalibs/strerr2.h> + +void xmexec_af (char const *file, char const *const *argv, char const *const *envp, size_t envlen) +{ + xmexec_af(file, argv, envp, envlen) ; + strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; +} diff --git a/src/libenvexec/xmexec_afm.c b/src/libenvexec/xmexec_afm.c @@ -0,0 +1,12 @@ +/* ISC license. */ + +#include <errno.h> + +#include <skalibs/exec.h> +#include <skalibs/strerr2.h> + +void xmexec_afm (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen) +{ + mexec_afm(file, argv, envp, envlen, modif, modiflen) ; + strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; +} diff --git a/src/libenvexec/xmexec_afn.c b/src/libenvexec/xmexec_afn.c @@ -0,0 +1,12 @@ +/* ISC license. */ + +#include <errno.h> + +#include <skalibs/exec.h> +#include <skalibs/strerr2.h> + +void xmexec_afn (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modif, size_t modiflen, size_t modifn) +{ + mexec_afn(file, argv, envp, envlen, modif, modiflen, modifn) ; + strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; +} diff --git a/src/libstddjb/env_merge.c b/src/libstddjb/env_merge.c @@ -1,26 +0,0 @@ -/* ISC license. */ - -#include <string.h> -#include <errno.h> -#include <skalibs/bytestr.h> -#include <skalibs/env.h> - -size_t env_merge (char const **v, size_t vmax, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) -{ - size_t n = byte_count(modifs, modiflen, '\0') ; - size_t vlen = envlen ; - size_t i = 0 ; - if (envlen + n + 1 > vmax) return (errno = ENAMETOOLONG, 0) ; - for (; i < envlen ; i++) v[i] = envp[i] ; - for (i = 0 ; i < modiflen ; i += strlen(modifs + i) + 1) - { - size_t split = str_chr(modifs + i, '=') ; - size_t j = 0 ; - for (; j < vlen ; j++) - if (!strncmp(modifs + i, v[j], split) && (v[j][split] == '=')) break ; - if (j < vlen) v[j] = v[--vlen] ; - if (modifs[i + split]) v[vlen++] = modifs + i ; - } - v[vlen++] = 0 ; - return vlen ; -} diff --git a/src/libstddjb/envalloc_merge.c b/src/libstddjb/envalloc_merge.c @@ -1,15 +0,0 @@ -/* ISC license. */ - -#include <skalibs/bytestr.h> -#include <skalibs/env.h> -#include <skalibs/genalloc.h> -#include <skalibs/envalloc.h> - -int envalloc_merge (genalloc *v, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) -{ - size_t n = envlen + 1 + byte_count(modifs, modiflen, '\0') ; - if (!genalloc_readyplus(char const *, v, n)) return 0 ; - n = env_merge(genalloc_s(char const *, v) + genalloc_len(char const *, v), n, envp, envlen, modifs, modiflen) ; - genalloc_setlen(char const *, v, genalloc_len(char const *, v) + n) ; - return 1 ; -} diff --git a/src/libstddjb/pathexec.c b/src/libstddjb/pathexec.c @@ -1,12 +0,0 @@ -/* ISC license. */ - -/* MT-unsafe */ - -#include <skalibs/env.h> -#include <skalibs/djbunix.h> -#include <skalibs/posixplz.h> - -void pathexec (char const *const *argv) -{ - pathexec_fromenv(argv, (char const **)environ, env_len((char const **)environ)) ; -} diff --git a/src/libstddjb/pathexec0.c b/src/libstddjb/pathexec0.c @@ -1,10 +0,0 @@ -/* ISC license. */ - -#include <unistd.h> -#include <skalibs/djbunix.h> - -void pathexec0 (char const *const *argv) -{ - if (!argv[0]) _exit(0) ; - pathexec(argv) ; -} diff --git a/src/libstddjb/pathexec0_run.c b/src/libstddjb/pathexec0_run.c @@ -1,10 +0,0 @@ -/* ISC license. */ - -#include <unistd.h> -#include <skalibs/djbunix.h> - -void pathexec0_run (char const *const *argv, char const *const *envp) -{ - if (!argv[0]) _exit(0) ; - pathexec_run(argv[0], argv, envp) ; -} diff --git a/src/libstddjb/pathexec_fromenv.c b/src/libstddjb/pathexec_fromenv.c @@ -1,17 +0,0 @@ -/* ISC license. */ - -#include <skalibs/stralloc.h> -#include <skalibs/env.h> -#include <skalibs/djbunix.h> - -static stralloc plus = STRALLOC_ZERO ; - -int pathexec_env (char const *s, char const *t) /* historic, bad name */ -{ - return env_addmodif(&plus, s, t) ; -} - -void pathexec_fromenv (char const *const *argv, char const *const *envp, size_t envlen) -{ - pathexec_r(argv, envp, envlen, plus.s, plus.len) ; -} diff --git a/src/libstddjb/pathexec_r.c b/src/libstddjb/pathexec_r.c @@ -1,8 +0,0 @@ -/* ISC license. */ - -#include <skalibs/djbunix.h> - -void pathexec_r (char const *const *argv, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) -{ - pathexec_r_name(argv[0], argv, envp, envlen, modifs, modiflen) ; -} diff --git a/src/libstddjb/pathexec_r_name.c b/src/libstddjb/pathexec_r_name.c @@ -1,13 +0,0 @@ -/* ISC license. */ - -#include <skalibs/bytestr.h> -#include <skalibs/env.h> -#include <skalibs/djbunix.h> - -void pathexec_r_name (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) -{ - size_t n = envlen + 1 + byte_count(modifs, modiflen, '\0') ; - char const *v[n] ; - if (env_merge(v, n, envp, envlen, modifs, modiflen)) - pathexec_run(file, argv, v) ; -} diff --git a/src/libstddjb/pathexec_run.c b/src/libstddjb/pathexec_run.c @@ -1,13 +0,0 @@ -/* ISC license. */ - -#include <stdlib.h> -#include <skalibs/config.h> -#include <skalibs/posixplz.h> -#include <skalibs/djbunix.h> - -void pathexec_run (char const *file, char const *const *argv, char const *const *envp) -{ - char const *path = getenv("PATH") ; - if (!path) path = SKALIBS_DEFAULTPATH ; - execvep(file, argv, envp, path) ; -} diff --git a/src/libstddjb/xexecvep.c b/src/libstddjb/xexecvep.c @@ -1,12 +0,0 @@ -/* ISC license. */ - -#include <errno.h> -#include <skalibs/posixplz.h> -#include <skalibs/djbunix.h> -#include <skalibs/strerr2.h> - -void xexecvep (char const *file, char const *const *argv, char const *const *envp, char const *path) -{ - execvep(file, argv, envp, path) ; - strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; -} diff --git a/src/libstddjb/xpathexec.c b/src/libstddjb/xpathexec.c @@ -1,12 +0,0 @@ -/* ISC license. */ - -#include <errno.h> - -#include <skalibs/djbunix.h> -#include <skalibs/strerr2.h> - -void xpathexec (char const *const *argv) -{ - pathexec(argv) ; - strerr_dieexec(errno == ENOENT ? 127 : 126, argv[0]) ; -} diff --git a/src/libstddjb/xpathexec0.c b/src/libstddjb/xpathexec0.c @@ -1,12 +0,0 @@ -/* ISC license. */ - -#include <errno.h> - -#include <skalibs/djbunix.h> -#include <skalibs/strerr2.h> - -void xpathexec0 (char const *const *argv) -{ - pathexec0(argv) ; - strerr_dieexec(errno == ENOENT ? 127 : 126, argv[0]) ; -} diff --git a/src/libstddjb/xpathexec0_run.c b/src/libstddjb/xpathexec0_run.c @@ -1,12 +0,0 @@ -/* ISC license. */ - -#include <errno.h> - -#include <skalibs/djbunix.h> -#include <skalibs/strerr2.h> - -void xpathexec0_run (char const *const *argv, char const *const *envp) -{ - pathexec0_run(argv, envp) ; - strerr_dieexec(errno == ENOENT ? 127 : 126, argv[0]) ; -} diff --git a/src/libstddjb/xpathexec_fromenv.c b/src/libstddjb/xpathexec_fromenv.c @@ -1,12 +0,0 @@ -/* ISC license. */ - -#include <errno.h> - -#include <skalibs/djbunix.h> -#include <skalibs/strerr2.h> - -void xpathexec_fromenv (char const *const *argv, char const *const *envp, size_t envlen) -{ - pathexec_fromenv(argv, envp, envlen) ; - strerr_dieexec(errno == ENOENT ? 127 : 126, argv[0]) ; -} diff --git a/src/libstddjb/xpathexec_r.c b/src/libstddjb/xpathexec_r.c @@ -1,12 +0,0 @@ -/* ISC license. */ - -#include <errno.h> - -#include <skalibs/djbunix.h> -#include <skalibs/strerr2.h> - -void xpathexec_r (char const *const *argv, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) -{ - pathexec_r(argv, envp, envlen, modifs, modiflen) ; - strerr_dieexec(errno == ENOENT ? 127 : 126, argv[0]) ; -} diff --git a/src/libstddjb/xpathexec_r_name.c b/src/libstddjb/xpathexec_r_name.c @@ -1,12 +0,0 @@ -/* ISC license. */ - -#include <errno.h> - -#include <skalibs/djbunix.h> -#include <skalibs/strerr2.h> - -void xpathexec_r_name (char const *file, char const *const *argv, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) -{ - pathexec_r_name(file, argv, envp, envlen, modifs, modiflen) ; - strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; -} diff --git a/src/libstddjb/xpathexec_run.c b/src/libstddjb/xpathexec_run.c @@ -1,12 +0,0 @@ -/* ISC license. */ - -#include <errno.h> - -#include <skalibs/djbunix.h> -#include <skalibs/strerr2.h> - -void xpathexec_run (char const *file, char const *const *argv, char const *const *envp) -{ - pathexec_run(file, argv, envp) ; - strerr_dieexec(errno == ENOENT ? 127 : 126, file) ; -}