Author: lslezak
Date: Wed Feb 11 14:15:40 2009
New Revision: 55414
URL: http://svn.opensuse.org/viewcvs/yast?rev=55414&view=rev
Log:
- DBus service - added org.opensuse.yast.modules.policy file, added
"Lock" and "Unlock" methonds to ModuleManager interface,
obtain PolicyKit authorization when PolicyKit result is
POLKIT_RESULT_ONLY_VIA_*_AUTH_*
Added:
branches/tmp/lslezak/core/dbus/namespace_service/org.opensuse.yast.modules.policy
Modified:
branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc
branches/tmp/lslezak/core/dbus/namespace_service/Makefile.am
branches/tmp/lslezak/core/dbus/namespace_service/Yast_dbus_server.cc
branches/tmp/lslezak/core/liby2dbus/src/DBusCaller.cc
branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.cc
branches/tmp/lslezak/core/liby2dbus/src/DBusServerBase.h
branches/tmp/lslezak/core/liby2dbus/src/PolKit.cc
Modified: branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc?rev=55414&r1=55413&r2=55414&view=diff
==============================================================================
--- branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc (original)
+++ branches/tmp/lslezak/core/dbus/namespace_service/DBusModulesServer.cc Wed Feb 11 14:15:40 2009
@@ -223,6 +223,11 @@
// register the manager object: register_function(object, interface, method, signature, handler)
register_method("", "org.opensuse.yast.modules.ModuleManager", "Import", sig, manager_callback);
+
+ DBusSignature void_sig;
+ // register the manager object: register_function(object, interface, method, signature, handler)
+ register_method("", "org.opensuse.yast.modules.ModuleManager", "Unlock", void_sig, manager_callback);
+ register_method("", "org.opensuse.yast.modules.ModuleManager", "Lock", void_sig, manager_callback);
}
std::string DBusModulesServer::Y2Dtype(constTypePtr type) const
@@ -517,7 +522,7 @@
std::string object(request.path());
std::string interface(request.interface());
- y2internal("ModuleManager request: object: %s, method: %s, interface: %s",
+ y2milestone("ModuleManager request: object: %s, method: %s, interface: %s",
object.c_str(), method.c_str(), interface.c_str());
YCPValue ret;
@@ -566,6 +571,14 @@
y2error("ModuleManager function %s got %d parameters instead of 1", method.c_str(), request.arguments());
}
}
+ else if (method == "Unlock")
+ {
+ unregister_client(request.sender());
+ }
+ else if (method == "Lock")
+ {
+ register_client(request.sender());
+ }
}
}
@@ -583,16 +596,25 @@
std::string DBusModulesServer::createActionId(const DBusMsg &msg)
{
// actionId: <prefix>.<namespace>.<method>
- std::string ret("org.opensuse.yast.modules");
+ std::string ret(msg.interface() == "org.opensuse.yast.modules.ModuleManager"
+ ? "org.opensuse.yast.module_manager" : "org.opensuse.yast.modules");
std::string obj(msg.path());
- if (!obj.empty() && obj[0] == '/')
+ if (!obj.empty())
{
- obj.erase(obj.begin());
+ if (obj[0] == '/')
+ {
+ obj.erase(obj.begin());
+ }
+
+ if (!obj.empty())
+ {
+ ret += '.' + obj;
+ }
}
- ret += '.' + obj + '.' + msg.method();
+ ret += '.' + msg.method();
if (!PolKit::isValidActionID(ret))
{
Modified: branches/tmp/lslezak/core/dbus/namespace_service/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/dbus/namespace_service/Makefile.am?rev=55414&r1=55413&r2=55414&view=diff
==============================================================================
--- branches/tmp/lslezak/core/dbus/namespace_service/Makefile.am (original)
+++ branches/tmp/lslezak/core/dbus/namespace_service/Makefile.am Wed Feb 11 14:15:40 2009
@@ -2,9 +2,9 @@
# Makefile.am for dbus/service
#
-EXTRA_DIST=org.opensuse.yast.modules.service.in org.opensuse.yast.modules.conf.in
+EXTRA_DIST=org.opensuse.yast.modules.service.in org.opensuse.yast.modules.conf.in org.opensuse.yast.modules.policy
-AM_CXXFLAGS = -DY2LOG=\"SCR-service\" -DSUSEVERSION=\"${SUSEVERSION}\"
+AM_CXXFLAGS = -DY2LOG=\"DBus-service\" -DSUSEVERSION=\"${SUSEVERSION}\"
INCLUDES = ${AGENT_INCLUDES}
@@ -16,6 +16,14 @@
Yast_dbus_server_LDADD = ${AGENT_LIBADD} $(top_builddir)/liby2dbus/src/liby2dbus.la $(top_builddir)/scr/src/libpy2scr.la $(top_builddir)/wfm/src/libpy2wfm.la
+# PolicyKit defaults
+polkit_policiesdir = `pkg-config --print-errors --variable policydir polkit`
+polkit_policies_DATA = org.opensuse.yast.modules.policy
+
+# validate the policy files in 'make check' target
+check-local:
+ polkit-policy-file-validate $(polkit_policies_DATA)
+
# service activation config
Modified: branches/tmp/lslezak/core/dbus/namespace_service/Yast_dbus_server.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/dbus/namespace_service/Yast_dbus_server.cc?rev=55414&r1=55413&r2=55414&view=diff
==============================================================================
--- branches/tmp/lslezak/core/dbus/namespace_service/Yast_dbus_server.cc (original)
+++ branches/tmp/lslezak/core/dbus/namespace_service/Yast_dbus_server.cc Wed Feb 11 14:15:40 2009
@@ -43,6 +43,7 @@
{
y2error ("Usage: %s [--disable-timer] namespace <namespace> <namespace>....", argv[0]);
std::cerr << "Usage: " << argv[0] << " [--disable-timer] namespace <namespace> <namespace>..." << std::endl;
+ std::cerr << " --disable-timer Disable automatic shutdown of the service, useful for debugging\n";
return 1;
}
Added: branches/tmp/lslezak/core/dbus/namespace_service/org.opensuse.yast.modules.policy
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/core/dbus/namespace_service/org.opensuse.yast.modules.policy?rev=55414&view=auto
==============================================================================
--- branches/tmp/lslezak/core/dbus/namespace_service/org.opensuse.yast.modules.policy (added)
+++ branches/tmp/lslezak/core/dbus/namespace_service/org.opensuse.yast.modules.policy Wed Feb 11 14:15:40 2009
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
+
+<policyconfig>
+ <vendor>Novell, Inc.</vendor>
+