[PATCH] Allow disable of SysV init/rcN.d support at compile time.

2010-09-07 Thread Gustavo Sverzut Barbieri
This patch adds a cpp definition HAVE_SYSV_COMPAT that is used to
isolate code dealing with /etc/init.d and /etc/rcN.d for systems where
it does not make sense (one that does not use sysv or one that is fully
systemd native).

The patch tries to be as little intrusive as possible, however in
order to minimize the number of #ifdef'ed regions I've reordered some
code in path-lookup.c:lookup_paths_init() where all code dealing with
sysv is now isolated under running_as == MANAGER_SYSTEM as well.
---
 configure.ac   |   17 ++---
 src/dbus-manager.c |2 +
 src/path-lookup.c  |  102 
 src/path-lookup.h  |2 +
 src/service.c  |   41 -
 5 files changed, 102 insertions(+), 62 deletions(-)

diff --git a/configure.ac b/configure.ac
index ba9bbf8..30b291f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -310,7 +310,8 @@ case $with_distro in
 M4_DISTRO_FLAG=-DTARGET_ARCH=1
 ;;
 gentoo)
-SYSTEM_SYSVRCND_PATH=/etc
+SYSTEM_SYSVINIT_PATH=
+SYSTEM_SYSVRCND_PATH=
 SPECIAL_SYSLOG_SERVICE=syslog-ng.service
 AC_DEFINE(TARGET_GENTOO, [], [Target is Gentoo])
 M4_DISTRO_FLAG=-DTARGET_GENTOO=1
@@ -322,10 +323,6 @@ case $with_distro in
 M4_DISTRO_FLAG=-DTARGET_SLACKWARE=1
 ;;
 other)
-AS_IF([test "x$with_sysvinit_path" = "x"],
-[AC_MSG_ERROR([With --distro=other, you must pass 
--with-sysvinit-path= to configure])])
-AS_IF([test "x$with_sysvrcd_path" = "x"],
-[AC_MSG_ERROR([With --distro=other, you must pass 
--with-sysvrcd-path= to configure])])
 AS_IF([test "x$with_syslog_service" = "x"],
 [AC_MSG_ERROR([With --distro=other, you must pass 
--with-syslog-service= to configure])])
 ;;
@@ -357,6 +354,15 @@ AC_SUBST(SYSTEM_SYSVRCND_PATH)
 AC_SUBST(SPECIAL_SYSLOG_SERVICE)
 AC_SUBST(M4_DISTRO_FLAG)
 
+if test "x${SYSTEM_SYSVINIT_PATH}" != "x" -a "x${SYSTEM_SYSVRCND_PATH}" != 
"x"; then
+AC_DEFINE(HAVE_SYSV_COMPAT, [], [SysV init scripts and rcN.d links are 
supported.])
+SYSTEM_SYSV_COMPAT="enabled"
+elif test "x${SYSTEM_SYSVINIT_PATH}" != "x" -o "x${SYSTEM_SYSVRCND_PATH}" != 
"x"; then
+AC_MSG_ERROR([*** You need both --with-sysvinit-path=PATH and 
--with-sysvrcd-path=PATH to enable SysV compatibility support, or both empty to 
disable it.])
+else
+SYSTEM_SYSV_COMPAT="disabled"
+fi
+
 AM_CONDITIONAL(TARGET_FEDORA, test x"$with_distro" = xfedora)
 AM_CONDITIONAL(TARGET_SUSE, test x"$with_distro" = xsuse)
 AM_CONDITIONAL(TARGET_DEBIAN, test x"$with_distro" = xdebian)
@@ -416,6 +422,7 @@ echo "
 $PACKAGE_NAME $VERSION
 
 Distribution:${with_distro}
