[systemd-devel] [PATCH 1/2] path_lookup: moved _cleanup_lookup_paths_free_ from install.c to path-lookup.h

2013-10-27 Thread Daniel Buch
---
 src/shared/install.c  | 1 -
 src/shared/path-lookup.h  | 2 ++
 src/systemctl/systemctl.c | 4 +---
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/shared/install.c b/src/shared/install.c
index 3bced1a..987b36d 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -44,7 +44,6 @@ typedef struct {
 Hashmap *have_installed;
 } InstallContext;
 
-#define _cleanup_lookup_paths_free_ _cleanup_(lookup_paths_free)
 #define _cleanup_install_context_done_ _cleanup_(install_context_done)
 
 static int lookup_paths_init_from_scope(LookupPaths *paths, UnitFileScope 
scope) {
diff --git a/src/shared/path-lookup.h b/src/shared/path-lookup.h
index 9dee85f..a3ef824 100644
--- a/src/shared/path-lookup.h
+++ b/src/shared/path-lookup.h
@@ -36,6 +36,8 @@ typedef enum SystemdRunningAs {
 _SYSTEMD_RUNNING_AS_INVALID = -1
 } SystemdRunningAs;
 
+#define _cleanup_lookup_paths_free_ _cleanup_(lookup_paths_free)
+
 const char* systemd_running_as_to_string(SystemdRunningAs i) _const_;
 SystemdRunningAs systemd_running_as_from_string(const char *s) _pure_;
 
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index d458c65..87a6985 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -4223,7 +4223,7 @@ static int enable_sysv_units(const char *verb, char 
**args) {
 
 #if defined(HAVE_SYSV_COMPAT) && defined(HAVE_CHKCONFIG)
 unsigned f = 1, t = 1;
-LookupPaths paths = {};
+_cleanup_lookup_paths_free_ LookupPaths paths = {};
 
 if (arg_scope != UNIT_FILE_SYSTEM)
 return 0;
@@ -4361,8 +4361,6 @@ static int enable_sysv_units(const char *verb, char 
**args) {
 }
 
 finish:
-lookup_paths_free(&paths);
-
 /* Drop all SysV units */
 for (f = 0, t = 0; args[f]; f++) {
 
-- 
1.8.4.1

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


[systemd-devel] [PATCH 2/2] test-strv.c: added STRV_FOREACH and STRV_FOREACH_BACKWARDS

2013-10-27 Thread Daniel Buch
---
 src/test/test-strv.c | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index c3d536d..de5cef0 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -282,6 +282,34 @@ static void test_strv_append(void) {
 assert_se(streq(c[0], "test3"));
 }
 
+static void test_strv_foreach(void) {
+   _cleanup_strv_free_ char **a;
+   unsigned i = 0;
+   char **check;
+
+   a = strv_new("one", "two", "three", NULL);
+
+   assert_se(a);
+
+   STRV_FOREACH(check, a) {
+   assert_se(streq(*check, input_table_multiple[i++]));
+   }
+}
+
+static void test_strv_foreach_backwards(void) {
+   _cleanup_strv_free_ char **a;
+   unsigned i = 2;
+   char **check;
+
+   a = strv_new("one", "two", "three", NULL);
+
+   assert_se(a);
+
+   STRV_FOREACH_BACKWARDS(check, a) {
+   assert_se(streq(*check, input_table_multiple[i--]));
+   }
+}
+
 static void test_strv_foreach_pair(void) {
 _cleanup_strv_free_ char **a = NULL;
 char **x, **y;
@@ -298,6 +326,8 @@ static void test_strv_foreach_pair(void) {
 
 int main(int argc, char *argv[]) {
 test_specifier_printf();
+test_strv_foreach();
+test_strv_foreach_backwards();
 test_strv_foreach_pair();
 test_strv_find();
 test_strv_find_prefix();
-- 
1.8.4.1

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


Re: [systemd-devel] [udev] Wrong PID used in netlink socket

2013-10-27 Thread Jan Engelhardt

On Thursday 2013-10-10 15:36, Kay Sievers wrote:
>
>Note, that the netlink *address* just happens to be the PID in the
>usual case, but it's not necessarily the PID. For netlink t's just a
>number, an address not a PID. The second netlink socket a process
>opens gets a negative address instead of anything related to the PID
>of the caller.

Is there a particular reason we do use the process ID (process group
ID) instead of the thread ID (process ID) when autoselecting the
netlink socket address?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 2/2] test-strv.c: added STRV_FOREACH and STRV_FOREACH_BACKWARDS

2013-10-27 Thread Zbigniew Jędrzejewski-Szmek
On Sun, Oct 27, 2013 at 12:45:53PM +0100, Daniel Buch wrote:
> ---
>  src/test/test-strv.c | 30 ++
>  1 file changed, 30 insertions(+)

Applied and updated report pushed to 
http://www.freedesktop.org/software/systemd/coverage/.
Overall: 30.7% → 30.9% :)

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


[systemd-devel] journal like cyclic buffer?

2013-10-27 Thread Warpme

Hi *

Is there possibility to configure systemd journal to behave like cyclic 
buffer with given buffer size?
Currently I see only rotation mechanism. Issue with rotation is that 
just after rotation, journal is almost empty and user don't have access 
to old log data.
I have already many situations where interesting me log entries were 
unavailable (via journalctl) due rotated journal files.

Thx in advance!

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


Re: [systemd-devel] journal like cyclic buffer?

2013-10-27 Thread Mantas Mikulėnas
On Sun, Oct 27, 2013 at 7:52 PM, Warpme  wrote:
> Hi *
>
> Is there possibility to configure systemd journal to behave like cyclic
> buffer with given buffer size?
> Currently I see only rotation mechanism. Issue with rotation is that just
> after rotation, journal is almost empty and user don't have access to old
> log data.
> I have already many situations where interesting me log entries were
> unavailable (via journalctl) due rotated journal files.
> Thx in advance!

It is not directly possible, but you could configure the rotation to
keep many small journal files (e.g. RuntimeMaxFileSize=1M,
RuntimeMaxUse=16M).

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


Re: [systemd-devel] journal like cyclic buffer?

2013-10-27 Thread Colin Guthrie
Hi,

'Twas brillig, and Warpme at 27/10/13 17:52 did gyre and gimble:
> Is there possibility to configure systemd journal to behave like cyclic
> buffer with given buffer size?
> Currently I see only rotation mechanism. Issue with rotation is that
> just after rotation, journal is almost empty and user don't have access
> to old log data.
> I have already many situations where interesting me log entries were
> unavailable (via journalctl) due rotated journal files.


If you don't see any old log data after rotation then something is
broken. journalctl should read all journals, even rotated ones.

Col


-- 

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] journal like cyclic buffer?

2013-10-27 Thread Kay Sievers
On Sun, Oct 27, 2013 at 6:52 PM, Warpme  wrote:
> Is there possibility to configure systemd journal to behave like cyclic
> buffer with given buffer size?
> Currently I see only rotation mechanism. Issue with rotation is that just
> after rotation, journal is almost empty and user don't have access to old
> log data.
> I have already many situations where interesting me log entries were
> unavailable (via journalctl) due rotated journal files.

The journal data is stored in several files. It's already a "ring
buffer", just with the granularity of the size of the individual
files. The size can be configured.

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


Re: [systemd-devel] [RFC][PATCH] udev: add network link configuration tool

2013-10-27 Thread Tollef Fog Heen
]] Tom Gundersen 

> The tool is configured by .link files in /etc/net/links/ (with the usual
> overriding logic in /run and /lib). The first (in lexicographical order)
> matching .link file is applied to a given device, and all others are ignored.

Breaking tab completion for /etc/network (on Debian systems) will be
considered rude.  Can you consider using another directory name?

-- 
Tollef Fog Heen
UNIX is user friendly, it's just picky about who its friends are
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [RFC][PATCH] libsystemd-rtnl: add a rtnetlink library

2013-10-27 Thread Tom Gundersen
This is intentionally as similar to sd-bus as possible. While it
would be simple to export it, the intentions is to keep this
internal (at least for the forseeable future).

Currently only synchronous communication is implemented

Once this has been applied, I'll add the missing pieces to the
net_link builtin (setting name/mtu/mac), and also port over
loopback_setup and udev's netif name setting.

TODO:
  - async calls: rtnl_send() and rtnl_send_with_repyl()
  - sd-loop integration
---
 .gitignore  |   1 +
 Makefile.am |  19 ++
 src/libsystemd-rtnl/rtnl-internal.h |  40 
 src/libsystemd-rtnl/rtnl-message.c  | 448 
 src/libsystemd-rtnl/sd-rtnl.c   | 188 +++
 src/libsystemd-rtnl/test-rtnl.c | 126 ++
 src/systemd/sd-rtnl.h   |  52 +
 7 files changed, 874 insertions(+)
 create mode 100644 src/libsystemd-rtnl/rtnl-internal.h
 create mode 100644 src/libsystemd-rtnl/rtnl-message.c
 create mode 100644 src/libsystemd-rtnl/sd-rtnl.c
 create mode 100644 src/libsystemd-rtnl/test-rtnl.c
 create mode 100644 src/systemd/sd-rtnl.h

diff --git a/.gitignore b/.gitignore
index d3cf8ef..dd6432c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -135,6 +135,7 @@
 /test-path-util
 /test-prioq
 /test-replace-var
+/test-rtnl
 /test-sched-prio
 /test-sleep
 /test-strip-tab-ansi
diff --git a/Makefile.am b/Makefile.am
index e619100..6ce4b7f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -621,6 +621,25 @@ EXTRA_DIST += \
 
 # 
--
 noinst_LTLIBRARIES += \
+   libsystemd-rtnl.la
+
+libsystemd_rtnl_la_SOURCES = \
+   src/systemd/sd-rtnl.h \
+   src/libsystemd-rtnl/sd-rtnl.c \
+   src/libsystemd-rtnl/rtnl-internal.h \
+   src/libsystemd-rtnl/rtnl-message.c
+
+test_rtnl_SOURCES = \
+   src/libsystemd-rtnl/test-rtnl.c
+
+test_rtnl_LDADD = \
+   libsystemd-shared.la \
+   libsystemd-rtnl.la
+
+tests += test-rtnl
+
+# 
--
+noinst_LTLIBRARIES += \
libsystemd-shared.la
 
 libsystemd_shared_la_SOURCES = \
diff --git a/src/libsystemd-rtnl/rtnl-internal.h 
b/src/libsystemd-rtnl/rtnl-internal.h
new file mode 100644
index 000..37b1d3d
--- /dev/null
+++ b/src/libsystemd-rtnl/rtnl-internal.h
@@ -0,0 +1,40 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2013 Tom Gundersen 
+
+  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 .
+***/
+
+#include "refcnt.h"
+
+struct sd_rtnl {
+RefCount n_ref;
+
+int fd;
+
+union {
+struct sockaddr sa;
+struct sockaddr_nl nl;
+} sockaddr;
+
+unsigned serial;
+};
+int message_get_errno(sd_rtnl_message *m);
+int message_get_serial(sd_rtnl_message *m);
+int message_seal(sd_rtnl *nl, sd_rtnl_message *m);
+int socket_write_message(sd_rtnl *nl, sd_rtnl_message *m);
+int socket_read_message(sd_rtnl *nl, sd_rtnl_message **ret);
diff --git a/src/libsystemd-rtnl/rtnl-message.c 
b/src/libsystemd-rtnl/rtnl-message.c
new file mode 100644
index 000..82ec1c9
--- /dev/null
+++ b/src/libsystemd-rtnl/rtnl-message.c
@@ -0,0 +1,448 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2013 Tom Gundersen 
+
+  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 .
+***/
+
+#include 
+#include 
+#include 
+#include 
+
+#include "util.h"
+#include "refcnt.h"
+
+#include "sd-rtnl.h"
+#include "rtnl-internal.h"
+
+struct sd_rtnl_message {
+RefCount n_ref;
+
+struct nlmsghdr *hdr;
+
+struct rtattr *next_rta;
+size_t rema

Re: [systemd-devel] [RFC][PATCH] libsystemd-rtnl: add a rtnetlink library

2013-10-27 Thread Tom Gundersen
On Sun, Oct 27, 2013 at 9:47 PM, Tom Gundersen  wrote:
> This is intentionally as similar to sd-bus as possible. While it
> would be simple to export it, the intentions is to keep this
> internal (at least for the forseeable future).
>
> Currently only synchronous communication is implemented
>
> Once this has been applied, I'll add the missing pieces to the
> net_link builtin (setting name/mtu/mac), and also port over
> loopback_setup and udev's netif name setting.

As suggested by Kay, this has now been committed. Comments and testing
still very much appreciated.

Cheers,

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


Re: [systemd-devel] journal like cyclic buffer?

2013-10-27 Thread Lennart Poettering
On Sun, 27.10.13 18:52, Warpme (war...@o2.pl) wrote:

> Hi *
> 
> Is there possibility to configure systemd journal to behave like
> cyclic buffer with given buffer size?

This is how things already behave. Simply use SystemMaxUse= in
journald.conf to set the maximum buffer size. With SystemMaxFileSize=
you can set the granularity in which we rotate the ring buffer.

> Currently I see only rotation mechanism. Issue with rotation is that
> just after rotation, journal is almost empty and user don't have
> access to old log data.

No, this is not how this works. journalctl (actually libsystemd-journal)
will transparently merge all available journal files into a single
continious stream regardless whether the journal files are marked as
"archived" or are live. Rotation hence has no effect on what you
see. It's little more than an internal scheme how things are stored on
disk.

> I have already many situations where interesting me log entries were
> unavailable (via journalctl) due rotated journal files.

This can only really happen if the granularity used for rotation is too
small. Use SystemMaxFileSize= to influence this setting.

Lennart

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


Re: [systemd-devel] [PATCH] nspawn: use the mode_t of the source file for copy_file()

2013-10-27 Thread Lennart Poettering
On Sat, 26.10.13 21:17, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) wrote:

> 
> On Sat, Oct 26, 2013 at 12:59:40AM +0100, Djalal Harouni wrote:
> > Instead of hard-coding the permission mode, stat() the source file and
> > use its mode to create the destination file.
> Hi,
> 
> Is this patch trying to fix something specific? copy_file is only used
> to copy resolv.conf into the container. It's unlikely that the mode
> from host is relevant in the container.

(Also, quick side note: doing the stat() separately before is creates a
race. It's a mucher better idea to use fstat() here, so that we might
not end up copying a mode over from an older file. -- but yeah, I agree
with Zbigniew, I see no reason for this patch and if we really want this
different then moving the mode into a copy_file() parameter to make it
explicit sounds more robust anyway.)

> 
> > Signed-off-by: Djalal Harouni 
> No need to add that in systemd.
> 
> Zbyszek
> 
> > ---
> >  src/shared/util.c | 6 +-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/shared/util.c b/src/shared/util.c
> > index d086fac..0886674 100644
> > --- a/src/shared/util.c
> > +++ b/src/shared/util.c
> > @@ -4133,16 +4133,20 @@ int vt_disallocate(const char *name) {
> >  
> >  int copy_file(const char *from, const char *to, int flags) {
> >  _cleanup_close_ int fdf = -1;
> > +struct stat st = {};
> >  int r, fdt;
> >  
> >  assert(from);
> >  assert(to);
> >  
> > +if (stat(from, &st) < 0)
> > +return -errno;
> > +
> >  fdf = open(from, O_RDONLY|O_CLOEXEC|O_NOCTTY);
> >  if (fdf < 0)
> >  return -errno;
> >  
> > -fdt = open(to, flags|O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0644);
> > +fdt = open(to, flags|O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 
> > st.st_mode);
> >  if (fdt < 0)
> >  return -errno;
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Lennart

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