Skip to content

Commit

Permalink
Merge pull request #753 from imobachgs/unify-users-and-manager
Browse files Browse the repository at this point in the history
Unify users and manager services
  • Loading branch information
imobachgs authored Sep 14, 2023
2 parents 5dc90d5 + 6fc7564 commit 5b3172e
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 338 deletions.
2 changes: 1 addition & 1 deletion rust/agama-lib/src/users/proxies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use zbus::dbus_proxy;

#[dbus_proxy(
interface = "org.opensuse.Agama.Users1",
default_service = "org.opensuse.Agama.Users1",
default_service = "org.opensuse.Agama.Manager1",
default_path = "/org/opensuse/Agama/Users1"
)]
trait Users1 {
Expand Down
7 changes: 7 additions & 0 deletions rust/package/agama-cli.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Sep 14 10:10:37 UTC 2023 - Imobach Gonzalez Sosa <[email protected]>

- Use a single D-Bus service to connect to the manager and the
users API (gh#openSUSE/agama#753, follow-up of
gh#openSUSE/agama#729).

-------------------------------------------------------------------
Wed Sep 13 09:27:22 UTC 2023 - Knut Anderssen <[email protected]>

Expand Down
2 changes: 0 additions & 2 deletions rust/share/dbus-test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@
<allow own="org.opensuse.Agama.Manager1" />
<allow own="org.opensuse.Agama.Software1" />
<allow own="org.opensuse.Agama.Storage1" />
<allow own="org.opensuse.Agama.Users1" />

<!-- only root can send anything to the services -->
<allow send_destination="org.opensuse.Agama1" />
<allow send_destination="org.opensuse.Agama.Manager1" />
<allow send_destination="org.opensuse.Agama.Software1" />
<allow send_destination="org.opensuse.Agama.Storage1" />
<allow send_destination="org.opensuse.Agama.Users1" />
</policy>

<include if_selinux_enabled="yes" selinux_root_relative="yes">contexts/dbus_contexts</include>
Expand Down
115 changes: 0 additions & 115 deletions service/lib/agama/dbus/clients/users.rb

This file was deleted.

25 changes: 4 additions & 21 deletions service/lib/agama/dbus/manager_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,9 @@ module DBus
# It connects to the system D-Bus and answers requests on objects below
# `/org/opensuse/Agama1`.
class ManagerService
# List of D-Bus services exposed by this class
#
# This basically allows to define "aliases" - all exposed services holds the same objects
# but under different names
#
# @return [Array<String>]
MANAGER_SERVICE = "org.opensuse.Agama.Manager1"
USERS_SERVICE = "org.opensuse.Agama.Users1"
private_constant :MANAGER_SERVICE
private_constant :USERS_SERVICE
# D-Bus service (org.opensuse.Agama.Manager1)
SERVICE_NAME = "org.opensuse.Agama.Manager1"
private_constant :SERVICE_NAME

# Agama D-Bus
#
Expand Down Expand Up @@ -94,9 +87,6 @@ def export

paths = dbus_objects.map(&:path).join(", ")
logger.info "Exported #{paths} objects"

# Request our service names only when we're ready to serve the objects
service_aliases.each { |s| bus.request_name(s) }
end

# Call this from some main loop to dispatch the D-Bus messages
Expand All @@ -117,16 +107,9 @@ def setup_cockpit
cockpit.setup(config.data["web"])
end

def service_aliases
@service_aliases ||= [
MANAGER_SERVICE,
USERS_SERVICE
]
end

# @return [::DBus::ObjectServer]
def service
@service ||= bus.object_server
@service ||= bus.request_service(SERVICE_NAME)
end

# @return [Array<::DBus::Object>]
Expand Down
7 changes: 1 addition & 6 deletions service/lib/agama/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
require "agama/dbus/clients/locale"
require "agama/dbus/clients/software"
require "agama/dbus/clients/storage"
require "agama/dbus/clients/users"
require "agama/helpers"

Yast.import "Stage"
Expand Down Expand Up @@ -160,11 +159,7 @@ def language
#
# @return [DBus::Clients::Users]
def users
@users ||= DBus::Clients::Users.new.tap do |client|
client.on_service_status_change do |status|
service_status_recorder.save(client.service.name, status)
end
end
@users ||= Users.new(logger)
end

# Network manager
Expand Down
8 changes: 7 additions & 1 deletion service/lib/agama/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ module Agama
# Backend class using YaST code.
#
# {Agama::DBus::Users} wraps it with a D-Bus interface and
# {Agama::DBus::Clients::Users} is a D-Bus client for that.
class Users
include Helpers

Expand Down Expand Up @@ -141,6 +140,13 @@ def validate
]
end

# Determines whether the users configuration is valid
#
# @return [Boolean]
def valid?
validate.empty?
end

private

attr_reader :logger
Expand Down
7 changes: 7 additions & 0 deletions service/package/rubygem-agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Sep 14 09:04:29 UTC 2023 - Imobach Gonzalez Sosa <[email protected]>

- Use a single D-Bus service to expose the manager and the users
settings (gh#openSUSE/agama#753, follow-up of
gh#openSUSE/agama#729).

-------------------------------------------------------------------
Tue Sep 12 12:27:33 UTC 2023 - Imobach Gonzalez Sosa <[email protected]>

Expand Down
2 changes: 0 additions & 2 deletions service/share/dbus.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@
<allow own="org.opensuse.Agama.Manager1" />
<allow own="org.opensuse.Agama.Software1" />
<allow own="org.opensuse.Agama.Storage1" />
<allow own="org.opensuse.Agama.Users1" />

<!-- only root can send anything to the services -->
<allow send_destination="org.opensuse.Agama1" />
<allow send_destination="org.opensuse.Agama.Manager1" />
<allow send_destination="org.opensuse.Agama.Software1" />
<allow send_destination="org.opensuse.Agama.Storage1" />
<allow send_destination="org.opensuse.Agama.Users1" />
</policy>

<include if_selinux_enabled="yes" selinux_root_relative="yes">contexts/dbus_contexts</include>
Expand Down
4 changes: 0 additions & 4 deletions service/share/org.opensuse.Agama.Users1.service

This file was deleted.

Loading

0 comments on commit 5b3172e

Please sign in to comment.