Mailinglist Archive: yast-commit (870 mails)
| < Previous | Next > |
[yast-commit] r49299 - in /trunk/core: ./ base/src/ dbus/ dbus/SCR_service/ libscr/src/ libscr/src/include/scr/ libscr/testsuite/ liby2dbus/ liby2dbus/src/ scr/src/ wfm/testsuite/
- From: lslezak@xxxxxxxxxxxxxxxx
- Date: Mon, 21 Jul 2008 15:04:21 -0000
- Message-id: <20080721150421.DDAB72A0D6@xxxxxxxxxxxxxxxx>
Author: lslezak
Date: Mon Jul 21 17:04:21 2008
New Revision: 49299
URL: http://svn.opensuse.org/viewcvs/yast?rev=49299&view=rev
Log:
- merged experimental DBus/PolicyKit support from
http://svn.opensuse.org/svn/yast/branches/tmp/lslezak/workshop/core/
branch (rev. 48695:49298)
Added:
trunk/core/dbus/ (props changed)
- copied from r49298, branches/tmp/lslezak/workshop/core/dbus/
trunk/core/dbus/Makefile.am
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/dbus/Makefile.am
trunk/core/dbus/SCR_service/ (props changed)
- copied from r49298, branches/tmp/lslezak/workshop/core/dbus/SCR_service/
trunk/core/dbus/SCR_service/DBusServer.cc
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/dbus/SCR_service/DBusServer.cc
trunk/core/dbus/SCR_service/DBusServer.h
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/dbus/SCR_service/DBusServer.h
trunk/core/dbus/SCR_service/Makefile.am
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/dbus/SCR_service/Makefile.am
trunk/core/dbus/SCR_service/SCR_dbus_server.cc
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/dbus/SCR_service/SCR_dbus_server.cc
trunk/core/dbus/SCR_service/org.opensuse.yast.SCR.conf.in
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/dbus/SCR_service/org.opensuse.yast.SCR.conf.in
trunk/core/dbus/SCR_service/org.opensuse.yast.SCR.service.in
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/dbus/SCR_service/org.opensuse.yast.SCR.service.in
trunk/core/liby2dbus/ (props changed)
- copied from r49298, branches/tmp/lslezak/workshop/core/liby2dbus/
trunk/core/liby2dbus/Makefile.am
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/Makefile.am
trunk/core/liby2dbus/src/ (props changed)
- copied from r49298, branches/tmp/lslezak/workshop/core/liby2dbus/src/
trunk/core/liby2dbus/src/DBusConn.cc
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/src/DBusConn.cc
trunk/core/liby2dbus/src/DBusConn.h
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/src/DBusConn.h
trunk/core/liby2dbus/src/DBusMsg.cc
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/src/DBusMsg.cc
trunk/core/liby2dbus/src/DBusMsg.h
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/src/DBusMsg.h
trunk/core/liby2dbus/src/Makefile.am
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/src/Makefile.am
trunk/core/liby2dbus/src/PolKit.cc
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/src/PolKit.cc
trunk/core/liby2dbus/src/PolKit.h
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/src/PolKit.h
Modified:
trunk/core/SUBDIRS
trunk/core/base/src/Makefile.am
trunk/core/configure.in.in
trunk/core/libscr/src/Makefile.am
trunk/core/libscr/src/SCR.cc
trunk/core/libscr/src/include/scr/SCR.h
trunk/core/libscr/testsuite/Makefile.am
trunk/core/scr/src/Makefile.am
trunk/core/scr/src/ScriptingAgent.h
trunk/core/wfm/testsuite/Makefile.am
trunk/core/yast2-core.spec.in
Modified: trunk/core/SUBDIRS
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/SUBDIRS?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/SUBDIRS (original)
+++ trunk/core/SUBDIRS Mon Jul 21 17:04:21 2008
@@ -1 +1 @@
-liby2util-r liby2 libycp libscr agent-dummy scr agent-system agent-any
agent-ini agent-modules agent-resolver agents-non-y2 agents-perl wfm base
autodocs agent-process
+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
base autodocs agent-process dbus
Modified: trunk/core/base/src/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/base/src/Makefile.am?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/base/src/Makefile.am (original)
+++ trunk/core/base/src/Makefile.am Mon Jul 21 17:04:21 2008
@@ -8,12 +8,11 @@
YAST2CORE = \
../../wfm/src/libpy2wfm.la \
+ ../../scr/src/libpy2scr.la \
../../libycp/src/libycp.la \
../../liby2/src/liby2.la \
../../libscr/src/libscr.la
-# ../../scr/src/libpy2scr.la
-
y2base_DEPENDENCIES = $(YAST2CORE)
Modified: trunk/core/configure.in.in
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/configure.in.in?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/configure.in.in (original)
+++ trunk/core/configure.in.in Mon Jul 21 17:04:21 2008
@@ -90,6 +90,41 @@
AC_MSG_ERROR(Headers for blocxx are missing. Please install the package
blocxx-devel.)
fi
+PKG_CHECK_MODULES(DBUS, dbus-1)
+
+## check for PolicyKit
+AC_ARG_ENABLE([policykit],
+ AS_HELP_STRING([--enable-policykit], [Enable experimental PolicyKit
support]),
+ [
+ case "${enableval}" in
+ yes) policykit=yes ;;
+ no) policykit=no ;;
+ *) AC_MSG_ERROR(--enable-policykit: Unknwon value
${enableval}) ;;
+ esac
+ ],
+ [policykit=yes])
+
+if test "x${policykit}" == xyes ; then
+ PKG_CHECK_MODULES(POLKIT, [ polkit-dbus >= 0.7 ],
+ [
+ HAVE_POLKIT=1
+ AC_DEFINE([HAVE_POLKIT], 1, [Have PolicyKit])
+ policydir=`pkg-config polkit-dbus --variable
prefix`/share/PolicyKit/policy/
+ AC_SUBST(policydir)
+ ],
+ [
+ HAVE_POLKIT=0
+ AC_MSG_ERROR([*** PolicyKit support not found, install
PolicyKit-devel: 'zypper in PolicyKit-devel' or libpolkit-dbus-dev.deb])
+ ])
+else
+ HAVE_POLKIT=0
+fi
+
+AC_SUBST(POLKIT_CFLAGS)
+AC_SUBST(POLKIT_LIBS)
+AC_SUBST(HAVE_POLKIT)
+AM_CONDITIONAL([HAVE_POLKIT], [test "x$HAVE_POLKIT" = x1])
+
## and generate the output
AC_CONFIG_FILES([
liby2/doc/Y2-access.html
Modified: trunk/core/libscr/src/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/libscr/src/Makefile.am?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/libscr/src/Makefile.am (original)
+++ trunk/core/libscr/src/Makefile.am Mon Jul 21 17:04:21 2008
@@ -11,9 +11,15 @@
libscr_la_SOURCES = \
SCRAgent.cc SCR.cc
+libscr_la_CPPFLAGS = $(DBUS_CFLAGS)
+
+libscr_la_LIBADD = $(srcdir)/../../liby2dbus/src/liby2dbus.la
+
INCLUDES = \
-I$(srcdir)/../../libycp/src/include \
-I$(srcdir)/../../liby2/src/include \
+ -I$(srcdir)/../../liby2dbus/src \
+ -I$(srcdir)/../../scr/src \
-I$(srcdir)/include \
${Y2UTIL_CFLAGS}
Modified: trunk/core/libscr/src/SCR.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/libscr/src/SCR.cc?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/libscr/src/SCR.cc (original)
+++ trunk/core/libscr/src/SCR.cc Mon Jul 21 17:04:21 2008
@@ -29,12 +29,96 @@
#include "ycp/y2log.h"
#include "scr/SCRAgent.h"
+#include "DBusConn.h"
+#include "DBusMsg.h"
+
extern StaticDeclaration static_declarations;
bool SCR::registered = false;
+// DBus related variables
+DBusConn *connection;
+
+bool check_dbus_env()
+{
+ const char* y2dbus = ::getenv("Y2DBUS");
+
+ if (y2dbus != NULL)
+ {
+ if (::strcmp(y2dbus, "1") == 0)
+ return true;
+ }
+
+ return false;
+}
+
+static YCPValue CallDBus(const char *method, const YCPPath &path = YCPNull(),
const YCPValue &args = YCPNull (),
+ const YCPValue &opt = YCPNull ())
+{
+
+ y2milestone("Calling DBus method %s: path: %s, args: %s, opt: %s", method,
path.isNull() ? "NULL" : path->toString().c_str(), args.isNull() ? "NULL" :
args->toString().c_str(), opt.isNull() ? "NULL" : opt->toString().c_str());
+
+ DBusMsg msg;
+ // TODO create constants for these strings
+ msg.createCall("org.opensuse.yast.SCR", "/SCR",
"org.opensuse.yast.SCR.Methods", method);
+
+ if (!path.isNull())
+ {
+ msg.addYCPValue(path);
+ }
+
+ if (!args.isNull())
+ {
+ msg.addYCPValue(args);
+ }
+
+ if (!opt.isNull())
+ {
+ msg.addYCPValue(opt);
+ }
+
+ // send the message and get the response
+ DBusMsg reply(connection->call(msg));
+
+ y2debug("Received reply type: %d", reply.type());
+
+ // return the first argument from the reply
+ YCPValue ret = reply.getYCPValue(0);
+
+ // validate the reply (check for exceptions)
+ if (reply.type() != DBUS_MESSAGE_TYPE_METHOD_RETURN)
+ {
+ if (reply.type() == DBUS_MESSAGE_TYPE_ERROR)
+ {
+ if (!ret.isNull())
+ {
+ y2error("Received Error reply: %s",
ret->toString().c_str());
+ }
+ }
+
+ return YCPVoid();
+ }
+
+ if (!ret.isNull())
+ {
+ y2milestone("Received reply: %s", ret->toString().c_str());
+ }
+ else
+ {
+ y2error("Received YCPNull or the value is missing");
+ }
+
+ return ret;
+}
+
static YCPValue
SCRRead3 (const YCPPath &path, const YCPValue &args = YCPNull (), const
YCPValue &opt = YCPNull ()) {
+
+ if (connection != NULL)
+ {
+ return CallDBus("Read", path, args, opt);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -57,6 +141,11 @@
static YCPValue
SCRWrite2 (const YCPPath &path, const YCPValue& value) {
+ if (connection != NULL)
+ {
+ return CallDBus("Write", path, value);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -68,6 +157,11 @@
static YCPValue
SCRWrite3 (const YCPPath &path, const YCPValue& value, const YCPValue& arg) {
+ if (connection != NULL)
+ {
+ return CallDBus("Write", path, value, arg);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -79,6 +173,11 @@
static YCPValue
SCRDir (const YCPPath& path) {
+ if (connection != NULL)
+ {
+ return CallDBus("Dir", path);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -90,6 +189,11 @@
static YCPValue
SCRExecute (const YCPPath &path) {
+ if (connection != NULL)
+ {
+ return CallDBus("Execute", path);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -101,6 +205,11 @@
static YCPValue
SCRError (const YCPPath &path) {
+ if (connection != NULL)
+ {
+ return CallDBus("Error", path);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -114,6 +223,11 @@
static YCPValue
SCRExecute2 (const YCPPath &path, const YCPValue &arg) {
+ if (connection != NULL)
+ {
+ return CallDBus("Execute", path, arg);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -128,6 +242,11 @@
static YCPValue
SCRExecute3 (const YCPPath &path, const YCPValue &arg, const YCPValue &opt) {
+ if (connection != NULL)
+ {
+ return CallDBus("Execute", path, arg, opt);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -142,6 +261,11 @@
static YCPValue
SCRRegisterAgentS (const YCPPath &path, const YCPString &arg) {
+ if (connection != NULL)
+ {
+ return CallDBus("RegisterAgent", path, arg);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -155,6 +279,11 @@
static YCPValue
SCRRegisterAgentT (const YCPPath &path, const YCPTerm &arg) {
+ if (connection != NULL)
+ {
+ return CallDBus("RegisterAgent", path, arg);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -168,6 +297,11 @@
static YCPValue
SCRUnregisterAgent (const YCPPath &path) {
+ if (connection != NULL)
+ {
+ return CallDBus("UnregisterAgent", path);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -180,6 +314,11 @@
static YCPValue
SCRUnregisterAllAgents () {
+ if (connection != NULL)
+ {
+ return CallDBus("UnregisterAllAgents");
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -191,6 +330,11 @@
static YCPValue
SCRUnmountAgent (const YCPPath &path) {
+ if (connection != NULL)
+ {
+ return CallDBus("UnmountAgent", path);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -203,6 +347,11 @@
static YCPValue
SCRRegisterNewAgents () {
+ if (connection != NULL)
+ {
+ return CallDBus("RegisterNewAgents");
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -244,5 +393,32 @@
static_declarations.registerDeclarations ("SCR", declarations);
registered = true;
+
+ bool y2dbus = check_dbus_env();
+
+ // use std SCR or DBUS SCR?
+ if (y2dbus)
+ {
+ y2debug("Y2DBUS is set, using DBUS for SCR access");
+ connection = new DBusConn;
+
+ // connect to the system bus
+ if (!connection->connect(DBUS_BUS_SYSTEM))
+ {
+ y2error("Cannot connect to DBus, exiting...");
+ exit(1);
+ }
+ }
+ else
+ {
+ y2debug("Y2DBUS is not set, using embedded SCR");
+ }
}
+SCR::~SCR()
+{
+ if (connection != NULL)
+ {
+ delete connection;
+ }
+}
Modified: trunk/core/libscr/src/include/scr/SCR.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/libscr/src/include/scr/SCR.h?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/libscr/src/include/scr/SCR.h (original)
+++ trunk/core/libscr/src/include/scr/SCR.h Mon Jul 21 17:04:21 2008
@@ -25,6 +25,7 @@
public:
SCR ();
+ ~SCR();
static bool registered;
};
Modified: trunk/core/libscr/testsuite/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/libscr/testsuite/Makefile.am?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/libscr/testsuite/Makefile.am (original)
+++ trunk/core/libscr/testsuite/Makefile.am Mon Jul 21 17:04:21 2008
@@ -12,7 +12,7 @@
noinst_PROGRAMS = runscr
runscr_SOURCES = runscr.cc
-runscr_LDADD = ../src/libscr.la ../../liby2/src/liby2.la
../../libycp/src/libycp.la ${Y2UTIL_LIBS}
+runscr_LDADD = ../src/libscr.la ../../liby2/src/liby2.la
../../libycp/src/libycp.la ${Y2UTIL_LIBS} ../../liby2dbus/src/liby2dbus.la
PACKAGE = libscr
AUTOMAKE_OPTIONS = dejagnu
Modified: trunk/core/scr/src/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/scr/src/Makefile.am?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/scr/src/Makefile.am (original)
+++ trunk/core/scr/src/Makefile.am Mon Jul 21 17:04:21 2008
@@ -31,3 +31,5 @@
libpy2scr_la_LDFLAGS = -version-info 2:0
INCLUDES = ${AGENT_INCLUDES}
+
+
Modified: trunk/core/scr/src/ScriptingAgent.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/scr/src/ScriptingAgent.h?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/scr/src/ScriptingAgent.h (original)
+++ trunk/core/scr/src/ScriptingAgent.h Mon Jul 21 17:04:21 2008
@@ -104,6 +104,18 @@
*/
virtual YCPBoolean UnmountAgent (const YCPPath &path);
+ /**
+ * Register new agents. (bnc#245508#c16)
+ * Rescan the scrconf registration directories and register any
+ * agents at new(!) paths. Agents, even new ones, on paths that
+ * are registered already, will not be replaced. This means that
+ * .oes.specific.agent will start to work but something like
+ * adding
+ * /usr/local/etc/sysconfig to .sysconfig.network would not.
+ */
+ virtual YCPBoolean RegisterNewAgents ();
+
+
private:
// once we have to do a sweep (read all scr files because of
@@ -157,17 +169,6 @@
void Sweep ();
/**
- * Register new agents. (bnc#245508#c16)
- * Rescan the scrconf registration directories and register any
- * agents at new(!) paths. Agents, even new ones, on paths that
- * are registered already, will not be replaced. This means that
- * .oes.specific.agent will start to work but something like
- * adding
- * /usr/local/etc/sysconfig to .sysconfig.network would not.
- */
- YCPBoolean RegisterNewAgents ();
-
- /**
* For .foo.bar.baz, register foo.bar.baz.scr, or foo.bar.scr, or foo.scr.
* BTW we can register an unrelated path because this is just a heuristic.
*/
Modified: trunk/core/wfm/testsuite/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/wfm/testsuite/Makefile.am?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/wfm/testsuite/Makefile.am (original)
+++ trunk/core/wfm/testsuite/Makefile.am Mon Jul 21 17:04:21 2008
@@ -22,7 +22,8 @@
runwfm_LDADD = \
../src/libpy2wfm.la \
- $(top_builddir)/libscr/src/libscr.la \
+ $(top_builddir)/scr/src/libpy2scr.la \
+ $(top_builddir)/libscr/src/libscr.la \
$(top_builddir)/libycp/src/libycp.la \
$(top_builddir)/liby2/src/liby2.la \
${Y2UTIL_LIBS}
@@ -30,7 +31,8 @@
runc_SOURCES = runc.cc
runc_LDFLAGS = -L$(libdir)
runc_LDADD = ../src/libpy2wfm.la \
- $(top_builddir)/libscr/src/libscr.la \
+ $(top_builddir)/scr/src/libpy2scr.la \
+ $(top_builddir)/libscr/src/libscr.la \
$(top_builddir)/libycp/src/libycp.la \
$(top_builddir)/liby2/src/liby2.la \
${Y2UTIL_LIBS}
Modified: trunk/core/yast2-core.spec.in
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/yast2-core.spec.in?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/yast2-core.spec.in (original)
+++ trunk/core/yast2-core.spec.in Mon Jul 21 17:04:21 2008
@@ -22,6 +22,9 @@
# libycp includes crypto built-ins
BuildRequires: libxcrypt-devel
+# for SCR DBus service
+BuildRequires: dbus-1-devel PolicyKit-devel
+
Summary: -
Requires: perl = %{perl_version}
Provides: liby2util = 2.16.1
@@ -95,6 +98,11 @@
# .packlist
%{perl_vendorarch}/auto/ycp
/var/adm/perl-modules/%name
+# DBus service
+@ybindir@/SCR_dbus_server
+# DBus service config
+/usr/share/dbus-1/system-services/org.opensuse.yast.SCR.service
+/etc/dbus-1/system.d/org.opensuse.yast.SCR.conf
%files devel
%defattr(-,root,root)
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx
Date: Mon Jul 21 17:04:21 2008
New Revision: 49299
URL: http://svn.opensuse.org/viewcvs/yast?rev=49299&view=rev
Log:
- merged experimental DBus/PolicyKit support from
http://svn.opensuse.org/svn/yast/branches/tmp/lslezak/workshop/core/
branch (rev. 48695:49298)
Added:
trunk/core/dbus/ (props changed)
- copied from r49298, branches/tmp/lslezak/workshop/core/dbus/
trunk/core/dbus/Makefile.am
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/dbus/Makefile.am
trunk/core/dbus/SCR_service/ (props changed)
- copied from r49298, branches/tmp/lslezak/workshop/core/dbus/SCR_service/
trunk/core/dbus/SCR_service/DBusServer.cc
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/dbus/SCR_service/DBusServer.cc
trunk/core/dbus/SCR_service/DBusServer.h
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/dbus/SCR_service/DBusServer.h
trunk/core/dbus/SCR_service/Makefile.am
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/dbus/SCR_service/Makefile.am
trunk/core/dbus/SCR_service/SCR_dbus_server.cc
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/dbus/SCR_service/SCR_dbus_server.cc
trunk/core/dbus/SCR_service/org.opensuse.yast.SCR.conf.in
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/dbus/SCR_service/org.opensuse.yast.SCR.conf.in
trunk/core/dbus/SCR_service/org.opensuse.yast.SCR.service.in
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/dbus/SCR_service/org.opensuse.yast.SCR.service.in
trunk/core/liby2dbus/ (props changed)
- copied from r49298, branches/tmp/lslezak/workshop/core/liby2dbus/
trunk/core/liby2dbus/Makefile.am
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/Makefile.am
trunk/core/liby2dbus/src/ (props changed)
- copied from r49298, branches/tmp/lslezak/workshop/core/liby2dbus/src/
trunk/core/liby2dbus/src/DBusConn.cc
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/src/DBusConn.cc
trunk/core/liby2dbus/src/DBusConn.h
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/src/DBusConn.h
trunk/core/liby2dbus/src/DBusMsg.cc
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/src/DBusMsg.cc
trunk/core/liby2dbus/src/DBusMsg.h
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/src/DBusMsg.h
trunk/core/liby2dbus/src/Makefile.am
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/src/Makefile.am
trunk/core/liby2dbus/src/PolKit.cc
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/src/PolKit.cc
trunk/core/liby2dbus/src/PolKit.h
- copied unchanged from r49298,
branches/tmp/lslezak/workshop/core/liby2dbus/src/PolKit.h
Modified:
trunk/core/SUBDIRS
trunk/core/base/src/Makefile.am
trunk/core/configure.in.in
trunk/core/libscr/src/Makefile.am
trunk/core/libscr/src/SCR.cc
trunk/core/libscr/src/include/scr/SCR.h
trunk/core/libscr/testsuite/Makefile.am
trunk/core/scr/src/Makefile.am
trunk/core/scr/src/ScriptingAgent.h
trunk/core/wfm/testsuite/Makefile.am
trunk/core/yast2-core.spec.in
Modified: trunk/core/SUBDIRS
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/SUBDIRS?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/SUBDIRS (original)
+++ trunk/core/SUBDIRS Mon Jul 21 17:04:21 2008
@@ -1 +1 @@
-liby2util-r liby2 libycp libscr agent-dummy scr agent-system agent-any
agent-ini agent-modules agent-resolver agents-non-y2 agents-perl wfm base
autodocs agent-process
+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
base autodocs agent-process dbus
Modified: trunk/core/base/src/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/base/src/Makefile.am?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/base/src/Makefile.am (original)
+++ trunk/core/base/src/Makefile.am Mon Jul 21 17:04:21 2008
@@ -8,12 +8,11 @@
YAST2CORE = \
../../wfm/src/libpy2wfm.la \
+ ../../scr/src/libpy2scr.la \
../../libycp/src/libycp.la \
../../liby2/src/liby2.la \
../../libscr/src/libscr.la
-# ../../scr/src/libpy2scr.la
-
y2base_DEPENDENCIES = $(YAST2CORE)
Modified: trunk/core/configure.in.in
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/configure.in.in?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/configure.in.in (original)
+++ trunk/core/configure.in.in Mon Jul 21 17:04:21 2008
@@ -90,6 +90,41 @@
AC_MSG_ERROR(Headers for blocxx are missing. Please install the package
blocxx-devel.)
fi
+PKG_CHECK_MODULES(DBUS, dbus-1)
+
+## check for PolicyKit
+AC_ARG_ENABLE([policykit],
+ AS_HELP_STRING([--enable-policykit], [Enable experimental PolicyKit
support]),
+ [
+ case "${enableval}" in
+ yes) policykit=yes ;;
+ no) policykit=no ;;
+ *) AC_MSG_ERROR(--enable-policykit: Unknwon value
${enableval}) ;;
+ esac
+ ],
+ [policykit=yes])
+
+if test "x${policykit}" == xyes ; then
+ PKG_CHECK_MODULES(POLKIT, [ polkit-dbus >= 0.7 ],
+ [
+ HAVE_POLKIT=1
+ AC_DEFINE([HAVE_POLKIT], 1, [Have PolicyKit])
+ policydir=`pkg-config polkit-dbus --variable
prefix`/share/PolicyKit/policy/
+ AC_SUBST(policydir)
+ ],
+ [
+ HAVE_POLKIT=0
+ AC_MSG_ERROR([*** PolicyKit support not found, install
PolicyKit-devel: 'zypper in PolicyKit-devel' or libpolkit-dbus-dev.deb])
+ ])
+else
+ HAVE_POLKIT=0
+fi
+
+AC_SUBST(POLKIT_CFLAGS)
+AC_SUBST(POLKIT_LIBS)
+AC_SUBST(HAVE_POLKIT)
+AM_CONDITIONAL([HAVE_POLKIT], [test "x$HAVE_POLKIT" = x1])
+
## and generate the output
AC_CONFIG_FILES([
liby2/doc/Y2-access.html
Modified: trunk/core/libscr/src/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/libscr/src/Makefile.am?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/libscr/src/Makefile.am (original)
+++ trunk/core/libscr/src/Makefile.am Mon Jul 21 17:04:21 2008
@@ -11,9 +11,15 @@
libscr_la_SOURCES = \
SCRAgent.cc SCR.cc
+libscr_la_CPPFLAGS = $(DBUS_CFLAGS)
+
+libscr_la_LIBADD = $(srcdir)/../../liby2dbus/src/liby2dbus.la
+
INCLUDES = \
-I$(srcdir)/../../libycp/src/include \
-I$(srcdir)/../../liby2/src/include \
+ -I$(srcdir)/../../liby2dbus/src \
+ -I$(srcdir)/../../scr/src \
-I$(srcdir)/include \
${Y2UTIL_CFLAGS}
Modified: trunk/core/libscr/src/SCR.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/libscr/src/SCR.cc?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/libscr/src/SCR.cc (original)
+++ trunk/core/libscr/src/SCR.cc Mon Jul 21 17:04:21 2008
@@ -29,12 +29,96 @@
#include "ycp/y2log.h"
#include "scr/SCRAgent.h"
+#include "DBusConn.h"
+#include "DBusMsg.h"
+
extern StaticDeclaration static_declarations;
bool SCR::registered = false;
+// DBus related variables
+DBusConn *connection;
+
+bool check_dbus_env()
+{
+ const char* y2dbus = ::getenv("Y2DBUS");
+
+ if (y2dbus != NULL)
+ {
+ if (::strcmp(y2dbus, "1") == 0)
+ return true;
+ }
+
+ return false;
+}
+
+static YCPValue CallDBus(const char *method, const YCPPath &path = YCPNull(),
const YCPValue &args = YCPNull (),
+ const YCPValue &opt = YCPNull ())
+{
+
+ y2milestone("Calling DBus method %s: path: %s, args: %s, opt: %s", method,
path.isNull() ? "NULL" : path->toString().c_str(), args.isNull() ? "NULL" :
args->toString().c_str(), opt.isNull() ? "NULL" : opt->toString().c_str());
+
+ DBusMsg msg;
+ // TODO create constants for these strings
+ msg.createCall("org.opensuse.yast.SCR", "/SCR",
"org.opensuse.yast.SCR.Methods", method);
+
+ if (!path.isNull())
+ {
+ msg.addYCPValue(path);
+ }
+
+ if (!args.isNull())
+ {
+ msg.addYCPValue(args);
+ }
+
+ if (!opt.isNull())
+ {
+ msg.addYCPValue(opt);
+ }
+
+ // send the message and get the response
+ DBusMsg reply(connection->call(msg));
+
+ y2debug("Received reply type: %d", reply.type());
+
+ // return the first argument from the reply
+ YCPValue ret = reply.getYCPValue(0);
+
+ // validate the reply (check for exceptions)
+ if (reply.type() != DBUS_MESSAGE_TYPE_METHOD_RETURN)
+ {
+ if (reply.type() == DBUS_MESSAGE_TYPE_ERROR)
+ {
+ if (!ret.isNull())
+ {
+ y2error("Received Error reply: %s",
ret->toString().c_str());
+ }
+ }
+
+ return YCPVoid();
+ }
+
+ if (!ret.isNull())
+ {
+ y2milestone("Received reply: %s", ret->toString().c_str());
+ }
+ else
+ {
+ y2error("Received YCPNull or the value is missing");
+ }
+
+ return ret;
+}
+
static YCPValue
SCRRead3 (const YCPPath &path, const YCPValue &args = YCPNull (), const
YCPValue &opt = YCPNull ()) {
+
+ if (connection != NULL)
+ {
+ return CallDBus("Read", path, args, opt);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -57,6 +141,11 @@
static YCPValue
SCRWrite2 (const YCPPath &path, const YCPValue& value) {
+ if (connection != NULL)
+ {
+ return CallDBus("Write", path, value);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -68,6 +157,11 @@
static YCPValue
SCRWrite3 (const YCPPath &path, const YCPValue& value, const YCPValue& arg) {
+ if (connection != NULL)
+ {
+ return CallDBus("Write", path, value, arg);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -79,6 +173,11 @@
static YCPValue
SCRDir (const YCPPath& path) {
+ if (connection != NULL)
+ {
+ return CallDBus("Dir", path);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -90,6 +189,11 @@
static YCPValue
SCRExecute (const YCPPath &path) {
+ if (connection != NULL)
+ {
+ return CallDBus("Execute", path);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -101,6 +205,11 @@
static YCPValue
SCRError (const YCPPath &path) {
+ if (connection != NULL)
+ {
+ return CallDBus("Error", path);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -114,6 +223,11 @@
static YCPValue
SCRExecute2 (const YCPPath &path, const YCPValue &arg) {
+ if (connection != NULL)
+ {
+ return CallDBus("Execute", path, arg);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -128,6 +242,11 @@
static YCPValue
SCRExecute3 (const YCPPath &path, const YCPValue &arg, const YCPValue &opt) {
+ if (connection != NULL)
+ {
+ return CallDBus("Execute", path, arg, opt);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -142,6 +261,11 @@
static YCPValue
SCRRegisterAgentS (const YCPPath &path, const YCPString &arg) {
+ if (connection != NULL)
+ {
+ return CallDBus("RegisterAgent", path, arg);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -155,6 +279,11 @@
static YCPValue
SCRRegisterAgentT (const YCPPath &path, const YCPTerm &arg) {
+ if (connection != NULL)
+ {
+ return CallDBus("RegisterAgent", path, arg);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -168,6 +297,11 @@
static YCPValue
SCRUnregisterAgent (const YCPPath &path) {
+ if (connection != NULL)
+ {
+ return CallDBus("UnregisterAgent", path);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -180,6 +314,11 @@
static YCPValue
SCRUnregisterAllAgents () {
+ if (connection != NULL)
+ {
+ return CallDBus("UnregisterAllAgents");
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -191,6 +330,11 @@
static YCPValue
SCRUnmountAgent (const YCPPath &path) {
+ if (connection != NULL)
+ {
+ return CallDBus("UnmountAgent", path);
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -203,6 +347,11 @@
static YCPValue
SCRRegisterNewAgents () {
+ if (connection != NULL)
+ {
+ return CallDBus("RegisterNewAgents");
+ }
+
if (! SCRAgent::instance())
{
ycperror ( "No SCR instance found" );
@@ -244,5 +393,32 @@
static_declarations.registerDeclarations ("SCR", declarations);
registered = true;
+
+ bool y2dbus = check_dbus_env();
+
+ // use std SCR or DBUS SCR?
+ if (y2dbus)
+ {
+ y2debug("Y2DBUS is set, using DBUS for SCR access");
+ connection = new DBusConn;
+
+ // connect to the system bus
+ if (!connection->connect(DBUS_BUS_SYSTEM))
+ {
+ y2error("Cannot connect to DBus, exiting...");
+ exit(1);
+ }
+ }
+ else
+ {
+ y2debug("Y2DBUS is not set, using embedded SCR");
+ }
}
+SCR::~SCR()
+{
+ if (connection != NULL)
+ {
+ delete connection;
+ }
+}
Modified: trunk/core/libscr/src/include/scr/SCR.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/libscr/src/include/scr/SCR.h?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/libscr/src/include/scr/SCR.h (original)
+++ trunk/core/libscr/src/include/scr/SCR.h Mon Jul 21 17:04:21 2008
@@ -25,6 +25,7 @@
public:
SCR ();
+ ~SCR();
static bool registered;
};
Modified: trunk/core/libscr/testsuite/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/libscr/testsuite/Makefile.am?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/libscr/testsuite/Makefile.am (original)
+++ trunk/core/libscr/testsuite/Makefile.am Mon Jul 21 17:04:21 2008
@@ -12,7 +12,7 @@
noinst_PROGRAMS = runscr
runscr_SOURCES = runscr.cc
-runscr_LDADD = ../src/libscr.la ../../liby2/src/liby2.la
../../libycp/src/libycp.la ${Y2UTIL_LIBS}
+runscr_LDADD = ../src/libscr.la ../../liby2/src/liby2.la
../../libycp/src/libycp.la ${Y2UTIL_LIBS} ../../liby2dbus/src/liby2dbus.la
PACKAGE = libscr
AUTOMAKE_OPTIONS = dejagnu
Modified: trunk/core/scr/src/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/scr/src/Makefile.am?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/scr/src/Makefile.am (original)
+++ trunk/core/scr/src/Makefile.am Mon Jul 21 17:04:21 2008
@@ -31,3 +31,5 @@
libpy2scr_la_LDFLAGS = -version-info 2:0
INCLUDES = ${AGENT_INCLUDES}
+
+
Modified: trunk/core/scr/src/ScriptingAgent.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/scr/src/ScriptingAgent.h?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/scr/src/ScriptingAgent.h (original)
+++ trunk/core/scr/src/ScriptingAgent.h Mon Jul 21 17:04:21 2008
@@ -104,6 +104,18 @@
*/
virtual YCPBoolean UnmountAgent (const YCPPath &path);
+ /**
+ * Register new agents. (bnc#245508#c16)
+ * Rescan the scrconf registration directories and register any
+ * agents at new(!) paths. Agents, even new ones, on paths that
+ * are registered already, will not be replaced. This means that
+ * .oes.specific.agent will start to work but something like
+ * adding
+ * /usr/local/etc/sysconfig to .sysconfig.network would not.
+ */
+ virtual YCPBoolean RegisterNewAgents ();
+
+
private:
// once we have to do a sweep (read all scr files because of
@@ -157,17 +169,6 @@
void Sweep ();
/**
- * Register new agents. (bnc#245508#c16)
- * Rescan the scrconf registration directories and register any
- * agents at new(!) paths. Agents, even new ones, on paths that
- * are registered already, will not be replaced. This means that
- * .oes.specific.agent will start to work but something like
- * adding
- * /usr/local/etc/sysconfig to .sysconfig.network would not.
- */
- YCPBoolean RegisterNewAgents ();
-
- /**
* For .foo.bar.baz, register foo.bar.baz.scr, or foo.bar.scr, or foo.scr.
* BTW we can register an unrelated path because this is just a heuristic.
*/
Modified: trunk/core/wfm/testsuite/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/wfm/testsuite/Makefile.am?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/wfm/testsuite/Makefile.am (original)
+++ trunk/core/wfm/testsuite/Makefile.am Mon Jul 21 17:04:21 2008
@@ -22,7 +22,8 @@
runwfm_LDADD = \
../src/libpy2wfm.la \
- $(top_builddir)/libscr/src/libscr.la \
+ $(top_builddir)/scr/src/libpy2scr.la \
+ $(top_builddir)/libscr/src/libscr.la \
$(top_builddir)/libycp/src/libycp.la \
$(top_builddir)/liby2/src/liby2.la \
${Y2UTIL_LIBS}
@@ -30,7 +31,8 @@
runc_SOURCES = runc.cc
runc_LDFLAGS = -L$(libdir)
runc_LDADD = ../src/libpy2wfm.la \
- $(top_builddir)/libscr/src/libscr.la \
+ $(top_builddir)/scr/src/libpy2scr.la \
+ $(top_builddir)/libscr/src/libscr.la \
$(top_builddir)/libycp/src/libycp.la \
$(top_builddir)/liby2/src/liby2.la \
${Y2UTIL_LIBS}
Modified: trunk/core/yast2-core.spec.in
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/yast2-core.spec.in?rev=49299&r1=49298&r2=49299&view=diff
==============================================================================
--- trunk/core/yast2-core.spec.in (original)
+++ trunk/core/yast2-core.spec.in Mon Jul 21 17:04:21 2008
@@ -22,6 +22,9 @@
# libycp includes crypto built-ins
BuildRequires: libxcrypt-devel
+# for SCR DBus service
+BuildRequires: dbus-1-devel PolicyKit-devel
+
Summary: -
Requires: perl = %{perl_version}
Provides: liby2util = 2.16.1
@@ -95,6 +98,11 @@
# .packlist
%{perl_vendorarch}/auto/ycp
/var/adm/perl-modules/%name
+# DBus service
+@ybindir@/SCR_dbus_server
+# DBus service config
+/usr/share/dbus-1/system-services/org.opensuse.yast.SCR.service
+/etc/dbus-1/system.d/org.opensuse.yast.SCR.conf
%files devel
%defattr(-,root,root)
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx
| < Previous | Next > |