Skip to content
This repository has been archived by the owner on Mar 5, 2018. It is now read-only.

Commit

Permalink
Just inline uid/gid fix
Browse files Browse the repository at this point in the history
  • Loading branch information
silas committed Jan 11, 2014
1 parent 3580533 commit 86bf4d3
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions ops.py
Expand Up @@ -27,20 +27,10 @@

log = logging.getLogger('ops')
type_ = type
darwin = sys.platform == 'darwin'

class Error(Exception): pass
class ValidationError(Error): pass

def _uid_gid(path, uid, gid):
if uid == -1 or gid == -1:
st = stat(path)
if uid == -1:
uid = st.st_uid
if gid == -1:
gid = st.st_gid
return uid, gid

def _chmod(path, value=None):
try:
os.chmod(path, value.numeric)
Expand Down Expand Up @@ -80,8 +70,12 @@ def _chown(path, uid=-1, gid=-1):
log.error('chown: invalid uid or gid: %s' % path)
return False
# hack around Apple's broken patch (http://bugs.python.org/issue13315)
if darwin:
uid, gid = _uid_gid(path, uid, gid)
if sys.platform == 'darwin' and uid == -1 or gid == -1:
st = stat(path)
if uid == -1:
uid = st.st_uid
if gid == -1:
gid = st.st_gid
try:
os.chown(path, uid, gid)
return True
Expand Down

0 comments on commit 86bf4d3

Please sign in to comment.