[systemd-devel] [PATCH v2 4/4] run: introduce timer support option

2014-10-30 Thread WaLyong Cho
Supported timer options --on-active=, --on-boot=, --on-startup=,
--on-unit-active=, --on-unit-inactive=, --on-calendar=. Each options
corresponding with OnActiveSec=, OnBootSec=, OnStartupSec=,
OnUnitActiveSec=, OnUnitInactiveSec= of timer respectively.
---
 man/systemd-run.xml  |  42 +++
 src/libsystemd/sd-bus/bus-util.c |  14 +-
 src/run/run.c| 634 +++
 3 files changed, 571 insertions(+), 119 deletions(-)

diff --git a/man/systemd-run.xml b/man/systemd-run.xml
index 0c9d13d..d359941 100644
--- a/man/systemd-run.xml
+++ b/man/systemd-run.xml
@@ -210,6 +210,37 @@ along with systemd; If not, see 
http://www.gnu.org/licenses/.
   xi:include href=user-system-options.xml xpointer=host /
   xi:include href=user-system-options.xml xpointer=machine /
 
+  varlistentry
+termoption--on-active=/option/term
+termoption--on-boot=/option/term
+termoption--on-startup=/option/term
+termoption--on-unit-active=/option/term
+termoption--on-unit-inactive=/option/term
+
+listitemparaDefines monotonic timers relative to different
+starting points. Also see varnameOnActiveSec=/varname,
+varnameOnBootSec=/varname,
+varnameOnStartupSec=/varname,
+varnameOnUnitActiveSec=/varname and
+varnameOnUnitInactiveSec=/varname in
+
citerefentryrefentrytitlesystemd.timer/refentrytitlemanvolnum5/manvolnum/citerefentry.
 This
+option has no effect in conjunction with
+option--scope/option./para
+/listitem
+  /varlistentry
+
+  varlistentry
+termoption--on-calendar=/option/term
+
+listitemparaDefines realtime (i.e. wallclock) timers with
+calendar event expressions. Also see
+varnameOnCalendar=/varname in
+
citerefentryrefentrytitlesystemd.timer/refentrytitlemanvolnum5/manvolnum/citerefentry.
 This
+option has no effect in conjunction with
+option--scope/option./para
+/listitem
+  /varlistentry
+
   xi:include href=standard-options.xml xpointer=help /
   xi:include href=standard-options.xml xpointer=version /
 /variablelist
@@ -250,6 +281,16 @@ Sep 08 07:37:21 bupkis env[19948]: 
BOOT_IMAGE=/vmlinuz-3.11.0-0.rc5.git6.2.fc20.
 property./para
 
 programlisting# systemd-run -p BlockIOWeight=10 updatedb/programlisting
+
+paraThe following command will touch a file after 10 seconds./para
+
+programlisting# date; systemd-run --on-active=10 touch /tmp/hello
+Mon Oct 27 20:02:57 KST 2014
+Running as unit run-66.timer.
+# journalctl -u run-115.service
+-- Logs begin at Mon 2014-10-27 19:44:57 KST, end at Mon 2014-10-27 20:03:15 
KST. --
+Oct 27 20:03:15 container systemd[1]: Starting /bin/touch /tmp/hello...
+Oct 27 20:03:15 container systemd[1]: Started /bin/touch 
/tmp/hello./programlisting
   /refsect1
 
   refsect1
@@ -263,6 +304,7 @@ Sep 08 07:37:21 bupkis env[19948]: 
BOOT_IMAGE=/vmlinuz-3.11.0-0.rc5.git6.2.fc20.
   
citerefentryrefentrytitlesystemd.slice/refentrytitlemanvolnum5/manvolnum/citerefentry,
   
citerefentryrefentrytitlesystemd.exec/refentrytitlemanvolnum5/manvolnum/citerefentry,
   
citerefentryrefentrytitlesystemd.resource-control/refentrytitlemanvolnum5/manvolnum/citerefentry,
+  
citerefentryrefentrytitlesystemd.timer/refentrytitlemanvolnum5/manvolnum/citerefentry,
   
citerefentryrefentrytitlemachinectl/refentrytitlemanvolnum1/manvolnum/citerefentry
 /para
   /refsect1
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
index 43acf5b..13fb9e6 100644
--- a/src/libsystemd/sd-bus/bus-util.c
+++ b/src/libsystemd/sd-bus/bus-util.c
@@ -1361,7 +1361,8 @@ int bus_append_unit_property_assignment(sd_bus_message 
*m, const char *assignmen
 
 if (STR_IN_SET(field,
CPUAccounting, MemoryAccounting, 
BlockIOAccounting,
-   SendSIGHUP, SendSIGKILL)) {
+   SendSIGHUP, SendSIGKILL,
+   WakeSystem)) {
 
 r = parse_boolean(eq);
 if (r  0) {
@@ -1522,6 +1523,17 @@ int bus_append_unit_property_assignment(sd_bus_message 
*m, const char *assignmen
 
 r = sd_bus_message_append(m, v, i, sig);
 
+} else if (streq(field, AccuracySec)) {
+usec_t u;
+
+r = parse_sec(eq, u);
+if (r  0) {
+log_error(Failed to parse %s value %s, field, eq);
+return -EINVAL;
+}
+
+r = sd_bus_message_append(m, v, t, u);
+
 } else {
 log_error(Unknown assignment %s., assignment);
 return -EINVAL;
diff --git a/src/run/run.c b/src/run/run.c
index e3b6293..0c92a1c 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -30,6 +30,7 @@
 #include env-util.h
 #include path-util.h
 #include bus-error.h
+#include calendarspec.h
 
 static 

[systemd-devel] [PATCH v2 3/4] unit: add UnitMask enum and get unit scope(mask) api from property

2014-10-30 Thread WaLyong Cho
---
 Makefile.am  |   7 ++
 src/shared/.gitignore|   1 +
 src/shared/unit-name.c   |  22 
 src/shared/unit-name.h   |  26 +
 src/shared/unit-property-scope.gperf | 202 +++
 5 files changed, 258 insertions(+)
 create mode 100644 src/shared/unit-property-scope.gperf

diff --git a/Makefile.am b/Makefile.am
index c80d25d..737d6d7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -816,6 +816,7 @@ libsystemd_shared_la_SOURCES = \
src/shared/cgroup-show.h \
src/shared/unit-name.c \
src/shared/unit-name.h \
+   src/shared/unit-property-scope.c \
src/shared/utmp-wtmp.h \
src/shared/watchdog.c \
src/shared/watchdog.h \
@@ -905,6 +906,12 @@ libsystemd_shared_la_CFLAGS = \
$(SECCOMP_CFLAGS) \
-pthread
 
+EXTRA_DIST += \
+   src/shared/unit-property-scope.gperf
+
+CLEANFILES += \
+   src/shared/unit-property-scope.c
+
 # 
--
 noinst_LTLIBRARIES += \
libsystemd-units.la
diff --git a/src/shared/.gitignore b/src/shared/.gitignore
index 61709e8..e7faa23 100644
--- a/src/shared/.gitignore
+++ b/src/shared/.gitignore
@@ -10,3 +10,4 @@
 /arphrd-from-name.h
 /arphrd-list.txt
 /arphrd-to-name.h
+/unit-property-scope.c
diff --git a/src/shared/unit-name.c b/src/shared/unit-name.c
index 2ef8545..e4669dd 100644
--- a/src/shared/unit-name.c
+++ b/src/shared/unit-name.c
@@ -621,3 +621,25 @@ static const char* const 
unit_dependency_table[_UNIT_DEPENDENCY_MAX] = {
 };
 
 DEFINE_STRING_TABLE_LOOKUP(unit_dependency, UnitDependency);
+
+static UnitMask unit_get_mask_from_property(const char *property) {
+const unit_property_scope_mapping *m;
+
+assert(property);
+
+m = unit_property_scope_mapping_lookup(property, strlen(property));
+if (m)
+return m-scope;
+
+return _UNIT_MASK_MAX;
+
+}
+
+bool unit_can_have_property(UnitType t, const char *property) {
+UnitMask m;
+
+assert(property);
+
+m = unit_get_mask_from_property(property);
+return !!((1ULL  t)  m);
+}
diff --git a/src/shared/unit-name.h b/src/shared/unit-name.h
index daeb56a..e1d4e27 100644
--- a/src/shared/unit-name.h
+++ b/src/shared/unit-name.h
@@ -28,6 +28,7 @@
 #define UNIT_NAME_MAX 256
 
 typedef enum UnitType UnitType;
+typedef enum UnitMask UnitMask;
 typedef enum UnitLoadState UnitLoadState;
 typedef enum UnitDependency UnitDependency;
 
@@ -49,6 +50,23 @@ enum UnitType {
 _UNIT_TYPE_INVALID = -1
 };
 
+enum UnitMask {
+UNIT_MASK_SERVICE   = 1ULL  UNIT_SERVICE,
+UNIT_MASK_SOCKET= 1ULL  UNIT_SOCKET,
+UNIT_MASK_BUSNAME   = 1ULL  UNIT_BUSNAME,
+UNIT_MASK_TARGET= 1ULL  UNIT_TARGET,
+UNIT_MASK_SNAPSHOT  = 1ULL  UNIT_SNAPSHOT,
+UNIT_MASK_DEVICE= 1ULL  UNIT_DEVICE,
+UNIT_MASK_MOUNT = 1ULL  UNIT_MOUNT,
+UNIT_MASK_AUTOMOUNT = 1ULL  UNIT_AUTOMOUNT,
+UNIT_MASK_SWAP  = 1ULL  UNIT_SWAP,
+UNIT_MASK_TIMER = 1ULL  UNIT_TIMER,
+UNIT_MASK_PATH  = 1ULL  UNIT_PATH,
+UNIT_MASK_SLICE = 1ULL  UNIT_SLICE,
+UNIT_MASK_SCOPE = 1ULL  UNIT_SCOPE,
+_UNIT_MASK_MAX  = 1ULL _UNIT_TYPE_MAX,
+};
+
 enum UnitLoadState {
 UNIT_STUB = 0,
 UNIT_LOADED,
@@ -163,3 +181,11 @@ int build_subslice(const char *slice, const char*name, 
char **subslice);
 
 const char *unit_dependency_to_string(UnitDependency i) _const_;
 UnitDependency unit_dependency_from_string(const char *s) _pure_;
+
+struct unit_property_scope_mapping {
+const char* property;
+UnitMask scope;
+};
+typedef struct unit_property_scope_mapping unit_property_scope_mapping;
+const unit_property_scope_mapping* unit_property_scope_mapping_lookup 
(register const char *str, register unsigned int len);
+bool unit_can_have_property(UnitType t, const char *property);
diff --git a/src/shared/unit-property-scope.gperf 
b/src/shared/unit-property-scope.gperf
new file mode 100644
index 000..bbcfcba
--- /dev/null
+++ b/src/shared/unit-property-scope.gperf
@@ -0,0 +1,202 @@
+%{
+#include unit-name.h
+#include bus-util.h
+%}
+unit_property_scope_mapping;
+%null_strings
+%language=ANSI-C
+%define slot-name property
+%define hash-function-name bus_property_scope_mapping_hash
+%define lookup-function-name unit_property_scope_mapping_lookup
+%readonly-tables
+%omit-struct-type
+%struct-type
+%includes
+%%
+Description,
UNIT_MASK_SERVICE|UNIT_MASK_SOCKET|UNIT_MASK_DEVICE|UNIT_MASK_MOUNT|UNIT_MASK_AUTOMOUNT|UNIT_MASK_SWAP|UNIT_MASK_TARGET|UNIT_MASK_PATH|UNIT_MASK_TIMER|UNIT_MASK_SNAPSHOT|UNIT_MASK_SLICE|UNIT_MASK_SCOPE
+Documentation,  

[systemd-devel] [PATCH v2 2/4] timer: timer can be a transient unit

2014-10-30 Thread WaLyong Cho
---
 src/core/dbus-timer.c | 159 ++
 src/core/dbus-timer.h |   3 +
 src/core/timer.c  |   4 ++
 3 files changed, 166 insertions(+)

diff --git a/src/core/dbus-timer.c b/src/core/dbus-timer.c
index f1f8c54..e916f5a 100644
--- a/src/core/dbus-timer.c
+++ b/src/core/dbus-timer.c
@@ -24,6 +24,8 @@
 #include dbus-unit.h
 #include dbus-timer.h
 #include bus-util.h
+#include errno-list.h
+#include strv.h
 
 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, timer_result, 
TimerResult);
 
@@ -183,3 +185,160 @@ const sd_bus_vtable bus_timer_vtable[] = {
 SD_BUS_PROPERTY(WakeSystem, b, bus_property_get_bool, 
offsetof(Timer, wake_system), SD_BUS_VTABLE_PROPERTY_CONST),
 SD_BUS_VTABLE_END
 };
+
+static int bus_timer_set_transient_property(
+Timer *t,
+const char *name,
+sd_bus_message *message,
+UnitSetPropertiesMode mode,
+sd_bus_error *error) {
+
+const char *str;
+int r;
+
+assert(t);
+assert(name);
+assert(message);
+
+if (STR_IN_SET(name,
+   OnActiveSec,
+   OnBootSec,
+   OnStartupSec,
+   OnUnitActiveSec,
+   OnUnitInactiveSec)) {
+
+TimerValue *v;
+TimerBase b = _TIMER_BASE_INVALID;
+usec_t u = 0;
+
+b = timer_base_from_string(name);
+if (b  0)
+return 0;
+
+r = sd_bus_message_read(message, t, u);
+if (r  0)
+return r;
+
+if (mode != UNIT_CHECK) {
+unit_write_drop_in_private_format(UNIT(t),
+  mode,
+  name,
+  %s=%lu\n,
+  name,
+  u);
+
+v = new0(TimerValue, 1);
+if (!v)
+return -ENOMEM;
+
+v-base = b;
+v-value = u;
+
+LIST_PREPEND(value, t-values, v);
+}
+
+return 1;
+
+} else if (streq(name, OnCalendar)) {
+
+TimerValue *v;
+CalendarSpec *c = NULL;
+
+r = sd_bus_message_read(message, s, str);
+if (r  0)
+return r;
+
+if (mode != UNIT_CHECK) {
+r = calendar_spec_from_string(str, c);
+if (r  0)
+return r;
+
+unit_write_drop_in_private_format(UNIT(t),
+  mode,
+  name,
+  %s=%s\n,
+  name,
+  str);
+
+v = new0(TimerValue, 1);
+if (!v) {
+if (c)
+calendar_spec_free(c);
+return -ENOMEM;
+}
+
+v-base = TIMER_CALENDAR;
+v-calendar_spec = c;
+
+LIST_PREPEND(value, t-values, v);
+}
+
+return 1;
+
+} else if (streq(name, AccuracySec)) {
+
+usec_t u = 0;
+
+r = sd_bus_message_read(message, t, u);
+if (r  0)
+return r;
+
+if (mode != UNIT_CHECK) {
+t-accuracy_usec = u;
+unit_write_drop_in_private_format(UNIT(t),
+  mode,
+  name,
+  %s=%lu\n,
+  name,
+  u);
+}
+
+return 1;
+
+} else if (streq(name, WakeSystem)) {
+
+int b;
+
+r = sd_bus_message_read(message, b, b);
+if (r  0)
+return r;
+
+if (mode != UNIT_CHECK) {
+t-wake_system = b;
+unit_write_drop_in_private_format(UNIT(t),
+  mode,
+  name,
+

[systemd-devel] [PATCH v2 1/4] bus: StartTransientUnit can have aux unit

2014-10-30 Thread WaLyong Cho
---
 src/core/dbus-manager.c | 123 +---
 1 file changed, 105 insertions(+), 18 deletions(-)

diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index c54abd3..bba4b27 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -615,6 +615,93 @@ static int method_set_unit_properties(sd_bus *bus, 
sd_bus_message *message, void
 return bus_unit_method_set_properties(bus, message, u, error);
 }
 
+static int transient_unit_from_message(
+Manager *m,
+sd_bus_message *message,
+const char *name,
+Unit **unit,
+sd_bus_error *error) {
+
+Unit *u;
+int r;
+
+assert(m);
+assert(message);
+assert(name);
+
+r = manager_load_unit(m, name, NULL, error, u);
+if (r  0)
+return r;
+
+if (u-load_state != UNIT_NOT_FOUND ||
+set_size(u-dependencies[UNIT_REFERENCED_BY])  0)
+return sd_bus_error_setf(error,
+ BUS_ERROR_UNIT_EXISTS,
+ Unit %s already exists.,
+ name);
+
+/* OK, the unit failed to load and is unreferenced, now let's
+ * fill in the transient data instead */
+r = unit_make_transient(u);
+if (r  0)
+return r;
+
+/* Set our properties */
+r = bus_unit_set_properties(u, message, UNIT_RUNTIME, false, error);
+if (r  0)
+return r;
+
+*unit = u;
+
+return 0;
+}
+
+static int try_aux_units_in_message(
+Manager *m,
+sd_bus_message *message,
+sd_bus_error *error) {
+
+Unit *u;
+char *name = NULL;
+int r;
+
+assert(m);
+assert(message);
+
+r = sd_bus_message_enter_container(message, 'a', (sa(sv)));
+if (r  0)
+return r;
+
+while ((r = sd_bus_message_enter_container(message, 'r', sa(sv)))  
0) {
+if (r = 0)
+return r;
+
+r = sd_bus_message_read(message, s, name);
+if (r  0)
+return r;
+
+r = transient_unit_from_message(m, message, name, u, error);
+if (r  0  r != -EEXIST)
+return r;
+
+r = sd_bus_message_exit_container(message);
+if (r  0)
+return r;
+
+r = unit_load(u);
+if (r  0)
+return r;
+}
+if (r  0)
+return r;
+
+r = sd_bus_message_exit_container(message);
+if (r  0)
+return r;
+
+return 0;
+}
+
 static int method_start_transient_unit(sd_bus *bus, sd_bus_message *message, 
void *userdata, sd_bus_error *error) {
 const char *name, *smode;
 Manager *m = userdata;
@@ -631,7 +718,9 @@ static int method_start_transient_unit(sd_bus *bus, 
sd_bus_message *message, voi
 if (r  0)
 return r;
 if (r == 0)
-return 1; /* No authorization for now, but the async polkit 
stuff will call us again when it has it */
+/* No authorization for now, but the async polkit
+ * stuff will call us again when it has it */
+return 1;
 
 r = sd_bus_message_read(message, ss, name, smode);
 if (r  0)
@@ -639,34 +728,32 @@ static int method_start_transient_unit(sd_bus *bus, 
sd_bus_message *message, voi
 
 t = unit_name_to_type(name);
 if (t  0)
-return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, 
Invalid unit type.);
+return sd_bus_error_setf(error,
+ SD_BUS_ERROR_INVALID_ARGS,
+ Invalid unit type.);
 
 if (!unit_vtable[t]-can_transient)
-return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, 
Unit type %s does not support transient units., unit_type_to_string(t));
-
-mode = job_mode_from_string(smode);
-if (mode  0)
-return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, 
Job mode %s is invalid., smode);
+return sd_bus_error_setf(error,
+ SD_BUS_ERROR_INVALID_ARGS,
+ Unit type %s does not support 
transient units.,
+ unit_type_to_string(t));
 
 r = mac_selinux_access_check(message, start, error);
 if (r  0)
 return r;
 
-r = manager_load_unit(m, name, NULL, error, u);
-if (r  0)
-return r;
-
-if (u-load_state != UNIT_NOT_FOUND || 
set_size(u-dependencies[UNIT_REFERENCED_BY])  0)
-   

[systemd-devel] [PATCH] bus: use STR_IN_SET

2014-10-30 Thread WaLyong Cho
---
 src/core/dbus-unit.c | 24 ++--
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 9b13c6e..2d1862c 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -859,20 +859,16 @@ static int bus_unit_set_transient_property(
 }
 
 return 1;
-
-} else if (streq(name, Requires) ||
-   streq(name, RequiresOverridable) ||
-   streq(name, Requisite) ||
-   streq(name, RequisiteOverridable) ||
-   streq(name, Wants) ||
-   streq(name, BindsTo) ||
-   streq(name, Conflicts) ||
-   streq(name, Before) ||
-   streq(name, After) ||
-   streq(name, OnFailure) ||
-   streq(name, PropagatesReloadTo) ||
-   streq(name, ReloadPropagatedFrom) ||
-   streq(name, PartOf)) {
+} else if (STR_IN_SET(name,
+  Requires, RequiresOverridable,
+  Requisite, RequisiteOverridable,
+  Wants,
+  BindsTo,
+  Conflicts,
+  Before, After,
+  OnFailure,
+  PropagatesReloadTo, ReloadPropagatedFrom,
+  PartOf)) {
 
 UnitDependency d;
 const char *other;
-- 
1.9.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] hwdb: Ignore brightness keys on Dell Inspiron 1520 to avoid double events

2014-10-30 Thread Hans de Goede
On the Dell Inspiron 1520 both the atkbd and acpi-video input devices report
an event for pressing the brightness up / down key-combos, resulting in user
space seeing double events and increasing / decreasing the brightness 2 steps
for each keypress.

This hwdb snippet suppresses the atkbd events, making the Inspiron 1520 work
like most modern laptops which emit brightness up / down events through
acpi-video only.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1141525
Cc: Pavel Malyshev p.malis...@gmail.com
Reported-by: Pavel Malyshev p.malis...@gmail.com
Signed-off-by: Hans de Goede hdego...@redhat.com
---
 hwdb/60-keyboard.hwdb | 5 +
 1 file changed, 5 insertions(+)

diff --git a/hwdb/60-keyboard.hwdb b/hwdb/60-keyboard.hwdb
index 06caba9..d2ca965 100644
--- a/hwdb/60-keyboard.hwdb
+++ b/hwdb/60-keyboard.hwdb
@@ -230,6 +230,11 @@ keyboard:dmi:bvn*:bvr*:bd*:svnDell*:pnInspiron*1110:pvr*
 keyboard:dmi:bvn*:bvr*:bd*:svnDell*:pnInspiron*1210:pvr*
  KEYBOARD_KEY_84=wlan
 
+# Dell Inspiron 1520
+keyboard:dmi:bvn*:bvr*:bd*:svnDell*:pnInspiron*1520:pvr*
+ KEYBOARD_KEY_85=unknown  # Brightness Down, also emitted by acpi-video, ignore
+ KEYBOARD_KEY_86=unknown  # Brightness Up, also emitted by acpi-video, ignore
+
 # Latitude XT2
 keyboard:dmi:bvn*:bvr*:bd*:svnDell*:pnLatitude*XT2:pvr*
  KEYBOARD_KEY_9b=up # tablet rocker up
-- 
2.1.0

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] bash-completion: fix systemctl isolate

2014-10-30 Thread Jan Synacek
Jan Synacek jsyna...@redhat.com writes:
 Jan Synacek (1):
   bash-completion: fix systemctl isolate

I've just tested the latest systemd (commit 81333ec) and after the
bash-completion patches, this patch seems obsolete and not needed
anymore.

-- 
Jan Synacek
Software Engineer, Red Hat


signature.asc
Description: PGP signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] hwdb: Ignore brightness keys on Dell Inspiron 1520 to avoid double events

2014-10-30 Thread Martin Pitt
Hello Hans,

Hans de Goede [2014-10-30 10:15 +0100]:
 On the Dell Inspiron 1520 both the atkbd and acpi-video input devices report
 an event for pressing the brightness up / down key-combos, resulting in user
 space seeing double events and increasing / decreasing the brightness 2 steps
 for each keypress.

Thanks! Applied with some commit log cleanup (we don't usually do
Signed-Off-By etc. in systemd):

  http://cgit.freedesktop.org/systemd/systemd/commit/?id=aba248e

Martin
-- 
Martin Pitt| http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] manager: do not print anything while passwords are being queried

2014-10-30 Thread Karel Zak
On Tue, Oct 28, 2014 at 03:28:32PM +0100, Lennart Poettering wrote:
 On Tue, 28.10.14 15:00, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) wrote:
 
  On Mon, Oct 27, 2014 at 06:37:21PM +0100, Lennart Poettering wrote:
   On Sun, 26.10.14 05:37, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) 
   wrote:
   
https://bugs.freedesktop.org/show_bug.cgi?id=73942
   
   So in really old systemd versions I had a concept in place of never
   printing to the console if there was a controlling process on it. The
   kernel's concept of a controlling process we used as a somewhat
   natural synchronization on the tty. However, this functionality has
   pretty much been lost. 
   
   I am not entirely sure what happened between all the reworks there,
   but maybe we should just resurrect that scheme? Suppressing output on
   the console if there's a controlling process would not just
   automatically avoid mixing password queries with getty login prompts,
   but also all other cases where some process wants exclusive ownership
   of the tty.
   
   Using the controlling tty for this would be somewhat nice, as all
   users of the tty would just work with it. Another idea could be to use
   BSD locks on the /dev/console device node. Everybody with access on
   the tty could take one of the logs. We would even have R/W locks then,
   where the status output would just take a read lock, while things like
   gettys and the password stuff would take a full write lock.
  I don't get this r/w distinction. In either case access has to
  be exclusive.
 
 Well, so, on the console it is fine if five clients write messages at
 the same time (as long as they print full lines at a time). However,
 only one client should read fro it at the same time, as otherwise it's
 pretty much random which component will actually get the input.
 
 We can use the BSD LOCK_SH vs. LOCK_EX bits for this. LOCK_SH is for
 everything which wants to just print a status message, LOCK_EX is for
 everything which wants to also read input. The weird bit of course is
 that in this case the writers take shared locks and the readers
 exclusive locks, even though classic R/W locks are of course the other
 way round...
 
   I am slightly leaning towards the BSD lock solution I must say. In
   particular as it is compatible with the story we kinda want to push
   people using /dev/ttyS* towards, who really should use BSD locks too,
   instead of the awful LCK.. files...
 
 One question remains though: which part shall take the LOCK_EX locks?
 I figure this should be agetty. 
 
 Karel, can we convince you to take a LOCK_EX BSD file lock on the tty
 devices agetty opens? 

in agetty and sulogin we already have code to detect possible collisions with
plymouth (implemented by Werner, CC:). The plymounth uses exotic TIOCGLCKTRMIOS
and TIOCSLCKTRMIOS ioctls to lock the tty configuration.

Maybe we can use the same concept, it means lock by TIOCSLCKTRMIOS if we wait 
for user's response.

I have no strong opinion about the lock type (flock or the tty ioctls), but 
I'd like to use the same concept (locks) for all tty components (agetty, 
plymouth and systemd-ask-password) without exceptions.

