1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 18:50:38 +03:00

Added new applier for files

This commit is contained in:
Valery Sinelnikov 2022-07-05 11:51:24 +04:00
parent cc80d8c74a
commit 31bcb2cd2a

View File

@ -0,0 +1,84 @@
#
# GPOA - GPO Applier for Linux
#
# Copyright (C) 2019-2022 BaseALT Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from pathlib import Path
from .applier_frontend import (
applier_frontend
, check_enabled
)
from util.logging import log
from util.windows import expand_windows_var
import re
class file_applier(applier_frontend):
__module_name = 'FilesApplier'
__module_experimental = True
__module_enabled = False
def __init__(self, storage, file_cache, sid):
self.storage = storage
self.sid = sid
self.file_cache = file_cache
self.files = self.storage.get_files(self.sid)
self.__module_enabled = check_enabled(self.storage, self.__module_name, self.__module_enabled)
# def apply(self):
# if self.__module_enabled:
# log('#########D107#########')
# for file_obj in self.files:
# check_from = expand_windows_var(file_obj.fromPath).replace('\\', '/')
# check_target = expand_windows_var(file_obj.targetPath).replace('\\', '/')
# else:
# log('#############D108')
class file_applier_user(applier_frontend):
__module_name = 'FilesApplierUser'
__module_experimental = True
__module_enabled = False
def __init__(self, storage, file_cache, sid, username):
self.storage = storage
self.file_cache = file_cache
self.sid = sid
self.username = username
self.files = self.storage.get_files(self.sid)
self.__module_enabled = check_enabled(
self.storage
, self.__module_name
, self.__module_experimental
)
def run(self):
for file_obj in self.files:
check_from = expand_windows_var(file_obj.fromPath).replace('\\', '/')
check_target = expand_windows_var(file_obj.targetPath).replace('\\', '/')
# def admin_context_apply(self):
# if self.__module_enabled:
# log('###########D109')
# self.run()
# else:
# log('############D110')
# def user_context_apply(self):
# if self.__module_enabled:
# log('##############D111')
# self.run()
# else:
# log('#############D112')