+SysV compatibility:  ${SYSTEM_SYSV_COMPAT}
 SysV init scripts:   ${SYSTEM_SYSVINIT_PATH}
 SysV rc?.d directories:  ${SYSTEM_SYSVRCND_PATH}
 Syslog service:  ${SPECIAL_SYSLOG_SERVICE}
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index cffa547..f268e10 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -250,8 +250,10 @@ static DBusHandlerResult 
bus_manager_message_handler(DBusConnection *connection,
 { "org.freedesktop.systemd1.Manager", "ShowStatus",
bus_property_append_bool,  "b",  &m->show_status},
 { "org.freedesktop.systemd1.Manager", "SysVConsole",   
bus_property_append_bool,  "b",  &m->sysv_console   },
 { "org.freedesktop.systemd1.Manager", "UnitPath",  
bus_property_append_strv,  "as", m->lookup_paths.unit_path },
+#ifdef HAVE_SYSV_COMPAT
 { "org.freedesktop.systemd1.Manager", "SysVInitPath",  
bus_property_append_strv,  "as", m->lookup_paths.sysvinit_path },
 { "org.freedesktop.systemd1.Manager", "SysVRcndPath",  
bus_property_append_strv,  "as", m->lookup_paths.sysvrcnd_path },
+#endif
 { "org.freedesktop.systemd1.Manager", "NotifySocket",  
bus_property_append_string,"s",  m->notify_socket   },
 { "org.freedesktop.systemd1.Manager", "ControlGroupHierarchy", 
bus_property_append_string, "s", m->cgroup_hierarchy },
 { "org.freedesktop.systemd1.Manager", "MountAuto", 
bus_property_append_bool,  "b",  &m->mount_auto },
diff --git a/src/path-lookup.c b/src/path-lookup.c
index 28336eb..258252a 100644
--- a/src/path-lookup.c
+++ b/src/path-lookup.c
@@ -191,7 +191,26 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs 
running_as) {
 return -ENOMEM;
 }
 
+if (p->unit_path)
+if (!strv_path_canonicalize(p->unit_path))
+return -ENOMEM;
+
+strv_uniq(p->unit_path);
+
+if (!strv_isempty(p->unit_path

[PATCH] Allow disable of SysV init/rcN.d support at compile time.

2010-09-08 Thread Gustavo Sverzut Barbieri
This patch adds a cpp definition HAVE_SYSV_COMPAT that is used to
isolate code dealing with /etc/init.d and /etc/rcN.d for systems where
it does not make sense (one that does not use sysv or one that is fully
systemd native).

The patch tries to be as little intrusive as possible, however in
order to minimize the number of #ifdef'ed regions I've reordered some
code in path-lookup.c:lookup_paths_init() where all code dealing with
sysv is now isolated under running_as == MANAGER_SYSTEM as well.
---
 configure.ac   |   17 ++---
 src/build.h|8 -
 src/dbus-manager.c |2 +
 src/path-lookup.c  |  102 
 src/path-lookup.h  |2 +
 src/service.c  |   41 -
 6 files changed, 109 insertions(+), 63 deletions(-)

diff --git a/configure.ac b/configure.ac
index ba9bbf8..30b291f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -310,7 +310,8 @@ case $with_distro in
 M4_DISTRO_FLAG=-DTARGET_ARCH=1
 ;;
 gentoo)
-SYSTEM_SYSVRCND_PATH=/etc
+SYSTEM_SYSVINIT_PATH=
+SYSTEM_SYSVRCND_PATH=
 SPECIAL_SYSLOG_SERVICE=syslog-ng.service
 AC_DEFINE(TARGET_GENTOO, [], [Target is Gentoo])
 M4_DISTRO_FLAG=-DTARGET_GENTOO=1
@@ -322,10 +323,6 @@ case $with_distro in
 M4_DISTRO_FLAG=-DTARGET_SLACKWARE=1
 ;;
 other)
-AS_IF([test "x$with_sysvinit_path" = "x"],
-[AC_MSG_ERROR([With --distro=other, you must pass 
--with-sysvinit-path= to configure])])
-AS_IF([test "x$with_sysvrcd_path" = "x"],
-[AC_MSG_ERROR([With --distro=other, you must pass 
--with-sysvrcd-path= to configure])])
 AS_IF([test "x$with_syslog_service" = "x"],
 [AC_MSG_ERROR([With --distro=other, you must pass 
--with-syslog-service= to configure])])
 ;;
@@ -357,6 +354,15 @@ AC_SUBST(SYSTEM_SYSVRCND_PATH)
 AC_SUBST(SPECIAL_SYSLOG_SERVICE)
 AC_SUBST(M4_DISTRO_FLAG)
 
+if test "x${SYSTEM_SYSVINIT_PATH}" != "x" -a "x${SYSTEM_SYSVRCND_PATH}" != 
"x"; then
+AC_DEFINE(HAVE_SYSV_COMPAT, [], [SysV init scripts and rcN.d links are 
supported.])
+SYSTEM_SYSV_COMPAT="enabled"
+elif test "x${SYSTEM_SYSVINIT_PATH}" != "x" -o "x${SYSTEM_SYSVRCND_PATH}" != 
"x"; then
+AC_MSG_ERROR([*** You need both --with-sysvinit-path=PATH and 
--with-sysvrcd-path=PATH to enable SysV compatibility support, or both empty to 
disable it.])
+else
+SYSTEM_SYSV_COMPAT="disabled"
+fi
+
 AM_CONDITIONAL(TARGET_FEDORA, test x"$with_distro" = xfedora)
 AM_CONDITIONAL(TARGET_SUSE, test x"$with_distro" = xsuse)
 AM_CONDITIONAL(TARGET_DEBIAN, test x"$with_distro" = xdebian)
@@ -416,6 +422,7 @@ echo "
 $PACKAGE_NAME $VERSION
 
 Distribution:${with_distro}
+SysV compatibility:  ${SYSTEM_SYSV_COMPAT}
 SysV init scripts:   ${SYSTEM_SYSVINIT_PATH}
 SysV rc?.d directories:  ${SYSTEM_SYSVRCND_PATH}
 Syslog service:  ${SPECIAL_SYSLOG_SERVICE}
diff --git a/src/build.h b/src/build.h
index 5cb69be..b7f647a 100644
--- a/src/build.h
+++ b/src/build.h
@@ -46,6 +46,12 @@
 #define _SELINUX_FEATURE_ "-SELINUX"
 #endif
 
-#define SYSTEMD_FEATURES _PAM_FEATURE_ " " _LIBWRAP_FEATURE_ " " 
_AUDIT_FEATURE_ " " _SELINUX_FEATURE_
+#ifdef HAVE_SYSV
+#define _SYSVINIT_FEATURE_ "+SYSVINIT"
+#else
+#define _SYSVINIT_FEATURE_ "-SYSVINIT"
+#endif
+
+#define SYSTEMD_FEATURES _PAM_FEATURE_ " " _LIBWRAP_FEATURE_ " " 
_AUDIT_FEATURE_ " " _SELINUX_FEATURE_ " " _SYSVINIT_FEATURE_
 
 #endif
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index cffa547..f268e10 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -250,8 +250,10 @@ static DBusHandlerResult 
bus_manager_message_handler(DBusConnection *connection,
 { "org.freedesktop.systemd1.Manager", "ShowStatus",
bus_property_append_bool,  "b",  &m->show_status},
 { "org.freedesktop.systemd1.Manager", "SysVConsole",   
bus_property_append_bool,  "b",  &m->sysv_console   },
 { "org.freedesktop.systemd1.Manager", "UnitPath",  
bus_property_append_strv,  "as", m->lookup_paths.unit_path },
+#ifdef HAVE_SYSV_COMPAT
 { "org.freedesktop.systemd1.Manager", "SysVInitPath",  
bus_property_append_strv,  "as", m->lookup_paths.sysvinit_path },
 { "org.freedesktop.systemd1.Manager", "SysVRcndPath",  
bus_property_append_strv,  "as", m->lookup_paths.sysvrcnd_path },
+#endif
 { "org.freedesktop.systemd1.Manager", "NotifySocket",  
bus_property_append_string,"s",  m->notify_socket   },
 { "org.freedesktop.systemd1.Manager", "ControlGroupHierarchy", 
bus_property_append_string, "s", m->cgroup_hierarchy },
 { "org.freedesktop.systemd1.Manager", "

Re: [PATCH] Allow disable of SysV init/rcN.d support at compile time.

2010-09-08 Thread Gustavo Sverzut Barbieri
On Wed, Sep 8, 2010 at 1:32 AM, Gustavo Sverzut Barbieri
 wrote:
> This patch adds a cpp definition HAVE_SYSV_COMPAT that is used to
> isolate code dealing with /etc/init.d and /etc/rcN.d for systems where
> it does not make sense (one that does not use sysv or one that is fully
> systemd native).
>
> The patch tries to be as little intrusive as possible, however in
> order to minimize the number of #ifdef'ed regions I've reordered some
> code in path-lookup.c:lookup_paths_init() where all code dealing with
> sysv is now isolated under running_as == MANAGER_SYSTEM as well.

Oops, this version lacked build.h and thus we don't have a nice way to
check if it was enabled/disabled during runtime. A new patch will be
provided.


-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] Allow disable of SysV init/rcN.d support at compile time

2010-09-20 Thread Gustavo Sverzut Barbieri
From: Fabiano Fidencio 

This patch adds a cpp definition HAVE_SYSV_COMPAT that is used to
isolate code dealing with /etc/init.d and /etc/rcN.d for systems where
it does not make sense (one that does not use sysv or one that is fully
systemd native).

The patch tries to be as little intrusive as possible, however in
order to minimize the number of #ifdef'ed regions I've reordered some
code in path-lookup.c:lookup_paths_init() where all code dealing with
sysv is now isolated under running_as == MANAGER_SYSTEM as well.

Moreover, In struct Service, some fields were rearranged to reduce
the number of ifdefs.

Lennart's suggestions were fixed and squashed with the original patch,
that was sent by Gustavo Sverzut Barbieri (barbi...@profusion.mobi).
---
 configure.ac|   17 ++--
 src/build.h |8 +++-
 src/dbus-manager.c  |   49 ++--
 src/dbus-service.c  |   31 +++
 src/load-fragment.c |   25 
 src/main.c  |   22 ++-
 src/manager.h   |2 +
 src/path-lookup.c   |  102 +++---
 src/path-lookup.h   |2 +
 src/service.c   |   22 +++
 src/service.h   |5 +-
 src/systemctl.c |   15 +++-
 12 files changed, 230 insertions(+), 70 deletions(-)

diff --git a/configure.ac b/configure.ac
index e3c1fdd..27f40a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -310,7 +310,8 @@ case $with_distro in
 M4_DISTRO_FLAG=-DTARGET_ARCH=1
 ;;
 gentoo)