Karel

-- 
 Karel Zak  k...@redhat.com
 http://karelzak.blogspot.com
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] remote-fs ordering, iSCSI and _netdev

2014-10-30 Thread Karel Zak
On Tue, Oct 28, 2014 at 02:29:35AM +0100, Lennart Poettering wrote:
 On Mon, 27.10.14 14:10, Chris Leech (cle...@redhat.com) wrote:
 
  So for any mounts to remote block devices (unlike remote file system
  protocols which are detected by the fs name), unless there is an fstab
  entry at the time fstab-generator is run they get treated like local fs
  mounts and connectivity to the storage target may be disrupted before
  unmounting (possibly resulting in file system errors).
  
  I'm currently at a loss for how to handle this, other than to claim that
  if filesystems are going to be left mounted they should be added to
  fstab and a daemon-reload is required.
 
 IIRC mount nowadays stores the full mount option string, including all
 the userspace-only options in /run. We could either read those
 directly from there in systemd, or we could make systemd make use of
 libmount to get that information.
 
_netdev is information about device rather than about filesystem.
Would be possible to have this info (this is iSCSI) in udev db? 

You know, all userpsace mount options suck, it's always fragile to
maintain mount options in userspace (due to namespaces, ...)

 Karel, what are the details there? Would it be OK if we read the files
 in /run directly to augment whatever we got from /proc/self/mountinfo?

I'd like to keep /run/mount/utab as private libmount file. It would be
better to use mnt_table_parse_mtab() libmount function to get parsed
mountinfo + userspace mount options.

IMHO you can implement it as optional feature #ifdef HAVE_LIBMOUNT to
optionally use mnt_table_parse_mtab() from libmount rather than directly
parse /proc/self/mountinfo.

Karel

-- 
 Karel Zak  k...@redhat.com
 http://karelzak.blogspot.com
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 0/5] Features and fixes for OnCalendar events

2014-10-30 Thread Daniele Medri
Following the previously submitted patches and the relative comments of
our Bürgermeister, I renewed a bit my code and added something new after
v217 tag.

Could be better? Do it.
Need some fixes? Fix it.

Daniele Medri (5):
- calendar: semesterly alias for semi-annually
- man: reorganization of calendar specs
- readability: cases sorted by time (where *time* is the key)
- constant for weekdays_bits
- calendar: parse months's names (functions and man page updates)

 man/systemd.time.xml |  40 ---
 src/shared/calendarspec.c| 267 ++-
 src/shared/calendarspec.h|   1 +
 src/test/test-calendarspec.c |   1 +
 4 files changed, 261 insertions(+), 48 deletions(-)

HTH

Good Halloween.

-- 
1.9.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 4/5] constant for weekdays_bits

2014-10-30 Thread Daniele Medri
---
 src/shared/calendarspec.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c
index a937f8b..9b05f13 100644
--- a/src/shared/calendarspec.c
+++ b/src/shared/calendarspec.c
@@ -24,6 +24,8 @@
 
 #include calendarspec.h
 
