mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-09 14:40:07 +00:00
include: add fexecve() for Android's Bionic
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
6400238d08
commit
9d361e0fd4
57
src/include/fexecve.c
Normal file
57
src/include/fexecve.c
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/* liblxcapi
|
||||||
|
*
|
||||||
|
* Copyright © 2019 Christian Brauner <christian.brauner@ubuntu.com>.
|
||||||
|
* Copyright © 2019 Canonical Ltd.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this library; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
#define _GNU_SOURCE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "macro.h"
|
||||||
|
#include "raw_syscalls.h"
|
||||||
|
|
||||||
|
int fexecve(int fd, char *const argv[], char *const envp[])
|
||||||
|
{
|
||||||
|
char procfd[LXC_PROC_PID_FD_LEN];
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (fd < 0 || !argv || !envp) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __NR_execveat
|
||||||
|
lxc_raw_execveat(fd, "", argv, envp, AT_EMPTY_PATH);
|
||||||
|
if (errno != ENOSYS)
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ret = snprintf(procfd, sizeof(procfd), "/proc/self/fd/%d", fd);
|
||||||
|
if (ret < 0 || (size_t)ret >= sizeof(procfd)) {
|
||||||
|
errno = ENAMETOOLONG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
execve(procfd, argv, envp);
|
||||||
|
return -1;
|
||||||
|
}
|
27
src/include/fexecve.h
Normal file
27
src/include/fexecve.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/* liblxcapi
|
||||||
|
*
|
||||||
|
* Copyright © 2019 Christian Brauner <christian.brauner@ubuntu.com>.
|
||||||
|
* Copyright © 2019 Canonical Ltd.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this library; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LXC_FEXECVE_H
|
||||||
|
#define _LXC_FEXECVE_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
extern int fexecve(int fd, char *const argv[], char *const envp[]);
|
||||||
|
|
||||||
|
#endif /* _LXC_FEXECVE_H */
|
@ -47,7 +47,8 @@ noinst_HEADERS = api_extensions.h \
|
|||||||
utils.h
|
utils.h
|
||||||
|
|
||||||
if IS_BIONIC
|
if IS_BIONIC
|
||||||
noinst_HEADERS += ../include/lxcmntent.h \
|
noinst_HEADERS += ../include/fexecve.h \
|
||||||
|
../include/lxcmntent.h \
|
||||||
../include/openpty.h
|
../include/openpty.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -145,7 +146,8 @@ liblxc_la_SOURCES = af_unix.c af_unix.h \
|
|||||||
$(LSM_SOURCES)
|
$(LSM_SOURCES)
|
||||||
|
|
||||||
if IS_BIONIC
|
if IS_BIONIC
|
||||||
liblxc_la_SOURCES += ../include/lxcmntent.c ../include/lxcmntent.h \
|
liblxc_la_SOURCES += ../include/fexecve.c ../include/fexecve.h \
|
||||||
|
../include/lxcmntent.c ../include/lxcmntent.h \
|
||||||
../include/openpty.c ../include/openpty.h
|
../include/openpty.c ../include/openpty.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -31,6 +31,10 @@
|
|||||||
#include "string_utils.h"
|
#include "string_utils.h"
|
||||||
#include "syscall_wrappers.h"
|
#include "syscall_wrappers.h"
|
||||||
|
|
||||||
|
#if IS_BIONIC
|
||||||
|
#include "../include/fexecve.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LXC_MEMFD_REXEC_SEALS \
|
#define LXC_MEMFD_REXEC_SEALS \
|
||||||
(F_SEAL_SEAL | F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE)
|
(F_SEAL_SEAL | F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user