Skip to content

Commit

Permalink
Fixed an issue in linux_xrdp_server role where Polkit configuration…
Browse files Browse the repository at this point in the history
… did not apply on Kali Linux
  • Loading branch information
AllRWeak authored and bl0way committed Jan 4, 2024
1 parent 6606520 commit 8a8f4e5
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 56 deletions.
36 changes: 11 additions & 25 deletions nova/core/roles/linux_xrdp_server/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,23 @@
# Role Name
# linux_xrdp_server

COMING SOON
A brief description of the role goes here.
This roles installs and configures xrdp on a Linux machine.

## Requirements

COMING SOON
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
none

## Role Variables

COMING SOON
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
All required role variables are coming from gather_facts.

## Dependencies

COMING SOON
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
none

## Example Playbook
## Example

COMING SOON
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:

- hosts: servers
roles:
- { role: username.rolename, x: 42 }

## License

AGPL-3.0-or-later

## Author Information

COMING SOON
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
```yaml
- name: Inlcude role linux_xrdp_server
ansible.builtin.include_role:
name: nova.core.linux_xrdp_server
```
13 changes: 13 additions & 0 deletions nova/core/roles/linux_xrdp_server/files/10-configuration.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
polkit.addRule(function(action, subject) {
if ((action.id == "org.freedesktop.color-manager.create-device" ||
action.id == "org.freedesktop.color-manager.create-profile" ||
action.id == "org.freedesktop.color-manager.delete-device" ||
action.id == "org.freedesktop.color-manager.delete-profile" ||
action.id == "org.freedesktop.color-manager.modify-device" ||
action.id == "org.freedesktop.color-manager.modify-profile" ||
action.id == "org.freedesktop.login1.reboot" ||
action.id == "org.freedesktop.login1.reboot-multiple-sessions" ) &&
(subject.isInGroup ("sudo") || subject.isInGroup ("users"))) {
return polkit.Result.YES;
}
});
35 changes: 5 additions & 30 deletions nova/core/roles/linux_xrdp_server/tasks/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
retries: 5
delay: 3

- name: Creating colord start cron job... # Temporary hack to avoid colord error on first login
ansible.builtin.cron:
name: Start colord.service
special_time: reboot
job: systemctl start colord.service
user: root
when: ansible_facts.lsb.id == "Kali"

- name: Adding xrdp user to ssl-cert group...
ansible.builtin.user:
name: xrdp
Expand Down Expand Up @@ -51,30 +43,13 @@
line: ls_background_image= # Enables setting login screen background
notify: Restarting xrdp service...

- name: Creating xrdp start cron job... # Because if there's a lot of (security) agents installed the xrdp service times out on boot
ansible.builtin.cron:
name: Start xrdp.service
special_time: reboot
job: sleep 30 && systemctl restart xrdp.service
user: root
- name: Including {{ ansible_distribution }} specific tasks...
ansible.builtin.include_tasks: ubuntu.yml
when: ansible_distribution == "Ubuntu"

- name: Creating folders for configuration...
ansible.builtin.file:
path: /etc/polkit-1/localauthority/50-local.d
state: directory
mode: "0755"

- name: Configuring XRDP polkit...
ansible.builtin.copy:
src: "{{ polkit_config.src }}"
dest: "{{ polkit_config.dest }}"
mode: "0644"
loop_control:
loop_var: polkit_config
loop:
- src: custom-configuration.pkla
dest: /etc/polkit-1/localauthority/50-local.d/custom-configuration.pkla
- name: Including {{ ansible_distribution }} specific tasks...
ansible.builtin.include_tasks: kali.yml
when: ansible_distribution == 'Kali'

- name: Enabling xrdp service...
ansible.builtin.systemd_service:
Expand Down
7 changes: 7 additions & 0 deletions nova/core/roles/linux_xrdp_server/tasks/kali.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# https://c-nergy.be/blog/?p=12073
- name: Configuring XRDP polkit...
ansible.builtin.copy:
src: 10-configuration.rules
dest: /etc/polkit-1/rules.d/10-configuration.rules
mode: "0644"
2 changes: 1 addition & 1 deletion nova/core/roles/linux_xrdp_server/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
- name: Installing xrdp on Debian based OS...
ansible.builtin.include_tasks: debian.yml
when: (ansible_distribution == 'Debian') or (ansible_distribution == 'Kali') or (ansible_distribution == "Ubuntu")
when: ansible_os_family == "Debian"
14 changes: 14 additions & 0 deletions nova/core/roles/linux_xrdp_server/tasks/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# http://c-nergy.be/blog/?p=12043
- name: Configuring XRDP polkit...
ansible.builtin.copy:
src: 10-configuration.pkla
dest: /etc/polkit-1/localauthority/50-local.d/10-configuration.pkla
mode: "0644"

- name: Creating xrdp start cron job... # Because if there's a lot of (security) agents installed the xrdp service times out on boot
ansible.builtin.cron:
name: Start xrdp.service
special_time: reboot
job: sleep 30 && systemctl restart xrdp.service
user: root

0 comments on commit 8a8f4e5

Please sign in to comment.