+#define BITS_WEEKDAYS  127
+
 static void free_chain(CalendarComponent *c) {
 CalendarComponent *n;
 
@@ -120,7 +122,7 @@ static void fix_year(CalendarComponent *c) {
 int calendar_spec_normalize(CalendarSpec *c) {
 assert(c);
 
-if (c-weekdays_bits = 0 || c-weekdays_bits = 127)
+if (c-weekdays_bits = 0 || c-weekdays_bits = BITS_WEEKDAYS)
 c-weekdays_bits = -1;
 
 fix_year(c-year);
@@ -154,7 +156,7 @@ _pure_ static bool chain_valid(CalendarComponent *c, int 
from, int to) {
 _pure_ bool calendar_spec_valid(CalendarSpec *c) {
 assert(c);
 
-if (c-weekdays_bits  127)
+if (c-weekdays_bits  BITS_WEEKDAYS)
 return false;
 
 if (!chain_valid(c-year, 1970, 2199))
@@ -194,7 +196,7 @@ static void format_weekdays(FILE *f, const CalendarSpec *c) 
{
 
 assert(f);
 assert(c);
-assert(c-weekdays_bits  0  c-weekdays_bits = 127);
+assert(c-weekdays_bits  0  c-weekdays_bits = BITS_WEEKDAYS);
 
 for (x = 0, l = -1; x  (int) ELEMENTSOF(days); x++) {
 
@@ -259,7 +261,7 @@ int calendar_spec_to_string(const CalendarSpec *c, char 
**p) {
 if (!f)
 return -ENOMEM;
 
-if (c-weekdays_bits  0  c-weekdays_bits = 127) {
+if (c-weekdays_bits  0  c-weekdays_bits = BITS_WEEKDAYS) {
 format_weekdays(f, c);
 fputc(' ', f);
 }
@@ -881,7 +883,7 @@ static bool matches_weekday(int weekdays_bits, const struct 
tm *tm) {
 struct tm t;
 int k;
 
-if (weekdays_bits  0 || weekdays_bits = 127)
+if (weekdays_bits  0 || weekdays_bits = BITS_WEEKDAYS)
 return true;
 
 t = *tm;
-- 
1.9.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 5/5] calendar: parse months's names

2014-10-30 Thread Daniele Medri
---
 man/systemd.time.xml  |   9 +++
 src/shared/calendarspec.c | 202 ++
 src/shared/calendarspec.h |   1 +
 3 files changed, 212 insertions(+)

diff --git a/man/systemd.time.xml b/man/systemd.time.xml
index 2ee5858..d108871 100644
--- a/man/systemd.time.xml
+++ b/man/systemd.time.xml
@@ -225,6 +225,15 @@
 range of continuous weekdays. literal,/literal and
 literal-/literal may be combined freely./para
 
+paraThe months's names specification is available too.
+It should consist of one or more English
+language months's names, either in the abbreviated
+(Apr) or non-abbreviated (April) form (case does
+not matter), separated by commas. Specifying two
+months separated by literal-/literal refers to a
+range of continuous months. literal,/literal and
+literal-/literal may be combined freely./para
+
 paraIn the date and time specifications, any
 component may be specified as literal*/literal in
 which case any value will match. Alternatively, each
diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c
index 9b05f13..dea83ce 100644
--- a/src/shared/calendarspec.c
+++ b/src/shared/calendarspec.c
@@ -25,6 +25,7 @@
 #include calendarspec.h
 
 #define BITS_WEEKDAYS  127
+#define BITS_MONTHS4095/* 0^2 + 1^2 + ... + 11^2 */
 
 static void free_chain(CalendarComponent *c) {
 CalendarComponent *n;
@@ -125,6 +126,9 @@ int calendar_spec_normalize(CalendarSpec *c) {
 if (c-weekdays_bits = 0 || c-weekdays_bits = BITS_WEEKDAYS)
 c-weekdays_bits = -1;
 
+if (c-months_bits = 0 || c-months_bits = BITS_MONTHS)
+c-months_bits = -1;
+
 fix_year(c-year);
 
 sort_chain(c-year);
@@ -159,6 +163,9 @@ _pure_ bool calendar_spec_valid(CalendarSpec *c) {
 if (c-weekdays_bits  BITS_WEEKDAYS)
 return false;
 
+if (c-months_bits  BITS_MONTHS)
+return false;
+
 if (!chain_valid(c-year, 1970, 2199))
 return false;
 
@@ -229,6 +236,60 @@ static void format_weekdays(FILE *f, const CalendarSpec 
*c) {
 }
 }
 
+static void format_months(FILE *f, const CalendarSpec *c) {
+static const char *const months[] = {
+Jan,
+Feb,
+Mar,
+Apr,
+May,
+Jun,
+Jul,
+Aug,
+Sep,
+Oct,
+Nov,
+Dec
+};
+
+int l, x;
+bool need_colon = false;
+
+assert(f);
+assert(c);
+assert(c-months_bits  0  c-months_bits = BITS_MONTHS);
+
+for (x = 0, l = -1; x  (int) ELEMENTSOF(months); x++) {
+
+if (c-months_bits  (1  x)) {
+
+if (l  0) {
+if (need_colon)
+fputc(',', f);
+else
+need_colon = true;
+
+fputs(months[x], f);
+l = x;
+}
+
+} else if (l = 0) {
+
+if (x  l + 1) {
+fputc(x  l + 2 ? '-' : ',', f);
+fputs(months[x-1], f);
+}
+
+l = -1;
+}
+}
+
+if (l = 0  x  l + 1) {
+fputc(x  l + 2 ? '-' : ',', f);
+fputs(months[x-1], f);
+}
+}
+
 static void format_chain(FILE *f, int space, const CalendarComponent *c) {
 assert(f);
 
@@ -266,6 +327,11 @@ int calendar_spec_to_string(const CalendarSpec *c, char 
**p) {
 fputc(' ', f);
 }
 
+if (c-months_bits  0  c-months_bits = BITS_MONTHS) {
+format_months(f, c);
+fputc(' ', f);
+}
+
 format_chain(f, 4, c-year);
 fputc('-', f);
 format_chain(f, 2, c-month);
@@ -385,6 +451,108 @@ static int parse_weekdays(const char **p, CalendarSpec 
*c) {
 }
 }
 
+static int parse_months(const char **p, CalendarSpec *c) {
+static const struct {
+const char *name;
+const int nr;
+} month_nr[] = {
+{ January,   0 },
+{ Jan,   0 },
+{ February,  1 },
+{ Feb,   1 },
+{ March, 2 },
+{ Mar,   2 },
+{ April, 3 },
+{ Apr,   3 },
+{ May,   4 },
+{ June,  5 },
+{ Jun,   5 },
+{ July,  6 },
+{ Jul,   6 },

[systemd-devel] [PATCH 1/5] calendar: semesterly alias for semi-annually

2014-10-30 Thread Daniele Medri
---
 man/systemd.time.xml | 4 ++--
 src/shared/calendarspec.c| 3 ++-
 src/test/test-calendarspec.c | 1 +
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/man/systemd.time.xml b/man/systemd.time.xml
index f35ccd7..2342684 100644
--- a/man/systemd.time.xml
+++ b/man/systemd.time.xml
@@ -247,8 +247,8 @@
 literalmonthly/literal, literalweekly/literal,
 literalyearly/literal,
 literalquarterly/literal,
-literalsemiannually/literal may be used as
-calendar events which refer to
+   literalsemesterly/literal or literalsemiannually/literal
+   may be used as calendar events which refer to
 literal*-*-* *:*:00/literal,
 literal*-*-* *:00:00/literal,
 literal*-*-* 00:00:00/literal,
diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c
index 7efcf7b..3115bba 100644
--- a/src/shared/calendarspec.c
+++ b/src/shared/calendarspec.c
@@ -757,7 +757,8 @@ int calendar_spec_from_string(const char *p, CalendarSpec 
**spec) {
 } else if (strcaseeq(p, biannually) ||
strcaseeq(p, bi-annually) ||
strcaseeq(p, semiannually) ||
-   strcaseeq(p, semi-annually)) {
+   strcaseeq(p, semi-annually) ||
+   strcaseeq(p, semesterly)) {
 
 r = const_chain(1, c-month);
 if (r  0)
diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c
index 87e1da1..7610cff 100644
--- a/src/test/test-calendarspec.c
+++ b/src/test/test-calendarspec.c
@@ -80,6 +80,7 @@ int main(int argc, char* argv[]) {
 test_one(minutely, *-*-* *:*:00);
 test_one(quarterly, *-01,04,07,10-01 00:00:00);
 test_one(semi-annually, *-01,07-01 00:00:00);
+test_one(semesterly, *-01,07-01 00:00:00);
 test_one(annually, *-01-01 00:00:00);
 test_one(*:2/3, *-*-* *:02/3:00);
 
-- 
1.9.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 2/5] man: reorganization of calendar specs

2014-10-30 Thread Daniele Medri
---
 man/systemd.time.xml | 31 ++-
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/man/systemd.time.xml b/man/systemd.time.xml
index 2342684..2ee5858 100644
--- a/man/systemd.time.xml
+++ b/man/systemd.time.xml
@@ -241,23 +241,20 @@
 
 paraTimezone names may not be specified./para
 
-paraThe special expressions
-literalminutely/literal,
-literalhourly/literal, literaldaily/literal,
-literalmonthly/literal, literalweekly/literal,
-literalyearly/literal,
-literalquarterly/literal,
-   literalsemesterly/literal or literalsemiannually/literal
-   may be used as calendar events which refer to
-literal*-*-* *:*:00/literal,
-literal*-*-* *:00:00/literal,
-literal*-*-* 00:00:00/literal,
-literal*-*-01 00:00:00/literal,
-literalMon *-*-* 00:00:00/literal,
-literal*-01-01 00:00:00/literal,
-literal*-01,04,07,10-01 00:00:0/literal and
-literal*-01,07-01 00:00:00/literal respectively.
-/para
+paraSpecial expressions may be used as calendar 
events:/para
+
+   programlisting
+  minutely → *-*-* *:*:00
+hourly → *-*-* *:00:00
+ daily → *-*-* 00:00:00
+weekly → Mon *-*-* 00:00:00
+   monthly → *-*-01 00:00:00
+ quarterly → *-01,04,07,10-01 00:00:00
+semesterly → *-01,07-01 00:00:00
+  semiannually → *-01,07-01 00:00:00
+yearly → *-01-01 00:00:00
+  annually → *-01-01 00:00:00
+/programlisting
 
 paraExamples for valid timestamps and their
 normalized form:/para
-- 
1.9.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 3/5] readability: cases sorted by time

2014-10-30 Thread Daniele Medri
---
 src/shared/calendarspec.c | 50 +++
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c
index 3115bba..a937f8b 100644
--- a/src/shared/calendarspec.c
+++ b/src/shared/calendarspec.c
@@ -679,10 +679,10 @@ int calendar_spec_from_string(const char *p, CalendarSpec 
**spec) {
 if (r  0)
 goto fail;
 
-} else if (strcaseeq(p, monthly)) {
-r = const_chain(1, c-day);
-if (r  0)
-goto fail;
+} else if (strcaseeq(p, weekly)) {
+
+c-weekdays_bits = 1;
+
 r = const_chain(0, c-hour);
 if (r  0)
 goto fail;
@@ -693,13 +693,7 @@ int calendar_spec_from_string(const char *p, CalendarSpec 
**spec) {
 if (r  0)
 goto fail;
 
-} else if (strcaseeq(p, annually) ||
-   strcaseeq(p, yearly) ||
-   strcaseeq(p, anually) /* backwards compatibility */ ) {
-
-r = const_chain(1, c-month);
-if (r  0)
-goto fail;
+} else if (strcaseeq(p, monthly)) {
 r = const_chain(1, c-day);
 if (r  0)
 goto fail;
@@ -713,20 +707,6 @@ int calendar_spec_from_string(const char *p, CalendarSpec 
**spec) {
 if (r  0)
 goto fail;
 
-} else if (strcaseeq(p, weekly)) {
-
-c-weekdays_bits = 1;
-
-r = const_chain(0, c-hour);
-if (r  0)
-goto fail;
-r = const_chain(0, c-minute);
-if (r  0)
-goto fail;
-r = const_chain(0, c-second);
-if (r  0)
-goto fail;
-
 } else if (strcaseeq(p, quarterly)) {
 
 r = const_chain(1, c-month);
@@ -779,6 +759,26 @@ int calendar_spec_from_string(const char *p, CalendarSpec 
**spec) {
 if (r  0)
 goto fail;
 
+} else if (strcaseeq(p, annually) ||
+   strcaseeq(p, yearly) ||
+   strcaseeq(p, anually) /* backwards compatibility */ ) {
+
+r = const_chain(1, c-month);
+if (r  0)
+goto fail;
+r = const_chain(1, c-day);
+if (r  0)
+goto fail;
+r = const_chain(0, c-hour);
+if (r  0)
+goto fail;
+r = const_chain(0, c-minute);
+if (r  0)
+goto fail;
+r = const_chain(0, c-second);
+if (r  0)
+goto fail;
+
 } else {
 r = parse_weekdays(p, c);
 if (r  0)
-- 
1.9.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] systemctl user start Xorg

2014-10-30 Thread arnaud gaboury
Archlinux 3.16.3
systemd 216-3
startx at login prompt. No DM


I am slowly trying to use systemctl --user facilities.
Until now, I am able to start few basic user services. Now it is time
to start Xorg as a user service, but I can't manage to do it. As
documentation is currently very sparse, I must admit I am a little
lost when it comes to write the unit files. I can't even know if it is
feasible.

I have tried all kinds of things in my xorg.service file. Below are
two ways among others.
---
[Unit]
Description=Xorg server at display :0
Requires=xorg.socket
After=xorg.socket

[Service]
# ExecStart=/usr/bin/Xorg.bin -nolisten tcp vt$XDG_VTNR
 ExecStart=/usr/bin/xinit -- :0 -nolisten tcp vt$XDG_VTNR
--

Results are usually failed status. Here are some logs:
---
● xorg.service - Xorg server at display :0
   Loaded: loaded (/home/gabx/.config/systemd/user/xorg.service; static)
   Active: failed (Result: exit-code) since Thu 2014-10-30 10:22:34 CET; 39s ago
  Process: 11792 ExecStart=/usr/bin/Xorg.bin -nolisten tcp vt$XDG_VTNR
(code=exited, status=1/FAILURE)
 Main PID: 11792 (code=exited, status=1/FAILURE)

Oct 30 10:22:34 hortensia systemd[850]: Started Xorg server at display :0.
Oct 30 10:22:34 hortensia Xorg.bin[11792]: use: X [:display] [option]
Oct 30 10:22:34 hortensia Xorg.bin[11792]: -a #
default pointer acceleration (factor)
Oct 30 10:22:34 hortensia Xorg.bin[11792]: -ac
disable access control restrictions
Oct 30 10:22:34 hortensia systemd[850]: xorg.service: main process
exited, code=exited, status=1/FAILURE
Oct 30 10:22:34 hortensia systemd[850]: Unit xorg.service entered failed state.
---
● xorg.service - Xorg server at display :0
   Loaded: loaded (/home/gabx/.config/systemd/user/xorg.service; static)
   Active: failed (Result: exit-code) since Thu 2014-10-30 10:42:17
CET; 1min 8s ago
  Process: 12191 ExecStart=/usr/bin/xinit -- :0 -nolisten tcp
vt$XDG_VTNR (code=exited, status=1/FAILURE)
 Main PID: 12191 (code=exited, status=1/FAILURE)

Oct 30 10:42:02 hortensia systemd[850]: Started Xorg server at display :0.
Oct 30 10:42:02 hortensia xinit[12191]: /usr/bin/Xorg.wrap: Only
console users are allowed to run the X server
Oct 30 10:42:17 hortensia systemd[850]: xorg.service: main process
exited, code=exited, status=1/FAILURE
Oct 30 10:42:17 hortensia systemd[850]: Unit xorg.service entered failed state.
---

I even tried to set $XDG_VTNR variable this way:
$ systemctl --user set-environment XDG_VTNR=1



Some info about my system:

gabx@hortensia ➤➤ ~ % systemctl --user status
● hortensia
State: running
 Jobs: 0 queued
   Failed: 0 units
Since: Thu 2014-10-30 11:09:46 CET; 18min ago
   CGroup: /user.slice/user-1000.slice/user@1000.service
   ├─852 /usr/lib/systemd/systemd --user
   ├─853 (sd-pam)
   ├─dbus.service
   │ └─2238 /usr/bin/dbus-daemon --session --address=systemd:
--nofork --systemd-activation
   ├─tmux.service
   │ ├─900 /usr/bin/tmux new-session -d -n irc irssi  zsh
   │ ├─901 zsh -c irssi  zsh
   │ └─906 irssi
   ├─urxvtd.service
   │ └─1394 /usr/bin/urxvtd -o -q -f
   ├─gpg-agent.service
   │ └─898 /usr/bin/gpg-agent --homedir
/home/gabx/.config/gnupg --daemon --write-env-file
/home/gabx/.config/gnupg/gpg-agent.info
   └/home/g─ssh-agent.service
 └─892 /usr/bin/ssh-agent -d -a /run/user/1000/ssh_auth_sock
-
gabx@hortensia ➤➤ ~ % systemctl --user show-environment
DISPLAY=:0
HOME=/home/gabx
LANG=en_US.UTF-8
LC_COLLATE=C
LOGNAME=gabx
MAIL=/var/spool/mail/gabx
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
SHELL=/usr/bin/zsh
USER=gabx
XDG_RUNTIME_DIR=/run/user/1000
--
gabx@hortensia ➤➤ ~ % systemd-cgls
├─1 /usr/lib/systemd/systemd
├─system.slice
│ ├─dbus.service
│ │ └─608 /usr/bin/dbus-daemon --system --address=systemd: --nofork
--nopidfile --systemd-activation
│ ├─lvm2-lvmetad.service
│ │ └─365 /usr/bin/lvmetad -f
│ ├─systemd-machined.service
│ │ └─843 /usr/lib/systemd/systemd-machined
│ ├─mysqld.service
│ │ └─519 /usr/bin/mysqld --pid-file=/run/mysqld/mysqld.pid
│ ├─adb.service
│ │ └─583 adb -P 5037 fork-server server
│ ├─systemd-journald.service
│ │ └─200 /usr/lib/systemd/systemd-journald
│ ├─system-devmon.slice
│ │ └─devmon@gabx.service
│ │   ├─ 549 /bin/bash /usr/bin/devmon
│ │   └─1098 /usr/sbin/udevil --monitor
│ ├─udisks2.service
│ │ └─2202 /usr/lib/udisks2/udisksd --no-debug
│ ├─systemd-timesyncd.service
│ │ └─463 /usr/lib/systemd/systemd-timesyncd
│ ├─systemd-logind.service
│ │ └─590 /usr/lib/systemd/systemd-logind
│ ├─systemd-networkd.service
│ │ └─675 /usr/lib/systemd/systemd-networkd
│ ├─systemd-udevd.service

[systemd-devel] [PATCHv6] tmpfiles, man: Add xattr support to tmpfiles

2014-10-30 Thread Maciej Wereski
This patch makes it possible to set extended attributes on files created
by tmpfiles. This can be especially used to set SMACK security labels on
volatile files and directories.

It is done by adding new line of type t. Such line should contain
attributes in Argument field, using following format:

name=value

All other fields are ignored.

If value contains spaces, then it must be surrounded by quotation marks.
User can also put quotation mark in value by escaping it with backslash.

Example:
D /var/run/cups - - - -
t /var/run/cups - - - - security.SMACK64=printing
---
v6:
* rebase
* man fixes
* use glibc xattr
* use unquote_first_word() instead of own parsing logic

v5:
* fixes for HAVE_XATTR undefined
* use cunescape() instead of strreplace()
* cache result of strv_length()
* fix typo in manpage

v4:
* grammar fix in man
* style fix

v3:
* may be used instead of should be used in manpage
* use strv_isempty() instead of != NULL
* rework item_set_xattrs() with split_pair()
* remove copy_item_contents()
* use hashmap_replace() instead of removed copy_item_contents()
* use strv_extend() instead of strv_append()
* cleanup
---
 man/tmpfiles.d.xml  |  32 --
 src/tmpfiles/tmpfiles.c | 160 
 2 files changed, 173 insertions(+), 19 deletions(-)

diff --git a/man/tmpfiles.d.xml b/man/tmpfiles.d.xml
index f2360ba..731efd9 100644
--- a/man/tmpfiles.d.xml
+++ b/man/tmpfiles.d.xml
@@ -343,6 +343,25 @@ L/tmp/foobar ----   
/dev/null/programlisting
 normal path
 names./para/listitem
 /varlistentry
+
+varlistentry
+termvarnamet/varname/term
+listitemparaSet extended
+attributes on item. It may be
+used in conjunction with other
+types (only varnamed/varname,
+varnameD/varname, 
varnamef/varname,
+varnameF/varname, 
varnameL/varname,
+varnamep/varname, 
varnamec/varname,
+varnameb/varname, 
varnamez/varname
+makes sense). If used as a standalone
+line, then commandsystemd-tmpfiles
+/command will try to set extended
+attributes on specified path.
+This can be especially used to set
+SMACK labels.
+/para/listitem
+/varlistentry
 /variablelist
 
 paraIf the exclamation mark is used, this
@@ -430,7 +449,7 @@ r! /tmp/.X[0-9]*-lock/programlisting
 will not be modified. This parameter is
 ignored for varnamex/varname,
 varnamer/varname, varnameR/varname,
-varnameL/varname lines./para
+varnameL/varname, varnamet/varname 
lines./para
 
 paraOptionally, if prefixed with
 literal~/literal, the access mode is masked
@@ -462,8 +481,8 @@ r! /tmp/.X[0-9]*-lock/programlisting
 ownership will not be modified. These
 parameters are ignored for
 varnamex/varname, varnamer/varname,
-varnameR/varname, varnameL/varname
-lines./para
+varnameR/varname, varnameL/varname,
+varnamet/varname lines./para
 /refsect2
 
 refsect2
@@ -527,8 +546,8 @@ r! /tmp/.X[0-9]*-lock/programlisting
 specify a short string that is written to the
 file, suffixed by a newline. For
 varnameC/varname, specifies the source file
-or directory. Ignored for all other
-lines./para
+or directory. For varnamet/varname determines
+extended attributes to be set. Ignored for all other 
lines./para
 /refsect2
 
 /refsect1
@@ -540,7 +559,8 @@ r! /tmp/.X[0-9]*-lock/programlisting
 paracommandscreen/command needs two directories 
created at boot with specific modes and ownership./para
 
 programlistingd /run/screens  1777 root root 10d
-d /run/uscreens 0755 root root 10d12h/programlisting
+d /run/uscreens 0755 root root 10d12h
+t /run/screen - - - - user.name=John 

[systemd-devel] [PATCH v2] core: improve error message when machine id is missing

2014-10-30 Thread Jan Synacek
---
Changes in v2:
 - show long explanation only when errno == EROFS

 src/core/machine-id-setup.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
index efb074f..2360904 100644
--- a/src/core/machine-id-setup.c
+++ b/src/core/machine-id-setup.c
@@ -191,7 +191,14 @@ int machine_id_setup(const char *root) {
 else {
 fd = open(etc_machine_id, O_RDONLY|O_CLOEXEC|O_NOCTTY);
 if (fd  0) {
-log_error(Cannot open %s: %m, 
etc_machine_id);
+if (errno == EROFS)
+log_error(System cannot boot: Missing 
/etc/machine-id and /etc is mounted read-only.\n
+  Booting up is supported 
only when:\n
+  1) /etc/machine-id exists 
and is populated.\n
+  2) /etc/machine-id exists 
and is empty.\n
+  3) /etc/machine-id is 
missing and /etc is writable.\n);
+else
+log_error(Cannot open %s: %m, 
etc_machine_id);
 return -errno;
 }
 
-- 
1.9.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] missing: Correct and extend getrandom syscall defines

2014-10-30 Thread Lennart Poettering
On Wed, 29.10.14 21:02, Dave Reisner (d...@falconindy.com) wrote:

 On Wed, Oct 29, 2014 at 11:55:29PM +0100, Lennart Poettering wrote:
  On Wed, 29.10.14 14:29, Cristian Rodríguez (crrodrig...@opensuse.org) wrote:
  
   Add syscall numbers for 32 bit x86 and arm and Correct
   the system call number for x86_64 (it is 318 not 278)
  
  Hmm? I did my testing on x86_64 3.18rc2, 278 is what worked
  here... Did you test 318? Where does that number come from?
 
 I didn't see Cristian's patch and committed this:
 
 http://cgit.freedesktop.org/systemd/systemd/commit/?id=74a550c

Humm? Did you test it with that? I tested it on my 3.18 with 278, and
it worked fine. 

 Is there a reason to avoid the syscall on i386?

No, I just didn't have any system to test it with. The other numebrs
should of course be added...

Lennart

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


Re: [systemd-devel] [PATCH] missing: Correct and extend getrandom syscall defines

2014-10-30 Thread Dave Reisner
On Thu, Oct 30, 2014 at 12:39:53PM +0100, Lennart Poettering wrote:
 On Wed, 29.10.14 21:02, Dave Reisner (d...@falconindy.com) wrote:
 
  On Wed, Oct 29, 2014 at 11:55:29PM +0100, Lennart Poettering wrote:
   On Wed, 29.10.14 14:29, Cristian Rodríguez (crrodrig...@opensuse.org) 
   wrote:
   
Add syscall numbers for 32 bit x86 and arm and Correct
the system call number for x86_64 (it is 318 not 278)
   
   Hmm? I did my testing on x86_64 3.18rc2, 278 is what worked
   here... Did you test 318? Where does that number come from?
  
  I didn't see Cristian's patch and committed this:
  
  http://cgit.freedesktop.org/systemd/systemd/commit/?id=74a550c
 
 Humm? Did you test it with that? I tested it on my 3.18 with 278, and
 it worked fine. 
 

Sure did. A value of 278 leads me to a unusuable nspawn binary and an
unbootable system. After my change to 318, nspawn works again, and I can
boot.

Where did you get this value from? How did you test it? My hypothesis:
your kernel API headers are from 3.17 and provide a definition of
__NR_getrandom. Therefore, this fallback was never picked up from
configure.ac in your test build.

  Is there a reason to avoid the syscall on i386?
 
 No, I just didn't have any system to test it with. The other numebrs
 should of course be added...

Fair enough.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Switch root slowness

2014-10-30 Thread Jan Synáček
Hello,

commit 539618a0ddc2dc7f0fbe28de2ae0e07b34c81e60
Author: Lennart Poettering lenn...@poettering.net
Date:   Wed Oct 29 17:06:32 2014 +0100

util: make use of the new getrandom() syscall if it is available when 
needing entropy

Doesn't require an fd, and could be a bit faster, so let's make use of
it, if it is available.

Beginning from this commit, switch root takes about a minute on my machine.

Excerpts from the journal:
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: random: systemd urandom 
read with 10 bits of entropy available
Oct 30 13:08:37 fedora-rawhide-systemd-virt systemd-journal[109]: Journal 
started
Oct 30 13:08:37 fedora-rawhide-systemd-virt dracut-cmdline[105]: dracut-22 
(Rawhide) dracut-038-36.git20140815.fc22
Oct 30 13:08:37 fedora-rawhide-systemd-virt dracut-cmdline[105]: Using kernel 
command line parameters:
Oct 30 13:08:37 fedora-rawhide-systemd-virt systemd-udevd[158]: starting 
version 216

This line is pretty weird too, this commit is after v217 had been tagged.

Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] Initialized drm 1.1.0 
20060810
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] Device Version 0.0
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] Compression level 0 
log level 0
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] Currently using mode 
#0, list at 0x488
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] 12286 io pages at 
offset 0x100
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] 16777216 byte draw 
area at offset 0x0
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] RAM header offset: 
0x3ffe000
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] rom modes offset 
0x488 for 128 modes
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [TTM] Zone  kernel: 
Available graphics memory: 1024780 kiB
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [TTM] Initializing pool 
allocator
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [TTM] Initializing DMA pool 
allocator
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] qxl: 16M of VRAM 
memory size
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] qxl: 63M of IO pages 
memory ready (VRAM domain)
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] qxl: 64M of Surface 
memory size
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] main mem slot 1 
[f400,3ffe000]
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] surface mem slot 2 
[f800,400]
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] Supports vblank 
timestamp caching Rev 2 (21.10.2013).
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] No driver support for 
vblank timestamp query.
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] fb mappable at 
0xF400, size 3145728
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] fb: depth 24, pitch 
4096, width 1024, height 768
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: fbcon: qxldrmfb (fb0) is 
primary device
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: Console: switching to 
colour frame buffer device 128x48
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: qxl :00:02.0: fb0: 
qxldrmfb frame buffer device
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: qxl :00:02.0: 
registered panic notifier
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: [drm] Initialized qxl 0.1.0 
20120117 for :00:02.0 on minor 0
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: PM: Starting manual resume 
from disk
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: PM: Hibernation image 
partition 8:2 present
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: PM: Looking for hibernation 
image.
Oct 30 13:08:37 fedora-rawhide-systemd-virt systemd-fsck[198]: /dev/sda3: 
clean, 83696/853440 files, 1149042/3410688 blocks
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: PM: Image not found (code 
-22)
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: PM: Hibernation image not 
present or could not be loaded.
Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: EXT4-fs (sda3): mounted 
filesystem with ordered data mode. Opts: (null)
Oct 30 13:08:38 fedora-rawhide-systemd-virt systemd[1]: Switching root.
Oct 30 13:08:38 fedora-rawhide-systemd-virt systemd-journal[109]: Journal 
stopped

Hangs here for a while with no output.

Oct 30 13:09:44 fedora-rawhide-systemd-virt systemd-journal[279]: Runtime 
journal is using 8.0M (max allowed 100.0M, trying to leave 150.1M free of 
992.7M available → current limit 100.0M).
Oct 30 13:09:44 fedora-rawhide-systemd-virt systemd-journal[279]: Runtime 
journal is using 8.0M (max allowed 100.0M, trying to leave 150.1M free of 
992.7M available → current limit 100.0M).
Oct 30 13:09:44 fedora-rawhide-systemd-virt systemd-journald[109]: Received 
SIGTERM from PID 1 (systemd).
snip a lot of selinux related stuff
Oct 30 13:09:44 fedora-rawhide-systemd-virt kernel: random: 

Re: [systemd-devel] Switch root slowness

2014-10-30 Thread Dave Reisner
On Thu, Oct 30, 2014 at 01:18:24PM +0100, Jan Synáček wrote:
 Hello,
 
 commit 539618a0ddc2dc7f0fbe28de2ae0e07b34c81e60
 Author: Lennart Poettering lenn...@poettering.net
 Date:   Wed Oct 29 17:06:32 2014 +0100
 
 util: make use of the new getrandom() syscall if it is available when 
 needing entropy
 
 Doesn't require an fd, and could be a bit faster, so let's make use of
 it, if it is available.
 
 Beginning from this commit, switch root takes about a minute on my machine.
 
 Excerpts from the journal:
 Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: random: systemd urandom 
 read with 10 bits of entropy available
 Oct 30 13:08:37 fedora-rawhide-systemd-virt systemd-journal[109]: Journal 
 started
 Oct 30 13:08:37 fedora-rawhide-systemd-virt dracut-cmdline[105]: dracut-22 
 (Rawhide) dracut-038-36.git20140815.fc22
 Oct 30 13:08:37 fedora-rawhide-systemd-virt dracut-cmdline[105]: Using kernel 
 command line parameters:
 Oct 30 13:08:37 fedora-rawhide-systemd-virt systemd-udevd[158]: starting 
 version 216
 
 This line is pretty weird too, this commit is after v217 had been tagged.
 

Not that weird, it just means you didn't update your initrd after
updating to 217.

 ...

 Oct 30 13:08:38 fedora-rawhide-systemd-virt systemd[1]: Switching root.
 Oct 30 13:08:38 fedora-rawhide-systemd-virt systemd-journal[109]: Journal 
 stopped
 
 Hangs here for a while with no output.
 
 Oct 30 13:09:44 fedora-rawhide-systemd-virt systemd-journal[279]: Runtime 
 journal is using 8.0M (max allowed 100.0M, trying to leave 150.1M free of 
 992.7M available → current limit 100.0M).
 Oct 30 13:09:44 fedora-rawhide-systemd-virt systemd-journal[279]: Runtime 
 journal is using 8.0M (max allowed 100.0M, trying to leave 150.1M free of 
 992.7M available → current limit 100.0M).
 Oct 30 13:09:44 fedora-rawhide-systemd-virt systemd-journald[109]: Received 
 SIGTERM from PID 1 (systemd).
 snip a lot of selinux related stuff
 Oct 30 13:09:44 fedora-rawhide-systemd-virt kernel: random: nonblocking pool 
 is initialized
 
 Is anyone else running into this?

Probably fixed by:

http://cgit.freedesktop.org/systemd/systemd/commit/?id=74a550c5d8228

d
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemctl user start Xorg

2014-10-30 Thread poma
On 30.10.2014 12:20, arnaud gaboury wrote:
...
 Oct 30 10:42:02 hortensia systemd[850]: Started Xorg server at display :0.
 Oct 30 10:42:02 hortensia xinit[12191]: /usr/bin/Xorg.wrap: Only
 console users are allowed to run the X server
 Oct 30 10:42:17 hortensia systemd[850]: xorg.service: main process
 exited, code=exited, status=1/FAILURE
 Oct 30 10:42:17 hortensia systemd[850]: Unit xorg.service entered failed 
 state.
...


Perhaps 
/etc/X11/Xwrapper.config
needs_root_rights = auto
allowed_users = anybody

man 1 Xorg.wrap


poma


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] sysusers: Preserve ownership and mode on /etc/passwd and friends

2014-10-30 Thread Zbigniew Jędrzejewski-Szmek
On Wed, Oct 29, 2014 at 05:27:28PM +, Colin Guthrie wrote:
 FWIW, I tested this now and it seems to have worked fine and properly
 preserved both mode and ownership of the files in question.
 
 OK to push this one?
Yeah, looks reasonable.

