mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Joseph Sible <josephcsible@gmail.com>
To: musl@lists.openwall.com
Subject: [PATCH] fexecve: implement in terms of execveat when it exists
Date: Sun, 2 Sep 2018 00:04:55 -0400	[thread overview]
Message-ID: <CABpewhEt=raW3t4PJyANcpcudd5udWewOmhynfWbJ1gUJ7ty5A@mail.gmail.com> (raw)

This lets fexecve work even when /proc isn't mounted.
---
 src/process/fexecve.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/process/fexecve.c b/src/process/fexecve.c
index 6507b42..905487e 100644
--- a/src/process/fexecve.c
+++ b/src/process/fexecve.c
@@ -1,13 +1,20 @@
+#define _GNU_SOURCE
 #include <unistd.h>
 #include <errno.h>
+#include <fcntl.h>
+#include "syscall.h"

 void __procfdname(char *, unsigned);

 int fexecve(int fd, char *const argv[], char *const envp[])
 {
+#ifdef SYS_execveat
+       return syscall(SYS_execveat, fd, "", argv, envp, AT_EMPTY_PATH);
+#else
        char buf[15 + 3*sizeof(int)];
        __procfdname(buf, fd);
        execve(buf, argv, envp);
        if (errno == ENOENT) errno = EBADF;
        return -1;
+#endif
 }
--
2.7.4


             reply	other threads:[~2018-09-02  4:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-02  4:04 Joseph Sible [this message]
2018-09-02 17:11 ` Rich Felker
2018-09-02 17:42   ` Joseph C. Sible
2018-09-04 23:30     ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABpewhEt=raW3t4PJyANcpcudd5udWewOmhynfWbJ1gUJ7ty5A@mail.gmail.com' \
    --to=josephcsible@gmail.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).