Author: aschnell
Date: Thu Jan 29 16:29:36 2009
New Revision: 55148
URL: http://svn.opensuse.org/viewcvs/yast?rev=55148&view=rev
Log:
- added dbus client agent (required for bnc #464453)
Added:
branches/SuSE-Code-11-Branch/core/agent-dbus/
branches/SuSE-Code-11-Branch/core/agent-dbus/Makefile.am
branches/SuSE-Code-11-Branch/core/agent-dbus/conf/
branches/SuSE-Code-11-Branch/core/agent-dbus/conf/Makefile.am
branches/SuSE-Code-11-Branch/core/agent-dbus/conf/dbus.scr
branches/SuSE-Code-11-Branch/core/agent-dbus/doc/
branches/SuSE-Code-11-Branch/core/agent-dbus/doc/Makefile.am
branches/SuSE-Code-11-Branch/core/agent-dbus/src/
branches/SuSE-Code-11-Branch/core/agent-dbus/src/DbusAgent.cc
branches/SuSE-Code-11-Branch/core/agent-dbus/src/DbusAgent.h
branches/SuSE-Code-11-Branch/core/agent-dbus/src/Makefile.am
branches/SuSE-Code-11-Branch/core/agent-dbus/src/Y2CCDbusAgent.cc
Modified:
branches/SuSE-Code-11-Branch/core/SUBDIRS
branches/SuSE-Code-11-Branch/core/VERSION
branches/SuSE-Code-11-Branch/core/package/yast2-core.changes
Modified: branches/SuSE-Code-11-Branch/core/SUBDIRS
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/SUBDIRS?rev=55148&r1=55147&r2=55148&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/SUBDIRS (original)
+++ branches/SuSE-Code-11-Branch/core/SUBDIRS Thu Jan 29 16:29:36 2009
@@ -1 +1 @@
-liby2util-r liby2 libycp liby2dbus libscr agent-dummy scr agent-system agent-any agent-ini agent-modules agent-resolver agents-non-y2 agents-perl wfm agent-process base autodocs dbus
+liby2util-r liby2 libycp liby2dbus libscr agent-dummy scr agent-system agent-dbus agent-any agent-ini agent-modules agent-resolver agents-non-y2 agents-perl wfm agent-process base autodocs dbus
Modified: branches/SuSE-Code-11-Branch/core/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/VERSION?rev=55148&r1=55147&r2=55148&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/VERSION (original)
+++ branches/SuSE-Code-11-Branch/core/VERSION Thu Jan 29 16:29:36 2009
@@ -1 +1 @@
-2.17.27
+2.17.28
Added: branches/SuSE-Code-11-Branch/core/agent-dbus/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-dbus/Makefile.am?rev=55148&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-dbus/Makefile.am (added)
+++ branches/SuSE-Code-11-Branch/core/agent-dbus/Makefile.am Thu Jan 29 16:29:36 2009
@@ -0,0 +1,5 @@
+#
+# Makefile.am for core/agent-dbus
+#
+
+SUBDIRS = conf doc src
Added: branches/SuSE-Code-11-Branch/core/agent-dbus/conf/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-dbus/conf/Makefile.am?rev=55148&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-dbus/conf/Makefile.am (added)
+++ branches/SuSE-Code-11-Branch/core/agent-dbus/conf/Makefile.am Thu Jan 29 16:29:36 2009
@@ -0,0 +1,7 @@
+#
+# Makefile.am for core/agent-dbus/conf
+#
+
+scrconf_DATA = dbus.scr
+
+EXTRA_DIST = $(scrconf_DATA)
Added: branches/SuSE-Code-11-Branch/core/agent-dbus/conf/dbus.scr
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-dbus/conf/dbus.scr?rev=55148&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-dbus/conf/dbus.scr (added)
+++ branches/SuSE-Code-11-Branch/core/agent-dbus/conf/dbus.scr Thu Jan 29 16:29:36 2009
@@ -0,0 +1,9 @@
+/**
+ * File:
+ * dbus.scr
+ * Authors:
+ * Arvin Schnell
+ */
+.dbus
+
+`ag_dbus()
Added: branches/SuSE-Code-11-Branch/core/agent-dbus/doc/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-dbus/doc/Makefile.am?rev=55148&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-dbus/doc/Makefile.am (added)
+++ branches/SuSE-Code-11-Branch/core/agent-dbus/doc/Makefile.am Thu Jan 29 16:29:36 2009
@@ -0,0 +1,16 @@
+#
+# Makefile.am for core/agent-dbus/doc
+#
+
+SUBDIRS =
+
+builtin = $(srcdir)/../src/DbusAgent.cc
+hbuiltin = ag_dbus.html
+$(hbuiltin): $(builtin)
+ `pkg-config --variable=ybindir yast2-devtools`/makebuiltindocs -t "SCR Dbus agent functions" -a $(builtin) > $@.new
+ mv $@.new $@
+
+compdir = $(yastdocdir)/components
+comp_DATA = $(hbuiltin)
+
+CLEANFILES = $(hbuiltin)
Added: branches/SuSE-Code-11-Branch/core/agent-dbus/src/DbusAgent.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-dbus/src/DbusAgent.cc?rev=55148&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-dbus/src/DbusAgent.cc (added)
+++ branches/SuSE-Code-11-Branch/core/agent-dbus/src/DbusAgent.cc Thu Jan 29 16:29:36 2009
@@ -0,0 +1,187 @@
+/*
+ * File: DbusAgent.cc
+ *
+ * Authors: Arvin Schnell
+ */
+
+#include "config.h"
+
+#include
+#include
+
+#include "DbusAgent.h"
+
+
+DbusAgent::DbusAgent()
+{
+ y2milestone("connecting dbus");
+
+ dbus_error_init(&error);
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (dbus_error_is_set(&error))
+ {
+ y2error("dbus_bus_get failed (%s)\n", error.message);
+ dbus_error_free(&error);
+ }
+
+ if (connection == NULL)
+ {
+ y2error("connecting dbus failed");
+ }
+}
+
+
+DbusAgent::~DbusAgent()
+{
+}
+
+
+YCPValue
+DbusAgent::Read(const YCPPath& path, const YCPValue& arg, const YCPValue&)
+{
+ y2debug("Read(%s)", path->toString().c_str());
+
+ if (path->isRoot())
+ {
+ ycp2error("Read() called without sub-path");
+ return YCPNull();
+ }
+
+ const string cmd = path->component_str(0); // just a shortcut
+
+ return YCPError(string("Undefined subpath for Read(") + path->toString() + ")");
+}
+
+
+YCPBoolean
+DbusAgent::Write(const YCPPath& path, const YCPValue& value,
+ const YCPValue& arg)
+{
+ y2debug("Write(%s)", path->toString().c_str());
+
+ if (path->isRoot())
+ {
+ ycp2error("Write() called without sub-path");
+ return YCPBoolean(false);
+ }
+
+ const string cmd = path->component_str(0); // just a shortcut
+
+ ycp2error("Undefined subpath for Write(%s)", path->toString ().c_str ());
+ return YCPBoolean(false);
+}
+
+
+YCPValue
+DbusAgent::Execute(const YCPPath& path, const YCPValue& value,
+ const YCPValue& arg)
+{
+ y2debug("Execute(%s)", path->toString().c_str());
+
+ if (path->isRoot())
+ {
+ return YCPError("Execute() called without sub-path");
+ }
+
+ if (value.isNull())
+ {
+ return YCPError(string("Execute(")+path->toString()+") without argument.");
+ }
+
+ const string cmd = path->component_str(0); // just a shortcut
+
+ if (cmd == "method")
+ {
+ /**
+ * @builtin Execute(.dbus.method, map params, list args) -> boolean
+ *
+ * params must contain parameters for dbus_message_new_method_call()
+ * and args must contain arguments for dbus method call.
+ */
+
+ if (!connection)
+ return YCPError("dbus connection failed");
+
+ if (!value->isMap())
+ return YCPError("value not a map");
+
+ if (!arg->isList())
+ return YCPError("arg not a list");
+
+ YCPMap tmp1 = value->asMap();
+
+ YCPValue destination = tmp1.value(YCPSymbol("destination"));
+ if (!destination->isString())
+ return YCPError("Missing or wrong type for 'destination'");
+
+ YCPValue path = tmp1.value(YCPSymbol("path"));
+ if (!path->isString())
+ return YCPError("Missing or wrong type for 'path'");
+
+ YCPValue interface = tmp1.value(YCPSymbol("interface"));
+ if (!interface->isString())
+ return YCPError("Missing or wrong type for 'interface'");
+
+ YCPValue method = tmp1.value(YCPSymbol("method"));
+ if (!method->isString())
+ return YCPError("Missing or wrong type for 'method'");
+
+ DBusMessage* message = dbus_message_new_method_call(destination->asString()->value_cstr(),
+ path->asString()->value_cstr(),
+ interface->asString()->value_cstr(),
+ method->asString()->value_cstr());
+ if (NULL == message)
+ {
+ return YCPError("dbus_message_new_method_call() failed");
+ }
+
+ DBusMessageIter args;
+
+ dbus_message_iter_init_append(message, &args);
+
+ YCPList tmp2 = arg->asList();
+ for (YCPListIterator it = tmp2.begin(); it != tmp2.end(); ++it)
+ {
+ const YCPValue& tmp3 = *it;
+
+ if (tmp3->isString())
+ {
+ const char* param = tmp3->asString()->value_cstr();
+ if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, ¶m))
+ return YCPError("dbus_message_iter_append_basic() failed");
+ }
+ else if (tmp3->isBoolean())
+ {
+ bool param = tmp3->asBoolean()->value();
+ if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_BOOLEAN, ¶m))
+ return YCPError("dbus_message_iter_append_basic() failed");
+ }
+ else
+ {
+ return YCPError("Unsupported type");
+ }
+ }
+
+ DBusMessage* reply = dbus_connection_send_with_reply_and_block(connection, message, -1, &error);
+
+ dbus_message_unref(message);
+
+ if (dbus_error_is_set(&error))
+ {
+ dbus_error_free(&error);
+ return YCPError("dbus_connection_send_with_reply_and_block() failed");
+ }
+
+ if (reply == NULL)
+ {
+ return YCPError("dbus_connection_send_with_reply_and_block() failed");
+ }
+
+ dbus_message_unref(reply);
+
+ return YCPBoolean(true);
+ }
+
+ return YCPError(string("Undefined subpath for Execute(") + path->toString() + ")");
+}
Added: branches/SuSE-Code-11-Branch/core/agent-dbus/src/DbusAgent.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-dbus/src/DbusAgent.h?rev=55148&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-dbus/src/DbusAgent.h (added)
+++ branches/SuSE-Code-11-Branch/core/agent-dbus/src/DbusAgent.h Thu Jan 29 16:29:36 2009
@@ -0,0 +1,63 @@
+/*
+ * File: DbusAgent.h
+ *
+ * Authors: Arvin Schnell
+ */
+
+#ifndef DbusAgent_h
+#define DbusAgent_h
+
+
+#include
+
+#include
+#include
+
+
+/**
+ * @short SCR Agent for DBus commands.
+ *
+ * aschnell: WARNING: This agent was written in a hurry for exactly one single
+ * purpose (acquire global HAL interface lock). Likely use for other commands
+ * is not possible but I'm confident the agent can be extended at the
+ * sacrifice of changing the API.
+ */
+class DbusAgent : public SCRAgent
+{
+
+public:
+
+ DbusAgent();
+ ~DbusAgent();
+
+ /**
+ * Read data
+ */
+ virtual YCPValue Read(const YCPPath& path, const YCPValue& arg = YCPNull(), const YCPValue& opt = YCPNull());
+
+ /**
+ * Write data
+ */
+ virtual YCPBoolean Write(const YCPPath& path, const YCPValue& value,
+ const YCPValue& arg = YCPNull());
+
+ /**
+ * Execute a command
+ */
+ virtual YCPValue Execute(const YCPPath& path, const YCPValue& value = YCPNull(),
+ const YCPValue& arg = YCPNull());
+
+ /**
+ * Get a list of all subtrees
+ */
+ virtual YCPList Dir(const YCPPath& path) { return YCPList(); }
+
+private:
+
+ DBusConnection* connection;
+ DBusError error;
+
+};
+
+
+#endif // DbusAgent_h
Added: branches/SuSE-Code-11-Branch/core/agent-dbus/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-dbus/src/Makefile.am?rev=55148&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-dbus/src/Makefile.am (added)
+++ branches/SuSE-Code-11-Branch/core/agent-dbus/src/Makefile.am Thu Jan 29 16:29:36 2009
@@ -0,0 +1,18 @@
+#
+# Makefile.am for core/agent-dbus/src
+#
+
+AM_CXXFLAGS = -DY2LOG=\"agent-dbus\"
+
+plugin_LTLIBRARIES = libpy2ag_dbus.la
+
+libpy2ag_dbus_la_SOURCES = \
+ Y2CCDbusAgent.cc \
+ DbusAgent.cc DbusAgent.h
+
+libpy2ag_dbus_la_CPPFLAGS = @DBUS_CFLAGS@
+libpy2ag_dbus_la_LDFLAGS = -version-info 2:0
+libpy2ag_dbus_la_LIBADD = @AGENT_LIBADD@ \
+ @DBUS_LIBS@
+
+INCLUDES = @AGENT_INCLUDES@
Added: branches/SuSE-Code-11-Branch/core/agent-dbus/src/Y2CCDbusAgent.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/agent-dbus/src/Y2CCDbusAgent.cc?rev=55148&view=auto
==============================================================================
--- branches/SuSE-Code-11-Branch/core/agent-dbus/src/Y2CCDbusAgent.cc (added)
+++ branches/SuSE-Code-11-Branch/core/agent-dbus/src/Y2CCDbusAgent.cc Thu Jan 29 16:29:36 2009
@@ -0,0 +1,17 @@
+
+
+/*
+ * Author: Arvin Schnell
+ */
+
+
+#include
+#include
+
+#include "DbusAgent.h"
+
+
+typedef Y2AgentComp<DbusAgent> Y2DbusAgentComp;
+
+Y2CCAgentComp<Y2DbusAgentComp> g_y2ccag_dbus("ag_dbus");
+
Modified: branches/SuSE-Code-11-Branch/core/package/yast2-core.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/core/package/yast2-core.changes?rev=55148&r1=55147&r2=55148&view=diff
==============================================================================
--- branches/SuSE-Code-11-Branch/core/package/yast2-core.changes (original)
+++ branches/SuSE-Code-11-Branch/core/package/yast2-core.changes Thu Jan 29 16:29:36 2009
@@ -1,8 +1,14 @@
-------------------------------------------------------------------
+Thu Jan 29 15:15:57 CET 2009 - aschnell@suse.de
+
+- added dbus client agent (required for bnc #464453)
+- 2.17.28
+
+-------------------------------------------------------------------
Mon Jan 26 14:00:31 CET 2009 - mvidner@suse.cz
- Fixed the D-Bus access policy (bnc#468390, CVE-2008-4311).
-- 2.18.27
+- 2.17.27
-------------------------------------------------------------------
Mon Dec 22 13:16:02 CET 2008 - mvidner@suse.cz
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org