-SYSTEM_SYSVRCND_PATH=/etc
+SYSTEM_SYSVINIT_PATH=
+SYSTEM_SYSVRCND_PATH=
 SPECIAL_SYSLOG_SERVICE=syslog-ng.service
 AC_DEFINE(TARGET_GENTOO, [], [Target is Gentoo])
 M4_DISTRO_FLAG=-DTARGET_GENTOO=1
@@ -322,10 +323,6 @@ case $with_distro in
 M4_DISTRO_FLAG=-DTARGET_SLACKWARE=1
 ;;
 other)
-AS_IF([test "x$with_sysvinit_path" = "x"],
-[AC_MSG_ERROR([With --distro=other, you must pass 
--with-sysvinit-path= to configure])])
-AS_IF([test "x$with_sysvrcd_path" = "x"],
-[AC_MSG_ERROR([With --distro=other, you must pass 
--with-sysvrcd-path= to configure])])
 AS_IF([test "x$with_syslog_service" = "x"],
 [AC_MSG_ERROR([With --distro=other, you must pass 
--with-syslog-service= to configure])])
 ;;
@@ -357,6 +354,15 @@ AC_SUBST(SYSTEM_SYSVRCND_PATH)
 AC_SUBST(SPECIAL_SYSLOG_SERVICE)
 AC_SUBST(M4_DISTRO_FLAG)
 
+if test "x${SYSTEM_SYSVINIT_PATH}" != "x" -a "x${SYSTEM_SYSVRCND_PATH}" != 
"x"; then
+AC_DEFINE(HAVE_SYSV_COMPAT, [], [SysV init scripts and rcN.d links are 
supported.])
+SYSTEM_SYSV_COMPAT="enabled"
+elif test "x${SYSTEM_SYSVINIT_PATH}" != "x" -o "x${SYSTEM_SYSVRCND_PATH}" != 
"x"; then
+AC_MSG_ERROR([*** You need both --with-sysvinit-path=PATH and 
--with-sysvrcd-path=PATH to enable SysV compatibility support, or both empty to 
disable it.])
+else
+SYSTEM_SYSV_COMPAT="disabled"
+fi
+
 AM_CONDITIONAL(TARGET_FEDORA, test x"$with_distro" = xfedora)
 AM_CONDITIONAL(TARGET_SUSE, test x"$with_distro" = xsuse)
 AM_CONDITIONAL(TARGET_DEBIAN, test x"$with_distro" = xdebian)
@@ -416,6 +422,7 @@ echo "
 $PACKAGE_NAME $VERSION
 
 Distribution:${with_distro}
+SysV compatibility:  ${SYSTEM_SYSV_COMPAT}
 SysV init scripts:   ${SYSTEM_SYSVINIT_PATH}
 SysV rc?.d directories:  ${SYSTEM_SYSVRCND_PATH}
 Syslog service:  ${SPECIAL_SYSLOG_SERVICE}
diff --git a/src/build.h b/src/build.h
index 5cb69be..b7f647a 100644
--- a/src/build.h
+++ b/src/build.h
@@ -46,6 +46,12 @@
 #define _SELINUX_FEATURE_ "-SELINUX"
 #endif
 
