Compare commits
1 Commits
master
...
createdirs
Author | SHA1 | Date |
---|---|---|
Duncan X Simpson | 9345d27d6a |
|
@ -4,8 +4,6 @@ Create required Onionr directories
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
from pwd import getpwuid
|
|
||||||
from getpass import getuser
|
|
||||||
|
|
||||||
from . import identifyhome
|
from . import identifyhome
|
||||||
import filepaths
|
import filepaths
|
||||||
|
@ -27,10 +25,6 @@ import onionrexceptions
|
||||||
home = identifyhome.identify_home()
|
home = identifyhome.identify_home()
|
||||||
|
|
||||||
|
|
||||||
def find_owner(filename):
|
|
||||||
return getpwuid(os.stat(filename).st_uid).pw_name
|
|
||||||
|
|
||||||
|
|
||||||
def create_dirs():
|
def create_dirs():
|
||||||
"""Create onionr data-related directories in
|
"""Create onionr data-related directories in
|
||||||
order of the hardcoded list below,
|
order of the hardcoded list below,
|
||||||
|
@ -41,7 +35,7 @@ def create_dirs():
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
else:
|
else:
|
||||||
if getuser() != find_owner(path):
|
if os.getuid() != os.stat(path).st_uid:
|
||||||
raise onionrexceptions.InsecureDirectoryUsage(
|
raise onionrexceptions.InsecureDirectoryUsage(
|
||||||
"Directory " + path +
|
"Directory " + path +
|
||||||
" already exists and is not owned by the same user")
|
" already exists and is not owned by the same user")
|
||||||
|
@ -54,4 +48,4 @@ def create_dirs():
|
||||||
try:
|
try:
|
||||||
db()
|
db()
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue