Author: lslezak Date: Fri Jul 11 16:26:20 2008 New Revision: 49004 URL: http://svn.opensuse.org/viewcvs/yast?rev=49004&view=rev Log: - start DBus servise on the system bus, added service config files Added: branches/tmp/lslezak/workshop/core/scr/src/org.opensuse.yast.SCR.conf.in branches/tmp/lslezak/workshop/core/scr/src/org.opensuse.yast.SCR.service.in Modified: branches/tmp/lslezak/workshop/core/scr/src/DBusMsg.cc branches/tmp/lslezak/workshop/core/scr/src/DBusServer.cc branches/tmp/lslezak/workshop/core/scr/src/Makefile.am branches/tmp/lslezak/workshop/core/scr/src/PolKit.cc Modified: branches/tmp/lslezak/workshop/core/scr/src/DBusMsg.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/core/scr/src/DBusMsg.cc?rev=49004&r1=49003&r2=49004&view=diff ============================================================================== --- branches/tmp/lslezak/workshop/core/scr/src/DBusMsg.cc (original) +++ branches/tmp/lslezak/workshop/core/scr/src/DBusMsg.cc Fri Jul 11 16:26:20 2008 @@ -141,7 +141,14 @@ return std::string(); } - return std::string(dbus_message_get_interface(msg)); + const char *interface = dbus_message_get_interface(msg); + + if (interface != NULL) + { + return std::string(interface); + } + + return std::string(); } std::string DBusMsg::method() const @@ -151,7 +158,14 @@ return std::string(); } - return std::string(dbus_message_get_member(msg)); + const char *member = dbus_message_get_member(msg); + + if (member != NULL) + { + return std::string(member); + } + + return std::string(); } bool DBusMsg::addYCPValue(const YCPValue &val) Modified: branches/tmp/lslezak/workshop/core/scr/src/DBusServer.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/core/scr/src/DBusServer.cc?rev=49004&r1=49003&r2=49004&view=diff ============================================================================== --- branches/tmp/lslezak/workshop/core/scr/src/DBusServer.cc (original) +++ branches/tmp/lslezak/workshop/core/scr/src/DBusServer.cc Fri Jul 11 16:26:20 2008 @@ -7,6 +7,7 @@ #include "DBusServer.h" #include "DBusMsg.h" + #ifdef HAVE_POLKIT #include "PolKit.h" #endif @@ -31,7 +32,7 @@ bool DBusServer::connect() { // connect to DBus, request a service name - return connection.connect(DBUS_BUS_SESSION, "org.opensuse.yast.SCR"); + return connection.connect(DBUS_BUS_SYSTEM, "org.opensuse.yast.SCR"); } @@ -64,7 +65,7 @@ request.interface().c_str(), request.method().c_str()); // check this is a method call for the right object, interface & method - if (request.type() == DBUS_MESSAGE_TYPE_METHOD_CALL && request.interface() == "org.opensuse.yast.SCR" && request.path() == "/SCR") + if (request.type() == DBUS_MESSAGE_TYPE_METHOD_CALL && request.interface() == "org.opensuse.yast.SCR.Methods" && request.path() == "/SCR") { int args = request.arguments(); @@ -170,7 +171,7 @@ // introcpection data for SCR node "<!DOCTYPE node PUBLIC '-//freedesktop//DTD D-BUS Object Introspection 1.0//EN' 'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'>" "<node>" -" <interface name='org.opensuse.yast.SCR'>" +" <interface name='org.opensuse.yast.SCR.Methods'>" " <method name='Read'>" " <arg name='path' type='s' direction='in'/>" " <arg name='arg' type='v' direction='in'/>" @@ -193,12 +194,12 @@ " <arg name='path' type='s' direction='in'/>" " <arg name='ret' type='av' direction='out'/>" " </method>" -" </interface>" " <interface name='org.freedesktop.DBus.Introspectable'>" " <method name='Introspect'>" " <arg name='xml_data' type='s' direction='out'/>" " </method>" " </interface>" +" </interface>" "</node>"; // create a reply to the request @@ -210,8 +211,11 @@ y2warning("Ignoring unknown interface or method call: interface: %s, method: %s", request.interface().c_str(), request.method().c_str()); - // report error - reply.createError(request, "Unknown object, interface or method", DBUS_ERROR_UNKNOWN_METHOD); + if (!request.method().empty() && !request.interface().empty()) + { + // report error + reply.createError(request, "Unknown object, interface or method", DBUS_ERROR_UNKNOWN_METHOD); + } } // was a reply set? Modified: branches/tmp/lslezak/workshop/core/scr/src/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/core/scr/src/Makefile.am?rev=49004&r1=49003&r2=49004&view=diff ============================================================================== --- branches/tmp/lslezak/workshop/core/scr/src/Makefile.am (original) +++ branches/tmp/lslezak/workshop/core/scr/src/Makefile.am Fri Jul 11 16:26:20 2008 @@ -33,6 +33,8 @@ INCLUDES = ${AGENT_INCLUDES} +# SCR DBus service section + ybin_PROGRAMS = SCR_dbus_server SCR_dbus_server_SOURCES = SCR_dbus_server.cc DBusServer.cc DBusServer.h \ @@ -46,3 +48,34 @@ SCR_dbus_server_LDADD = ${AGENT_LIBADD} libpy2scr.la $(DBUS_LIBS) $(POLKIT_LIBS) +# service activation config + +# FIXME?? dbus pkgconfig provides only 'session_bus_services_dir' +dbus_servicesdir = $(prefix)/share/dbus-1/system-services + +dbus_services_in_files = org.opensuse.yast.SCR.service.in + +dbus_services_DATA = $(dbus_services_in_files:.service.in=.service) + +$(dbus_services_DATA): $(dbus_services_in_files) + sed -e "s|\@YBINDIR\@|$(ybindir)|" $< > $@ + +# service config + +dbus_confdir = /etc/dbus-1/system.d + +dbus_conf_in_files = org.opensuse.yast.SCR.conf.in + +dbus_conf_DATA = $(dbus_conf_in_files:.conf.in=.conf) + +# set access mode according to the PolicyKit status +# if policykit is disabled only root can access the service +if HAVE_POLKIT +dbus_access_mode=allow +else +dbus_access_mode=deny +endif + +$(dbus_conf_DATA): $(dbus_conf_in_files) + sed -e "s|\@ACCESS_MODE\@|$(dbus_access_mode)|" $< > $@ + Modified: branches/tmp/lslezak/workshop/core/scr/src/PolKit.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/core/scr/src/PolKit.cc?rev=49004&r1=49003&r2=49004&view=diff ============================================================================== --- branches/tmp/lslezak/workshop/core/scr/src/PolKit.cc (original) +++ branches/tmp/lslezak/workshop/core/scr/src/PolKit.cc Fri Jul 11 16:26:20 2008 @@ -74,7 +74,7 @@ { std::string action_id(prefix + path + "." + method); - // actionID must contain only [a-z],[0-9] and _. characters + // TODO actionID must contain only [a-z][0-9] and .- characters, max. length is 255 characters action_id = toLower(action_id); return action_id; Added: branches/tmp/lslezak/workshop/core/scr/src/org.opensuse.yast.SCR.conf.in URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/core/scr/src/org.opensuse.yast.SCR.conf.in?rev=49004&view=auto ============================================================================== --- branches/tmp/lslezak/workshop/core/scr/src/org.opensuse.yast.SCR.conf.in (added) +++ branches/tmp/lslezak/workshop/core/scr/src/org.opensuse.yast.SCR.conf.in Fri Jul 11 16:26:20 2008 @@ -0,0 +1,11 @@ +<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> +<busconfig> + <policy user="root"> + <allow own="org.opensuse.yast.SCR"/> + <allow send_interface="org.opensuse.yast.SCR.Methods"/> + </policy> + <policy context="default"> + <deny own="org.opensuse.yast.SCR"/> + <@ACCESS_MODE@ send_interface="org.opensuse.yast.SCR.Methods"/> + </policy> +</busconfig> Added: branches/tmp/lslezak/workshop/core/scr/src/org.opensuse.yast.SCR.service.in URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/workshop/core/scr/src/org.opensuse.yast.SCR.service.in?rev=49004&view=auto ============================================================================== --- branches/tmp/lslezak/workshop/core/scr/src/org.opensuse.yast.SCR.service.in (added) +++ branches/tmp/lslezak/workshop/core/scr/src/org.opensuse.yast.SCR.service.in Fri Jul 11 16:26:20 2008 @@ -0,0 +1,5 @@ +# DBus service activation config +[D-BUS Service] +Names=org.opensuse.yast.SCR +Exec=@YBINDIR@/SCR_dbus_server +User=root -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org