mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-03-28 14:50:14 +03:00
shortcut_applier: Don't try to operate on non-existent home directory for user
This commit is contained in:
parent
8c42f00f89
commit
17467b5488
@ -22,6 +22,10 @@ from .applier_frontend import applier_frontend
|
||||
from gpt.shortcuts import json2sc
|
||||
from util.windows import expand_windows_var
|
||||
from util.logging import slogm
|
||||
from util.util import (
|
||||
get_homedir,
|
||||
homedir_exists
|
||||
)
|
||||
|
||||
def storage_get_shortcuts(storage, sid):
|
||||
'''
|
||||
@ -43,6 +47,17 @@ def write_shortcut(shortcut, username=None):
|
||||
:username: None means working with machine variables and paths
|
||||
'''
|
||||
dest_abspath = expand_windows_var(shortcut.dest, username).replace('\\', '/') + '.desktop'
|
||||
|
||||
# Check that we're working for user, not on global system level
|
||||
if username:
|
||||
# Check that link destination path starts with specification of
|
||||
# user's home directory
|
||||
if dest_abspath.startswith(get_homedir(username)):
|
||||
# Don't try to operate on non-existent directory
|
||||
if not homedir_exists(username):
|
||||
logging.warning(slogm('No home directory exists for user {}: will not create link {}'.format(username, dest_abspath)))
|
||||
return None
|
||||
|
||||
logging.debug(slogm('Writing shortcut file to {}'.format(dest_abspath)))
|
||||
shortcut.write_desktop(dest_abspath)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user