Last active
October 29, 2025 06:21
-
-
Save hraban/3a24019bfa633c3b3ec1d87154807c68 to your computer and use it in GitHub Desktop.
testing execve
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *.o | |
| execve | |
| execv | |
| # autoconf | |
| .deps | |
| Makefile | |
| Makefile.in | |
| aclocal.m4 | |
| *.cache | |
| compile | |
| config.* | |
| configure | |
| depcomp | |
| install-sh | |
| missing | |
| stamp-h1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AC_INIT([hraban], [1.0], [[email protected]]) | |
| AM_INIT_AUTOMAKE([-Wall -Werror foreign]) | |
| AC_PROG_CC | |
| AC_CONFIG_HEADERS([config.h]) | |
| AC_CONFIG_FILES([Makefile]) | |
| AC_OUTPUT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { pkgs ? import <nixpkgs> {} }: | |
| pkgs.stdenv.mkDerivation { | |
| name = "execvetest"; | |
| src = ./.; | |
| postPatch = '' | |
| sed -i -e 's@/usr/bin/env@${pkgs.coreutils}/bin/env@' *.c | |
| ''; | |
| nativeBuildInputs = [ pkgs.autoreconfHook ]; | |
| doCheck = true; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <CoreFoundation/CoreFoundation.h> | |
| extern char **environ; | |
| int | |
| main(int argc, char *argv[]) | |
| { | |
| CFStringRef myCFString = CFStringCreateWithCString(kCFAllocatorDefault, "testing execv:\n", kCFStringEncodingUTF8); | |
| CFShow(myCFString); | |
| char *eargv[] = {"env", NULL}; | |
| char *eenv[] = {"foo=bar", NULL}; | |
| environ = eenv; | |
| execv("/usr/bin/env", eargv); | |
| return -1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <CoreFoundation/CoreFoundation.h> | |
| int | |
| main(int argc, char *argv[]) | |
| { | |
| CFStringRef myCFString = CFStringCreateWithCString(kCFAllocatorDefault, "testing execve:\n", kCFStringEncodingUTF8); | |
| CFShow(myCFString); | |
| char *eargv[] = {"env", NULL}; | |
| char *eenv[] = {"foo=bar", NULL}; | |
| execve("/usr/bin/env", eargv, eenv); | |
| return -1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <CoreFoundation/CoreFoundation.h> | |
| extern char **environ; | |
| int | |
| main(int argc, char *argv[]) | |
| { | |
| CFStringRef myCFString = CFStringCreateWithCString(kCFAllocatorDefault, "testing execvp:\n", kCFStringEncodingUTF8); | |
| CFShow(myCFString); | |
| char *eargv[] = {"env", NULL}; | |
| char *eenv[] = {"foo=bar", NULL}; | |
| environ = eenv; | |
| execvp("env", eargv); | |
| return -1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bin_PROGRAMS = execve execv execvp | |
| execve_SOURCES = execve.c | |
| execv_SOURCES = execv.c | |
| AM_CFLAGS = -Wall -pedantic -std=c23 | |
| AM_LDFLAGS = -F/System/Library/Frameworks -framework CoreServices | |
| .PHONY: check | |
| check: $(bin_PROGRAMS) | |
| for f in $(bin_PROGRAMS) ; do [[ "$$(./$$f)" == "foo=bar" ]]; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment