# retrovision.c -rw-r--r-- 688 bytes View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
#include <sys/utsname.h>
#include <sys/personality.h>
extern char **environ;
int main(int argc, char **argv) {

	if (argc < 2) {
		fprintf(stderr,"%s\n",  "Must supply an executable path");
		exit(1);
	}
	int ev = personality(PER_LINUX | UNAME26);
	if (ev == -1) {
		fprintf(stderr,"%s\n", "Could not set execution domain");
		exit(1);
	}
	pid_t child = fork();
	if (child == 0) {
	 	ev = execve(argv[1], &argv[1], environ);
		if (ev) {
			perror("Exec error");
			exit(1);
		}

	}
	else {
		int status;
		waitpid(child, &status, 0);
		printf("%s\n", "welcome back");
	}
	
	return 0;


}