blob: 0805ceb70a89b6e5c1a29bdb3ec5eb911e407294 [file] [log] [blame]
#!/usr/bin/env python3
#
# Wrapper around 'chown' that redirects to root in all cases
import os
import shutil
import sys
# calculate path to the real 'chown'
path = os.environ['PATH']
path = path.replace(os.path.dirname(sys.argv[0]), '')
real_chown = shutil.which('chown', path=path)
args = list()
found = False
args.append(real_chown)
for i in sys.argv[1:]:
if i.startswith("-"):
args.append(i)
continue
if not found:
args.append("root:root")
found = True
else:
args.append(i)
os.execv(real_chown, args)