mirror of
https://github.com/45Drives/cockpit-navigator.git
synced 2025-07-31 01:24:37 +02:00
set inaccessible in stat if lstat fails
This commit is contained in:
parent
4bfa8e4e96
commit
b958496a5b
@ -25,7 +25,27 @@ from pwd import getpwuid
|
|||||||
from grp import getgrgid
|
from grp import getgrgid
|
||||||
|
|
||||||
def get_stat(full_path, filename = '/'):
|
def get_stat(full_path, filename = '/'):
|
||||||
|
try:
|
||||||
stats = os.lstat(full_path)
|
stats = os.lstat(full_path)
|
||||||
|
except OSError:
|
||||||
|
return {
|
||||||
|
"filename": filename,
|
||||||
|
"isdir": False,
|
||||||
|
"link-target": "",
|
||||||
|
"stat": {
|
||||||
|
"inaccessible": True,
|
||||||
|
"mode": 0,
|
||||||
|
"mode-str": "?",
|
||||||
|
"uid": 0,
|
||||||
|
"owner": "?",
|
||||||
|
"gid": 0,
|
||||||
|
"group": "?",
|
||||||
|
"size": 0,
|
||||||
|
"atime": 0,
|
||||||
|
"mtime": 0,
|
||||||
|
"ctime": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
isdir = False
|
isdir = False
|
||||||
try:
|
try:
|
||||||
isdir = S_ISDIR(os.stat(full_path).st_mode)
|
isdir = S_ISDIR(os.stat(full_path).st_mode)
|
||||||
@ -45,6 +65,7 @@ def get_stat(full_path, filename = '/'):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
response = {
|
response = {
|
||||||
|
"inaccessible": False,
|
||||||
"filename": filename,
|
"filename": filename,
|
||||||
"isdir": isdir,
|
"isdir": isdir,
|
||||||
"link-target": link_target,
|
"link-target": link_target,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user