Skip to content

Commit

Permalink
pupysh: special - drop priviliges if workdir owned by other user
Browse files Browse the repository at this point in the history
  • Loading branch information
alxchk committed Mar 29, 2020
1 parent a6d9e2c commit f5e3d97
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pupy/pupysh.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
if args.workdir:
os.chdir(args.workdir)

if os.getuid() == 0 and os.getgid() == 0:
wdstat = os.stat(args.workdir)
os.setresgid(wdstat.st_uid, wdstat.st_uid, wdstat.st_uid)
os.setresuid(wdstat.st_uid, wdstat.st_uid, wdstat.st_uid)

root_logger = logging.getLogger()

if args.logfile:
Expand Down

0 comments on commit f5e3d97

Please sign in to comment.