Browse Source

small fix to execution and debug mode

Jaromil 2 years ago
parent
commit
ae3efb732d
1 changed files with 7 additions and 8 deletions
  1. 7 8
      src/decode-exec.c

+ 7 - 8
src/decode-exec.c

@@ -53,10 +53,6 @@ void logger(void *context, const char *component,
53 53
 }
54 54
 lsb_logger lsb_vm_logger = { .context = (char*)"DECODE", .cb = logger };
55 55
 
56
-static const char *short_options = "-hc:";
57
-static const char *help =
58
-"Usage: decode-exec [-c config] script.lua\n";
59
-
60 56
 int main(int argc, char **argv) {
61 57
 	lsb_lua_sandbox *lsb = NULL;
62 58
 	char conffile[512] = CONF;
@@ -65,15 +61,18 @@ int main(int argc, char **argv) {
65 61
 	char *p;
66 62
 	int opt;
67 63
 
68
-#if DEBUG==1
69
-	set_debug(3);
70
-#endif
64
+	const char *short_options = "-hdc:";
65
+    const char *help =
66
+		"Usage: decode-exec [-c config] script.lua\n";
71 67
 
72 68
 	notice( "DECODE restricted execution environment v%s",VERSION);
73 69
 	act("Copyright (C) 2017 Dyne.org foundation");
74 70
 	do {
75 71
 		opt = getopt(argc, argv, short_options);
76 72
 		switch(opt) {
73
+		case 'd':
74
+			set_debug(3);
75
+			break;
77 76
 		case 'h':
78 77
 			fprintf(stdout,"%s",help);
79 78
 			exit(0);
@@ -97,7 +96,7 @@ int main(int argc, char **argv) {
97 96
 	else act("conf: %s", conffile);
98 97
 	func("\n%s",conf);
99 98
 
100
-	lsb = lsb_create(NULL, argv[1], conf, &lsb_vm_logger);
99
+	lsb = lsb_create(NULL, codefile, conf, &lsb_vm_logger);
101 100
 	if(!lsb) {
102 101
 		error("Error creating sandbox: %s", lsb_get_error(lsb));
103 102
 		goto teardown; }