summaryrefslogtreecommitdiff
path: root/nova/virt/libvirt/utils.py
diff options
context:
space:
mode:
authorMichael Still <mikal@stillhq.com>2017-06-08 09:34:02 +1000
committerMichael Still <mikal@stillhq.com>2017-09-08 03:07:57 +1000
commit0908d338c4f834d2f6ef24b7dc62649b6b7a7bc0 (patch)
tree4331a782913ad7eb663a72e56099ba2b1de41690 /nova/virt/libvirt/utils.py
parentc90f15ecd8d420f6b2c4d48b52511c41d2f647dd (diff)
downloadnova-0908d338c4f834d2f6ef24b7dc62649b6b7a7bc0.tar.gz
Move libvirt usages of chown to privsep.
A nice simple example of how to move things to privsep (and the new set of helpers). In a few of these cases I think a more complicated re-write is actually required, but I've put TODOs there are will do those in a followup patch. Change-Id: Ibb6ef001e3f2add459b0e37dfbd9f51c9eff2eb7
Diffstat (limited to 'nova/virt/libvirt/utils.py')
-rw-r--r--nova/virt/libvirt/utils.py33
1 files changed, 0 insertions, 33 deletions
diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py
index a87d2328f5..395dcae1ce 100644
--- a/nova/virt/libvirt/utils.py
+++ b/nova/virt/libvirt/utils.py
@@ -253,15 +253,6 @@ def write_to_file(path, contents, umask=None):
os.umask(saved_umask)
-def chown(path, owner):
- """Change ownership of file or directory
-
- :param path: File or directory whose ownership to change
- :param owner: Desired new owner (given as uid or username)
- """
- utils.execute('chown', owner, path, run_as_root=True)
-
-
def update_mtime(path):
"""Touch a file without being the owner.
@@ -529,27 +520,3 @@ def is_mounted(mount_path, source=None):
def is_valid_hostname(hostname):
return re.match(r"^[\w\-\.:]+$", hostname)
-
-
-def last_bytes(file_like_object, num):
- """Return num bytes from the end of the file, and remaining byte count.
-
- :param file_like_object: The file to read
- :param num: The number of bytes to return
-
- :returns: (data, remaining)
- """
-
- try:
- file_like_object.seek(-num, os.SEEK_END)
- except IOError as e:
- # seek() fails with EINVAL when trying to go before the start of
- # the file. It means that num is larger than the file size, so
- # just go to the start.
- if e.errno == errno.EINVAL:
- file_like_object.seek(0, os.SEEK_SET)
- else:
- raise
-
- remaining = file_like_object.tell()
- return (file_like_object.read(), remaining)