Bug 52230 - Не применяются переменные окружения через групповые политики (домен Windows Server 2019)
Summary: Не применяются переменные окружения через групповые политики (домен Windows S...
Status: NEW
Alias: None
Product: Sisyphus
Classification: Development
Component: gpupdate (show other bugs)
Version: unstable
Hardware: x86_64 Linux
: P5 normal
Assignee: Valery Sinelnikov
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-27 15:50 MSK by Белая Алёна
Modified: 2025-04-25 12:24 MSK (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Белая Алёна 2024-11-27 15:50:50 MSK
gpupdate-0.11.4-alt1
gpui-0.2.55-alt1
admx-basealt-0.1.13.6-alt1

Домен Windows Server 2019

Введены клиенты 
ALT Workstation 10.2
ALT Workstation K 10.4
ALT Education 10.2

На одном из клиентов установлен GPUI для изменения групповых политик.

Шаги воспроизведения:
1. Открыть GPUI
2. Добавить переменную окружения, например настройки прокси:
Настройки - Настройки системы - Окружение: Новый - Переменная окружения
	Действие: Заменить
	Тип переменной: Системная переменная
	Имя: HTTPS_PROXY
	Значение: http://IP:3128
Нажать ОК
3. На проверяемом клиенте применить политики:
$ gpupdate

4. Повторно авторизоваться доменным пользователем в систему

5. Проверить, что политика применилась и переменная создана:
$ env | grep -i proxy


Ожидаемый результат: переменная создана

Результат: переменная не создана

Переменная есть в кэшe на клиенте:
cat /var/cache/samba/gpo_cache/AD.TESTDOMAIN/POLICIES/\{31B2F340-016D-11D2-945F-00C04FB984F9\}/MACHINE/PREFERENCES/ENVIRONMENTVARIABLES/ENVIRONMENTVARIABLES.XML 
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<EnvironmentVariables clsid="{BF141A63-327B-438a-B9BF-2C188F13B7AD}">
  <EnvironmentVariable bypassErrors="0" changed="2024-11-27 10:28:56" clsid="{78570023-8373-4a19-BA80-2F150738EA19}" desc="" image="0" name="HTTPS_PROXY" removePolicy="0" status="" uid="{8a45be56-0e76-4914-8373-5d68750e3d1e}" userContext="0">
    <Properties action="R" name="HTTPS_PROXY" partial="0" user="0" value="http://IP:3128"/>
  </EnvironmentVariable>
  <EnvironmentVariable bypassErrors="0" changed="2024-11-27 10:28:56" clsid="{78570023-8373-4a19-BA80-2F150738EA19}" desc="" image="0" name="HTTP_PROXY" removePolicy="0" status="" uid="{4f862eb5-9a1c-4f7e-b17b-13822854ae6e}" userContext="0">
    <Properties action="R" name="HTTP_PROXY" partial="0" user="0" value="http://IP:3128"/>
  </EnvironmentVariable>

Также есть записи в конфигах, опеределяющих переменные:
# cat /etc/gpupdate/environment 
HTTPS_PROXY DEFAULT="http:IP:3128"

$ cat .gpupdate_environment 
HTTP_PROXY DEFAULT="http:IP:3128"

Но в выводе $ env | grep -i proxy переменные отсутствуют. 

При проверке в RSAT активирован дополнительный чекбокс "Остановить обработку элементов в этом расширении при возникновении ошибки". 
При установке переменных через RSAT результат аналогичный.

Проверено для тех же стендов в домене Samba(samba-4.19.9-alt1). Переменные успешно устанавливаются.
Comment 1 Vladislav Glinkin 2025-04-25 12:22:52 MSK
Версия: gpupdate-0.13.2-alt1

Поскольку ключи прилетают, а /etc/gpupdate/environment и .gpupdate_environment настроены, то всё выглядит так, будто /etc/pam.d/system-policy-gpupdate - кривой.

#%PAM-1.0
session         [success=2 perm_denied=ignore default=die]      pam_localuser.so
session         substack        gpupdate-remote-policy
session         [default=1]     pam_permit.so
session         [default=7]     pam_permit.so
session         [success=1 default=ignore]      pam_succeed_if.so user ingroup users quiet
session         [default=5]     pam_permit.so
session         [success=1 default=ignore]      pam_succeed_if.so uid >= 500 quiet
session         [default=3]     pam_permit.so
session         [success=1 default=ignore]      pam_succeed_if.so service = systemd-user quiet
-session        required        pam_oddjob_gpupdate.so
session         optional        pam_env.so user_readenv=1 conffile=/etc/gpupdate/environment user_envfile=.gpupdate_environment
session         required        pam_permit.so

Как минимум, pam_env.so настроен не по man'у:
OPTIONS
       conffile=/path/to/pam_env.conf
           Indicate an alternative pam_env.conf style configuration file to override the default. This can be useful when different services need different environments.

       debug
           A lot of debug information is printed with syslog(3).

       envfile=/path/to/environment
           Indicate an alternative environment file to override the default. The syntax are simple KEY=VAL pairs on separate lines. The export instruction can be
           specified for bash compatibility, but will be ignored. This can be useful when different services need different environments.

       readenv=0|1
           Turns on or off the reading of the file specified by envfile (0 is off, 1 is on). By default this option is on.

       user_envfile=filename
           Indicate an alternative .pam_environment file to override the default. The syntax is the same as for /etc/security/pam_env.conf. The filename is relative to
           the user home directory. This can be useful when different services need different environments.

       user_readenv=0|1
           Turns on or off the reading of the user specific environment file. 0 is off, 1 is on. By default this option is off as user supplied environment variables in
           the PAM environment could affect behavior of subsequent modules in the stack without the consent of the system administrator.

           Due to problematic security this functionality is deprecated since the 1.5.0 version and will be removed completely at some point in the future.

FILES
       /etc/security/pam_env.conf
           Default configuration file

       /etc/environment
           Default environment file

       $HOME/.pam_environment
           User specific environment file


Сейчас в исходниках /etc/gpupdate/environment настраивается аналогично .gpupdate_environment, хотя там синтаксис должен быть как в /etc/environment (KEY="VAL").
Если в /etc/gpupdate/environment привести синтаксис в порядок, а после в /etc/pam.d/lightdm для Workstation K или /etc/pam.d/lightdm для GNOME добавить -session        required        pam_env.so envfile=/etc/gpupdate/environment readenv=1 - то переменные будут получены.

Также, хочу упомянуть о использовании pam_env.so и проблемах с переменными, определёнными в /etc/profile - https://bugzilla.altlinux.org/53948
Comment 2 Vladislav Glinkin 2025-04-25 12:24:59 MSK
(Ответ для Vladislav Glinkin на комментарий #1)
> или /etc/pam.d/lightdm для GNOME

/etc/pam.d/gdm-password*