-#define SYSTEMD_FEATURES _PAM_FEATURE_ " " _LIBWRAP_FEATURE_ " " 
_AUDIT_FEATURE_ " " _SELINUX_FEATURE_
+#ifdef HAVE_SYSV
+#define _SYSVINIT_FEATURE_ "+SYSVINIT"
+#else
+#define _SYSVINIT_FEATURE_ "-SYSVINIT"
+#endif
+
+#define SYSTEMD_FEATURES _PAM_FEATURE_ " " _LIBWRAP_FEATURE_ " " 
_AUDIT_FEATURE_ " " _SELINUX_FEATURE_ " " _SYSVINIT_FEATURE_
 
 #endif
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index 53dbeac..31e7f8f 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -27,14 +27,16 @@
 #include "strv.h"
 #include "bus-errors.h"
 
-#define BUS_MANAGER_INTERFACE   \
-" \n"  \
+#define BUS_MANAGER_INTERFACE_BEGIN \
+" \n"
+
+#define BUS_MANAGER_INTERFACE_METHODS   \
 "  \n" \
 "   \n" \
 "   \n"\
 "  \n" \
 "  \n"\
-"   \n" \
+"   \n"  \
 "   \n"\
 "  \n"   

Re: [systemd-devel] [PATCH] Allow disable of SysV init/rcN.d support at compile time.

2010-09-13 Thread Lennart Poettering
On Wed, 08.09.10 11:35, Gustavo Sverzut Barbieri (barbi...@profusion.mobi) 
wrote:

> This patch adds a cpp definition HAVE_SYSV_COMPAT that is used to
> isolate code dealing with /etc/init.d and /etc/rcN.d for systems where
> it does not make sense (one that does not use sysv or one that is fully
> systemd native).
> 
> The patch tries to be as little intrusive as possible, however in
> order to minimize the number of #ifdef'ed regions I've reordered some
> code in path-lookup.c:lookup_paths_init() where all code dealing with
> sysv is now isolated under running_as == MANAGER_SYSTEM as well.

Patch looks mostly good, and I do believe that the ability to disable
SysV is definitely a good idea.

A few comments:

>  { "org.freedesktop.systemd1.Manager", "ShowStatus",
> bus_property_append_bool,  "b",  &m->show_status},
>  { "org.freedesktop.systemd1.Manager", "SysVConsole",   
> bus_property_append_bool,  "b",  &m->sysv_console   },

SysVConsole should also go away if SysV is disabled.

>  { "org.freedesktop.systemd1.Manager", "UnitPath",  
> bus_property_append_strv,  "as", m->lookup_paths.unit_path },
> +#ifdef HAVE_SYSV_COMPAT
>  { "org.freedesktop.systemd1.Manager", "SysVInitPath",  
> bus_property_append_strv,  "as", m->lookup_paths.sysvinit_path },
>  { "org.freedesktop.systemd1.Manager", "SysVRcndPath",  
> bus_property_append_strv,  "as", m->lookup_paths.sysvrcnd_path },
> +#endif

This must disappear from the XML introspection data too (whic you may
find in the same file a bit further up.)

> --- a/src/service.c
> +++ b/src/service.c
> @@ -44,6 +44,7 @@ typedef enum RunlevelType {
>  RUNLEVEL_SYSINIT
>  } RunlevelType;

RunlevelType should be ifdeffed away, too.

>  static int service_enumerate(Manager *m) {

The entire function should go away if SysV is disabled, and the entry in
the vtable can be initialized to NULL.

I am a bit concerned about the compatbility of all of this. I think it
is OK to remove D-Bus properties for legacy stuff if this is disabled at
compilation time, but we should make sure that the configuration files
that include such info still parse fine. i.e. SysVPriority in .service
files should be parsable, though maybe print a warning, that we ignore
the setting. Similar for SysVConsole= in system.conf.

The various sysv prefixed vars from struct Service and struct Manager
should be ifdeffed out too I guess, though I fear this might add quite a
bit of ifdeff's to the code which I'd rather avoid. So be creative
here... ;-)

Otherwise the patch looks good to me, and it would be cool if Gentoo
could become the first post-SysV distro this way... ;-)

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] Allow disable of SysV init/rcN.d support at compile time

2010-09-26 Thread Lennart Poettering
On Tue, 21.09.10 00:23, Gustavo Sverzut Barbieri (barbi...@profusion.mobi) 
wrote:

> From: Fabiano Fidencio 
> 
> This patch adds a cpp definition HAVE_SYSV_COMPAT that is used to
> isolate code dealing with /etc/init.d and /etc/rcN.d for systems where
> it does not make sense (one that does not use sysv or one that is fully
> systemd native).

Applied with a number of smaller fixes.

Thanks,

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel