Skip to content

Commit

Permalink
refs #44, #45: gcc target binary now get correct permissions!
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol committed Aug 24, 2017
1 parent 688a982 commit 6a37658
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions c/policy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ diff_to_default: true
# Following syscalls are blindly allowed.
# IMPORTANT: ptrace MUST NOT be included!
allowed_syscalls:
- "umask"
10 changes: 5 additions & 5 deletions c/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def build(self, build_cmd):
await self.run_subproc(cmd)
cfiles = ' '.join(map(lambda p: shlex.quote(str(p)), cfiles))
ofiles = ' '.join(map(lambda p: shlex.quote(str(p)), ofiles))
cmd = f'gcc {ofiles} {DEFAULT_LDFLAGS} -o ./main && chmod 755 ./main'
cmd = f'gcc {ofiles} {DEFAULT_LDFLAGS} -o ./main'
await self.run_subproc(cmd)
else:
log.error('cannot find build script ("Makefile") '
Expand All @@ -68,9 +68,9 @@ async def execute(self, exec_cmd):
return
elif exec_cmd == '*':
if Path('./main').is_file():
await self.run_subproc('chmod 755 ./main; ./main')
await self.run_subproc('./main')
elif Path('./a.out').is_file():
await self.run_subproc('chmod 755 ./a.out; ./a.out')
await self.run_subproc('./a.out')
else:
log.error('cannot find executable ("a.out" or "main").')
else:
Expand All @@ -83,8 +83,8 @@ async def query(self, code_text):
with tempfile.NamedTemporaryFile(suffix='.c', dir='.') as tmpf:
tmpf.write(code_text.encode('utf8'))
tmpf.flush()
cmd = (f'gcc {tmpf.name} {DEFAULT_CFLAGS} -o ./main {DEFAULT_LDFLAGS} '
f'&& chmod 755 ./main && ./main')
cmd = (f'gcc {tmpf.name} {DEFAULT_CFLAGS} -o ./main {DEFAULT_LDFLAGS} && '
f'./main')
await self.run_subproc(cmd)


Expand Down

0 comments on commit 6a37658

Please sign in to comment.