Explicação do arquivo - org.freedesktop.login1.policy

7

Estou usando o Ubuntu 16.04.

Existe um arquivo localizado em /usr/share/polkit-1/actions/org.freedesktop.login1.policy , que parece controlar as permissões referentes às opções de desligamento / suspensão / hibernação.

Neste arquivo, as opções revelantes estão neste formato:

<defaults>
  <allow_any>no</allow_any>
  <allow_inactive>auth_admin_keep</allow_inactive>
  <allow_active>yes</allow_active>
</defaults>

correspondente a cada ação (desligamento, suspensão etc.). Aqui é a versão completa desse arquivo.

Eu quero saber o significado das opções allow_any , allow_inactive e allow_active .
O que eles querem dizer exatamente?

O motivo da minha curiosidade é que eu quero hibernar não-interativamente sem raiz (do cron), mas estou recebendo erros de autorização .

E parece que esses erros podem ser resolvidos modificando esse arquivo.

    
por Anmol Singh Jaggi 11.06.2016 / 11:06

2 respostas

3

Da seção DECLARAÇÃO DE AÇÕES de polkit - Estrutura de autorização :

defaults

       This element is used to specify implicit authorizations for
       clients.

       Elements that can be used inside defaults includes:

       allow_any
           Implicit authorizations that apply to any client. Optional.

       allow_inactive
           Implicit authorizations that apply to clients in inactive
           sessions on local consoles. Optional.

       allow_active
           Implicit authorizations that apply to clients in active
           sessions on local consoles. Optional.

       Each of the allow_any, allow_inactive and allow_active elements can
       contain the following values:

       no
           Not authorized.

       yes
           Authorized.

       auth_self
           Authentication by the owner of the session that the client
           originates from is required.

       auth_admin
           Authentication by an administrative user is required.

       auth_self_keep
           Like auth_self but the authorization is kept for a brief
           period.

       auth_admin_keep
           Like auth_admin but the authorization is kept for a brief
           period.

Espero que isso deixe claro para você.

    
por 11.06.2016 / 12:14
4

Este link contém as informações dadas por a outra resposta de uma maneira melhor.

Especialmente esta parte:

The defaults tag is where the permissions or lack thereof are located.
It contains three settings: allow_any, allow_inactive, and allow_active.
Inactive sessions are generally remote sessions (SSH, VNC, etc.) whereas active sessions are logged directly into the machine on a TTY or an X display.
allow_any is the setting encompassing both scenarios.

For each of these settings the following options are available:

no: The user is not authorized to carry out the action. There is therefore no need for authentication.
yes: The user is authorized to carry out the action without any authentication.
auth_self: Authentication is required but the user need not be an administrative user.
auth_admin: Authentication as an administrative user is require.
auth_self_keep: The same as auth_self but, like sudo, the authorization lasts a few minutes.
auth_admin_keep: The same as auth_admin but, like sudo, the authorization lasts a few minutes.

Além disso, aqui é a página de manual oficial do polkit.

A hibernação pode ser feita para ser ativada no cron, alterando o no para yes dentro das tags allow_any nas ações org.freedesktop.login1.hibernate e org.freedesktop.login1.hibernate-multiple-sessions .

Mas esta não é uma solução recomendada , pois pode ser apagada durante atualizações futuras.

Em vez disso, você pode criar um arquivo contendo o seguinte:

[Enable hibernate to be run via cron]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate-multiple-sessions
ResultAny=yes 

chamado com.0.enable-hibernation-from-cron.pkla no diretório /etc/polkit-1/localauthority/50-local.d/ para obter o mesmo efeito.

Uma solução ainda melhor usando visudo é dada aqui .

    
por 12.06.2016 / 22:10