Zbyszek

 Colin Guthrie wrote on 29/10/14 14:34:
  When running sysusers we would clobber file ownership and permissions
  on the files /etc/passwd, /etc/group and /etc/[g]shadow.
  
  This simply preserves the ownership and mode if existing files are
  found.
  ---
   src/sysusers/sysusers.c | 61 
  +
   1 file changed, 41 insertions(+), 20 deletions(-)
  
  diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
  index 9b9be96..c133dc5 100644
  --- a/src/sysusers/sysusers.c
  +++ b/src/sysusers/sysusers.c
  @@ -358,6 +358,7 @@ static int write_files(void) {
   _cleanup_fclose_ FILE *passwd = NULL, *group = NULL, *shadow = 
  NULL, *gshadow = NULL;
   _cleanup_free_ char *passwd_tmp = NULL, *group_tmp = NULL, 
  *shadow_tmp = NULL, *gshadow_tmp = NULL;
   const char *passwd_path = NULL, *group_path = NULL, *shadow_path = 
  NULL, *gshadow_path = NULL;
  +struct stat st;
   bool group_changed = false;
   Iterator iterator;
   Item *i;
  @@ -372,15 +373,17 @@ static int write_files(void) {
   if (r  0)
   goto finish;
   
  -if (fchmod(fileno(group), 0644)  0) {
  -r = -errno;
  -goto finish;
  -}
  -
   original = fopen(group_path, re);
   if (original) {
   struct group *gr;
   
  +if (fstat(fileno(original), st)  0 ||
  +fchmod(fileno(group), st.st_mode  0)  0 
  ||
  +fchown(fileno(group), st.st_uid, st.st_gid)  
  0) {
  +r = -errno;
  +goto finish;
  +}
  +
   errno = 0;
   while ((gr = fgetgrent(original))) {
   /* Safety checks against name and GID
  @@ -418,6 +421,9 @@ static int write_files(void) {
   } else if (errno != ENOENT) {
   r = -errno;
   goto finish;
  +} else if (fchmod(fileno(group), 0644)  0) {
  +r = -errno;
  +goto finish;
   }
   
   HASHMAP_FOREACH(i, todo_gids, iterator) {
  @@ -449,15 +455,17 @@ static int write_files(void) {
   if (r  0)
   goto finish;
   
  -if (fchmod(fileno(gshadow), )  0) {
  -r = -errno;
  -goto finish;
  -}
  -
   original = fopen(gshadow_path, re);
   if (original) {
   struct sgrp *sg;
   
  +if (fstat(fileno(original), st)  0 ||
  +fchmod(fileno(gshadow), st.st_mode  0)  
  0 ||
  +fchown(fileno(gshadow), st.st_uid, st.st_gid) 
   0) {
  +r = -errno;
  +goto finish;
  +}
  +
   errno = 0;
   while ((sg = fgetsgent(original))) {
   
  @@ -483,6 +491,9 @@ static int write_files(void) {
   } else if (errno != ENOENT) {
   r = -errno;
   goto finish;
  +} else if (fchmod(fileno(gshadow), )  0) {
  +r = -errno;
  +goto finish;
   }
   
   HASHMAP_FOREACH(i, todo_gids, iterator) {
  @@ -513,15 +524,17 @@ static int write_files(void) {
   if (r  0)
   goto finish;
   
  -if (fchmod(fileno(passwd), 0644)  0) {
  -r = -errno;
  -goto finish;
  -}
  -
   original = fopen(passwd_path, re);
   if (original) {
   struct passwd *pw;
   
  +if (fstat(fileno(original), st)  0 ||
  +fchmod(fileno(passwd), st.st_mode  0)  0 
  ||
  +fchown(fileno(passwd), st.st_uid, st.st_gid)  
  0) {
  +r = -errno;
  +goto finish;
  +}
  +
   errno = 0;
   while ((pw = fgetpwent(original))) {
   
  @@ -552,6 +565,9 @@ static int write_files(void) {
   } else if (errno != ENOENT) {
   

Re: [systemd-devel] Switch root slowness

2014-10-30 Thread Lennart Poettering
On Thu, 30.10.14 13:18, Jan Synáček (jsyna...@redhat.com) wrote:

 Hello,
 
 commit 539618a0ddc2dc7f0fbe28de2ae0e07b34c81e60
 Author: Lennart Poettering lenn...@poettering.net
 Date:   Wed Oct 29 17:06:32 2014 +0100
 
 util: make use of the new getrandom() syscall if it is available when 
 needing entropy
 
 Doesn't require an fd, and could be a bit faster, so let's make use of
 it, if it is available.
 
 Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: EXT4-fs (sda3): mounted 
 filesystem with ordered data mode. Opts: (null)
 Oct 30 13:08:38 fedora-rawhide-systemd-virt systemd[1]: Switching root.
 Oct 30 13:08:38 fedora-rawhide-systemd-virt systemd-journal[109]: Journal 
 stopped
 
 Hangs here for a while with no output.
 
 Oct 30 13:09:44 fedora-rawhide-systemd-virt systemd-journal[279]: Runtime 
 journal is using 8.0M (max allowed 100.0M, trying to leave 150.1M free of 
 992.7M available → current limit 100.0M).
 Oct 30 13:09:44 fedora-rawhide-systemd-virt systemd-journal[279]: Runtime 
 journal is using 8.0M (max allowed 100.0M, trying to leave 150.1M free of 
 992.7M available → current limit 100.0M).
 Oct 30 13:09:44 fedora-rawhide-systemd-virt systemd-journald[109]: Received 
 SIGTERM from PID 1 (systemd).
 snip a lot of selinux related stuff
 Oct 30 13:09:44 fedora-rawhide-systemd-virt kernel: random: nonblocking pool 
 is initialized
 
 Is anyone else running into this?

This could be due to the blocking nature of getrandom() if little
entropy is available. The call waits by default until the pool is
initialized before returning, which is probably what your system is
waiting on.

I wish there was a way how we could use getrandom() in a way like
/dev/urandom, where we can pull out the non-initialized data
anyway. In absence of that we can just fallback to /dev/urandom on
EAGAIN I guess, and always pass GRND_NONBLOCK.

Lennart

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


Re: [systemd-devel] [PATCH] sysusers: Preserve ownership and mode on /etc/passwd and friends

2014-10-30 Thread Colin Guthrie

Zbigniew Jędrzejewski-Szmek wrote on 30/10/14 12:35:
 On Wed, Oct 29, 2014 at 05:27:28PM +, Colin Guthrie wrote:
 FWIW, I tested this now and it seems to have worked fine and properly
 preserved both mode and ownership of the files in question.

 OK to push this one?
 Yeah, looks reasonable.

Cool. Pushed as e3c72c21d62aadabf4df436c3e2c7219eeeccc1c


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Switch root slowness

2014-10-30 Thread Cristian Rodríguez

El 30/10/14 a las #4, Lennart Poettering escribió:
 In absence of that we can just fallback to /dev/urandom on

EAGAIN I guess, and always pass GRND_NONBLOCK.



Before you made this commit, I had a local patch that did exactly 
that..currently this is the best solution. I suggest to give up on any 
failure (not implemented, blocking..whatever) and fallback to reading 
/dev/urandom.



___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] missing: Correct and extend getrandom syscall defines

2014-10-30 Thread Lennart Poettering
On Thu, 30.10.14 07:57, Dave Reisner (d...@falconindy.com) wrote:

 On Thu, Oct 30, 2014 at 12:39:53PM +0100, Lennart Poettering wrote:
  On Wed, 29.10.14 21:02, Dave Reisner (d...@falconindy.com) wrote:
  
   On Wed, Oct 29, 2014 at 11:55:29PM +0100, Lennart Poettering wrote:
On Wed, 29.10.14 14:29, Cristian Rodríguez (crrodrig...@opensuse.org) 
wrote:

 Add syscall numbers for 32 bit x86 and arm and Correct
 the system call number for x86_64 (it is 318 not 278)

Hmm? I did my testing on x86_64 3.18rc2, 278 is what worked
here... Did you test 318? Where does that number come from?
   
   I didn't see Cristian's patch and committed this:
   
   http://cgit.freedesktop.org/systemd/systemd/commit/?id=74a550c
  
  Humm? Did you test it with that? I tested it on my 3.18 with 278, and
  it worked fine. 
  
 
 Sure did. A value of 278 leads me to a unusuable nspawn binary and an
 unbootable system. After my change to 318, nspawn works again, and I can
 boot.
 
 Where did you get this value from? How did you test it? My hypothesis:
 your kernel API headers are from 3.17 and provide a definition of
 __NR_getrandom. Therefore, this fallback was never picked up from
 configure.ac in your test build.

Oh, indeed. That explains it!

Lennart

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


Re: [systemd-devel] Switch root slowness

2014-10-30 Thread Jan Synacek
Dave Reisner d...@falconindy.com writes:
 On Thu, Oct 30, 2014 at 01:18:24PM +0100, Jan Synáček wrote:
 Hello,
 
 commit 539618a0ddc2dc7f0fbe28de2ae0e07b34c81e60
 Author: Lennart Poettering lenn...@poettering.net
 Date:   Wed Oct 29 17:06:32 2014 +0100
 
 util: make use of the new getrandom() syscall if it is available when 
 needing entropy
 
 Doesn't require an fd, and could be a bit faster, so let's make use of
 it, if it is available.
 
 Beginning from this commit, switch root takes about a minute on my machine.

 ...

 Probably fixed by:

 http://cgit.freedesktop.org/systemd/systemd/commit/?id=74a550c5d8228

Nope, still slow.

-- 
Jan Synacek
Software Engineer, Red Hat


signature.asc
Description: PGP signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Switch root slowness

2014-10-30 Thread Lennart Poettering
On Thu, 30.10.14 14:35, Lennart Poettering (lenn...@poettering.net) wrote:

 On Thu, 30.10.14 13:18, Jan Synáček (jsyna...@redhat.com) wrote:
 
  Hello,
  
  commit 539618a0ddc2dc7f0fbe28de2ae0e07b34c81e60
  Author: Lennart Poettering lenn...@poettering.net
  Date:   Wed Oct 29 17:06:32 2014 +0100
  
  util: make use of the new getrandom() syscall if it is available when 
  needing entropy
  
  Doesn't require an fd, and could be a bit faster, so let's make use of
  it, if it is available.
  
  Oct 30 13:08:37 fedora-rawhide-systemd-virt kernel: EXT4-fs (sda3): mounted 
  filesystem with ordered data mode. Opts: (null)
  Oct 30 13:08:38 fedora-rawhide-systemd-virt systemd[1]: Switching root.
  Oct 30 13:08:38 fedora-rawhide-systemd-virt systemd-journal[109]: Journal 
  stopped
  
  Hangs here for a while with no output.
  
  Oct 30 13:09:44 fedora-rawhide-systemd-virt systemd-journal[279]: Runtime 
  journal is using 8.0M (max allowed 100.0M, trying to leave 150.1M free of 
  992.7M available → current limit 100.0M).
  Oct 30 13:09:44 fedora-rawhide-systemd-virt systemd-journal[279]: Runtime 
  journal is using 8.0M (max allowed 100.0M, trying to leave 150.1M free of 
  992.7M available → current limit 100.0M).
  Oct 30 13:09:44 fedora-rawhide-systemd-virt systemd-journald[109]: Received 
  SIGTERM from PID 1 (systemd).
  snip a lot of selinux related stuff
  Oct 30 13:09:44 fedora-rawhide-systemd-virt kernel: random: nonblocking 
  pool is initialized
  
  Is anyone else running into this?
 
 This could be due to the blocking nature of getrandom() if little
 entropy is available. The call waits by default until the pool is
 initialized before returning, which is probably what your system is
 waiting on.
 
 I wish there was a way how we could use getrandom() in a way like
 /dev/urandom, where we can pull out the non-initialized data
 anyway. In absence of that we can just fallback to /dev/urandom on
 EAGAIN I guess, and always pass GRND_NONBLOCK.

I have now implemented that. Please test!

Lennart

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


[systemd-devel] [PATCH v3] Bootchart: use /proc/pid/mountinfo for root bdev

2014-10-30 Thread Timofey Titovets

Good time of day, list.
I have try to fix Fixme in svg.c:
/* FIXME: this works only in the simple case */

By default function try to get only root=/dev/*
I also attach patch. Thanks.

v2:
	Rewrited with use fstab_node_to_udev_node() and 
canonicalize_file_name() functions.

v3:
Rewrited for parsing /proc/self/mountinfo

Please test it, i'm can't test because i not have /proc/schedstat file 
(custom kernel)


I use  0  for searching root device its correct?
For test:
[$]: grep  0  /proc/self/mountinfo

I'm not use major:minor because on some setups it useless.
As example, my system root:
50 0 0:28 /@ / rw,relatime shared:1 - btrfs /dev/sda3 
rw,compress=zlib,space_cache,autodefrag


0:28 What?
But my system partition have 8:3
But i have only: /sys/class/bdi/8:0 and 8:1
What i missed?


From df889766a0dae0700cbc1378699e1abbad6b3f8d Mon Sep 17 00:00:00 2001
From: Timofey Titovets nefelim...@gmail.com
Date: Thu, 30 Oct 2014 17:23:32 +0300
Subject: [PATCH] Bootchart: use /proc/pid/mountinfo for root bdev

---
 src/bootchart/svg.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c
index faf377e..a6a69c1 100644
--- a/src/bootchart/svg.c
+++ b/src/bootchart/svg.c
@@ -33,6 +33,7 @@
 #include sys/stat.h
 #include fcntl.h

+#include fileio.h
 #include util.h
 #include macro.h
 #include store.h
@@ -153,16 +154,16 @@ static void svg_header(void) {

 static void svg_title(const char *build) {
 char cmdline[256] = ;
-char filename[PATH_MAX];
 char buf[256];
 char rootbdev[16] = Unknown;
 char model[256] = Unknown;
 char date[256] = Unknown;
 char cpu[256] = Unknown;
-char *c;
+char *ptr = NULL;
 FILE *f;
 time_t t;
 int fd, r;
+size_t length = 0;
 struct utsname uts;

 /* grab /proc/cmdline */
@@ -174,11 +175,12 @@ static void svg_title(const char *build) {
 fclose(f);
 }

-/* extract root fs so we can find disk model name in sysfs */
-/* FIXME: this works only in the simple case */
-c = strstr(cmdline, root=/dev/);
-if (c) {
-strncpy(rootbdev, c[10], 3);
+r = read_full_file(/proc/self/mountinfo, ptr, length);
+if (!r) {
+char filename[PATH_MAX]=;
+ptr = strtok(ptr,  0 );
+ptr = strtok(ptr,  /dev/);
+strncpy(rootbdev, ptr[6], 3);
 rootbdev[3] = '\0';
 sprintf(filename, block/%s/device/model, rootbdev);
 fd = openat(sysfd, filename, O_RDONLY);
--
2.1.3


From df889766a0dae0700cbc1378699e1abbad6b3f8d Mon Sep 17 00:00:00 2001
From: Timofey Titovets nefelim...@gmail.com
Date: Thu, 30 Oct 2014 17:23:32 +0300
Subject: [PATCH] Bootchart: use /proc/pid/mountinfo for root bdev

---
 src/bootchart/svg.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c
index faf377e..a6a69c1 100644
--- a/src/bootchart/svg.c
+++ b/src/bootchart/svg.c
@@ -33,6 +33,7 @@
 #include sys/stat.h
 #include fcntl.h
 
+#include fileio.h
 #include util.h
 #include macro.h
 #include store.h
@@ -153,16 +154,16 @@ static void svg_header(void) {
 
 static void svg_title(const char *build) {
 char cmdline[256] = ;
-char filename[PATH_MAX];
 char buf[256];
 char rootbdev[16] = Unknown;
 char model[256] = Unknown;
 char date[256] = Unknown;
 char cpu[256] = Unknown;
-char *c;
+char *ptr = NULL;
 FILE *f;
 time_t t;
 int fd, r;
+size_t length = 0;
 struct utsname uts;
 
 /* grab /proc/cmdline */
@@ -174,11 +175,12 @@ static void svg_title(const char *build) {
 fclose(f);
 }
 
-/* extract root fs so we can find disk model name in sysfs */
-/* FIXME: this works only in the simple case */
-c = strstr(cmdline, root=/dev/);
-if (c) {
-strncpy(rootbdev, c[10], 3);
+r = read_full_file(/proc/self/mountinfo, ptr, length);
+if (!r) {
+char filename[PATH_MAX]=;
+ptr = strtok(ptr,  0 );
+ptr = strtok(ptr,  /dev/);
+strncpy(rootbdev, ptr[6], 3);
 rootbdev[3] = '\0';
 sprintf(filename, block/%s/device/model, rootbdev);
 fd = openat(sysfd, filename, O_RDONLY);
-- 
2.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] starting Oracle with systemd

2014-10-30 Thread Lennart Poettering
On Tue, 28.10.14 15:08, Fisher, Charles J. (Top Echelon) 
(charles.fis...@alcoa.com) wrote:

 Is this the best way to start Oracle?
 
 [root@localhost system]# cat oracle-foo.service
 [Unit]
 Description=oracle db - foo
 After=syslog.target

The After=syslog.target line is unnecessary these days. It's implied.

 
 [Service]
 Environment=ORACLE_SID=foo ORACLE_HOME=/home/oracle/Ora12c/db
 ExecStart=/bin/ksh -c 'print connect / as sysdba \n startup \n quit | 
 $ORACLE_HOME/bin/sqlplus -silent /nolog'
 ExecStop=/bin/ksh -c 'print connect / as sysdba \n shutdown
 immediate \n quit | $ORACLE_HOME/bin/sqlplus -silent /nolog'

This looks quite suspicious as you spawn a shell and keep it
running. It's fine to run shells and then finally exec the real
binary, replacing the shell process, but keeping the shell around
would tell systemd that the shell was the actual daemon process.

 Type=forking
 User=oracle
 Group=dba
 
 [Install]
 WantedBy=multi-user.target
 
 #This file should be placed in /etc/systemd/system
 #enable for start at boot by: systemctl enable oracle_db-foo.service
 
 I used to do it with an init.d script that grabbed the SID out of
 argv[0] with ORACLE_SID=${0##*-} - I'm assuming that a systemd
 service file can't grab anything similarly out of argv[0], and I
 can't hard-link them all together.
 
 I may have several instances on a machine; I'd like one service to
 start/stop everything if possible (maybe with dbstart/dbshut), but I
 also want granular control over each Oracle instance.

If you have multiple instances, use systemd's unit instance concept:

http://0pointer.de/blog/projects/instances.html

As I don't really know Oracle I cannot really tell you how to start it
best, but I hope the hints above are useful.

Lennart

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


Re: [systemd-devel] [PATCH v2] core: improve error message when machine id is missing

2014-10-30 Thread Lennart Poettering
On Thu, 30.10.14 12:36, Jan Synacek (jsyna...@redhat.com) wrote:

 ---
 Changes in v2:
  - show long explanation only when errno == EROFS
 
  src/core/machine-id-setup.c | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)
 
 diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
 index efb074f..2360904 100644
 --- a/src/core/machine-id-setup.c
 +++ b/src/core/machine-id-setup.c
 @@ -191,7 +191,14 @@ int machine_id_setup(const char *root) {
  else {
  fd = open(etc_machine_id, 
 O_RDONLY|O_CLOEXEC|O_NOCTTY);
  if (fd  0) {
 -log_error(Cannot open %s: %m, 
 etc_machine_id);
 +if (errno == EROFS)
 +log_error(System cannot boot: 
 Missing /etc/machine-id and /etc is mounted read-only.\n
 +  Booting up is supported 
 only when:\n
 +  1) /etc/machine-id exists 
 and is populated.\n
 +  2) /etc/machine-id exists 
 and is empty.\n
 +  3) /etc/machine-id is 
 missing and /etc is writable.\n);
 +else
 +log_error(Cannot open %s: %m, 
 etc_machine_id);
  return -errno;
  }

This looks wrong. You need to remember the EROFS from the first
open(). The second open() will return ENOENT if the file is missing,
not EROFS...

Lennart

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


Re: [systemd-devel] starting Oracle with systemd

2014-10-30 Thread Fisher, Charles J. (Top Echelon)

On Tue, 28.10.14 15:08, Fisher, Charles J. (Top Echelon) 
(charles.fis...@alcoa.com) wrote:

 Is this the best way to start Oracle?
 [Service]
 Environment=ORACLE_SID=foo ORACLE_HOME=/home/oracle/Ora12c/db
 ExecStart=/bin/ksh -c 'print connect / as sysdba \n startup \n quit | 
 $ORACLE_HOME/bin/sqlplus -silent /nolog'
 ExecStop=/bin/ksh -c 'print connect / as sysdba \n shutdown
 immediate \n quit | $ORACLE_HOME/bin/sqlplus -silent /nolog'

This looks quite suspicious as you spawn a shell and keep it
running. It's fine to run shells and then finally exec the real
binary, replacing the shell process, but keeping the shell around
would tell systemd that the shell was the actual daemon process.

It doesn't work like that. The ksh dies when sqlplus exits, after it forks the 
instance background processes.

These are the binaries of interest:

-bash-4.2$ ls -l $ORACLE_HOME/bin/sqlplus $ORACLE_HOME/bin/oracle 
$ORACLE_HOME/bin/tnslsnr
-rwsr-s--x. 1 oracle dba 323649834 Aug 13 10:47 
/home/oracle/Ora12c/db/bin/oracle
-rwxr-x--x. 1 oracle dba 10525 Aug 13 10:46 
/home/oracle/Ora12c/db/bin/sqlplus
-rwxr-x--x. 1 oracle dba866455 Aug 13 10:46 
/home/oracle/Ora12c/db/bin/tnslsnr

The real problem is the tnslsnr. It can service multiple instances. If I run 
those instances in separate cgroups, and the listener can only be a member of 
one cgroup, then the listener's children die if the listener process is 
disturbed. This means all DB sessions are cut when the listener is stopped.

It looks like systemd will force separate listeners for all Oracle instances, 
and the usual port number (1521) can't multiplex them (unless a single cgroup 
is used).


-bash-4.2$ ps -ef | grep oracle
root  1742 1  0 11:21 ?00:00:00 login -- oracle
oracle1750  1742  0 11:21 tty2 00:00:00 -bash
root  2285  1190  0 11:34 ?00:00:00 sshd: oracle [priv]
oracle2301  2285  0 11:35 ?00:00:00 sshd: oracle@pts/0
oracle2302  2301  0 11:35 pts/000:00:00 -bash
oracle3379  2302  0 12:13 pts/000:00:00 ps -ef
oracle3380  2302  0 12:13 pts/000:00:00 grep --color=auto oracle

-bash-4.2$ $ORACLE_HOME/bin/sqlplus /nolog

SQL*Plus: Release 12.1.0.2.0 Production on Thu Oct 30 12:19:27 2014

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

SQL connect / as sysdba
Connected to an idle instance.

SQL !ps -ef | grep oracle
root  1742 1  0 11:21 ?00:00:00 login -- oracle
oracle1750  1742  0 11:21 tty2 00:00:00 -bash
root  2285  1190  0 11:34 ?00:00:00 sshd: oracle [priv]
oracle2301  2285  0 11:35 ?00:00:00 sshd: oracle@pts/0
oracle2302  2301  0 11:35 pts/000:00:00 -bash
oracle3431  2302  0 12:19 pts/000:00:00 
/home/oracle/Ora12c/db/bin/sqlplus
oracle3432  3431  0 12:19 ?00:00:00 oracleorcl 
(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle3433  3431  0 12:19 pts/000:00:00 /bin/bash -c ps -ef | grep 
oracle
oracle3434  3433  0 12:19 pts/000:00:00 ps -ef
oracle3435  3433  0 12:19 pts/000:00:00 grep oracle

SQL startup
ORACLE instance started.

Total System Global Area  834666496 bytes
Fixed Size  2929888 bytes
Variable Size 603982624 bytes
Database Buffers  98112 bytes
Redo Buffers5455872 bytes
Database mounted.
Database opened.
SQL quit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 
64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing 
options

***the ora_ processes below are all actually the $ORACLE_HOME/bin/oracle binary

-bash-4.2$ ps -ef | grep oracle
root  1742 1  0 11:21 ?00:00:00 login -- oracle
oracle1750  1742  0 11:21 tty2 00:00:00 -bash
root  2285  1190  0 11:34 ?00:00:00 sshd: oracle [priv]
oracle2301  2285  0 11:35 ?00:00:00 sshd: oracle@pts/0
oracle2302  2301  0 11:35 pts/000:00:00 -bash
oracle3439 1  0 12:19 ?00:00:00 ora_pmon_orcl
oracle3441 1  0 12:19 ?00:00:00 ora_psp0_orcl
oracle3443 1  1 12:19 ?00:00:00 ora_vktm_orcl
oracle3447 1  0 12:19 ?00:00:00 ora_gen0_orcl
oracle3449 1  0 12:19 ?00:00:00 ora_mman_orcl
oracle3453 1  0 12:19 ?00:00:00 ora_diag_orcl
oracle3455 1  0 12:19 ?00:00:00 ora_dbrm_orcl
oracle3457 1  0 12:19 ?00:00:00 ora_vkrm_orcl
oracle3459 1  0 12:19 ?00:00:00 ora_dia0_orcl
oracle3461 1  0 12:19 ?00:00:00 ora_dbw0_orcl
oracle3463 1  0 12:19 ?00:00:00 ora_lgwr_orcl
oracle3465 1  0 12:19 ?00:00:00 ora_ckpt_orcl
oracle3467 1  0 12:19 ?00:00:00 ora_lg00_orcl
oracle3469 1  0 12:19 ?00:00:00 ora_smon_orcl
oracle3471 1  0 12:19 ?00:00:00 ora_lg01_orcl
oracle3473 1  0 12:19 ?00:00:00 ora_reco_orcl
oracle3475 

Re: [systemd-devel] starting Oracle with systemd

2014-10-30 Thread Andrei Borzenkov
В Thu, 30 Oct 2014 13:29:10 -0400
Fisher, Charles J. (Top Echelon) charles.fis...@alcoa.com пишет:

 
 On Tue, 28.10.14 15:08, Fisher, Charles J. (Top Echelon) 
 (charles.fis...@alcoa.com) wrote:
 
  Is this the best way to start Oracle?
  [Service]
  Environment=ORACLE_SID=foo ORACLE_HOME=/home/oracle/Ora12c/db
  ExecStart=/bin/ksh -c 'print connect / as sysdba \n startup \n quit | 
  $ORACLE_HOME/bin/sqlplus -silent /nolog'
  ExecStop=/bin/ksh -c 'print connect / as sysdba \n shutdown
  immediate \n quit | $ORACLE_HOME/bin/sqlplus -silent /nolog'
 
 This looks quite suspicious as you spawn a shell and keep it
 running. It's fine to run shells and then finally exec the real
 binary, replacing the shell process, but keeping the shell around
 would tell systemd that the shell was the actual daemon process.
 
 It doesn't work like that. The ksh dies when sqlplus exits, after it forks 
 the instance background processes.
 
 These are the binaries of interest:
 
 -bash-4.2$ ls -l $ORACLE_HOME/bin/sqlplus $ORACLE_HOME/bin/oracle 
 $ORACLE_HOME/bin/tnslsnr
 -rwsr-s--x. 1 oracle dba 323649834 Aug 13 10:47 
 /home/oracle/Ora12c/db/bin/oracle
 -rwxr-x--x. 1 oracle dba 10525 Aug 13 10:46 
 /home/oracle/Ora12c/db/bin/sqlplus
 -rwxr-x--x. 1 oracle dba866455 Aug 13 10:46 
 /home/oracle/Ora12c/db/bin/tnslsnr
 
 The real problem is the tnslsnr. It can service multiple instances. If I run 
 those instances in separate cgroups, and the listener can only be a member of 
 one cgroup, then the listener's children die if the listener process is 
 disturbed. This means all DB sessions are cut when the listener is stopped.
 
 It looks like systemd will force separate listeners for all Oracle instances, 
 and the usual port number (1521) can't multiplex them (unless a single cgroup 
 is used).
 

Even in this case behavior is wrong. Currently stopping listener does
not affect existing database connections. Killing all client processes
on listener stop will be rather strong regression.

How ssh does it? It is something similar - master service that need to
spawn multiple independent children.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Service not restarting after Condition failed

2014-10-30 Thread D.S. Ljungmark
Hi
 we have a service set to:
ConditionFileNotEmpty=

and

Restart=Always


This combination would (in my feebled mind) cause the service to restart
once the Condition was fulfilled, but that doesn't seem to be the case.

Is there a way I can get a service to restart even after it has been set
as inactive (dead) start condition failed?

Should I simply remove the Condition, or something else?

//D.S.


-- 
8362 CB14 98AD 11EF CEB6  FA81 FCC3 7674 449E 3CFC



signature.asc
Description: OpenPGP digital signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] starting Oracle with systemd

2014-10-30 Thread Fisher, Charles J. (Top Echelon)

-Original Message-
From: systemd-devel [mailto:systemd-devel-boun...@lists.freedesktop.org] On 
Behalf Of Andrei Borzenkov

 Even in this case behavior is wrong. Currently stopping listener does
 not affect existing database connections. Killing all client processes
 on listener stop will be rather strong regression.

 How ssh does it? It is something similar - master service that need to
 spawn multiple independent children.

Observe...


[root@localhost bin]# systemctl start oracle-orcl.service

[root@localhost bin]# systemctl start oracle-listener.service

[root@localhost bin]# iptables -I INPUT -p tcp --dport 1521 --syn -j ACCEPT




C:\ver

Microsoft Windows [Version 6.1.7601]

C:\sqlplus 
system@(description=(address=(protocol=tcp)(host=10.58.17.250)(port=1521))(connect_data=(sid=orcl)))

SQL*Plus: Release 10.2.0.3.0 - Production on Thu Oct 30 12:46:35 2014

Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.

Enter password:

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing 
options

SQL select * from dual;

D
-
X




[root@localhost bin]# ps -ef | grep LOCAL
oracle4292 1  0 12:46 ?00:00:00 oracleorcl (LOCAL=NO)
root  4304  2687  0 12:47 pts/100:00:00 grep --color=auto LOCAL

[root@localhost bin]# systemctl stop oracle-listener.service

[root@localhost bin]# ps -ef | grep LOCAL
root  4321  2687  0 12:47 pts/100:00:00 grep --color=auto LOCAL




SQL select * from dual;
select * from dual
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel




It would be more sensible if the tnslsnr caused [one of] the oracle background 
process to fork off a client connection, so the cgroup is correct. This is not 
the case.

I don't think Oracle supports anything running systemd as yet. I can see why. 
It's a disaster if incorrectly used.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] starting Oracle with systemd

2014-10-30 Thread Lennart Poettering
On Thu, 30.10.14 13:29, Fisher, Charles J. (Top Echelon) 
(charles.fis...@alcoa.com) wrote:

 This looks quite suspicious as you spawn a shell and keep it
 running. It's fine to run shells and then finally exec the real
 binary, replacing the shell process, but keeping the shell around
 would tell systemd that the shell was the actual daemon process.
 
 It doesn't work like that. The ksh dies when sqlplus exits, after it forks 
 the instance background processes.
 
 These are the binaries of interest:
 
 -bash-4.2$ ls -l $ORACLE_HOME/bin/sqlplus $ORACLE_HOME/bin/oracle 
 $ORACLE_HOME/bin/tnslsnr
 -rwsr-s--x. 1 oracle dba 323649834 Aug 13 10:47 
 /home/oracle/Ora12c/db/bin/oracle
 -rwxr-x--x. 1 oracle dba 10525 Aug 13 10:46 
 /home/oracle/Ora12c/db/bin/sqlplus
 -rwxr-x--x. 1 oracle dba866455 Aug 13 10:46 
 /home/oracle/Ora12c/db/bin/tnslsnr
 
 The real problem is the tnslsnr. It can service multiple
 instances. If I run those instances in separate cgroups, and the
 listener can only be a member of one cgroup, then the listener's
 children die if the listener process is disturbed. This means all DB
 sessions are cut when the listener is stopped.

If you run those instances in separate cgroups? what's that supposed
to mean? We do not expose cgroups as concept in systemd. Are you
accessing cgroupfs directly?

 It looks like systemd will force separate listeners for all Oracle
 instances, and the usual port number (1521) can't multiplex them
 (unless a single cgroup is used).

I have no idea how Oracle works, and the above it too cryptic to fully
understand what point you are trying to make. Can you eloborate on
this for somebody who doesn't know a thing about Oracle? And please
don't paste tons of Oracle outputs here, they don't help, they make
everything more cryptic and unintelligible...

Lennart

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


[systemd-devel] [PATCH] sd-dhcp-client: clean up raw socket sd_event_source when creating new UDP socket

2014-10-30 Thread Dan Williams
The raw socket sd_event_source used for DHCP server solicitations
was simply dropped on the floor when creating the new UDP socket
after a lease has been acquired.  Clean it up properly so we're
not still listening and responding to events on it.

---
 src/libsystemd-network/sd-dhcp-client.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/libsystemd-network/sd-dhcp-client.c 
b/src/libsystemd-network/sd-dhcp-client.c
index dc9b2c2..5472082 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -1310,6 +1310,9 @@ static int client_handle_message(sd_dhcp_client *client, 
DHCPMessage *message,
 if (r = 0) {
 client-timeout_resend =
 sd_event_source_unref(client-timeout_resend);
+client-receive_message =
+sd_event_source_unref(client-receive_message);
+client-fd = asynchronous_close(client-fd);
 
 if (IN_SET(client-state, DHCP_STATE_REQUESTING,
DHCP_STATE_REBOOTING))
-- 
1.9.3


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] starting Oracle with systemd

2014-10-30 Thread Fisher, Charles J. (Top Echelon)
-Original Message-
From: Lennart Poettering [mailto:lenn...@poettering.net] 

 If you run those instances in separate cgroups? what's that supposed
 to mean? We do not expose cgroups as concept in systemd. Are you
 accessing cgroupfs directly?

 I have no idea how Oracle works, and the above it too cryptic to fully
 understand what point you are trying to make. Can you eloborate on
 this for somebody who doesn't know a thing about Oracle? And please
 don't paste tons of Oracle outputs here, they don't help, they make
 everything more cryptic and unintelligible...

...and I am rather weak on all the new systemd concepts. No, whatever cgroupfs 
is, I'm not using it. I think.

Summary: systemd kills Oracle sessions, with severe prejudice, when a listener 
and instance(s) are started as separate services.

This appears to be the key:

--
[root@localhost system]# psc | grep lsnr
8619 oracle   1:name=systemd:/system.slic /home/oracle/Ora12c/db/bin/tnslsnr 
LISTENER -inherit

[root@localhost system]# ps xawf -eo args,cgroup | tail
...
ora_q002_orcl   1:name=systemd:/system.slice/oracle-orcl.service
ora_q003_orcl   1:name=systemd:/system.slice/oracle-orcl.service
oracleorcl (LOCAL=NO)   1:name=systemd:/system.slice/oracle-listener.service
ora_j000_orcl   1:name=systemd:/system.slice/oracle-orcl.service
ora_j001_orcl   1:name=systemd:/system.slice/oracle-orcl.service
--

For the instance ORCL, the remote connections (LOCAL=NO) have the cgroup 
column above from the **LISTENER** (which is not associated with a specific 
instance), not from the background processes of the target instance in question.

When I stop the listener, systemd kills *all* of the LOCAL=NO processes, for 
all instances.

It is common for a single listener to spawn connections for multiple 
installations, versions, and instances. THEY ALL DIE when systemd goes on a 
listener stop rampage.

If/when I install a new version of Oracle and configure the latest listener to 
serve all my past installed instances, I will have a machine outage in moving 
the listener, rather than a short period where new connections are rejected 
(while existing sessions are unmolested).

This is not the fault of systemd. The tnslsnr process above is forking, not a 
background process. There is no reasonable way for system software to track 
this.

I hope Oracle fixes this with the next release.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] 'systemctl poweroff' no longer shuts down system -- instead, reboots ?

2014-10-30 Thread grantksupport
exec of

  systemctl poweroff

causes, as reported, a reboot/restart

but, exec of

  systemctl --force poweroff

otoh, does shut down the machine, though not gracefully
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] starting Oracle with systemd

2014-10-30 Thread Andrei Borzenkov
В Thu, 30 Oct 2014 20:06:55 +0100
Lennart Poettering lenn...@poettering.net пишет:


 
 I have no idea how Oracle works, and the above it too cryptic to fully
 understand what point you are trying to make. Can you eloborate on
 this for somebody who doesn't know a thing about Oracle? 

Oracle database server consists of two parts - set of backend processes
(database server) and network listener. Client connects to listener
which spawns process that performs database processing for this client.
Each client connection creates new process. Once client process is
started, listener no more is involved in further processing. This is
similar to socket activation used by systemd.

Listener can be configured to spawn client processes for multiple
databases. There is well known TCP port for client connection.

Conceptually listener is independent of database server. It is still
possible to connect locally when you are on the same host even if
listener is not running.

So the problem right now is, if listener is configured as separate
service all client processes belong to the same service and are stopped
if listener is stopped. 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] starting Oracle with systemd

2014-10-30 Thread Andrew Barnes
On 31 Oct, 2014 6:35 AM, Andrei Borzenkov arvidj...@gmail.com wrote:

 В Thu, 30 Oct 2014 20:06:55 +0100
 Lennart Poettering lenn...@poettering.net пишет:


 
  I have no idea how Oracle works, and the above it too cryptic to fully
  understand what point you are trying to make. Can you eloborate on
  this for somebody who doesn't know a thing about Oracle?

 Oracle database server consists of two parts - set of backend processes
 (database server) and network listener. Client connects to listener
 which spawns process that performs database processing for this client.
 Each client connection creates new process. Once client process is
 started, listener no more is involved in further processing. This is
 similar to socket activation used by systemd.

 Listener can be configured to spawn client processes for multiple
 databases. There is well known TCP port for client connection.

 Conceptually listener is independent of database server. It is still
 possible to connect locally when you are on the same host even if
 listener is not running.

 So the problem right now is, if listener is configured as separate
 service all client processes belong to the same service and are stopped
 if listener is stopped.


How about:

http://www.freedesktop.org/software/systemd/man/systemd.kill.html

Would setting KillMode=process for the listener service have the required
effect: on service stop, only kill the main process, leaving the child
processes and cgroup running?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/4] shared: add missing includes

2014-10-30 Thread Ronny Chevalier
---
 src/shared/copy.h| 3 +++
 src/shared/locale-util.h | 4 
 2 files changed, 7 insertions(+)

diff --git a/src/shared/copy.h b/src/shared/copy.h
index 0bf2598..6b93107 100644
--- a/src/shared/copy.h
+++ b/src/shared/copy.h
@@ -21,6 +21,9 @@
   along with systemd; If not, see http://www.gnu.org/licenses/.
 ***/
 
+#include stdbool.h
+#include sys/types.h
+
 int copy_file(const char *from, const char *to, int flags, mode_t mode);
 int copy_tree(const char *from, const char *to, bool merge);
 int copy_bytes(int fdf, int fdt, off_t max_bytes);
diff --git a/src/shared/locale-util.h b/src/shared/locale-util.h
index d7a3e4f..e48aa3d 100644
--- a/src/shared/locale-util.h
+++ b/src/shared/locale-util.h
@@ -21,6 +21,10 @@
   along with systemd; If not, see http://www.gnu.org/licenses/.
 ***/
 
+#include stdbool.h
+
+#include macro.h
+
 typedef enum LocaleVariable {
 /* We don't list LC_ALL here on purpose. People should be
  * using LANG instead. */
-- 
2.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 3/4] tests: add missing entry for LocalVariable to test-tables

2014-10-30 Thread Ronny Chevalier
---
 src/test/test-tables.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/test/test-tables.c b/src/test/test-tables.c
index 907958e..2138442 100644
--- a/src/test/test-tables.c
+++ b/src/test/test-tables.c
@@ -48,6 +48,7 @@
 #include link-config.h
 #include bus-policy.h
 #include journald-server.h
+#include locale-util.h
 
 #include test-tables.h
 
@@ -116,6 +117,7 @@ int main(int argc, char **argv) {
 test_table(unit_file_state, UNIT_FILE_STATE);
 test_table(unit_load_state, UNIT_LOAD_STATE);
 test_table(unit_type, UNIT_TYPE);
+test_table(locale_variable, VARIABLE_LC);
 
 test_table_sparse(object_compressed, OBJECT_COMPRESSED);
 
-- 
2.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 2/4] tests: add test-locale-util

2014-10-30 Thread Ronny Chevalier
---
 .gitignore  |  1 +
 Makefile.am |  9 ++-
 src/test/test-locale-util.c | 59 +
 3 files changed, 68 insertions(+), 1 deletion(-)
 create mode 100644 src/test/test-locale-util.c

diff --git a/.gitignore b/.gitignore
index 14f1691..7d5f04d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -198,6 +198,7 @@
 /test-libudev
 /test-libudev-sym*
 /test-list
+/test-locale-util
 /test-log
 /test-login
 /test-login-shared
diff --git a/Makefile.am b/Makefile.am
index 3b273d4..552f41a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1358,7 +1358,8 @@ tests += \
test-ratelimit \
test-condition-util \
test-uid-range \
-   test-bus-policy
+   test-bus-policy \
+   test-locale-util
 
 EXTRA_DIST += \
test/a.service \
@@ -1502,6 +1503,12 @@ test_async_SOURCES = \
 test_async_LDADD = \
libsystemd-shared.la
 
+test_locale_util_SOURCES = \
+   src/test/test-locale-util.c
+
+test_locale_util_LDADD = \
+   libsystemd-shared.la
+
 test_condition_util_SOURCES = \
src/test/test-condition-util.c
 
diff --git a/src/test/test-locale-util.c b/src/test/test-locale-util.c
new file mode 100644
index 000..1398a3a
--- /dev/null
+++ b/src/test/test-locale-util.c
@@ -0,0 +1,59 @@
+/***
+  This file is part of systemd
+
+  Copyright 2014 Ronny Chevalier
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see http://www.gnu.org/licenses/.
+***/
+
+#include unistd.h
+
+#include locale-util.h
+#include strv.h
+#include macro.h
+
+static void test_get_locales(void) {
+_cleanup_strv_free_ char **locales = NULL;
+char **p;
+int r;
+
+r = get_locales(locales);
+assert_se(r = 0);
+assert_se(locales);
+
+STRV_FOREACH(p, locales) {
+puts(*p);
+assert_se(locale_is_valid(*p));
+}
+}
+
+static void test_locale_is_valid(void) {
+assert_se(locale_is_valid(en_EN.utf8));
+assert_se(locale_is_valid(fr_FR.utf8));
+assert_se(locale_is_valid(fr_FR@euro));
+assert_se(locale_is_valid(fi_FI));
+assert_se(locale_is_valid(POSIX));
+assert_se(locale_is_valid(C));
+
+assert_se(!locale_is_valid());
+assert_se(!locale_is_valid(/usr/bin/foo));
+assert_se(!locale_is_valid(\x01gar\x02 bage\x03));
+}
+
+int main(int argc, char *argv[]) {
+test_get_locales();
+test_locale_is_valid();
+
+return 0;
+}
-- 
2.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 4/4] tests: add test-copy

2014-10-30 Thread Ronny Chevalier
---
 .gitignore   |   1 +
 Makefile.am  |   9 +++-
 src/test/test-copy.c | 115 +++
 3 files changed, 124 insertions(+), 1 deletion(-)
 create mode 100644 src/test/test-copy.c

diff --git a/.gitignore b/.gitignore
index 7d5f04d..23522ed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -159,6 +159,7 @@
 /test-compress-benchmark
 /test-condition-util
 /test-conf-files
+/test-copy
 /test-coredump-vacuum
 /test-daemon
 /test-date
diff --git a/Makefile.am b/Makefile.am
index 552f41a..8cb369f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1359,7 +1359,8 @@ tests += \
test-condition-util \
test-uid-range \
test-bus-policy \
-   test-locale-util
+   test-locale-util \
+   test-copy
 
 EXTRA_DIST += \
test/a.service \
@@ -1509,6 +1510,12 @@ test_locale_util_SOURCES = \
 test_locale_util_LDADD = \
libsystemd-shared.la
 
+test_copy_SOURCES = \
+   src/test/test-copy.c
+
+test_copy_LDADD = \
+   libsystemd-shared.la
+
 test_condition_util_SOURCES = \
src/test/test-condition-util.c
 
diff --git a/src/test/test-copy.c b/src/test/test-copy.c
new file mode 100644
index 000..6aa86a0
--- /dev/null
+++ b/src/test/test-copy.c
@@ -0,0 +1,115 @@
+/***
+  This file is part of systemd
+
+  Copyright 2014 Ronny Chevalier
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see http://www.gnu.org/licenses/.
+***/
+
+#include unistd.h
+
+#include copy.h
+#include path-util.h
+#include fileio.h
+#include mkdir.h
+#include strv.h
+#include macro.h
+#include util.h
+
+static void test_copy_file(void) {
+_cleanup_free_ char *buf = NULL;
+char fn[] = /tmp/test-copy_file.XX;
+char fn_copy[] = /tmp/test-copy_file.XX;
+size_t sz = 0;
+int fd;
+
+fd = mkostemp_safe(fn, O_RDWR|O_CLOEXEC);
+assert_se(fd = 0);
+close(fd);
+
+fd = mkostemp_safe(fn_copy, O_RDWR|O_CLOEXEC);
+assert_se(fd = 0);
+close(fd);
+
+assert_se(write_string_file(fn, foo bar bar bar foo) == 0);
+
+assert_se(copy_file(fn, fn_copy, 0, 0644) == 0);
+
+assert_se(read_full_file(fn_copy, buf, sz) == 0);
+assert_se(streq(buf, foo bar bar bar foo\n));
+
+unlink(fn);
+unlink(fn_copy);
+}
+
+static void test_copy_tree(void) {
+char original_dir[] = /tmp/test-copy_tree/;
+char copy_dir[] = /tmp/test-copy_tree-copy/;
+char **files = STRV_MAKE(file, dir1/file, dir1/dir2/file, 
dir1/dir2/dir3/dir4/dir5/file);
+char **links = STRV_MAKE(link, file,
+ link2, dir1/file);
+char **p, **link;
+
+rm_rf_dangerous(copy_dir, false, true, false);
+rm_rf_dangerous(original_dir, false, true, false);
+
+STRV_FOREACH(p, files) {
+char *f = strappenda(original_dir, *p);
+
+assert_se(mkdir_parents(f, 0755) = 0);
+assert_se(write_string_file(f, file) == 0);
+}
+
+STRV_FOREACH_PAIR(link, p, links) {
+char *f = strappenda(original_dir, *p);
+char *l = strappenda(original_dir, *link);
+
+assert_se(mkdir_parents(l, 0755) = 0);
+assert_se(symlink(f, l) == 0);
+}
+
+assert_se(copy_tree(original_dir, copy_dir, true) == 0);
+
+STRV_FOREACH(p, files) {
+_cleanup_free_ char *buf = NULL;
+size_t sz = 0;
+char *f = strappenda(copy_dir, *p);
+
+assert_se(access(f, F_OK) == 0);
+assert_se(read_full_file(f, buf, sz) == 0);
+assert_se(streq(buf, file\n));
+}
+
+STRV_FOREACH_PAIR(link, p, links) {
+_cleanup_free_ char *target = NULL;
+char *f = strappenda(original_dir, *p);
+char *l = strappenda(copy_dir, *link);
+
+assert_se(readlink_and_canonicalize(l, target) == 0);
+assert_se(path_equal(f, target));
+}
+
+assert_se(copy_tree(original_dir, copy_dir, false)  0);
+assert_se(copy_tree(/tmp/inexistent/foo/bar/fsdoi, copy_dir, false) 
 0);
+
+rm_rf_dangerous(copy_dir, false, true, false);
+rm_rf_dangerous(original_dir, false, true, false);
+}
+
+int main(int argc, char *argv[]) {
+test_copy_file();
+test_copy_tree();

[systemd-devel] [PATCH] shared: fix typo

2014-10-30 Thread Ronny Chevalier
---
 src/shared/capability.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/shared/capability.c b/src/shared/capability.c
index d2b9013..0226542 100644
--- a/src/shared/capability.c
+++ b/src/shared/capability.c
@@ -228,7 +228,7 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t 
keep_capabilities) {
  * which we want to avoid. */
 
 if (setresgid(gid, gid, gid)  0) {
-log_error(Failed change group ID: %m);
+log_error(Failed to change group ID: %m);
 return -errno;
 }
 
@@ -244,7 +244,7 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t 
keep_capabilities) {
 
 r = setresuid(uid, uid, uid);
 if (r  0) {
-log_error(Failed change user ID: %m);
+log_error(Failed to change user ID: %m);
 return -errno;
 }
 
-- 
2.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] tests: add tests for strv.c

2014-10-30 Thread Ronny Chevalier
add tests for:
- strv_find_startswith
- strv_push_prepend
- strv_consume_prepend
---
 src/test/test-strv.c | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index bbfe306..915fa46 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -113,6 +113,22 @@ static void test_strv_find_prefix(void) {
 assert_se(!strv_find_prefix((char **)input_table_multiple, onee));
 }
 
+static void test_strv_find_startswith(void) {
+char *r;
+
+r = strv_find_startswith((char **)input_table_multiple, o);
+assert_se(r  streq(r, ne));
+
+r = strv_find_startswith((char **)input_table_multiple, one);
+assert_se(r  streq(r, ));
+
+r = strv_find_startswith((char **)input_table_multiple, );
+assert_se(r  streq(r, one));
+
+assert_se(!strv_find_startswith((char **)input_table_multiple, xxx));
+assert_se(!strv_find_startswith((char **)input_table_multiple, 
onee));
+}
+
 static void test_strv_join(void) {
 _cleanup_free_ char *p = NULL, *q = NULL, *r = NULL, *s = NULL, *t = 
NULL;
 
@@ -416,6 +432,27 @@ static void test_strv_from_stdarg_alloca(void) {
 test_strv_from_stdarg_alloca_one(STRV_MAKE_EMPTY, NULL);
 }
 
+static void test_strv_push_prepend(void) {
+_cleanup_strv_free_ char **a = NULL;
+
+a = strv_new(foo, bar, three, NULL);
+
+assert_se(strv_push_prepend(a, strdup(first)) = 0);
+assert_se(streq(a[0], first));
+assert_se(streq(a[1], foo));
+assert_se(streq(a[2], bar));
+assert_se(streq(a[3], three));
+assert_se(!a[4]);
+
+assert_se(strv_consume_prepend(a, strdup(first2)) = 0);
+assert_se(streq(a[0], first2));
+assert_se(streq(a[1], first));
+assert_se(streq(a[2], foo));
+assert_se(streq(a[3], bar));
+assert_se(streq(a[4], three));
+assert_se(!a[5]);
+}
+
 int main(int argc, char *argv[]) {
 test_specifier_printf();
 test_strv_foreach();
@@ -423,6 +460,7 @@ int main(int argc, char *argv[]) {
 test_strv_foreach_pair();
 test_strv_find();
 test_strv_find_prefix();
+test_strv_find_startswith();
 test_strv_join();
 
 test_strv_quote_unquote(input_table_multiple, \one\ \two\ 
\three\);
@@ -462,6 +500,7 @@ int main(int argc, char *argv[]) {
 test_strv_extend();
 test_strv_extendf();
 test_strv_from_stdarg_alloca();
+test_strv_push_prepend();
 
 return 0;
 }
-- 
2.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] tests: add tests for fileio.c

2014-10-30 Thread Ronny Chevalier
add tests for the following functions:
- write_string_file_no_create
- load_env_file_pairs
---
 src/test/test-fileio.c | 63 ++
 1 file changed, 63 insertions(+)

diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
index 7e7b4ac..a713abd 100644
--- a/src/test/test-fileio.c
+++ b/src/test/test-fileio.c
@@ -331,6 +331,23 @@ static void test_write_string_file(void) {
 unlink(fn);
 }
 
+static void test_write_string_file_no_create(void) {
+char fn[] = /tmp/test-write_string_file_no_create-XX;
+_cleanup_close_ int fd;
+char buf[64] = {0};
+
+fd = mkostemp_safe(fn, O_RDWR);
+assert_se(fd = 0);
+
+
assert_se(write_string_file_no_create(/a/file/which/does/not/exists/i/guess, 
boohoo)  0);
+assert_se(write_string_file_no_create(fn, boohoo) == 0);
+
+assert_se(read(fd, buf, sizeof(buf)));
+assert_se(streq(buf, boohoo\n));
+
+unlink(fn);
+}
+
 static void test_sendfile_full(void) {
 char in_fn[] = /tmp/test-sendfile_full-XX;
 char out_fn[] = /tmp/test-sendfile_full-XX;
@@ -355,6 +372,50 @@ static void test_sendfile_full(void) {
 unlink(out_fn);
 }
 
+static void test_load_env_file_pairs(void) {
+char fn[] = /tmp/test-load_env_file_pairs-XX;
+int fd;
+int r;
+_cleanup_fclose_ FILE *f = NULL;
+_cleanup_strv_free_ char **l = NULL;
+char **k, **v;
+
+fd = mkostemp_safe(fn, O_RDWR);
+assert_se(fd = 0);
+
+r = write_string_file(fn,
+NAME=\Arch Linux\\n
+ID=arch\n
+PRETTY_NAME=\Arch Linux\\n
+ANSI_COLOR=\0;36\\n
+HOME_URL=\https://www.archlinux.org/\\n;
+SUPPORT_URL=\https://bbs.archlinux.org/\\n;
+BUG_REPORT_URL=\https://bugs.archlinux.org/\\n;
+);
+assert_se(r == 0);
+
+f = fdopen(fd, r);
+assert_se(f);
+
+r = load_env_file_pairs(f, fn, NULL, l);
+assert_se(r = 0);
+
+assert_se(strv_length(l) == 14);
+STRV_FOREACH_PAIR(k, v, l) {
+assert_se(STR_IN_SET(*k, NAME, ID, PRETTY_NAME, 
ANSI_COLOR, HOME_URL, SUPPORT_URL, BUG_REPORT_URL));
+printf(%s=%s\n, *k, *v);
+if (streq(*k, NAME)) assert_se(streq(*v, Arch Linux));
+if (streq(*k, ID)) assert_se(streq(*v, arch));
+if (streq(*k, PRETTY_NAME)) assert_se(streq(*v, Arch 
Linux));
+if (streq(*k, ANSI_COLOR)) assert_se(streq(*v, 0;36));
+if (streq(*k, HOME_URL)) assert_se(streq(*v, 
https://www.archlinux.org/;));
+if (streq(*k, SUPPORT_URL)) assert_se(streq(*v, 
https://bbs.archlinux.org/;));
+if (streq(*k, BUG_REPORT_URL)) assert_se(streq(*v, 
https://bugs.archlinux.org/;));
+}
+
+unlink(fn);
+}
+
 int main(int argc, char *argv[]) {
 log_parse_environment();
 log_open();
@@ -366,7 +427,9 @@ int main(int argc, char *argv[]) {
 test_capeff();
 test_write_string_stream();
 test_write_string_file();
+test_write_string_file_no_create();
 test_sendfile_full();
+test_load_env_file_pairs();
 
 return 0;
 }
-- 
2.1.3

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] remote-fs ordering, iSCSI and _netdev

2014-10-30 Thread Chris Leech
On Thu, Oct 30, 2014 at 12:10:16PM +0100, Karel Zak wrote:
 On Tue, Oct 28, 2014 at 02:29:35AM +0100, Lennart Poettering wrote:
  On Mon, 27.10.14 14:10, Chris Leech (cle...@redhat.com) wrote:
  
   So for any mounts to remote block devices (unlike remote file system
   protocols which are detected by the fs name), unless there is an fstab
   entry at the time fstab-generator is run they get treated like local fs
   mounts and connectivity to the storage target may be disrupted before
   unmounting (possibly resulting in file system errors).
   
   I'm currently at a loss for how to handle this, other than to claim that
   if filesystems are going to be left mounted they should be added to
   fstab and a daemon-reload is required.
  
  IIRC mount nowadays stores the full mount option string, including all
  the userspace-only options in /run. We could either read those
  directly from there in systemd, or we could make systemd make use of
  libmount to get that information.
  
 _netdev is information about device rather than about filesystem.
 Would be possible to have this info (this is iSCSI) in udev db? 

Yes, the _netdev option is ugly.  For iSCSI specifically, we'd have to
trace the block device back to the scsi_host, then match that up with an
iscsi_host from the transport class.  Or come up with some change to
make that process easier.  And it would need to work for dm/md device
over the actually scsi device.
 
 You know, all userpsace mount options suck, it's always fragile to
 maintain mount options in userspace (due to namespaces, ...)
 
  Karel, what are the details there? Would it be OK if we read the files
  in /run directly to augment whatever we got from /proc/self/mountinfo?
 
 I'd like to keep /run/mount/utab as private libmount file. It would be
 better to use mnt_table_parse_mtab() libmount function to get parsed
 mountinfo + userspace mount options.
 
 IMHO you can implement it as optional feature #ifdef HAVE_LIBMOUNT to
 optionally use mnt_table_parse_mtab() from libmount rather than directly
 parse /proc/self/mountinfo.

Thanks for the direction, I've worked up a patch that does this and
using libmount here was pretty easy.

Unfortunatly with systemd triggering off of the change event from
/proc/self/mountinfo, it ends up racing with the mount command to access
/run/mount/utab and the _netdev option I'm looking for isn't
consistantly picked up.  I'll see what else I can come up with.

- Chris
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] sd-dhcp-client: clean up raw socket sd_event_source when creating new UDP socket

2014-10-30 Thread Tom Gundersen
On Thu, Oct 30, 2014 at 11:03 PM, Dave Reisner d...@falconindy.com wrote:
 On Thu, Oct 30, 2014 at 09:39:40PM +0100, Tom Gundersen wrote:
 Applied. Thanks!


 Does this address:

 https://bugs.freedesktop.org/show_bug.cgi?id=84661

 ??

Yes, it should, closed bug now.

Cheers,

Tom
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] remote-fs ordering, iSCSI and _netdev

2014-10-30 Thread Chris Leech
On Tue, Oct 28, 2014 at 06:41:32AM +0300, Andrei Borzenkov wrote:
 В Mon, 27 Oct 2014 14:10:47 -0700
 Chris Leech cle...@redhat.com пишет:
  
  But there are two cases that are problematic, adding entries to fstab at
  runtime and manually mounting without adding to fstab (while still using
  the _netdev option, some hint is needed).  The first case actually ends
  up being the second, with the possible work-around of always remembering
  to run a daemon-reload after editing fstab to run fstab-generator again.
 
 
 Even known network filesystems still have a problem. If network
 filesystem is mounted on boot, it pulls in network-online.target which
 (hopefully) serves as synchronization point on shutdown. If there is no
 network filesystem to mount at boot, network-online.target is not
 started. If you mount NFS manually later there is nothing to wait for
 on shutdown so network could be teared down before filesystem is
 unmounted.

Hmm, I hadn't noticed that with iSCSI because a service gets started to
connect to the target so the dependencies can be taken care of there.

Should the remote mount unit be generating a Wants dependency along with
the Before/After to ensure the synchronization point targets are active?
Or would that not work for some reason?

- Chris
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] remote-fs ordering, iSCSI and _netdev

2014-10-30 Thread Chris Leech
On Tue, Oct 28, 2014 at 01:57:06AM +0100, Zbigniew Jędrzejewski-Szmek wrote:
 On Mon, Oct 27, 2014 at 02:10:47PM -0700, Chris Leech wrote:
  ...
  If there's no matching mount unit from fstab-generator, one gets created
  dynamically when the fs is mounted by monitoring /proc/self/mountinfo.
 Actually, it is more correct to say that a unit *always* get created based
 on /proc/self/mountinfo. If there was a unit previously, it is replaced
 by the new one, but inherits the dependencies. In effect it leads to
 the behaviour you described.

Thanks for making that clear.

  So for any mounts to remote block devices (unlike remote file system
  protocols which are detected by the fs name), unless there is an fstab
  entry at the time fstab-generator is run they get treated like local fs
  mounts and connectivity to the storage target may be disrupted before
  unmounting (possibly resulting in file system errors).
 Yes, that seems right. It seems reasonable to change the code which
 generates units based on /p/s/mounintinfo to behave as if _netdev option
 was specified, for the known network filesystem types.

That's in place and (I'm haven't been testing it but I think) working.
The problem is with network block devices where the fstype is the
on-disk filesystem.

- Chris
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH v3] Bootchart: use /proc/pid/mountinfo for root bdev

2014-10-30 Thread Zbigniew Jędrzejewski-Szmek
On Thu, Oct 30, 2014 at 05:45:53PM +0300, Timofey Titovets wrote:
 Good time of day, list.
 I have try to fix Fixme in svg.c:
 /* FIXME: this works only in the simple case */
 
 By default function try to get only root=/dev/*
 I also attach patch. Thanks.
 
 v2:
   Rewrited with use fstab_node_to_udev_node() and
 canonicalize_file_name() functions.
 v3:
   Rewrited for parsing /proc/self/mountinfo
 
 Please test it, i'm can't test because i not have /proc/schedstat
 file (custom kernel)
 
 I use  0  for searching root device its correct?
 For test:
 [$]: grep  0  /proc/self/mountinfo
No:

13 1 179:53 / / rw,noatime shared:1 - ext4 /dev/root rw,data=ordered

Why not check field 5 for /?

 I'm not use major:minor because on some setups it useless.
 As example, my system root:
 50 0 0:28 /@ / rw,relatime shared:1 - btrfs /dev/sda3
 rw,compress=zlib,space_cache,autodefrag ^
True, but you have the device name in there too   |

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] shared/install: avoid prematurely rejecting missing units

2014-10-30 Thread Dave Reisner
f7101b7368df copied some logic to prevent enabling masked units, but
also added a check which causes attempts to enable templated units to
fail. Since we know the logic beyond this check will properly handle
units which truly do not exist, we can rely on the unit file state
comparison to suffice for expressing the intent of f7101b7368df.

ref: https://bugs.archlinux.org/task/42616
---
This seems to me like the right thing to do, but I'm not so familiar with
this code...

 src/shared/install.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/src/shared/install.c b/src/shared/install.c
index 035b44c..3ad5362 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -1621,11 +1621,6 @@ int unit_file_enable(
 UnitFileState state;
 
 state = unit_file_get_state(scope, root_dir, *i);
-if (state  0) {
-log_error(Failed to get unit file state for %s: %s, 
*i, strerror(-state));
-return state;
-}
-
 if (state == UNIT_FILE_MASKED || state == 
UNIT_FILE_MASKED_RUNTIME) {
 log_error(Failed to enable unit: Unit %s is masked, 
*i);
 return -ENOTSUP;
-- 
2.1.3
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] sd-dhcp-client: clean up raw socket sd_event_source when creating new UDP socket

2014-10-30 Thread Dave Reisner
On Thu, Oct 30, 2014 at 09:39:40PM +0100, Tom Gundersen wrote:
 Applied. Thanks!
 

But not pushed?

 On Thu, Oct 30, 2014 at 8:23 PM, Dan Williams d...@redhat.com wrote:
  The raw socket sd_event_source used for DHCP server solicitations
  was simply dropped on the floor when creating the new UDP socket
  after a lease has been acquired.  Clean it up properly so we're
  not still listening and responding to events on it.
 
  ---
  ...
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] remote-fs ordering, iSCSI and _netdev

2014-10-30 Thread Zbigniew Jędrzejewski-Szmek
On Thu, Oct 30, 2014 at 03:09:25PM -0700, Chris Leech wrote:
 On Tue, Oct 28, 2014 at 01:57:06AM +0100, Zbigniew Jędrzejewski-Szmek wrote:
  On Mon, Oct 27, 2014 at 02:10:47PM -0700, Chris Leech wrote:
   ...
   If there's no matching mount unit from fstab-generator, one gets created
   dynamically when the fs is mounted by monitoring /proc/self/mountinfo.
  Actually, it is more correct to say that a unit *always* get created based
  on /proc/self/mountinfo. If there was a unit previously, it is replaced
  by the new one, but inherits the dependencies. In effect it leads to
  the behaviour you described.
 
 Thanks for making that clear.
 
   So for any mounts to remote block devices (unlike remote file system
   protocols which are detected by the fs name), unless there is an fstab
   entry at the time fstab-generator is run they get treated like local fs
   mounts and connectivity to the storage target may be disrupted before
   unmounting (possibly resulting in file system errors).
  Yes, that seems right. It seems reasonable to change the code which
  generates units based on /p/s/mounintinfo to behave as if _netdev option
  was specified, for the known network filesystem types.
 
 That's in place and (I'm haven't been testing it but I think) working.
 The problem is with network block devices where the fstype is the
 on-disk filesystem.
Sorry, I don't know too much about iscsi. Is it easy to tell that the
device requires network to function? Some udev tag or property that could
be easily queried?

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] shared/install: avoid prematurely rejecting missing units

2014-10-30 Thread Zbigniew Jędrzejewski-Szmek
On Thu, Oct 30, 2014 at 08:28:14PM -0400, Dave Reisner wrote:
 f7101b7368df copied some logic to prevent enabling masked units, but
 also added a check which causes attempts to enable templated units to
 fail. Since we know the logic beyond this check will properly handle
 units which truly do not exist, we can rely on the unit file state
 comparison to suffice for expressing the intent of f7101b7368df.
 
 ref: https://bugs.archlinux.org/task/42616
 ---
 This seems to me like the right thing to do, but I'm not so familiar with
 this code...

I verified that your fix works. Can you add a comment in the code which
explains why state is not checked though? It should help with future
modifications.

Zbyszek

 
  src/shared/install.c | 5 -
  1 file changed, 5 deletions(-)
 
 diff --git a/src/shared/install.c b/src/shared/install.c
 index 035b44c..3ad5362 100644
 --- a/src/shared/install.c
 +++ b/src/shared/install.c
 @@ -1621,11 +1621,6 @@ int unit_file_enable(
  UnitFileState state;
  
  state = unit_file_get_state(scope, root_dir, *i);
 -if (state  0) {
 -log_error(Failed to get unit file state for %s: 
 %s, *i, strerror(-state));
 -return state;
 -}
 -
  if (state == UNIT_FILE_MASKED || state == 
 UNIT_FILE_MASKED_RUNTIME) {
  log_error(Failed to enable unit: Unit %s is 
 masked, *i);
  return -ENOTSUP;
 -- 
 2.1.3
 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] starting Oracle with systemd

2014-10-30 Thread Andrei Borzenkov
В Fri, 31 Oct 2014 08:11:54 +1100
Andrew Barnes barnes...@gmail.com пишет:

 On 31 Oct, 2014 6:35 AM, Andrei Borzenkov arvidj...@gmail.com wrote:
 
  В Thu, 30 Oct 2014 20:06:55 +0100
  Lennart Poettering lenn...@poettering.net пишет:
 
 
  
   I have no idea how Oracle works, and the above it too cryptic to fully
   understand what point you are trying to make. Can you eloborate on
   this for somebody who doesn't know a thing about Oracle?
 
  Oracle database server consists of two parts - set of backend processes
  (database server) and network listener. Client connects to listener
  which spawns process that performs database processing for this client.
  Each client connection creates new process. Once client process is
  started, listener no more is involved in further processing. This is
  similar to socket activation used by systemd.
 
  Listener can be configured to spawn client processes for multiple
  databases. There is well known TCP port for client connection.
 
  Conceptually listener is independent of database server. It is still
  possible to connect locally when you are on the same host even if
  listener is not running.
 
  So the problem right now is, if listener is configured as separate
  service all client processes belong to the same service and are stopped
  if listener is stopped.
 
 
 How about:
 
 http://www.freedesktop.org/software/systemd/man/systemd.kill.html
 
 Would setting KillMode=process for the listener service have the required
 effect: on service stop, only kill the main process, leaving the child
 processes and cgroup running?

Yes, that probably will work around this problem. 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] remote-fs ordering, iSCSI and _netdev

2014-10-30 Thread Andrei Borzenkov
В Fri, 31 Oct 2014 01:53:26 +0100
Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl пишет:

 On Thu, Oct 30, 2014 at 03:09:25PM -0700, Chris Leech wrote:
  On Tue, Oct 28, 2014 at 01:57:06AM +0100, Zbigniew Jędrzejewski-Szmek wrote:
   On Mon, Oct 27, 2014 at 02:10:47PM -0700, Chris Leech wrote:
...
If there's no matching mount unit from fstab-generator, one gets created
dynamically when the fs is mounted by monitoring /proc/self/mountinfo.
   Actually, it is more correct to say that a unit *always* get created based
   on /proc/self/mountinfo. If there was a unit previously, it is replaced
   by the new one, but inherits the dependencies. In effect it leads to
   the behaviour you described.
  
  Thanks for making that clear.
  
So for any mounts to remote block devices (unlike remote file system
protocols which are detected by the fs name), unless there is an fstab
entry at the time fstab-generator is run they get treated like local fs
mounts and connectivity to the storage target may be disrupted before
unmounting (possibly resulting in file system errors).
   Yes, that seems right. It seems reasonable to change the code which
   generates units based on /p/s/mounintinfo to behave as if _netdev option
   was specified, for the known network filesystem types.
  
  That's in place and (I'm haven't been testing it but I think) working.
  The problem is with network block devices where the fstype is the
  on-disk filesystem.
 Sorry, I don't know too much about iscsi. Is it easy to tell that the
 device requires network to function? Some udev tag or property that could
 be easily queried?

It does not help in case of layered configuration (LVM on MD on iSCSI).
one would need to go all the way to find out if some of devices
involved may depend on network.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] remote-fs ordering, iSCSI and _netdev

2014-10-30 Thread Andrei Borzenkov
В Thu, 30 Oct 2014 15:15:03 -0700
Chris Leech cle...@redhat.com пишет:

 On Tue, Oct 28, 2014 at 06:41:32AM +0300, Andrei Borzenkov wrote:
  В Mon, 27 Oct 2014 14:10:47 -0700
  Chris Leech cle...@redhat.com пишет:
   
   But there are two cases that are problematic, adding entries to fstab at
   runtime and manually mounting without adding to fstab (while still using
   the _netdev option, some hint is needed).  The first case actually ends
   up being the second, with the possible work-around of always remembering
   to run a daemon-reload after editing fstab to run fstab-generator again.
  
  
  Even known network filesystems still have a problem. If network
  filesystem is mounted on boot, it pulls in network-online.target which
  (hopefully) serves as synchronization point on shutdown. If there is no
  network filesystem to mount at boot, network-online.target is not
  started. If you mount NFS manually later there is nothing to wait for
  on shutdown so network could be teared down before filesystem is
  unmounted.
 
 Hmm, I hadn't noticed that with iSCSI because a service gets started to
 connect to the target so the dependencies can be taken care of there.
 
 Should the remote mount unit be generating a Wants dependency along with
 the Before/After to ensure the synchronization point targets are active?
 Or would that not work for some reason?
 

Wants works only when unit is started but it does not happen here - you
manually do mount server:/path /mnt and while unit gets created
afterwards, there is no unit startup phase in systemd sense so Wants
does not kick in.

May be it could be extended similar to what happens with device -
device cannot be started as well, but systemd fakes startup when
device appears. We could do the same for mount units newly appeared.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH v3] Bootchart: use /proc/pid/mountinfo for root bdev

2014-10-30 Thread Timofey Titovets
2014-10-31 3:06 GMT+03:00 Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl:
 On Thu, Oct 30, 2014 at 05:45:53PM +0300, Timofey Titovets wrote:
 Good time of day, list.
 I have try to fix Fixme in svg.c:
 /* FIXME: this works only in the simple case */

 By default function try to get only root=/dev/*
 I also attach patch. Thanks.

 v2:
   Rewrited with use fstab_node_to_udev_node() and
 canonicalize_file_name() functions.
 v3:
   Rewrited for parsing /proc/self/mountinfo

 Please test it, i'm can't test because i not have /proc/schedstat
 file (custom kernel)

 I use  0  for searching root device its correct?
 For test:
 [$]: grep  0  /proc/self/mountinfo
 No:

 13 1 179:53 / / rw,noatime shared:1 - ext4 /dev/root rw,data=ordered

 Why not check field 5 for /?

To be honest - I don't know how write it prettily _
read file with fscanf like:
fscanf(fd, %s %s %s %s %s %s %s - %s %s %s\n, ...) //Looks ugly.

Then, perhaps can i search 'shared:1 '  entry ?

 I'm not use major:minor because on some setups it useless.
 As example, my system root:
 50 0 0:28 /@ / rw,relatime shared:1 - btrfs /dev/sda3
 rw,compress=zlib,space_cache,autodefrag ^
 True, but you have the device name in there too   |

 Zbyszek

Hm.. If you insinuate that i can use block device name from root
mount line, i already did it:
 +   ptr = strtok(ptr,  /dev/);
 +   strncpy(rootbdev, ptr[6], 3);

-- 
Have a nice day,
Timofey.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel