mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-19 04:41:28 +00:00
Strengthen sudo warning to an error and abort if user doesn't own $HOME
This commit is contained in:
parent
b76649ea94
commit
fab2200666
@ -88,12 +88,16 @@ class pbuilder_dist:
|
|||||||
self.base = os.path.expanduser(os.environ.get('PBUILDFOLDER',
|
self.base = os.path.expanduser(os.environ.get('PBUILDFOLDER',
|
||||||
'~/pbuilder/'))
|
'~/pbuilder/'))
|
||||||
|
|
||||||
|
if 'SUDO_USER' in os.environ:
|
||||||
|
print >> stderr, ("Warning: pbuilder-dist running under sudo. "
|
||||||
|
"This is probably not what you want. "
|
||||||
|
"pbuilder-dist will use sudo itself, "
|
||||||
|
"when necessary.")
|
||||||
|
if os.stat(os.environ['HOME']).st_uid != os.getuid():
|
||||||
|
print >> stderr, "Error: You don't own $HOME"
|
||||||
|
exit(1)
|
||||||
|
|
||||||
if not os.path.isdir(self.base):
|
if not os.path.isdir(self.base):
|
||||||
if 'SUDO_USER' in os.environ:
|
|
||||||
print >> stderr, ("Warning: pbuilder-dist running under sudo. "
|
|
||||||
"This is probably not what you want. "
|
|
||||||
"pbuilder-dist will use sudo itself, "
|
|
||||||
"when necessary.")
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(self.base)
|
os.makedirs(self.base)
|
||||||
except os.OSError:
|
except os.OSError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user