-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.c
61 lines (52 loc) · 1.73 KB
/
main.c
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "mvh.h"
#include "common.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
int main(int argc, char * const argv[]){
int opt=-1;
char * ip= NULL, * port = NULL, * visibility= NULL;
static struct option long_options[] = {
{"public", no_argument, 0, 1 },
{"private", no_argument, 0, 2 },
{0, 0, 0, 0 }
};
if ( argc <= 2)
argument_error(argv[0], usage);
while ((opt = getopt_long(argc, argv, "+p:s:", long_options, NULL)) != EOF) {
switch (opt) {
case 's': /*server ip*/
ip=optarg;
DPRINT(DEBUG_INFO, "Set server ip to %s\n", ip);
break;
case 'p': /*server port */
port=optarg;
DPRINT(DEBUG_INFO, "Set server port to %s\n", port);
break;
case 1: /* Public process */
visibility = "public";
DPRINT(DEBUG_INFO, "This process has been configured as %s\n",
visibility);
break;
case 2: /* Private process */
visibility = "private";
DPRINT(DEBUG_INFO, "This process has been configured as %s\n",
visibility);
break;
default: /* '?' */
argument_error(argv[0],usage);
}
}
if(visibility == NULL){
fprintf(stderr, "You must specify the process visibility\n");
argument_error(argv[0], usage);
}
argv += optind;
// install the sanbox enviroment
verify_dynamic_symbol(argv[0]);
// run the untrusted application
run_preocess(argv, ip, port, visibility);
return 0;
}