Commit ca3bee7b authored by segfault's avatar segfault
Browse files

Check owner before opening files in tails-debugging-info.py

parent 9f0988e3
......@@ -31,6 +31,7 @@
'''
import os
import sys
from pwd import getpwuid
import sh
......@@ -100,6 +101,13 @@ def debug_file(user, filename):
if not os.path.isfile(filename):
return
owner = getpwuid(os.stat(filename).st_uid)
if owner != user:
print()
print('WARNING: not opening file {}, '.format(filename), end='')
print('because it is owned by {} instead of {}'.format(owner, user))
return
print()
print('===== content of {} ====='.format(filename))
with open(filename) as f:
......@@ -115,6 +123,13 @@ def debug_directory(user, dir_name):
if not os.path.isdir(dir_name):
return
owner = getpwuid(os.stat(dir_name).st_uid)
if owner != user:
print()
print('WARNING: not opening directory {}, '.format(dir_name), end='')
print('because it is owned by {} instead of {}'.format(owner, user))
return
files = os.listdir(dir_name)
print('===== listing of {} ====='.format(dir_name))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment