krebs pkgs += execve
This commit is contained in:
parent
c1aaaca7f7
commit
8827469a35
@ -1,11 +1,13 @@
|
||||
{ lib, pkgs, ... }:
|
||||
|
||||
with import ../4lib { inherit lib; };
|
||||
|
||||
let
|
||||
inherit (pkgs) callPackage;
|
||||
in
|
||||
|
||||
pkgs //
|
||||
{
|
||||
rec {
|
||||
cac = callPackage ./cac.nix {};
|
||||
dic = callPackage ./dic.nix {};
|
||||
genid = callPackage ./genid.nix {};
|
||||
@ -15,6 +17,20 @@ pkgs //
|
||||
nq = callPackage ./nq.nix {};
|
||||
posix-array = callPackage ./posix-array.nix {};
|
||||
|
||||
execve = name: { filename, argv, envp }:
|
||||
writeC name {} ''
|
||||
#include <unistd.h>
|
||||
int main () {
|
||||
const char *filename = ${toC filename};
|
||||
char *const argv[] = ${toC (argv ++ [null])};
|
||||
char *const envp[] = ${toC (
|
||||
mapAttrsToList (k: v: "${k}=${v}") envp ++ [null]
|
||||
)};
|
||||
execve(filename, argv, envp);
|
||||
return -1;
|
||||
}
|
||||
'';
|
||||
|
||||
writeC = name: {}: src: pkgs.runCommand name {} ''
|
||||
PATH=${lib.makeSearchPath "bin" (with pkgs; [
|
||||
binutils
|
||||
|
Loading…
Reference in New Issue
Block a user