mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Make a few commands that were Unix-only no longer
Also clean up some more linux-specific (`setPersonality`) code in alignment with recent best practices.
This commit is contained in:
parent
cde0fae7d9
commit
6fa3656a32
11 changed files with 21 additions and 13 deletions
|
@ -1,18 +1,15 @@
|
|||
#include "personality.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#if __linux__
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/personality.h>
|
||||
#endif
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace nix {
|
||||
namespace nix::linux {
|
||||
|
||||
void setPersonality(std::string_view system)
|
||||
{
|
||||
#if __linux__
|
||||
/* Change the personality to 32-bit if we're doing an
|
||||
i686-linux build on an x86_64-linux machine. */
|
||||
struct utsname utsbuf;
|
||||
|
@ -39,7 +36,6 @@ void setPersonality(std::string_view system)
|
|||
determinism. */
|
||||
int cur = personality(0xffffffff);
|
||||
if (cur != -1) personality(cur | ADDR_NO_RANDOMIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
namespace nix {
|
||||
namespace nix::linux {
|
||||
|
||||
void setPersonality(std::string_view system);
|
||||
|
|
@ -8,6 +8,9 @@ libstore_SOURCES := $(wildcard $(d)/*.cc $(d)/builtins/*.cc)
|
|||
ifdef HOST_UNIX
|
||||
libstore_SOURCES += $(wildcard $(d)/unix/*.cc $(d)/unix/builtins/*.cc $(d)/unix/build/*.cc)
|
||||
endif
|
||||
ifdef HOST_LINUX
|
||||
libstore_SOURCES += $(wildcard $(d)/linux/*.cc)
|
||||
endif
|
||||
ifdef HOST_WINDOWS
|
||||
libstore_SOURCES += $(wildcard $(d)/windows/*.cc)
|
||||
endif
|
||||
|
@ -39,6 +42,9 @@ INCLUDE_libstore := -I $(d) -I $(d)/build
|
|||
ifdef HOST_UNIX
|
||||
INCLUDE_libstore += -I $(d)/unix
|
||||
endif
|
||||
ifdef HOST_LINUX
|
||||
INCLUDE_libstore += -I $(d)/linux
|
||||
endif
|
||||
ifdef HOST_WINDOWS
|
||||
INCLUDE_libstore += -I $(d)/windows
|
||||
endif
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "topo-sort.hh"
|
||||
#include "callback.hh"
|
||||
#include "json-utils.hh"
|
||||
#include "personality.hh"
|
||||
#include "current-process.hh"
|
||||
#include "child.hh"
|
||||
#include "unix-domain-socket.hh"
|
||||
|
@ -52,6 +51,7 @@
|
|||
# endif
|
||||
# define pivot_root(new_root, put_old) (syscall(SYS_pivot_root, new_root, put_old))
|
||||
# include "cgroup.hh"
|
||||
# include "personality.hh"
|
||||
#endif
|
||||
|
||||
#if __APPLE__
|
||||
|
@ -1957,7 +1957,9 @@ void LocalDerivationGoal::runChild()
|
|||
/* Close all other file descriptors. */
|
||||
closeMostFDs({STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO});
|
||||
|
||||
setPersonality(drv->platform);
|
||||
#if __linux__
|
||||
linux::setPersonality(drv->platform);
|
||||
#endif
|
||||
|
||||
/* Disable core dumps by default. */
|
||||
struct rlimit limit = { 0, RLIM_INFINITY };
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
#include "shared.hh"
|
||||
#include "store-api.hh"
|
||||
#include "derivations.hh"
|
||||
#include "local-store.hh"
|
||||
#include "local-fs-store.hh"
|
||||
#include "finally.hh"
|
||||
#include "source-accessor.hh"
|
||||
#include "progress-bar.hh"
|
||||
#include "eval.hh"
|
||||
#include "build/personality.hh"
|
||||
|
||||
#if __linux__
|
||||
#include <sys/mount.h>
|
||||
# include <sys/mount.h>
|
||||
# include "personality.hh"
|
||||
#endif
|
||||
|
||||
#include <queue>
|
||||
|
@ -56,8 +56,10 @@ void runProgramInStore(ref<Store> store,
|
|||
throw SysError("could not execute chroot helper");
|
||||
}
|
||||
|
||||
#if __linux__
|
||||
if (system)
|
||||
setPersonality(*system);
|
||||
linux::setPersonality(*system);
|
||||
#endif
|
||||
|
||||
if (useSearchPath == UseSearchPath::Use)
|
||||
execvp(program.c_str(), stringsToCharPtrs(args).data());
|
||||
|
@ -277,8 +279,10 @@ void chrootHelper(int argc, char * * argv)
|
|||
writeFile("/proc/self/uid_map", fmt("%d %d %d", uid, uid, 1));
|
||||
writeFile("/proc/self/gid_map", fmt("%d %d %d", gid, gid, 1));
|
||||
|
||||
#if __linux__
|
||||
if (system != "")
|
||||
setPersonality(system);
|
||||
linux::setPersonality(system);
|
||||
#endif
|
||||
|
||||
execvp(cmd.c_str(), stringsToCharPtrs(args).data());
|
||||
|
Loading…
Reference in a new issue