Skip to content

Commit

Permalink
Do lock/xattr operations as root via xrootd
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Nov 30, 2021
1 parent 88d35ab commit 9126a30
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/xrootiface.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,25 +244,25 @@ def statx(endpoint, fileid, userid, versioninv=0):
}


def setxattr(endpoint, filepath, userid, key, value):
def setxattr(endpoint, filepath, _userid, key, value):
'''Set the extended attribute <key> to <value> via a special open on behalf of the given userid'''
_xrootcmd(endpoint, 'attr', 'set', userid, 'mgm.attr.key=user.' + key + '&mgm.attr.value=' + str(value) + \
_xrootcmd(endpoint, 'attr', 'set', '0:0', 'mgm.attr.key=user.' + key + '&mgm.attr.value=' + str(value) + \
'&mgm.path=' + _getfilepath(filepath, encodeamp=True))


def getxattr(endpoint, filepath, userid, key):
def getxattr(endpoint, filepath, _userid, key):
'''Get the extended attribute <key> via a special open on behalf of the given userid'''
try:
res = _xrootcmd(endpoint, 'attr', 'get', userid, 'mgm.attr.key=user.' + key + '&mgm.path=' + _getfilepath(filepath, encodeamp=True))
res = _xrootcmd(endpoint, 'attr', 'get', '0:0', 'mgm.attr.key=user.' + key + '&mgm.path=' + _getfilepath(filepath, encodeamp=True))
# if no error, the response comes in the format <key>="<value>"
return res.split('"')[1]
except (IndexError, IOError):
return None


def rmxattr(endpoint, filepath, userid, key):
def rmxattr(endpoint, filepath, _userid, key):
'''Remove the extended attribute <key> via a special open on behalf of the given userid'''
_xrootcmd(endpoint, 'attr', 'rm', userid, 'mgm.attr.key=user.' + key + '&mgm.path=' + _getfilepath(filepath, encodeamp=True))
_xrootcmd(endpoint, 'attr', 'rm', '0:0', 'mgm.attr.key=user.' + key + '&mgm.path=' + _getfilepath(filepath, encodeamp=True))


def setlock(endpoint, filepath, userid, value):
Expand Down

0 comments on commit 9126a30

Please sign in to comment.