Re: [systemd-devel] [RFC 25/25] add -z muldefs to linker flags

2014-09-18 Thread Michael Biebl
2014-09-19 0:34 GMT+02:00 David Herrmann :
>>  -Wl,-fuse-ld=gold])

The reason to use gold  was that the compat libraries require the
ifunc functionality.

This is no longer the case, so I'd suggest to not override the default
linker and simply use the system default one.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [RFC 14/25] shared/missing.h: check for missing __compar_fn_t typedef

2014-09-18 Thread David Herrmann
Hi

On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> ---
>  src/shared/missing.h | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/src/shared/missing.h b/src/shared/missing.h
> index 55e61f6..be099c5 100644
> --- a/src/shared/missing.h
> +++ b/src/shared/missing.h
> @@ -147,6 +147,11 @@ static inline char *canonicalize_file_name(const char 
> *path) {
>})
>  #endif
>
> +#ifndef __COMPAR_FN_T
> +#define __COMPAR_FN_T
> +typedef int (*__compar_fn_t)(const void *, const void *);
> +#endif
> +

Why not simply define this in your libc? I mean, it doesn't add any
code, so seems totally legit to add.

Thanks
David

>  #ifdef __x86_64__
>  #  ifndef __NR_fanotify_init
>  #define __NR_fanotify_init 300
> --
> 2.1.0
>
> ___
> 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] [RFC 25/25] add -z muldefs to linker flags

2014-09-18 Thread David Herrmann
Hi

On Thu, Sep 18, 2014 at 3:25 PM, Emil Renner Berthing  wrote:
> In case we don't have the new gold linker,
> linking with ld fails without this option.
> ---
>  configure.ac | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/configure.ac b/configure.ac
> index 3f17833..4be6e08 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -216,6 +216,7 @@ CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
>  -Wl,--gc-sections \
>  -Wl,-z,relro \
>  -Wl,-z,now \
> +-Wl,-z,muldefs \

Where exactly is that needed? I don't think this is the right fix. We
avoid multiple definitions wherever we can, so please either include
the culprit in the commit-message or fix them directly.

Thanks
David

>  -pie \
>  -Wl,-fuse-ld=gold])
>  AC_SUBST([OUR_LDFLAGS], "$with_ldflags $sanitizer_ldflags")
> --
> 2.1.0
>
> ___
> 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] [RFC 05/25] shared/util.h: include sys/reg.h for __WORDSIZE

2014-09-18 Thread David Herrmann
Hi

On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> ---
>  src/shared/util.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/shared/util.h b/src/shared/util.h
> index 08d556f..32e5090 100644
> --- a/src/shared/util.h
> +++ b/src/shared/util.h
> @@ -24,6 +24,7 @@
>  #include 
>  #include 
>  #include 
> +#include 

__WORDSIZE is declared in bits/wordsize.h on glibc. Can you check
where exactly it's defined on your system? sys/reg.h sounds weird. I'd
prefer something like sys/types.h, stdint.h, limits.h. They all work
on glibc and kinda make sense.

Thanks
David

>  #include 
>  #include 
>  #include 
> --
> 2.1.0
>
> ___
> 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] [RFC 07/25] shared/sparse-endian.h: add missing byteswap.h include

2014-09-18 Thread David Herrmann
Hi

On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> ---
>  src/shared/sparse-endian.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/shared/sparse-endian.h b/src/shared/sparse-endian.h
> index eb4dbf3..c913fda 100644
> --- a/src/shared/sparse-endian.h
> +++ b/src/shared/sparse-endian.h
> @@ -21,6 +21,7 @@
>  #ifndef SPARSE_ENDIAN_H
>  #define SPARSE_ENDIAN_H
>
> +#include 
>  #include 

Kinda ridiculous to make endian.h not include byteswap.h, but ok, no
reason not to support this.

Applied!

Thanks
David

>  #include 
>
> --
> 2.1.0
>
> ___
> 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] [RFC 06/25] shared/label.h: add missing stdio.h include

2014-09-18 Thread David Herrmann
Hi

On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> ---
>  src/shared/label.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/shared/label.h b/src/shared/label.h
> index 7294820..cb2ec79 100644
> --- a/src/shared/label.h
> +++ b/src/shared/label.h
> @@ -24,6 +24,7 @@
>  #include 
>  #include 
>  #include 
> +#include 

Applied!

Thanks
David

>
>  int label_init(const char *prefix);
>  void label_finish(void);
> --
> 2.1.0
>
> ___
> 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] [RFC 10/25] shared/pty: fall back to kernel header for TIOCSIG

2014-09-18 Thread David Herrmann
Hi

On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> ---
>  src/shared/pty.c | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/src/shared/pty.c b/src/shared/pty.c
> index 2863da4..21a87e5 100644
> --- a/src/shared/pty.c
> +++ b/src/shared/pty.c
> @@ -61,6 +61,11 @@
>  #include 
>  #include 
>
> +/* If sys/ioctl.h doesn't provide TIOCSIG use the kernel header */
> +#ifndef TIOCSIG
> +#include 
> +#endif
> +

I'd prefer to include linux/ioctl.h. Does that work for you? It is
kinda linux specific, so it sounds reasonable to include the linux
header. I pushed a fix for that. If it still doesn't work, lemme know.

Thanks
David

>  #include "barrier.h"
>  #include "macro.h"
>  #include "pty.h"
> --
> 2.1.0
>
> ___
> 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] [RFC 00/25] Compile against the musl libc

2014-09-18 Thread Emil Renner Berthing
Hi Tom,

On 18 September 2014 18:29, Tom Gundersen  wrote:
> In general, I don't think we should add patches for the sole purpose
> of non-glibc compatibility. You would in most cases be much better
> served by adding the missing functionality to your libc, rather than
> to each of the project requiring the functionality.

Thank you for looking through these. The problem is that musl is aiming
at making a lean and efficient posix libc, not a glibc clone. So stuff
like parse_printf_format and canonicalize_file_name is not a fix, but
unnecessary bloat. So it seems I'm stuck between a rock and a hard place.
I guess I had hoped the resistance in this camp would be more against
doing the work rather than actually be able to work with a posix libc and not
only glibc.

> That said, we are of course happy to take patches that are "the right
> thing to do" regardless of which libc is being used, so I merged some
> of the patches you posted.

Cool. I can resend updates of the ones you commented on.

> Btw, have you considered simply putting glibc on your router in the
> first place? If you can fit systemd, you can probably fit glibc too...

Well, last time I tried this linux, musl, systemd, busybox, base, I had a
Lua webserver running from linux + squashfs taking around 3MB out
the 8MB available on the gadget. Maybe systemd has grown since then,
I didn't get this far this time around.

Also I think I might have made a mistake in mentioning OpenWRT. My
point was more that I'd like systemd to run on hardware with the same
kind of specs as OpenWRT is designed for, not necessarely replacing
OpenWRT everywhere. I was thinking of gadgets like the VoCore [1],
Arduino's Yun [2], Intel's Galileo boards[3] and Edison SOC [4] to name
a few.

[1] 
https://www.indiegogo.com/projects/vocore-a-coin-sized-linux-computer-with-wifi
[2] http://arduino.cc/en/Main/ArduinoBoardYun
[3] 
http://www.intel.com/content/www/us/en/do-it-yourself/galileo-maker-quark-board.html
[4] http://www.youtube.com/watch?v=GY8kaaFzbTE
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [RFC 21/25] make sure basename that doesn't alter it's argument

2014-09-18 Thread Cristian Rodríguez
El 18/09/14 a las #4, Emil Renner Berthing escribió:
> ---

And all of this because the POSIX versions of basename modify the
argument .. see the problem ? it is the standard versions that are wrong.

what about implementing a gnu_basename in the C library and using that
instead ?


-- 
Cristian
"I don't know the key to success, but the key to failure is trying to
please everybody."
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [RFC 24/25] units: order options before other arguments

2014-09-18 Thread Dave Reisner
On Thu, Sep 18, 2014 at 06:10:06PM +0200, Tom Gundersen wrote:
> For kmod and systemctl this is fine (so I'd be happy to take a patch
> to make that change), but for udevadm it feels weird as the
> documentation there says the format should be "udevadm trigger". Maybe
> something to fix in the libc (assuming the problem is that it enforces
> an order).

It's not just the documentation. This patch wasn't tested at all:

$ udevadm --type=devices --action=add trigger
udevadm: unrecognized option '--type=devices'

udevadm makes 2 option parsing rounds with the first round stopping as
soon as it encounters a non-option argument. So, the rationale behind
this patch is bogus, as is the change.

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


Re: [systemd-devel] [PATCH] journal-remote: check return code of sd_event_default

2014-09-18 Thread Tom Gundersen
Applied. Thanks!

Tom

On Thu, Sep 18, 2014 at 5:52 PM, Andreas Henriksson  wrote:
> Handle sd_event_default returning error and bail out properly
> as done in every other caller of this function.
>
> Found by coverity. Fixes: CID#1238957
> ---
>  src/journal-remote/journal-remote.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/journal-remote/journal-remote.c 
> b/src/journal-remote/journal-remote.c
> index 12de820..f06c2cb 100644
> --- a/src/journal-remote/journal-remote.c
> +++ b/src/journal-remote/journal-remote.c
> @@ -808,7 +808,11 @@ static int remoteserver_init(RemoteServer *s,
>  return -EINVAL;
>  }
>
> -sd_event_default(&s->events);
> +r = sd_event_default(&s->events);
> +if (r < 0) {
> +log_error("Failed to allocate event loop: %s", strerror(-r));
> +return r;
> +}
>
>  setup_signals(s);
>
> --
> 2.1.0
>
> ___
> 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] [PATCH 0/3] Minor patches for gcc warnings

2014-09-18 Thread Tom Gundersen
Applied all three. Thanks!

Tom

On Thu, Sep 18, 2014 at 5:56 PM,   wrote:
> From: Philippe De Swert 
>
> Hi,
>
> While compiling systemd I came across these warnings. And as I recompile
> a lot these days for Coverity they started to bug me and I just decided
> to fix them as they are quite trivial issues.
>
> Cheers!
>
> Philippe De Swert (3):
>   journal-upload: Remove compilation warning
>   core: Remove uninitialized warnings from bus-endpoint.c
>   sysusers: Remove some gcc warnings about uninitialized variables
>
>  src/core/bus-endpoint.c | 4 ++--
>  src/journal-remote/journal-upload.c | 2 +-
>  src/sysusers/sysusers.c | 4 ++--
>  3 files changed, 5 insertions(+), 5 deletions(-)
>
> --
> 1.8.3.2
>
> ___
> 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] [RFC 00/25] Compile against the musl libc

2014-09-18 Thread Tom Gundersen
On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> Around the internet one can read statements such as "systemd
> is designed with glibc in mind" and "the systemd developers' idea
> of a standard libc is one that has bug-for-bug compatibility with
> glibc". So in a fit of naivety I decided to test this out and see
> how much work it would take to make systemd work with musl.
>
> The real reason is of course that I'd like to see systemd running
> on my router and other small devices that usually run some OpenWRT
> derivative.
>
> This series makes systemd compile cleanly against musl 1.1.4 with
> a minimal configuration and also fixes a few runtime errors. It is
> only lightly tested and a few of patches could definitely be done
> in a nicer, more generic way. Also I'd love to get even more stuff
> working like eg. networkd and resolved. However I would like some
> early feedback and see if this is something that could one day make
> it upstream or I'm just wasting my time.
>
> The first two patches are not strictly needed, but it makes the
> compilation much quieter and they are correct according POSIX.

In general, I don't think we should add patches for the sole purpose
of non-glibc compatibility. You would in most cases be much better
served by adding the missing functionality to your libc, rather than
to each of the project requiring the functionality.

That said, we are of course happy to take patches that are "the right
thing to do" regardless of which libc is being used, so I merged some
of the patches you posted.

Btw, have you considered simply putting glibc on your router in the
first place? If you can fit systemd, you can probably fit glibc too...

Thanks!

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


Re: [systemd-devel] [RFC 11/25] shared/missing.h: fall pack to insecure getenv

2014-09-18 Thread Tom Gundersen
On Thu, Sep 18, 2014 at 4:01 PM, Emil Renner Berthing  wrote:
> On 18 September 2014 15:56, Karol Lewandowski  
> wrote:>
>> I think it would be way better (and easy) to reimplement original
>> secure_getenv() rather than falling back to function with different
>> semantics.  secure_ is there for a reason.
>
> Agreed. Added to my TODO, thanks.


Yeah, please do this in the libc. We cannot fall back to
broken/insecure behaviour.

Cheers,

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


Re: [systemd-devel] [RFC 21/25] make sure basename that doesn't alter it's argument

2014-09-18 Thread Tom Gundersen
This needs a bit more explanation. Why this change?

Cheers,

Tom

On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> ---
>  src/core/execute.c  |  6 +++---
>  src/core/load-fragment.c|  2 +-
>  src/core/manager.c  |  2 +-
>  src/core/unit.c |  4 ++--
>  src/delta/delta.c   | 14 +++---
>  src/journal/journalctl.c|  2 +-
>  src/locale/localectl.c  |  2 +-
>  src/login/logind-inhibit.c  |  2 +-
>  src/login/logind-seat.c |  2 +-
>  src/login/logind-session.c  |  2 +-
>  src/nspawn/nspawn.c |  2 +-
>  src/shared/cgroup-show.c|  4 ++--
>  src/shared/conf-files.c |  4 ++--
>  src/shared/install.c| 14 +++---
>  src/shared/path-util.c  |  8 
>  src/shared/path-util.h  |  5 +
>  src/shared/util.c   |  4 ++--
>  src/shared/utmp-wtmp.c  |  2 +-
>  src/systemctl/systemctl.c   | 12 ++--
>  src/sysv-generator/sysv-generator.c |  4 ++--
>  src/test/test-install.c | 18 +-
>  src/test/test-path-util.c   |  8 
>  22 files changed, 68 insertions(+), 55 deletions(-)
>
> diff --git a/src/core/execute.c b/src/core/execute.c
> index e73eb8e..77724ce 100644
> --- a/src/core/execute.c
> +++ b/src/core/execute.c
> @@ -912,7 +912,7 @@ static void rename_process_from_path(const char *path) {
>  /* This resulting string must fit in 10 chars (i.e. the length
>   * of "/sbin/init") to look pretty in /bin/ps */
>
> -p = basename(path);
> +p = path_basename(path);
>  if (isempty(p)) {
>  rename_process("(...)");
>  return;
> @@ -1331,13 +1331,13 @@ static int exec_child(ExecCommand *command,
>  return err;
>  }
>
> -err = setup_output(context, STDOUT_FILENO, socket_fd, 
> basename(command->path), params->unit_id, params->apply_tty_stdin);
> +err = setup_output(context, STDOUT_FILENO, socket_fd, 
> path_basename(command->path), params->unit_id, params->apply_tty_stdin);
>  if (err < 0) {
>  *error = EXIT_STDOUT;
>  return err;
>  }
>
> -err = setup_output(context, STDERR_FILENO, socket_fd, 
> basename(command->path), params->unit_id, params->apply_tty_stdin);
> +err = setup_output(context, STDERR_FILENO, socket_fd, 
> path_basename(command->path), params->unit_id, params->apply_tty_stdin);
>  if (err < 0) {
>  *error = EXIT_STDERR;
>  return err;
> diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
> index 0620882..61db112 100644
> --- a/src/core/load-fragment.c
> +++ b/src/core/load-fragment.c
> @@ -3322,7 +3322,7 @@ static int open_follow(char **filename, FILE **_f, Set 
> *names, char **_final) {
>  /* Add the file name we are currently looking at to
>   * the names of this unit, but only if it is a valid
>   * unit name. */
> -name = basename(*filename);
> +name = path_basename(*filename);
>
>  if (unit_name_is_valid(name, TEMPLATE_VALID)) {
>
> diff --git a/src/core/manager.c b/src/core/manager.c
> index 88d660d..22a9c89 100644
> --- a/src/core/manager.c
> +++ b/src/core/manager.c
> @@ -1217,7 +1217,7 @@ int manager_load_unit_prepare(
>  return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Path 
> %s is not absolute.", path);
>
>  if (!name)
> -name = basename(path);
> +name = path_basename(path);
>
>  t = unit_name_to_type(name);
>
> diff --git a/src/core/unit.c b/src/core/unit.c
> index def5c36..c14859e 100644
> --- a/src/core/unit.c
> +++ b/src/core/unit.c
> @@ -2170,7 +2170,7 @@ static const char *resolve_template(Unit *u, const char 
> *name, const char*path,
>  assert(p);
>
>  if (!name)
> -name = basename(path);
> +name = path_basename(path);
>
>  if (!unit_name_is_template(name)) {
>  *p = NULL;
> @@ -2941,7 +2941,7 @@ UnitFileState unit_get_unit_file_state(Unit *u) {
>  if (u->unit_file_state < 0 && u->fragment_path)
>  u->unit_file_state = unit_file_get_state(
>  u->manager->running_as == SYSTEMD_SYSTEM ? 
> UNIT_FILE_SYSTEM : UNIT_FILE_USER,
> -NULL, basename(u->fragment_path));
> +NULL, path_basename(u->fragment_path));
>
>  return u->unit_file_state;
>  }
> diff --git a/src/delta/delta.c b/src/delta/delta.c
> index 91f8592..cb049e8 100644
> --- a/src/delta/delta.c
> +++ b/src/delta/delta.c
> @@ -282,8 +282,8 @@ static int enumerate_dir_d(Hashmap *top, Hashmap *bottom, 
> Hashmap *drops, const
>   

Re: [systemd-devel] [RFC 23/25] mount: order options before other arguments to mount

2014-09-18 Thread Tom Gundersen
Applied. Thanks!

Tom

On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> ---
>  src/core/mount.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/core/mount.c b/src/core/mount.c
> index e284357..f3ec736 100644
> --- a/src/core/mount.c
> +++ b/src/core/mount.c
> @@ -903,10 +903,10 @@ static void mount_enter_mounting(Mount *m) {
>  m->control_command,
>  "/bin/mount",
>  m->sloppy_options ? "-ns" : "-n",
> +"-t", m->parameters_fragment.fstype ? 
> m->parameters_fragment.fstype : "auto",
> +"-o", m->parameters_fragment.options ? 
> m->parameters_fragment.options : "",
>  m->parameters_fragment.what,
>  m->where,
> -"-t", m->parameters_fragment.fstype ? 
> m->parameters_fragment.fstype : "auto",
> -m->parameters_fragment.options ? "-o" : 
> NULL, m->parameters_fragment.options,
>  NULL);
>  else
>  r = -ENOENT;
> @@ -951,10 +951,10 @@ static void mount_enter_remounting(Mount *m) {
>  m->control_command,
>  "/bin/mount",
>  m->sloppy_options ? "-ns" : "-n",
> -m->parameters_fragment.what,
> -m->where,
>  "-t", m->parameters_fragment.fstype ? 
> m->parameters_fragment.fstype : "auto",
>  "-o", o,
> +m->parameters_fragment.what,
> +m->where,
>  NULL);
>  } else
>  r = -ENOENT;
> --
> 2.1.0
>
> ___
> 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] [RFC 24/25] units: order options before other arguments

2014-09-18 Thread Tom Gundersen
For kmod and systemctl this is fine (so I'd be happy to take a patch
to make that change), but for udevadm it feels weird as the
documentation there says the format should be "udevadm trigger". Maybe
something to fix in the libc (assuming the problem is that it enforces
an order).

On Thu, Sep 18, 2014 at 3:25 PM, Emil Renner Berthing  wrote:
> ---
>  units/initrd-udevadm-cleanup-db.service.in | 2 +-
>  units/kmod-static-nodes.service.in | 2 +-
>  units/systemd-journal-flush.service.in | 2 +-
>  units/systemd-udev-hwdb-update.service.in  | 2 +-
>  units/systemd-udev-trigger.service.in  | 2 +-
>  5 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/units/initrd-udevadm-cleanup-db.service.in 
> b/units/initrd-udevadm-cleanup-db.service.in
> index 5c6654e..3ec5451 100644
> --- a/units/initrd-udevadm-cleanup-db.service.in
> +++ b/units/initrd-udevadm-cleanup-db.service.in
> @@ -15,4 +15,4 @@ Before=initrd-switch-root.target
>
>  [Service]
>  Type=oneshot
> -ExecStart=-@rootbindir@/udevadm info --cleanup-db
> +ExecStart=-@rootbindir@/udevadm --cleanup-db info
> diff --git a/units/kmod-static-nodes.service.in 
> b/units/kmod-static-nodes.service.in
> index 0934a87..1b5e71d 100644
> --- a/units/kmod-static-nodes.service.in
> +++ b/units/kmod-static-nodes.service.in
> @@ -15,4 +15,4 @@ ConditionPathExists=/lib/modules/%v/modules.devname
>  [Service]
>  Type=oneshot
>  RemainAfterExit=yes
> -ExecStart=@KMOD@ static-nodes --format=tmpfiles 
> --output=/run/tmpfiles.d/kmod.conf
> +ExecStart=@KMOD@ --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf 
> static-nodes
> diff --git a/units/systemd-journal-flush.service.in 
> b/units/systemd-journal-flush.service.in
> index 503e8a6..29b9342 100644
> --- a/units/systemd-journal-flush.service.in
> +++ b/units/systemd-journal-flush.service.in
> @@ -14,5 +14,5 @@ After=systemd-journald.service local-fs.target 
> remote-fs.target
>  Before=systemd-user-sessions.service
>
>  [Service]
> -ExecStart=@rootbindir@/systemctl kill --kill-who=main --signal=SIGUSR1 
> systemd-journald.service
> +ExecStart=@rootbindir@/systemctl --kill-who=main --signal=SIGUSR1 kill 
> systemd-journald.service
>  Type=oneshot
> diff --git a/units/systemd-udev-hwdb-update.service.in 
> b/units/systemd-udev-hwdb-update.service.in
> index 153d93c..ec4b8c4 100644
> --- a/units/systemd-udev-hwdb-update.service.in
> +++ b/units/systemd-udev-hwdb-update.service.in
> @@ -17,4 +17,4 @@ ConditionNeedsUpdate=/etc
>  [Service]
>  Type=oneshot
>  RemainAfterExit=yes
> -ExecStart=@rootbindir@/udevadm hwdb --update
> +ExecStart=@rootbindir@/udevadm --update hwdb
> diff --git a/units/systemd-udev-trigger.service.in 
> b/units/systemd-udev-trigger.service.in
> index 0c33909..101adaf 100644
> --- a/units/systemd-udev-trigger.service.in
> +++ b/units/systemd-udev-trigger.service.in
> @@ -17,4 +17,4 @@ ConditionPathIsReadWrite=/sys
>  [Service]
>  Type=oneshot
>  RemainAfterExit=yes
> -ExecStart=@rootbindir@/udevadm trigger --type=subsystems --action=add ; 
> @rootbindir@/udevadm trigger --type=devices --action=add
> +ExecStart=@rootbindir@/udevadm --type=subsystems --action=add trigger ; 
> @rootbindir@/udevadm --type=devices --action=add trigger
> --
> 2.1.0
>
> ___
> 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] [RFC 01/25] include poll.h rather than sys/poll.h

2014-09-18 Thread David Herrmann
Hi

On Thu, Sep 18, 2014 at 6:03 PM, Tom Gundersen  wrote:
> Hm, this one doesn't apply for me. If you rebase and resend I'll apply.

And, please, where applicable, keep alphabetical order.

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


Re: [systemd-devel] [RFC 01/25] include poll.h rather than sys/poll.h

2014-09-18 Thread Tom Gundersen
Hm, this one doesn't apply for me. If you rebase and resend I'll apply.

Thanks!

Tom

On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> ---
>  man/sd_journal_get_fd.xml   | 2 +-
>  src/ask-password/ask-password.c | 2 +-
>  src/bus-proxyd/bus-proxyd.c | 2 +-
>  src/core/execute.c  | 2 +-
>  src/core/manager.c  | 2 +-
>  src/core/unit.c | 2 +-
>  src/initctl/initctl.c   | 2 +-
>  src/journal/sd-journal.c| 2 +-
>  src/libsystemd/sd-bus/bus-socket.c  | 2 +-
>  src/libsystemd/sd-bus/sd-bus.c  | 2 +-
>  src/libsystemd/sd-login/sd-login.c  | 2 +-
>  src/libsystemd/sd-login/test-login.c| 2 +-
>  src/libsystemd/sd-network/sd-network.c  | 2 +-
>  src/libsystemd/sd-resolve/sd-resolve.c  | 2 +-
>  src/libudev/libudev-monitor.c   | 2 +-
>  src/readahead/readahead-collect.c   | 2 +-
>  src/reply-password/reply-password.c | 2 +-
>  src/resolve/resolved-manager.c  | 2 +-
>  src/shared/ask-password-api.c   | 2 +-
>  src/shared/logs-show.c  | 2 +-
>  src/shared/spawn-polkit-agent.c | 2 +-
>  src/shared/util.c   | 2 +-
>  src/shared/utmp-wtmp.c  | 2 +-
>  src/shutdownd/shutdownd.c   | 2 +-
>  src/tty-ask-password-agent/tty-ask-password-agent.c | 2 +-
>  src/udev/udev-ctrl.c| 2 +-
>  src/udev/udev-event.c   | 2 +-
>  src/udev/udevadm-settle.c   | 2 +-
>  src/udev/udevadm-test-builtin.c | 2 +-
>  src/udev/udevd.c| 2 +-
>  30 files changed, 30 insertions(+), 30 deletions(-)
>
> diff --git a/man/sd_journal_get_fd.xml b/man/sd_journal_get_fd.xml
> index 3aa79ce..56c2a75 100644
> --- a/man/sd_journal_get_fd.xml
> +++ b/man/sd_journal_get_fd.xml
> @@ -308,7 +308,7 @@ int main(int argc, char *argv[]) {
>  example lacks all error checking for the sake of
>  simplicity):
>
> -#include 
> +#include 
>  #include 
>
>  int wait_for_changes(sd_journal *j) {
> diff --git a/src/ask-password/ask-password.c b/src/ask-password/ask-password.c
> index 5c37cff..2eed25f 100644
> --- a/src/ask-password/ask-password.c
> +++ b/src/ask-password/ask-password.c
> @@ -20,7 +20,7 @@
>  ***/
>
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
> index d35d7f6..4de8e85 100644
> --- a/src/bus-proxyd/bus-proxyd.c
> +++ b/src/bus-proxyd/bus-proxyd.c
> @@ -28,7 +28,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>
> diff --git a/src/core/execute.c b/src/core/execute.c
> index f3c791e..e73eb8e 100644
> --- a/src/core/execute.c
> +++ b/src/core/execute.c
> @@ -37,7 +37,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>
> diff --git a/src/core/manager.c b/src/core/manager.c
> index e0c1cd1..88d660d 100644
> --- a/src/core/manager.c
> +++ b/src/core/manager.c
> @@ -25,7 +25,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/src/core/unit.c b/src/core/unit.c
> index 5978e21..def5c36 100644
> --- a/src/core/unit.c
> +++ b/src/core/unit.c
> @@ -24,7 +24,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c
> index f1c2b8d..7f22cb3 100644
> --- a/src/initctl/initctl.c
> +++ b/src/initctl/initctl.c
> @@ -27,7 +27,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
> index 1fc9f01..fec97c8 100644
> --- a/src/journal/sd-journal.c
> +++ b/src/journal/sd-journal.c
> @@ -24,7 +24,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>
> diff --git a/src/libsystemd/sd-bus/bus-socket.c 
> b/src/libsystemd/sd-bus/bus-socket.c
> index d124d9a..27b2ecf 100644
> --- a/src/libsystemd/sd-bus/bus-socket.c
> +++ b/src/libsystemd/sd-bus/bus-socket.c
> @@ -23,7 +23,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>
>  #include "util.h"
> diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
> index 28b993b..ff4beed 100644
> --- a/src/libsystemd/sd-bus/sd-bus.c
> +++ b/src/libsystemd/sd-bus/sd-bus.c
> @@ -2

Re: [systemd-devel] [PATCH] ask-password: Add --do-echo to enable echoing the user input

2014-09-18 Thread Colin Guthrie
David Sommerseth wrote on 17/09/14 13:26:
> If there are better ways how to solve this, please let me know and I'll
> go that path instead.

I asked much the same question a looong time back on this list regarding
a generic API to ask for more than just passwords although it was hidden
in a comment (also regarding openvpn) and thus I'm not sure it got much
notice.

http://lists.freedesktop.org/archives/systemd-devel/2012-November/007572.html

Various network enabled devices are being auto detected (audio output
devices being one) and a generic mechanism with graphical agents to get
appropriate credentials would be nice.

I'd rather the ability to make a single request and have the agent ask
for all credentials and reply once rather than looping over both
separately however.

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] [RFC 02/25] include fcntl.h rather than sys/fcntl.h

2014-09-18 Thread Tom Gundersen
Applied. Thanks!

Tom

On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> ---
>  src/socket-proxy/socket-proxyd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/socket-proxy/socket-proxyd.c 
> b/src/socket-proxy/socket-proxyd.c
> index 81d8457..ff2b24f 100644
> --- a/src/socket-proxy/socket-proxyd.c
> +++ b/src/socket-proxy/socket-proxyd.c
> @@ -26,7 +26,7 @@
>  #include 
>  #include 
>  #include 
> -#include 
> +#include 
>  #include 
>  #include 
>  #include 
> --
> 2.1.0
>
> ___
> 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


[systemd-devel] [PATCH 2/3] core: Remove uninitialized warnings from bus-endpoint.c

2014-09-18 Thread philippedeswert
From: Philippe De Swert 

Gcc is spewing some warnings about uninitialized variables.
Let's get rid of the noise.
---
 src/core/bus-endpoint.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/core/bus-endpoint.c b/src/core/bus-endpoint.c
index 1e8f07e..aac540d 100644
--- a/src/core/bus-endpoint.c
+++ b/src/core/bus-endpoint.c
@@ -34,8 +34,8 @@ int bus_endpoint_new(BusEndpoint **ep)
 
 int bus_endpoint_add_policy(BusEndpoint *ep, const char *name, BusPolicyAccess 
access)
 {
-_cleanup_free_ BusEndpointPolicy *po;
-_cleanup_free_ char *key;
+_cleanup_free_ BusEndpointPolicy *po = NULL;
+_cleanup_free_ char *key = NULL;
 int r;
 
 assert(ep);
-- 
1.8.3.2

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


[systemd-devel] [PATCH 1/3] journal-upload: Remove compilation warning

2014-09-18 Thread philippedeswert
From: Philippe De Swert 

When compiling we see this curl warning popping up:
src/journal-remote/journal-upload.c:194:17: warning: call to
‘_curl_easy_setopt_err_error_buffer’ declared with attribute
warning: curl_easy_setopt expects a char buffer of CURL_ERROR_SIZE
as argument for this option [enabled by default]
This patch removes the warning (which occurs twice).
---
 src/journal-remote/journal-upload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/journal-remote/journal-upload.c 
b/src/journal-remote/journal-upload.c
index 40c380a..e162044 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -191,7 +191,7 @@ int start_upload(Uploader *u,
 easy_setopt(curl, CURLOPT_POST, 1L,
 LOG_ERR, return -EXFULL);
 
-easy_setopt(curl, CURLOPT_ERRORBUFFER, &u->error,
+easy_setopt(curl, CURLOPT_ERRORBUFFER, u->error,
 LOG_ERR, return -EXFULL);
 
 /* set where to write to */
-- 
1.8.3.2

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


[systemd-devel] [PATCH 0/3] Minor patches for gcc warnings

2014-09-18 Thread philippedeswert
From: Philippe De Swert 

Hi,

While compiling systemd I came across these warnings. And as I recompile
a lot these days for Coverity they started to bug me and I just decided 
to fix them as they are quite trivial issues.

Cheers!

Philippe De Swert (3):
  journal-upload: Remove compilation warning
  core: Remove uninitialized warnings from bus-endpoint.c
  sysusers: Remove some gcc warnings about uninitialized variables

 src/core/bus-endpoint.c | 4 ++--
 src/journal-remote/journal-upload.c | 2 +-
 src/sysusers/sysusers.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

-- 
1.8.3.2

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


[systemd-devel] [PATCH 3/3] sysusers: Remove some gcc warnings about uninitialized variables

2014-09-18 Thread philippedeswert
From: Philippe De Swert 

Gcc is spewing some warnings about uninitialized variables.
Let's get rid of the noise.
---
 src/sysusers/sysusers.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index ba20d94..4203b3e 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -796,8 +796,8 @@ static int root_stat(const char *p, struct stat *st) {
 static int read_id_from_file(Item *i, uid_t *_uid, gid_t *_gid) {
 struct stat st;
 bool found_uid = false, found_gid = false;
-uid_t uid;
-gid_t gid;
+uid_t uid = 0;
+gid_t gid = 0;
 
 assert(i);
 
-- 
1.8.3.2

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


Re: [systemd-devel] [RFC 20/25] udevadm-hwdb: don't use glibc-specific qsort_r

2014-09-18 Thread Tom Gundersen
It does not make sense for us to work around this. Please add it to
your libc instead.

On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> ---
>  src/udev/udevadm-hwdb.c | 16 ++--
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
> index 65cbf61..3f31662 100644
> --- a/src/udev/udevadm-hwdb.c
> +++ b/src/udev/udevadm-hwdb.c
> @@ -123,13 +123,13 @@ static void trie_node_cleanup(struct trie_node *node) {
>  free(node);
>  }
>
> -static int trie_values_cmp(const void *v1, const void *v2, void *arg) {
> +static struct trie *trie_node_add_value_trie;
> +static int trie_values_cmp(const void *v1, const void *v2) {
>  const struct trie_value_entry *val1 = v1;
>  const struct trie_value_entry *val2 = v2;
> -struct trie *trie = arg;
>
> -return strcmp(trie->strings->buf + val1->key_off,
> -  trie->strings->buf + val2->key_off);
> +return strcmp(trie_node_add_value_trie->strings->buf + val1->key_off,
> +  trie_node_add_value_trie->strings->buf + 
> val2->key_off);
>  }
>
>  static int trie_node_add_value(struct trie *trie, struct trie_node *node,
> @@ -150,7 +150,9 @@ static int trie_node_add_value(struct trie *trie, struct 
> trie_node *node,
>  .value_off = v,
>  };
>
> -val = xbsearch_r(&search, node->values, node->values_count, 
> sizeof(struct trie_value_entry), trie_values_cmp, trie);
> +trie_node_add_value_trie = trie;
> +val = bsearch(&search, node->values, node->values_count, 
> sizeof(struct trie_value_entry), trie_values_cmp);
> +trie_node_add_value_trie = NULL;
>  if (val) {
>  /* replace existing earlier key with new value */
>  val->value_off = v;
> @@ -167,7 +169,9 @@ static int trie_node_add_value(struct trie *trie, struct 
> trie_node *node,
>  node->values[node->values_count].key_off = k;
>  node->values[node->values_count].value_off = v;
>  node->values_count++;
> -qsort_r(node->values, node->values_count, sizeof(struct 
> trie_value_entry), trie_values_cmp, trie);
> +trie_node_add_value_trie = trie;
> +qsort(node->values, node->values_count, sizeof(struct 
> trie_value_entry), trie_values_cmp);
> +trie_node_add_value_trie = NULL;
>  return 0;
>  }
>
> --
> 2.1.0
>
> ___
> 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


[systemd-devel] [PATCH] journal-remote: check return code of sd_event_default

2014-09-18 Thread Andreas Henriksson
Handle sd_event_default returning error and bail out properly
as done in every other caller of this function.

Found by coverity. Fixes: CID#1238957
---
 src/journal-remote/journal-remote.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/journal-remote/journal-remote.c 
b/src/journal-remote/journal-remote.c
index 12de820..f06c2cb 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -808,7 +808,11 @@ static int remoteserver_init(RemoteServer *s,
 return -EINVAL;
 }
 
-sd_event_default(&s->events);
+r = sd_event_default(&s->events);
+if (r < 0) {
+log_error("Failed to allocate event loop: %s", strerror(-r));
+return r;
+}
 
 setup_signals(s);
 
-- 
2.1.0

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


Re: [systemd-devel] [RFC 00/25] Compile against the musl libc

2014-09-18 Thread Cristian Rodríguez

El 18/09/14 a las #4, Emil Renner Berthing escribió:

Hi,

Around the internet one can read statements such as "systemd
is designed with glibc in mind" and "the systemd developers' idea
of a standard libc is one that has bug-for-bug compatibility with
glibc".


For all practical purposes this is correct. You not only need glibc but 
the behavior glibc has, documented or otherwise. If you need an init 
system supporting whatever other alternate or special libc libraries you 
have to look elsewhere. As far as I understand no code will be added to 
support other c libraries.





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


Re: [systemd-devel] [RFC 18/25] sd-ipv4all: fall back to random if no random_r

2014-09-18 Thread Tom Gundersen
No, this actually breaks the behaviour, so we absolutely cannot do
this. Again, I suggest adding the missing features to your libc.

Cheers,

Tom

On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> ---
>  configure.ac   |  1 +
>  src/libsystemd-network/sd-ipv4ll.c | 25 +
>  2 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 397521e..9cd4c05 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -301,6 +301,7 @@ RT_LIBS="$LIBS"
>  AC_SUBST(RT_LIBS)
>  LIBS="$save_LIBS"
>
> +AC_CHECK_FUNCS([random_r])
>  AC_CHECK_FUNCS([fanotify_init fanotify_mark])
>  AC_CHECK_FUNCS([__secure_getenv secure_getenv])
>  AC_CHECK_DECLS([gettid, pivot_root, canonicalize_file_name, strndupa, 
> name_to_handle_at, setns, LO_FLAGS_PARTSCAN],
> diff --git a/src/libsystemd-network/sd-ipv4ll.c 
> b/src/libsystemd-network/sd-ipv4ll.c
> index 8b24331..5712350 100644
> --- a/src/libsystemd-network/sd-ipv4ll.c
> +++ b/src/libsystemd-network/sd-ipv4ll.c
> @@ -81,8 +81,10 @@ struct sd_ipv4ll {
>  usec_t defend_window;
>  int next_wakeup_valid;
>  be32_t address;
> +#ifdef HAVE_RANDOM_R
>  struct random_data *random_data;
>  char *random_data_state;
> +#endif
>  /* External */
>  be32_t claimed_address;
>  struct ether_addr mac_addr;
> @@ -141,18 +143,24 @@ static sd_ipv4ll *ipv4ll_stop(sd_ipv4ll *ll, int event) 
> {
>
>  static int ipv4ll_pick_address(sd_ipv4ll *ll, be32_t *address) {
>  be32_t addr;
> -int r;
> -int32_t random;
>
>  assert(ll);
>  assert(address);
> +#ifdef HAVE_RANDOM_R
>  assert(ll->random_data);
> +#endif
>
>  do {
> -r = random_r(ll->random_data, &random);
> +#ifdef HAVE_RANDOM_R
> +int32_t value;
> +int r = random_r(ll->random_data, &value);
> +
>  if (r < 0)
>  return r;
> -addr = htonl((random & 0x) | IPV4LL_NETWORK);
> +#else
> +long int value = random();
> +#endif
> +addr = htonl((value & 0x) | IPV4LL_NETWORK);
>  } while (addr == ll->address ||
>  (ntohl(addr) & IPV4LL_NETMASK) != IPV4LL_NETWORK ||
>  (ntohl(addr) & 0xFF00) == 0x ||
> @@ -481,6 +489,7 @@ int sd_ipv4ll_set_address_seed (sd_ipv4ll *ll, uint8_t 
> seed[8]) {
>
>  entropy = *seed;
>
> +#ifdef HAVE_RANDOM_R
>  free(ll->random_data);
>  free(ll->random_data_state);
>
> @@ -503,6 +512,10 @@ error:
>  ll->random_data = NULL;
>  ll->random_data_state = NULL;
>  }
> +#else
> +srandom(entropy);
> +r = 0;
> +#endif
>  return r;
>  }
>
> @@ -535,6 +548,7 @@ int sd_ipv4ll_start (sd_ipv4ll *ll) {
>  ll->defend_window = 0;
>  ll->claimed_address = 0;
>
> +#ifdef HAVE_RANDOM_R
>  if (!ll->random_data) {
>  uint8_t seed[8];
>
> @@ -546,6 +560,7 @@ int sd_ipv4ll_start (sd_ipv4ll *ll) {
>  if (r < 0)
>  goto out;
>  }
> +#endif
>
>  if (ll->address == 0) {
>  r = ipv4ll_pick_address(ll, &ll->address);
> @@ -614,8 +629,10 @@ sd_ipv4ll *sd_ipv4ll_unref(sd_ipv4ll *ll) {
>
>  sd_ipv4ll_detach_event(ll);
>
> +#ifdef HAVE_RANDOM_R
>  free(ll->random_data);
>  free(ll->random_data_state);
> +#endif
>  free(ll);
>
>  return NULL;
> --
> 2.1.0
>
> ___
> 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] [RFC 16/25] add fallback parse_printf_format implementation

2014-09-18 Thread Tom Gundersen
This sholud definitely go in your libc instead.

Cheers,

Tom

On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> ---
>  Makefile.am  |   4 +
>  configure.ac |   2 +
>  src/journal/journal-send.c   |   2 +-
>  src/shared/log.c |   2 +-
>  src/shared/parse-printf-format.c | 273 
> +++
>  src/shared/parse-printf-format.h |  57 
>  6 files changed, 338 insertions(+), 2 deletions(-)
>  create mode 100644 src/shared/parse-printf-format.c
>  create mode 100644 src/shared/parse-printf-format.h
>
> diff --git a/Makefile.am b/Makefile.am
> index 5dc17f8..7fc682f 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -879,6 +879,10 @@ libsystemd_shared_la_SOURCES = \
> src/shared/switch-root.c \
> src/shared/nss-util.h
>
> +if !HAVE_PRINTF_H
> +libsystemd_shared_la_SOURCES += src/shared/parse-printf-format.c
> +endif
> +
>  nodist_libsystemd_shared_la_SOURCES = \
> src/shared/errno-from-name.h \
> src/shared/errno-to-name.h \
> diff --git a/configure.ac b/configure.ac
> index 3db0e24..397521e 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -283,6 +283,8 @@ AM_CONDITIONAL([HAVE_PYTHON_DEVEL], [test 
> "$have_python_devel" = "yes"])
>  AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([*** Dynamic linking loader 
> library not found])])
>  AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps 
> headers not found])])
>  AC_CHECK_HEADERS([linux/btrfs.h], [], [])
> +AC_CHECK_HEADERS([printf.h], [], [])
> +AM_CONDITIONAL(HAVE_PRINTF_H, [test "x$ac_cv_header_printf_h" = xyes])
>
>  # unconditionally pull-in librt with old glibc versions
>  AC_SEARCH_LIBS([clock_gettime], [rt], [], [])
> diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
> index bb1ef66..9ca4a0b 100644
> --- a/src/journal/journal-send.c
> +++ b/src/journal/journal-send.c
> @@ -25,12 +25,12 @@
>  #include 
>  #include 
>  #include 
> -#include 
>
>  #define SD_JOURNAL_SUPPRESS_LOCATION
>
>  #include "sd-journal.h"
>  #include "util.h"
> +#include "parse-printf-format.h"
>  #include "socket-util.h"
>
>  #define SNDBUF_SIZE (8*1024*1024)
> diff --git a/src/shared/log.c b/src/shared/log.c
> index 26c604a..8e968f1 100644
> --- a/src/shared/log.c
> +++ b/src/shared/log.c
> @@ -27,11 +27,11 @@
>  #include 
>  #include 
>  #include 
> -#include 
>
>  #include "log.h"
>  #include "util.h"
>  #include "missing.h"
> +#include "parse-printf-format.h"
>  #include "macro.h"
>  #include "socket-util.h"
>
> diff --git a/src/shared/parse-printf-format.c 
> b/src/shared/parse-printf-format.c
> new file mode 100644
> index 000..49437e5
> --- /dev/null
> +++ b/src/shared/parse-printf-format.c
> @@ -0,0 +1,273 @@
> +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
> +
> +/***
> +  This file is part of systemd.
> +
> +  Copyright 2014 Emil Renner Berthing 
> +
> +  With parts from the musl C library
> +  Copyright 2005-2014 Rich Felker, et al.
> +
> +  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 "parse-printf-format.h"
> +
> +static const char *consume_nonarg(const char *fmt)
> +{
> +do {
> +if (*fmt == '\0')
> +return fmt;
> +} while (*fmt++ != '%');
> +return fmt;
> +}
> +
> +static const char *consume_num(const char *fmt)
> +{
> +for (;*fmt >= '0' && *fmt <= '9'; fmt++)
> +/* do nothing */;
> +return fmt;
> +}
> +
> +static const char *consume_argn(const char *fmt, size_t *arg)
> +{
> +const char *p = fmt;
> +size_t val = 0;
> +
> +if (*p < '1' || *p > '9')
> +return fmt;
> +do {
> +val = 10*val + (*p++ - '0');
> +} while (*p >= '0' && *p <= '9');
> +
> +if (*p != '$')
> +return fmt;
> +*arg = val;
> +return p+1;
> +}
> +
> +static const char *consume_flags(const char *fmt)
> +{
> +while (1) {
> +switch (*fmt) {
> +case '#':
> +case '0':
> +case '-':
> +case ' ':
> +case '+':
> +case '\'':
> +case 'I':
> +fmt++;
> +continue;
>

Re: [systemd-devel] [RFC 08/25] don't fail if GLOB_BRACE is not defined

2014-09-18 Thread Tom Gundersen
On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> If the standard library doesn't provide brace
> expansion users just won't get it.

I don't think we should do this, it would mean implicitly providing a
subtly different feature-set to users, which surely would lead to
confusion. I'd rather suggest implementing the missing features in the
libc.

Cheers,

Tom

> ---
>  src/shared/util.c   | 6 ++
>  src/tmpfiles/tmpfiles.c | 6 ++
>  2 files changed, 12 insertions(+)
>
> diff --git a/src/shared/util.c b/src/shared/util.c
> index 9157b2f..76899f5 100644
> --- a/src/shared/util.c
> +++ b/src/shared/util.c
> @@ -86,6 +86,12 @@
>  #include "virt.h"
>  #include "def.h"
>
> +/* Don't fail if the standard library
> + * doesn't provide brace expansion */
> +#ifndef GLOB_BRACE
> +#define GLOB_BRACE 0
> +#endif
> +
>  int saved_argc = 0;
>  char **saved_argv = NULL;
>
> diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
> index f9830c4..8e1b80a 100644
> --- a/src/tmpfiles/tmpfiles.c
> +++ b/src/tmpfiles/tmpfiles.c
> @@ -55,6 +55,12 @@
>  #include "build.h"
>  #include "copy.h"
>
> +/* Don't fail if the standard library
> + * doesn't provide brace expansion */
> +#ifndef GLOB_BRACE
> +#define GLOB_BRACE 0
> +#endif
> +
>  /* This reads all files listed in /etc/tmpfiles.d/?*.conf and creates
>   * them in the file system. This is intended to be used to create
>   * properly owned directories beneath /tmp, /var/tmp, /run, which are
> --
> 2.1.0
>
> ___
> 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] [RFC 04/25] sd-rtnl: rtnl-message: remove unneeded linux includes

2014-09-18 Thread Tom Gundersen
Applied. Thanks!

Tom

On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> ---
>  src/libsystemd/sd-rtnl/rtnl-message.c | 6 --
>  1 file changed, 6 deletions(-)
>
> diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c 
> b/src/libsystemd/sd-rtnl/rtnl-message.c
> index 30e3358..b501a52 100644
> --- a/src/libsystemd/sd-rtnl/rtnl-message.c
> +++ b/src/libsystemd/sd-rtnl/rtnl-message.c
> @@ -23,12 +23,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
> -#include 
>
>  #include "util.h"
>  #include "refcnt.h"
> --
> 2.1.0
>
> ___
> 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] [RFC 03/25] udev: link-config: remove unneded linux/netdevice.h include

2014-09-18 Thread Tom Gundersen
Applied. Thanks!

Tom

On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> ---
>  src/udev/net/link-config.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
> index ee2865a..25e3cc8 100644
> --- a/src/udev/net/link-config.c
> +++ b/src/udev/net/link-config.c
> @@ -20,7 +20,6 @@
>  ***/
>
>  #include 
> -#include 
>
>  #include "sd-id128.h"
>
> --
> 2.1.0
>
> ___
> 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] [RFC 15/25] shared/utmp-wtmp: don't fail if libc doesn't support utmpx/wtmpx

2014-09-18 Thread Tom Gundersen
On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing  wrote:
> I'd like to make utmp/wtmp handling a configure option,

I think that would make more sense (and serve the same purpose), so I
suggest doing that instead.

> but for
> now this is the minimal change needed to make it compile with musl.
> The musl utmp/wtmp functions doesn't do anything anyway.
> ---
>  src/shared/utmp-wtmp.c | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/shared/utmp-wtmp.c b/src/shared/utmp-wtmp.c
> index e0319f0..619d6d1 100644
> --- a/src/shared/utmp-wtmp.c
> +++ b/src/shared/utmp-wtmp.c
> @@ -63,8 +63,10 @@ int utmp_get_runlevel(int *runlevel, int *previous) {
>  return 0;
>  }
>
> +#ifdef _PATH_UTMPX
>  if (utmpxname(_PATH_UTMPX) < 0)
>  return -errno;
> +#endif
>
>  setutxent();
>
> @@ -124,8 +126,10 @@ static int write_entry_utmp(const struct utmpx *store) {
>   * each entry type resp. user; i.e. basically a key/value
>   * table. */
>
> +#ifdef _PATH_UTMPX
>  if (utmpxname(_PATH_UTMPX) < 0)
>  return -errno;
> +#endif
>
>  setutxent();
>
> @@ -146,7 +150,9 @@ static int write_entry_wtmp(const struct utmpx *store) {
>  simply appended to * the end; i.e. basically a log. */
>
>  errno = 0;
> +#ifdef _PATH_WTMPX
>  updwtmpx(_PATH_WTMPX, store);
> +#endif
>  return -errno;
>  }
>
> --
> 2.1.0
>
> ___
> 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] [RFC 00/25] Compile against the musl libc

2014-09-18 Thread Jóhann B. Guðmundsson


On 09/18/2014 02:20 PM, Philippe De Swert wrote:

Hi,

On 18/09/14 17:13, Emil Renner Berthing wrote:

On 18 September 2014 16:10, "Jóhann B. Guðmundsson"  wrote:

On 09/18/2014 01:24 PM, Emil Renner Berthing wrote:

The real reason is of course that I'd like to see systemd running
on my router and other small devices that usually run some OpenWRT
derivative.

The openwrt community is still going forward with their (re)-invention of
init system called procd since they were incapable of using systemd built
with --disable-alots right?

Or are you talking about you dont want to use OpenWRT but your own or
something else and thus the request?

Yes, indeed. Also I am hoping that having this option means other small
devices will run systemd in the future.

I think you are missing the point of musl So you have so little
space you need a smaller libc but then you want to use a binary of ~1MB
+ tools to replace an init of a few Kb?

Moreover systemd needs a lot more kernel options, so making smaller
kernels gets hard. Not to mention for example cgroups etc is often very
unstable in the earlier kernels that have the support for those devices.
IOW more kernel crashes due to systemd requiring cgroups.

The reason why OpenWrt would do their own init, is to keep it small.
Often those routers etc have only a few Mb of flash. Even with
compression just having a 2Mb just for the init system is a bit much.


It would be interesting to get some "how low can you go" numbers from 
the embedded crowd regarding systemd and or systemd + udev-hwdb.


I would think 16MiB target should be fairly easy to achieved but 
anything less than that might be well work...


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


Re: [systemd-devel] [RFC 13/25] shared/missing.h: check for missing strndupa

2014-09-18 Thread Cristian Rodríguez

El 18/09/14 a las #4, Emil Renner Berthing escribió:


+#if !HAVE_DECL_STRNDUPA
+#define strndupa(s, n) \
+  ({ \
+const char *__old = (s); \
+size_t __len = strnlen(__old, (n)); \
+char *__new = (char *)alloca(__len + 1); \
+__new[__len] = '\0'; \
+(char *)memcpy(__new, __old, __len); \
+  })
+#endif



No, get strndupa implemented in the C library instead.

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


Re: [systemd-devel] [RFC 12/25] shared/missing.h: check for missing canonicalize_file_name

2014-09-18 Thread Cristian Rodríguez

El 18/09/14 a las #4, Emil Renner Berthing escribió:


+#if !HAVE_DECL_CANONICALIZE_FILE_NAME
+static inline char *canonicalize_file_name(const char *path) {
+return realpath(path, NULL);
+}
+#endif



No, no reimplementations of library functions here, only wrappers for 
syscalls which glibc still does not include.

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


Re: [systemd-devel] [RFC 11/25] shared/missing.h: fall pack to insecure getenv

2014-09-18 Thread Cristian Rodríguez

El 18/09/14 a las #4, Emil Renner Berthing escribió:

---
  src/shared/missing.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/missing.h b/src/shared/missing.h
index b441149..8389c28 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -353,7 +353,7 @@ static inline int name_to_handle_at(int fd, const char 
*name, struct file_handle
  #  ifdef HAVE___SECURE_GETENV
  #define secure_getenv __secure_getenv
  #  else
-#error "neither secure_getenv nor __secure_getenv are available"
+#define secure_getenv getenv
  #  endif
  #endif




No. this patch in particular (and maybe the whole sumbbision) is 
unnaceptable..


Systemd is designed to work with glibc and only glibc is supported, be 
comatible with it and there will be no need for any of this.


I suggest not to apply these series at all.

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


Re: [systemd-devel] [RFC 00/25] Compile against the musl libc

2014-09-18 Thread Philippe De Swert
Hi,

On 18/09/14 17:13, Emil Renner Berthing wrote:
> On 18 September 2014 16:10, "Jóhann B. Guðmundsson"  
> wrote:
>> On 09/18/2014 01:24 PM, Emil Renner Berthing wrote:
>>> The real reason is of course that I'd like to see systemd running
>>> on my router and other small devices that usually run some OpenWRT
>>> derivative.
>>
>> The openwrt community is still going forward with their (re)-invention of
>> init system called procd since they were incapable of using systemd built
>> with --disable-alots right?
>>
>> Or are you talking about you dont want to use OpenWRT but your own or
>> something else and thus the request?
> 
> Yes, indeed. Also I am hoping that having this option means other small
> devices will run systemd in the future.

I think you are missing the point of musl So you have so little
space you need a smaller libc but then you want to use a binary of ~1MB
+ tools to replace an init of a few Kb?

Moreover systemd needs a lot more kernel options, so making smaller
kernels gets hard. Not to mention for example cgroups etc is often very
unstable in the earlier kernels that have the support for those devices.
IOW more kernel crashes due to systemd requiring cgroups.

The reason why OpenWrt would do their own init, is to keep it small.
Often those routers etc have only a few Mb of flash. Even with
compression just having a 2Mb just for the init system is a bit much.

Regards,

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


Re: [systemd-devel] [RFC 00/25] Compile against the musl libc

2014-09-18 Thread Emil Renner Berthing
On 18 September 2014 16:10, "Jóhann B. Guðmundsson"  wrote:
> On 09/18/2014 01:24 PM, Emil Renner Berthing wrote:
>> The real reason is of course that I'd like to see systemd running
>> on my router and other small devices that usually run some OpenWRT
>> derivative.
>
> The openwrt community is still going forward with their (re)-invention of
> init system called procd since they were incapable of using systemd built
> with --disable-alots right?
>
> Or are you talking about you dont want to use OpenWRT but your own or
> something else and thus the request?

Yes, indeed. Also I am hoping that having this option means other small
devices will run systemd in the future.

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


Re: [systemd-devel] [RFC 00/25] Compile against the musl libc

2014-09-18 Thread Jóhann B. Guðmundsson


On 09/18/2014 01:24 PM, Emil Renner Berthing wrote:

The real reason is of course that I'd like to see systemd running
on my router and other small devices that usually run some OpenWRT
derivative.


The openwrt community is still going forward with their (re)-invention 
of init system called procd since they were incapable of using systemd 
built with --disable-alots right?


Or are you talking about you dont want to use OpenWRT but your own or 
something else and thus the request?


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


Re: [systemd-devel] [RFC 11/25] shared/missing.h: fall pack to insecure getenv

2014-09-18 Thread Emil Renner Berthing
On 18 September 2014 15:56, Karol Lewandowski  wrote:>
> I think it would be way better (and easy) to reimplement original
> secure_getenv() rather than falling back to function with different
> semantics.  secure_ is there for a reason.

Agreed. Added to my TODO, thanks.

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


Re: [systemd-devel] cdrom_id opens device with O_EXCL, why?

2014-09-18 Thread Hoyer, Marko (ADITG/SW2)
> -Original Message-
> From: David Herrmann [mailto:dh.herrm...@gmail.com]
> Sent: Thursday, September 18, 2014 1:57 PM
> To: Hoyer, Marko (ADITG/SW2)
> Cc: systemd-devel@lists.freedesktop.org; Harald Hoyer; Kay Sievers
> Subject: Re: [systemd-devel] cdrom_id opens device with O_EXCL, why?
> 
> Hi again
> 
> On Thu, Sep 18, 2014 at 1:34 PM, David Herrmann  wrote:
> > I'm putting Harald and Kay on CC, as they added O_EXCL to protect
> > against parallel burning-sessions. Maybe they can tell you whether
> > that is still needed today and whether we can drop it.
> 
> So my conception of O_EXCL was kinda wrong. O_EXCL on block devices fails with
> EBUSY if, and only if, there's someone else also opening the device with
> O_EXCL. You can still open it without O_EXCL. Now, the kernel-internal mount
> helpers always keep O_EXCL for mounted block devices. This way, user-space can
> open block devices via O_EXCL and be sure no-one can mount it in parallel.
> 

Yeah that's true, that's what I found as well. But exactly this parallel try to 
mount
the device while cdrom_id is working is the problem here. I understand that it 
is needed for
some processes to get exclusive access to a device for good reasons (to prevent 
mounting for instance).
I'd like to understand the reason for cdrom_id especially since it gets only 
exclusive access if no
one mounted the device before.

> For your automounter, this means you should just drop the event on EBUSY. If
> udev was the offender, you will get a follow-up event. If fsck was the
> offender, you're screwed anyway as it takes ages to complete (but fsck
> shouldn't be any problem for the automounter, anyway). if anyone else is the
> offender, you have no idea what they do, so you should just fail right away.

I've to think about just kicking the event. My first guess is that it is a kind 
of complicated
because there is a comparable complex state machine in the background. My way 
out would be probably
implementing a retry mechanism for the mounting. That would cover all you 
suggested as well, I guess.

> 
> Regarding lazy-unmount: It'd require kernel support to notice such usage in
> user-space. I don't plan on working on this (and nobody really cares). But if
> there will be a kernel-interface, we'd gladly accept patches to fix cdrom_id.

I'm not really happy with the lazy umount mechanism as well especially with the 
completely untransparent behavior in the background.
But in my case it seems to be the only way out. The thing is that I cannot 
guarantee that some applications just keeps i-nodes of
a mounted sd-card for instance (just "cd"ing into the subtree is enough). But I 
have to react somehow if the card is removed. There are two options:

1. I'm not unmounting the partition.
- In principal, this is somehow ok (not nice), any further IO access 
leads to IO errors. 
- Since the mount point is still available, other applications can 
enter as well (ok, but not nice)
- The shit happens when now someone inserts another sd card
-> I'm not able to mount the partition (with same number) of 
the new sda card since the device node is still mounted
-> Applications entering the mount point are getting lots of 
rubbish when they access i-nodes linked to cached parent nodes (the files in 
the root dir for instance)
So this is really not a good way out here.

2. I'm lazy umounting the partition so that the scope is really only limited to 
applications that are keeping i-nodes and only to the i-nodes that are kept.
- No other application can access the invalid cached i-nodes any more
- I can mount a new sd card without any problems even if we have the 
same partition number
- The kept i-nodes are removed automatically when the application 
decides to release them
- Part of the shit remains:
-> The application keeping the i-node are getting still rubbish 
in case a new card is inserted. But only this one application.
Well the world is not perfect.

So back to the initial question. Is there still a valid reason why cdrom_id is 
acquiring exclusive access? The cd buring case is at least for me not really a 
problem. If this is the only reason I could simply locally patch it out. But to 
be honest, I can't really imagine how this mechanism could even help with this 
use case ...

> 
> Thanks
> David

Regards,

Marko

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


Re: [systemd-devel] [RFC 11/25] shared/missing.h: fall pack to insecure getenv

2014-09-18 Thread Karol Lewandowski
On 2014-09-18 15:24, Emil Renner Berthing wrote:
> ---
>  src/shared/missing.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/shared/missing.h b/src/shared/missing.h
> index b441149..8389c28 100644
> --- a/src/shared/missing.h
> +++ b/src/shared/missing.h
> @@ -353,7 +353,7 @@ static inline int name_to_handle_at(int fd, const char 
> *name, struct file_handle
>  #  ifdef HAVE___SECURE_GETENV
>  #define secure_getenv __secure_getenv
>  #  else
> -#error "neither secure_getenv nor __secure_getenv are available"
> +#define secure_getenv getenv

I think it would be way better (and easy) to reimplement original
secure_getenv() rather than falling back to function with different
semantics.  secure_ is there for a reason.

Cheers,
-- 
Karol Lewandowski, Samsung R&D Institute Poland
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/3] journal: Do not count on the compiler initializing found_last to false

2014-09-18 Thread David Herrmann
Hi

On Tue, Sep 16, 2014 at 11:27 PM,   wrote:
> From: Philippe De Swert 
>
> There is a very unlikely case where this can happen since gcc usually
> does the sane thing. But let's make sure found_last is initialized anyway.

Applied.

Thanks
David

>
> Fixes: CID#996386
> ---
>  src/journal/journal-verify.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c
> index 6c8ca8c..b4e8f73 100644
> --- a/src/journal/journal-verify.c
> +++ b/src/journal/journal-verify.c
> @@ -804,7 +804,7 @@ int journal_file_verify(
>  usec_t last_usec = 0;
>  int data_fd = -1, entry_fd = -1, entry_array_fd = -1;
>  unsigned i;
> -bool found_last;
> +bool found_last = false;
>  #ifdef HAVE_GCRYPT
>  uint64_t last_tag = 0;
>  #endif
> --
> 1.8.3.2
>
> ___
> 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] [PATCH] man: use the escape for "-" in example instead of space.

2014-09-18 Thread David Herrmann
Hi

On Mon, Sep 15, 2014 at 11:07 PM, Michael Marineau
 wrote:
> This sentence can be misread to mean that "\x20" is the escape code for
> "-" which is the only character explicitly mentioned. This lead to at
> least one user loosing hair over why a mount unit for "/foo/bar-baz"
> didn't work. The example escape is arbitrary so lets prevent hair loss.

Applied.

Thanks
David

> ---
>  man/systemd.unit.xml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
> index 6ea552e..67d46ed 100644
> --- a/man/systemd.unit.xml
> +++ b/man/systemd.unit.xml
> @@ -226,7 +226,7 @@
>  result is usable as part of a filename. Basically,
>  given a path, "/" is replaced by "-", and all
>  unprintable characters and the "-" are replaced by
> -C-style "\x20" escapes. The root directory "/" is
> +C-style "\x2d" escapes. The root directory "/" is
>  encoded as single dash, while otherwise the initial
>  and ending "/" is removed from all paths during
>  transformation. This escaping is reversible.
> --
> 1.8.5.5
>
> ___
> 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] [PATCH] udev: always resolve correctly database names on 'change' event

2014-09-18 Thread David Herrmann
Hi

On Mon, Sep 15, 2014 at 2:03 PM, Robert Milasan  wrote:
> On Sat, 13 Sep 2014 15:29:23 +0200
> "Robert Milasan"  wrote:
>
>> Hello, I've found a lingering bug in udev since udev changed it's
>> database name from long names to short names 'ex: b9:1'.
>>
>> The bug is more visible or reproducible on s390(x) has there, we can
>> remove and add dasd disk/partitions.
>>
>> The outcome of the bug is that when removing and re-adding a
>> disk/partition, most or some of the links are not removed correctly or
>> at all. This leads to multiple UUID links for a single partition or
>> stale links in /dev/disk/{by-uuid,by-id}.
>>
>> How to reproduce:
>>
>> dasdfmt -b 4096 -v -y -f /dev/dasdb
>> fdasd -a /dev/dasdb
>> mke2fs /dev/dasdb1
>>
>> repeat this again and you will notice that /dev/dasdb1 has 2 or more
>> UUID links in /dev/disk/by-uuid.
>>
>> If you do not repeat this, just do 'dasdfmt -b 4096 -v -y
>> -f /dev/dasdb' the UUID link to /dev/dasdb1 will be stale, just the
>> same as /dev/disk/by-id links.
>>
>> NOTE: this bug might affect x86 machines too, but it might not be
>> visible (not sure).
>>
>> The issue is due to when there is a change event before the remove
>> event for dasdb/dasdb1, we are trying to resolve the database name
>> into ':', but event->dev_db doesn't get fill-up
>> with devnum (:) information, resulting in a database
>> name "+block:dasdb1", which doesn't exist.
>>
>> I've attached the patch, please review it and push it if there is no
>> complains :)
>>
>
> Will anybody be so kind and push the patch to systemd git.

I added a commit-message based on your email and then applied this patch.

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


[systemd-devel] [RFC 18/25] sd-ipv4all: fall back to random if no random_r

2014-09-18 Thread Emil Renner Berthing
---
 configure.ac   |  1 +
 src/libsystemd-network/sd-ipv4ll.c | 25 +
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 397521e..9cd4c05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -301,6 +301,7 @@ RT_LIBS="$LIBS"
 AC_SUBST(RT_LIBS)
 LIBS="$save_LIBS"
 
+AC_CHECK_FUNCS([random_r])
 AC_CHECK_FUNCS([fanotify_init fanotify_mark])
 AC_CHECK_FUNCS([__secure_getenv secure_getenv])
 AC_CHECK_DECLS([gettid, pivot_root, canonicalize_file_name, strndupa, 
name_to_handle_at, setns, LO_FLAGS_PARTSCAN],
diff --git a/src/libsystemd-network/sd-ipv4ll.c 
b/src/libsystemd-network/sd-ipv4ll.c
index 8b24331..5712350 100644
--- a/src/libsystemd-network/sd-ipv4ll.c
+++ b/src/libsystemd-network/sd-ipv4ll.c
@@ -81,8 +81,10 @@ struct sd_ipv4ll {
 usec_t defend_window;
 int next_wakeup_valid;
 be32_t address;
+#ifdef HAVE_RANDOM_R
 struct random_data *random_data;
 char *random_data_state;
+#endif
 /* External */
 be32_t claimed_address;
 struct ether_addr mac_addr;
@@ -141,18 +143,24 @@ static sd_ipv4ll *ipv4ll_stop(sd_ipv4ll *ll, int event) {
 
 static int ipv4ll_pick_address(sd_ipv4ll *ll, be32_t *address) {
 be32_t addr;
-int r;
-int32_t random;
 
 assert(ll);
 assert(address);
+#ifdef HAVE_RANDOM_R
 assert(ll->random_data);
+#endif
 
 do {
-r = random_r(ll->random_data, &random);
+#ifdef HAVE_RANDOM_R
+int32_t value;
+int r = random_r(ll->random_data, &value);
+
 if (r < 0)
 return r;
-addr = htonl((random & 0x) | IPV4LL_NETWORK);
+#else
+long int value = random();
+#endif
+addr = htonl((value & 0x) | IPV4LL_NETWORK);
 } while (addr == ll->address ||
 (ntohl(addr) & IPV4LL_NETMASK) != IPV4LL_NETWORK ||
 (ntohl(addr) & 0xFF00) == 0x ||
@@ -481,6 +489,7 @@ int sd_ipv4ll_set_address_seed (sd_ipv4ll *ll, uint8_t 
seed[8]) {
 
 entropy = *seed;
 
+#ifdef HAVE_RANDOM_R
 free(ll->random_data);
 free(ll->random_data_state);
 
@@ -503,6 +512,10 @@ error:
 ll->random_data = NULL;
 ll->random_data_state = NULL;
 }
+#else
+srandom(entropy);
+r = 0;
+#endif
 return r;
 }
 
@@ -535,6 +548,7 @@ int sd_ipv4ll_start (sd_ipv4ll *ll) {
 ll->defend_window = 0;
 ll->claimed_address = 0;
 
+#ifdef HAVE_RANDOM_R
 if (!ll->random_data) {
 uint8_t seed[8];
 
@@ -546,6 +560,7 @@ int sd_ipv4ll_start (sd_ipv4ll *ll) {
 if (r < 0)
 goto out;
 }
+#endif
 
 if (ll->address == 0) {
 r = ipv4ll_pick_address(ll, &ll->address);
@@ -614,8 +629,10 @@ sd_ipv4ll *sd_ipv4ll_unref(sd_ipv4ll *ll) {
 
 sd_ipv4ll_detach_event(ll);
 
+#ifdef HAVE_RANDOM_R
 free(ll->random_data);
 free(ll->random_data_state);
+#endif
 free(ll);
 
 return NULL;
-- 
2.1.0

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


[systemd-devel] [RFC 23/25] mount: order options before other arguments to mount

2014-09-18 Thread Emil Renner Berthing
---
 src/core/mount.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/core/mount.c b/src/core/mount.c
index e284357..f3ec736 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -903,10 +903,10 @@ static void mount_enter_mounting(Mount *m) {
 m->control_command,
 "/bin/mount",
 m->sloppy_options ? "-ns" : "-n",
+"-t", m->parameters_fragment.fstype ? 
m->parameters_fragment.fstype : "auto",
+"-o", m->parameters_fragment.options ? 
m->parameters_fragment.options : "",
 m->parameters_fragment.what,
 m->where,
-"-t", m->parameters_fragment.fstype ? 
m->parameters_fragment.fstype : "auto",
-m->parameters_fragment.options ? "-o" : NULL, 
m->parameters_fragment.options,
 NULL);
 else
 r = -ENOENT;
@@ -951,10 +951,10 @@ static void mount_enter_remounting(Mount *m) {
 m->control_command,
 "/bin/mount",
 m->sloppy_options ? "-ns" : "-n",
-m->parameters_fragment.what,
-m->where,
 "-t", m->parameters_fragment.fstype ? 
m->parameters_fragment.fstype : "auto",
 "-o", o,
+m->parameters_fragment.what,
+m->where,
 NULL);
 } else
 r = -ENOENT;
-- 
2.1.0

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


[systemd-devel] [RFC 25/25] add -z muldefs to linker flags

2014-09-18 Thread Emil Renner Berthing
In case we don't have the new gold linker,
linking with ld fails without this option.
---
 configure.ac | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure.ac b/configure.ac
index 3f17833..4be6e08 100644
--- a/configure.ac
+++ b/configure.ac
@@ -216,6 +216,7 @@ CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
 -Wl,--gc-sections \
 -Wl,-z,relro \
 -Wl,-z,now \
+-Wl,-z,muldefs \
 -pie \
 -Wl,-fuse-ld=gold])
 AC_SUBST([OUR_LDFLAGS], "$with_ldflags $sanitizer_ldflags")
-- 
2.1.0

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


[systemd-devel] [RFC 16/25] add fallback parse_printf_format implementation

2014-09-18 Thread Emil Renner Berthing
---
 Makefile.am  |   4 +
 configure.ac |   2 +
 src/journal/journal-send.c   |   2 +-
 src/shared/log.c |   2 +-
 src/shared/parse-printf-format.c | 273 +++
 src/shared/parse-printf-format.h |  57 
 6 files changed, 338 insertions(+), 2 deletions(-)
 create mode 100644 src/shared/parse-printf-format.c
 create mode 100644 src/shared/parse-printf-format.h

diff --git a/Makefile.am b/Makefile.am
index 5dc17f8..7fc682f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -879,6 +879,10 @@ libsystemd_shared_la_SOURCES = \
src/shared/switch-root.c \
src/shared/nss-util.h
 
+if !HAVE_PRINTF_H
+libsystemd_shared_la_SOURCES += src/shared/parse-printf-format.c
+endif
+
 nodist_libsystemd_shared_la_SOURCES = \
src/shared/errno-from-name.h \
src/shared/errno-to-name.h \
diff --git a/configure.ac b/configure.ac
index 3db0e24..397521e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -283,6 +283,8 @@ AM_CONDITIONAL([HAVE_PYTHON_DEVEL], [test 
"$have_python_devel" = "yes"])
 AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([*** Dynamic linking loader 
library not found])])
 AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps headers 
not found])])
 AC_CHECK_HEADERS([linux/btrfs.h], [], [])
+AC_CHECK_HEADERS([printf.h], [], [])
+AM_CONDITIONAL(HAVE_PRINTF_H, [test "x$ac_cv_header_printf_h" = xyes])
 
 # unconditionally pull-in librt with old glibc versions
 AC_SEARCH_LIBS([clock_gettime], [rt], [], [])
diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
index bb1ef66..9ca4a0b 100644
--- a/src/journal/journal-send.c
+++ b/src/journal/journal-send.c
@@ -25,12 +25,12 @@
 #include 
 #include 
 #include 
-#include 
 
 #define SD_JOURNAL_SUPPRESS_LOCATION
 
 #include "sd-journal.h"
 #include "util.h"
+#include "parse-printf-format.h"
 #include "socket-util.h"
 
 #define SNDBUF_SIZE (8*1024*1024)
diff --git a/src/shared/log.c b/src/shared/log.c
index 26c604a..8e968f1 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -27,11 +27,11 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "log.h"
 #include "util.h"
 #include "missing.h"
+#include "parse-printf-format.h"
 #include "macro.h"
 #include "socket-util.h"
 
diff --git a/src/shared/parse-printf-format.c b/src/shared/parse-printf-format.c
new file mode 100644
index 000..49437e5
--- /dev/null
+++ b/src/shared/parse-printf-format.c
@@ -0,0 +1,273 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2014 Emil Renner Berthing 
+
+  With parts from the musl C library
+  Copyright 2005-2014 Rich Felker, et al.
+
+  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 "parse-printf-format.h"
+
+static const char *consume_nonarg(const char *fmt)
+{
+do {
+if (*fmt == '\0')
+return fmt;
+} while (*fmt++ != '%');
+return fmt;
+}
+
+static const char *consume_num(const char *fmt)
+{
+for (;*fmt >= '0' && *fmt <= '9'; fmt++)
+/* do nothing */;
+return fmt;
+}
+
+static const char *consume_argn(const char *fmt, size_t *arg)
+{
+const char *p = fmt;
+size_t val = 0;
+
+if (*p < '1' || *p > '9')
+return fmt;
+do {
+val = 10*val + (*p++ - '0');
+} while (*p >= '0' && *p <= '9');
+
+if (*p != '$')
+return fmt;
+*arg = val;
+return p+1;
+}
+
+static const char *consume_flags(const char *fmt)
+{
+while (1) {
+switch (*fmt) {
+case '#':
+case '0':
+case '-':
+case ' ':
+case '+':
+case '\'':
+case 'I':
+fmt++;
+continue;
+}
+return fmt;
+}
+}
+
+enum state {
+BARE,
+LPRE,
+LLPRE,
+HPRE,
+HHPRE,
+BIGLPRE,
+ZTPRE,
+JPRE,
+STOP
+};
+
+enum type {
+NONE,
+PTR,
+INT,
+UINT,
+ULLONG,
+LONG,
+ULONG,
+SHORT,
+USHORT,
+CHAR,
+UCHAR,
+LLONG,
+S

[systemd-devel] [RFC 24/25] units: order options before other arguments

2014-09-18 Thread Emil Renner Berthing
---
 units/initrd-udevadm-cleanup-db.service.in | 2 +-
 units/kmod-static-nodes.service.in | 2 +-
 units/systemd-journal-flush.service.in | 2 +-
 units/systemd-udev-hwdb-update.service.in  | 2 +-
 units/systemd-udev-trigger.service.in  | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/units/initrd-udevadm-cleanup-db.service.in 
b/units/initrd-udevadm-cleanup-db.service.in
index 5c6654e..3ec5451 100644
--- a/units/initrd-udevadm-cleanup-db.service.in
+++ b/units/initrd-udevadm-cleanup-db.service.in
@@ -15,4 +15,4 @@ Before=initrd-switch-root.target
 
 [Service]
 Type=oneshot
-ExecStart=-@rootbindir@/udevadm info --cleanup-db
+ExecStart=-@rootbindir@/udevadm --cleanup-db info
diff --git a/units/kmod-static-nodes.service.in 
b/units/kmod-static-nodes.service.in
index 0934a87..1b5e71d 100644
--- a/units/kmod-static-nodes.service.in
+++ b/units/kmod-static-nodes.service.in
@@ -15,4 +15,4 @@ ConditionPathExists=/lib/modules/%v/modules.devname
 [Service]
 Type=oneshot
 RemainAfterExit=yes
-ExecStart=@KMOD@ static-nodes --format=tmpfiles 
--output=/run/tmpfiles.d/kmod.conf
+ExecStart=@KMOD@ --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf 
static-nodes
diff --git a/units/systemd-journal-flush.service.in 
b/units/systemd-journal-flush.service.in
index 503e8a6..29b9342 100644
--- a/units/systemd-journal-flush.service.in
+++ b/units/systemd-journal-flush.service.in
@@ -14,5 +14,5 @@ After=systemd-journald.service local-fs.target 
remote-fs.target
 Before=systemd-user-sessions.service
 
 [Service]
-ExecStart=@rootbindir@/systemctl kill --kill-who=main --signal=SIGUSR1 
systemd-journald.service
+ExecStart=@rootbindir@/systemctl --kill-who=main --signal=SIGUSR1 kill 
systemd-journald.service
 Type=oneshot
diff --git a/units/systemd-udev-hwdb-update.service.in 
b/units/systemd-udev-hwdb-update.service.in
index 153d93c..ec4b8c4 100644
--- a/units/systemd-udev-hwdb-update.service.in
+++ b/units/systemd-udev-hwdb-update.service.in
@@ -17,4 +17,4 @@ ConditionNeedsUpdate=/etc
 [Service]
 Type=oneshot
 RemainAfterExit=yes
-ExecStart=@rootbindir@/udevadm hwdb --update
+ExecStart=@rootbindir@/udevadm --update hwdb
diff --git a/units/systemd-udev-trigger.service.in 
b/units/systemd-udev-trigger.service.in
index 0c33909..101adaf 100644
--- a/units/systemd-udev-trigger.service.in
+++ b/units/systemd-udev-trigger.service.in
@@ -17,4 +17,4 @@ ConditionPathIsReadWrite=/sys
 [Service]
 Type=oneshot
 RemainAfterExit=yes
-ExecStart=@rootbindir@/udevadm trigger --type=subsystems --action=add ; 
@rootbindir@/udevadm trigger --type=devices --action=add
+ExecStart=@rootbindir@/udevadm --type=subsystems --action=add trigger ; 
@rootbindir@/udevadm --type=devices --action=add trigger
-- 
2.1.0

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


[systemd-devel] [RFC 22/25] support POSIX strerror_r returning int

2014-09-18 Thread Emil Renner Berthing
---
 configure.ac  |  2 ++
 src/journal/journal-send.c| 36 +++-
 src/libsystemd/sd-bus/bus-error.c | 14 +-
 3 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9cd4c05..3f17833 100644
--- a/configure.ac
+++ b/configure.ac
@@ -336,6 +336,8 @@ AC_CHECK_DECLS([IFLA_MACVLAN_FLAGS,
 #include 
 ]])
 
+AC_FUNC_STRERROR_R
+
 # This makes sure pkg.m4 is available.
 m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install 
pkg-config])
 
diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
index 9ca4a0b..62b40b2 100644
--- a/src/journal/journal-send.c
+++ b/src/journal/journal-send.c
@@ -341,6 +341,29 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int 
n) {
 return 0;
 }
 
+#ifdef STRERROR_R_CHAR_P
+static int posix_strerror_r(int errnum, char *buf, size_t buflen) {
+char *res;
+
+errno = 0;
+res = strerror_r(errnum, buf, buflen);
+if (errno)
+return errno;
+
+if (res != buf) {
+size_t len = strlen(res)+1;
+
+if (len > buflen)
+return ERANGE;
+
+memmove(buf, res, len);
+}
+return 0;
+}
+#else
+#define posix_strerror_r strerror_r
+#endif
+
 static int fill_iovec_perror_and_send(const char *message, int skip, struct 
iovec iov[]) {
 PROTECT_ERRNO;
 size_t n, k;
@@ -350,16 +373,11 @@ static int fill_iovec_perror_and_send(const char 
*message, int skip, struct iove
 
 for (;;) {
 char buffer[n];
-char* j;
+int ret = posix_strerror_r(_saved_errno_, buffer + 8 + k, n - 
8 - k);
 
-errno = 0;
-j = strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k);
-if (errno == 0) {
+if (ret == 0) {
 char error[6 + 10 + 1]; /* for a 32bit value */
 
-if (j != buffer + 8 + k)
-memmove(buffer + 8 + k, j, strlen(j)+1);
-
 memcpy(buffer, "MESSAGE=", 8);
 
 if (k > 0) {
@@ -377,8 +395,8 @@ static int fill_iovec_perror_and_send(const char *message, 
int skip, struct iove
 return sd_journal_sendv(iov, skip + 3);
 }
 
-if (errno != ERANGE)
-return -errno;
+if (ret != ERANGE)
+return -ret;
 
 n *= 2;
 }
diff --git a/src/libsystemd/sd-bus/bus-error.c 
b/src/libsystemd/sd-bus/bus-error.c
index c2e41fb..14bbaca 100644
--- a/src/libsystemd/sd-bus/bus-error.c
+++ b/src/libsystemd/sd-bus/bus-error.c
@@ -291,6 +291,18 @@ _public_ int sd_bus_error_get_errno(const sd_bus_error* e) 
{
 return bus_error_name_to_errno(e->name);
 }
 
+#ifdef STRERROR_R_CHAR_P
+#define gnu_strerror_r strerror_r
+#else
+static char *gnu_strerror_r(int errnum, char *buf, size_t buflen) {
+int ret = strerror_r(errnum, buf, buflen);
+
+if (ret)
+errno = ret;
+return buf;
+}
+#endif
+
 static void bus_error_strerror(sd_bus_error *e, int error) {
 size_t k = 64;
 char *m;
@@ -305,7 +317,7 @@ static void bus_error_strerror(sd_bus_error *e, int error) {
 return;
 
 errno = 0;
-x = strerror_r(error, m, k);
+x = gnu_strerror_r(error, m, k);
 if (errno == ERANGE || strlen(x) >= k - 1) {
 free(m);
 k *= 2;
-- 
2.1.0

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


[systemd-devel] [RFC 17/25] dhcp-internal.h: add fallback IPTOS_CLASS_CS6 definition

2014-09-18 Thread Emil Renner Berthing
---
 src/libsystemd-network/dhcp-internal.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/libsystemd-network/dhcp-internal.h 
b/src/libsystemd-network/dhcp-internal.h
index 1069c8a..f6d15c3 100644
--- a/src/libsystemd-network/dhcp-internal.h
+++ b/src/libsystemd-network/dhcp-internal.h
@@ -31,6 +31,10 @@
 #include "sd-dhcp-client.h"
 #include "dhcp-protocol.h"
 
+#ifndef IPTOS_CLASS_CS6
+#define IPTOS_CLASS_CS6 0xc0
+#endif
+
 int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link, 
uint32_t xid, struct ether_addr mac_addr);
 int dhcp_network_bind_udp_socket(be32_t address, uint16_t port);
 int dhcp_network_send_raw_socket(int s, const union sockaddr_union *link,
-- 
2.1.0

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


[systemd-devel] [RFC 19/25] mount-setup: skip relabelling when SELinux and SMACK not supported

2014-09-18 Thread Emil Renner Berthing
This is also the only place where FTW_ACTIONRETVAL is used, so
this makes systemd compile without SELinux or SMACK support
when the standard library doesn't support this extension.
---
 src/core/mount-setup.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
index 23a66d2..8e91217 100644
--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -351,6 +351,7 @@ int mount_cgroup_controllers(char ***join_controllers) {
 return 0;
 }
 
+#if defined(HAVE_SELINUX) || defined(HAVE_SMACK)
 static int nftw_cb(
 const char *fpath,
 const struct stat *sb,
@@ -372,6 +373,7 @@ static int nftw_cb(
 
 return FTW_CONTINUE;
 };
+#endif
 
 int mount_setup(bool loaded_policy) {
 int r;
@@ -384,6 +386,7 @@ int mount_setup(bool loaded_policy) {
 return r;
 }
 
+#if defined(HAVE_SELINUX) || defined(HAVE_SMACK)
 /* Nodes in devtmpfs and /run need to be manually updated for
  * the appropriate labels, after mounting. The other virtual
  * API file systems like /sys and /proc do not need that, they
@@ -402,6 +405,7 @@ int mount_setup(bool loaded_policy) {
 log_info("Relabelled /dev and /run in %s.",
  format_timespan(timespan, sizeof(timespan), 
after_relabel - before_relabel, 0));
 }
+#endif
 
 /* Create a few default symlinks, which are normally created
  * by udevd, but some scripts might need them before we start
-- 
2.1.0

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


[systemd-devel] [RFC 20/25] udevadm-hwdb: don't use glibc-specific qsort_r

2014-09-18 Thread Emil Renner Berthing
---
 src/udev/udevadm-hwdb.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
index 65cbf61..3f31662 100644
--- a/src/udev/udevadm-hwdb.c
+++ b/src/udev/udevadm-hwdb.c
@@ -123,13 +123,13 @@ static void trie_node_cleanup(struct trie_node *node) {
 free(node);
 }
 
-static int trie_values_cmp(const void *v1, const void *v2, void *arg) {
+static struct trie *trie_node_add_value_trie;
+static int trie_values_cmp(const void *v1, const void *v2) {
 const struct trie_value_entry *val1 = v1;
 const struct trie_value_entry *val2 = v2;
-struct trie *trie = arg;
 
-return strcmp(trie->strings->buf + val1->key_off,
-  trie->strings->buf + val2->key_off);
+return strcmp(trie_node_add_value_trie->strings->buf + val1->key_off,
+  trie_node_add_value_trie->strings->buf + val2->key_off);
 }
 
 static int trie_node_add_value(struct trie *trie, struct trie_node *node,
@@ -150,7 +150,9 @@ static int trie_node_add_value(struct trie *trie, struct 
trie_node *node,
 .value_off = v,
 };
 
-val = xbsearch_r(&search, node->values, node->values_count, 
sizeof(struct trie_value_entry), trie_values_cmp, trie);
+trie_node_add_value_trie = trie;
+val = bsearch(&search, node->values, node->values_count, 
sizeof(struct trie_value_entry), trie_values_cmp);
+trie_node_add_value_trie = NULL;
 if (val) {
 /* replace existing earlier key with new value */
 val->value_off = v;
@@ -167,7 +169,9 @@ static int trie_node_add_value(struct trie *trie, struct 
trie_node *node,
 node->values[node->values_count].key_off = k;
 node->values[node->values_count].value_off = v;
 node->values_count++;
-qsort_r(node->values, node->values_count, sizeof(struct 
trie_value_entry), trie_values_cmp, trie);
+trie_node_add_value_trie = trie;
+qsort(node->values, node->values_count, sizeof(struct 
trie_value_entry), trie_values_cmp);
+trie_node_add_value_trie = NULL;
 return 0;
 }
 
-- 
2.1.0

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


[systemd-devel] [RFC 21/25] make sure basename that doesn't alter it's argument

2014-09-18 Thread Emil Renner Berthing
---
 src/core/execute.c  |  6 +++---
 src/core/load-fragment.c|  2 +-
 src/core/manager.c  |  2 +-
 src/core/unit.c |  4 ++--
 src/delta/delta.c   | 14 +++---
 src/journal/journalctl.c|  2 +-
 src/locale/localectl.c  |  2 +-
 src/login/logind-inhibit.c  |  2 +-
 src/login/logind-seat.c |  2 +-
 src/login/logind-session.c  |  2 +-
 src/nspawn/nspawn.c |  2 +-
 src/shared/cgroup-show.c|  4 ++--
 src/shared/conf-files.c |  4 ++--
 src/shared/install.c| 14 +++---
 src/shared/path-util.c  |  8 
 src/shared/path-util.h  |  5 +
 src/shared/util.c   |  4 ++--
 src/shared/utmp-wtmp.c  |  2 +-
 src/systemctl/systemctl.c   | 12 ++--
 src/sysv-generator/sysv-generator.c |  4 ++--
 src/test/test-install.c | 18 +-
 src/test/test-path-util.c   |  8 
 22 files changed, 68 insertions(+), 55 deletions(-)

diff --git a/src/core/execute.c b/src/core/execute.c
index e73eb8e..77724ce 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -912,7 +912,7 @@ static void rename_process_from_path(const char *path) {
 /* This resulting string must fit in 10 chars (i.e. the length
  * of "/sbin/init") to look pretty in /bin/ps */
 
-p = basename(path);
+p = path_basename(path);
 if (isempty(p)) {
 rename_process("(...)");
 return;
@@ -1331,13 +1331,13 @@ static int exec_child(ExecCommand *command,
 return err;
 }
 
-err = setup_output(context, STDOUT_FILENO, socket_fd, 
basename(command->path), params->unit_id, params->apply_tty_stdin);
+err = setup_output(context, STDOUT_FILENO, socket_fd, 
path_basename(command->path), params->unit_id, params->apply_tty_stdin);
 if (err < 0) {
 *error = EXIT_STDOUT;
 return err;
 }
 
-err = setup_output(context, STDERR_FILENO, socket_fd, 
basename(command->path), params->unit_id, params->apply_tty_stdin);
+err = setup_output(context, STDERR_FILENO, socket_fd, 
path_basename(command->path), params->unit_id, params->apply_tty_stdin);
 if (err < 0) {
 *error = EXIT_STDERR;
 return err;
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 0620882..61db112 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -3322,7 +3322,7 @@ static int open_follow(char **filename, FILE **_f, Set 
*names, char **_final) {
 /* Add the file name we are currently looking at to
  * the names of this unit, but only if it is a valid
  * unit name. */
-name = basename(*filename);
+name = path_basename(*filename);
 
 if (unit_name_is_valid(name, TEMPLATE_VALID)) {
 
diff --git a/src/core/manager.c b/src/core/manager.c
index 88d660d..22a9c89 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1217,7 +1217,7 @@ int manager_load_unit_prepare(
 return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Path 
%s is not absolute.", path);
 
 if (!name)
-name = basename(path);
+name = path_basename(path);
 
 t = unit_name_to_type(name);
 
diff --git a/src/core/unit.c b/src/core/unit.c
index def5c36..c14859e 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2170,7 +2170,7 @@ static const char *resolve_template(Unit *u, const char 
*name, const char*path,
 assert(p);
 
 if (!name)
-name = basename(path);
+name = path_basename(path);
 
 if (!unit_name_is_template(name)) {
 *p = NULL;
@@ -2941,7 +2941,7 @@ UnitFileState unit_get_unit_file_state(Unit *u) {
 if (u->unit_file_state < 0 && u->fragment_path)
 u->unit_file_state = unit_file_get_state(
 u->manager->running_as == SYSTEMD_SYSTEM ? 
UNIT_FILE_SYSTEM : UNIT_FILE_USER,
-NULL, basename(u->fragment_path));
+NULL, path_basename(u->fragment_path));
 
 return u->unit_file_state;
 }
diff --git a/src/delta/delta.c b/src/delta/delta.c
index 91f8592..cb049e8 100644
--- a/src/delta/delta.c
+++ b/src/delta/delta.c
@@ -282,8 +282,8 @@ static int enumerate_dir_d(Hashmap *top, Hashmap *bottom, 
Hashmap *drops, const
 return -ENOMEM;
 
 log_debug("Adding to drops: %s %s %s %s %s",
-  unit, draw_special_char(DRAW_ARROW), basename(p), 
draw_special_char(DRAW_ARROW), p);
-k = hashmap_put(h, basename(p), p);
+  unit, draw_special_char(DRAW_ARROW), 
path_basename(

[systemd-devel] [RFC 07/25] shared/sparse-endian.h: add missing byteswap.h include

2014-09-18 Thread Emil Renner Berthing
---
 src/shared/sparse-endian.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/shared/sparse-endian.h b/src/shared/sparse-endian.h
index eb4dbf3..c913fda 100644
--- a/src/shared/sparse-endian.h
+++ b/src/shared/sparse-endian.h
@@ -21,6 +21,7 @@
 #ifndef SPARSE_ENDIAN_H
 #define SPARSE_ENDIAN_H
 
+#include 
 #include 
 #include 
 
-- 
2.1.0

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


[systemd-devel] [RFC 12/25] shared/missing.h: check for missing canonicalize_file_name

2014-09-18 Thread Emil Renner Berthing
---
 configure.ac | 3 ++-
 src/shared/missing.h | 6 ++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index fb16904..1f2bbd0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -301,8 +301,9 @@ LIBS="$save_LIBS"
 
 AC_CHECK_FUNCS([fanotify_init fanotify_mark])
 AC_CHECK_FUNCS([__secure_getenv secure_getenv])
-AC_CHECK_DECLS([gettid, pivot_root, name_to_handle_at, setns, 
LO_FLAGS_PARTSCAN],
+AC_CHECK_DECLS([gettid, pivot_root, canonicalize_file_name, name_to_handle_at, 
setns, LO_FLAGS_PARTSCAN],
[], [], [[
+#include 
 #include 
 #include 
 #include 
diff --git a/src/shared/missing.h b/src/shared/missing.h
index 8389c28..2379950 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -130,6 +130,12 @@ static inline int pivot_root(const char *new_root, const 
char *put_old) {
 }
 #endif
 
+#if !HAVE_DECL_CANONICALIZE_FILE_NAME
+static inline char *canonicalize_file_name(const char *path) {
+return realpath(path, NULL);
+}
+#endif
+
 #ifdef __x86_64__
 #  ifndef __NR_fanotify_init
 #define __NR_fanotify_init 300
-- 
2.1.0

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


[systemd-devel] [RFC 11/25] shared/missing.h: fall pack to insecure getenv

2014-09-18 Thread Emil Renner Berthing
---
 src/shared/missing.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/missing.h b/src/shared/missing.h
index b441149..8389c28 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -353,7 +353,7 @@ static inline int name_to_handle_at(int fd, const char 
*name, struct file_handle
 #  ifdef HAVE___SECURE_GETENV
 #define secure_getenv __secure_getenv
 #  else
-#error "neither secure_getenv nor __secure_getenv are available"
+#define secure_getenv getenv
 #  endif
 #endif
 
-- 
2.1.0

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


[systemd-devel] [RFC 14/25] shared/missing.h: check for missing __compar_fn_t typedef

2014-09-18 Thread Emil Renner Berthing
---
 src/shared/missing.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/shared/missing.h b/src/shared/missing.h
index 55e61f6..be099c5 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -147,6 +147,11 @@ static inline char *canonicalize_file_name(const char 
*path) {
   })
 #endif
 
+#ifndef __COMPAR_FN_T
+#define __COMPAR_FN_T
+typedef int (*__compar_fn_t)(const void *, const void *);
+#endif
+
 #ifdef __x86_64__
 #  ifndef __NR_fanotify_init
 #define __NR_fanotify_init 300
-- 
2.1.0

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


[systemd-devel] [RFC 01/25] include poll.h rather than sys/poll.h

2014-09-18 Thread Emil Renner Berthing
---
 man/sd_journal_get_fd.xml   | 2 +-
 src/ask-password/ask-password.c | 2 +-
 src/bus-proxyd/bus-proxyd.c | 2 +-
 src/core/execute.c  | 2 +-
 src/core/manager.c  | 2 +-
 src/core/unit.c | 2 +-
 src/initctl/initctl.c   | 2 +-
 src/journal/sd-journal.c| 2 +-
 src/libsystemd/sd-bus/bus-socket.c  | 2 +-
 src/libsystemd/sd-bus/sd-bus.c  | 2 +-
 src/libsystemd/sd-login/sd-login.c  | 2 +-
 src/libsystemd/sd-login/test-login.c| 2 +-
 src/libsystemd/sd-network/sd-network.c  | 2 +-
 src/libsystemd/sd-resolve/sd-resolve.c  | 2 +-
 src/libudev/libudev-monitor.c   | 2 +-
 src/readahead/readahead-collect.c   | 2 +-
 src/reply-password/reply-password.c | 2 +-
 src/resolve/resolved-manager.c  | 2 +-
 src/shared/ask-password-api.c   | 2 +-
 src/shared/logs-show.c  | 2 +-
 src/shared/spawn-polkit-agent.c | 2 +-
 src/shared/util.c   | 2 +-
 src/shared/utmp-wtmp.c  | 2 +-
 src/shutdownd/shutdownd.c   | 2 +-
 src/tty-ask-password-agent/tty-ask-password-agent.c | 2 +-
 src/udev/udev-ctrl.c| 2 +-
 src/udev/udev-event.c   | 2 +-
 src/udev/udevadm-settle.c   | 2 +-
 src/udev/udevadm-test-builtin.c | 2 +-
 src/udev/udevd.c| 2 +-
 30 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/man/sd_journal_get_fd.xml b/man/sd_journal_get_fd.xml
index 3aa79ce..56c2a75 100644
--- a/man/sd_journal_get_fd.xml
+++ b/man/sd_journal_get_fd.xml
@@ -308,7 +308,7 @@ int main(int argc, char *argv[]) {
 example lacks all error checking for the sake of
 simplicity):
 
-#include 
+#include 
 #include 
 
 int wait_for_changes(sd_journal *j) {
diff --git a/src/ask-password/ask-password.c b/src/ask-password/ask-password.c
index 5c37cff..2eed25f 100644
--- a/src/ask-password/ask-password.c
+++ b/src/ask-password/ask-password.c
@@ -20,7 +20,7 @@
 ***/
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
index d35d7f6..4de8e85 100644
--- a/src/bus-proxyd/bus-proxyd.c
+++ b/src/bus-proxyd/bus-proxyd.c
@@ -28,7 +28,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/src/core/execute.c b/src/core/execute.c
index f3c791e..e73eb8e 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -37,7 +37,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/src/core/manager.c b/src/core/manager.c
index e0c1cd1..88d660d 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -25,7 +25,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/src/core/unit.c b/src/core/unit.c
index 5978e21..def5c36 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -24,7 +24,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c
index f1c2b8d..7f22cb3 100644
--- a/src/initctl/initctl.c
+++ b/src/initctl/initctl.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 1fc9f01..fec97c8 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -24,7 +24,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/src/libsystemd/sd-bus/bus-socket.c 
b/src/libsystemd/sd-bus/bus-socket.c
index d124d9a..27b2ecf 100644
--- a/src/libsystemd/sd-bus/bus-socket.c
+++ b/src/libsystemd/sd-bus/bus-socket.c
@@ -23,7 +23,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #include "util.h"
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 28b993b..ff4beed 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -24,7 +24,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/src/libsystemd/sd-login/sd-login.c 
b/src/libsystemd/sd-login/sd-login.c
index 95cb6ff..d2336be 100644
--- a/src/libsystemd/sd-login/sd-login.c
+++ b/src/libsystemd/sd-login/sd-login.c
@@ -23,7 +23,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include "util.h"
 #include "cgroup-util.h"
diff --git a/src/libsystemd

[systemd-devel] [RFC 06/25] shared/label.h: add missing stdio.h include

2014-09-18 Thread Emil Renner Berthing
---
 src/shared/label.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/shared/label.h b/src/shared/label.h
index 7294820..cb2ec79 100644
--- a/src/shared/label.h
+++ b/src/shared/label.h
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 int label_init(const char *prefix);
 void label_finish(void);
-- 
2.1.0

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


[systemd-devel] [RFC 03/25] udev: link-config: remove unneded linux/netdevice.h include

2014-09-18 Thread Emil Renner Berthing
---
 src/udev/net/link-config.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index ee2865a..25e3cc8 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -20,7 +20,6 @@
 ***/
 
 #include 
-#include 
 
 #include "sd-id128.h"
 
-- 
2.1.0

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


[systemd-devel] [RFC 04/25] sd-rtnl: rtnl-message: remove unneeded linux includes

2014-09-18 Thread Emil Renner Berthing
---
 src/libsystemd/sd-rtnl/rtnl-message.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c 
b/src/libsystemd/sd-rtnl/rtnl-message.c
index 30e3358..b501a52 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -23,12 +23,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 
 #include "util.h"
 #include "refcnt.h"
-- 
2.1.0

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


[systemd-devel] [RFC 02/25] include fcntl.h rather than sys/fcntl.h

2014-09-18 Thread Emil Renner Berthing
---
 src/socket-proxy/socket-proxyd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
index 81d8457..ff2b24f 100644
--- a/src/socket-proxy/socket-proxyd.c
+++ b/src/socket-proxy/socket-proxyd.c
@@ -26,7 +26,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-- 
2.1.0

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


[systemd-devel] [RFC 05/25] shared/util.h: include sys/reg.h for __WORDSIZE

2014-09-18 Thread Emil Renner Berthing
---
 src/shared/util.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/shared/util.h b/src/shared/util.h
index 08d556f..32e5090 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.1.0

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


[systemd-devel] [RFC 15/25] shared/utmp-wtmp: don't fail if libc doesn't support utmpx/wtmpx

2014-09-18 Thread Emil Renner Berthing
I'd like to make utmp/wtmp handling a configure option, but for
now this is the minimal change needed to make it compile with musl.
The musl utmp/wtmp functions doesn't do anything anyway.
---
 src/shared/utmp-wtmp.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/shared/utmp-wtmp.c b/src/shared/utmp-wtmp.c
index e0319f0..619d6d1 100644
--- a/src/shared/utmp-wtmp.c
+++ b/src/shared/utmp-wtmp.c
@@ -63,8 +63,10 @@ int utmp_get_runlevel(int *runlevel, int *previous) {
 return 0;
 }
 
+#ifdef _PATH_UTMPX
 if (utmpxname(_PATH_UTMPX) < 0)
 return -errno;
+#endif
 
 setutxent();
 
@@ -124,8 +126,10 @@ static int write_entry_utmp(const struct utmpx *store) {
  * each entry type resp. user; i.e. basically a key/value
  * table. */
 
+#ifdef _PATH_UTMPX
 if (utmpxname(_PATH_UTMPX) < 0)
 return -errno;
+#endif
 
 setutxent();
 
@@ -146,7 +150,9 @@ static int write_entry_wtmp(const struct utmpx *store) {
 simply appended to * the end; i.e. basically a log. */
 
 errno = 0;
+#ifdef _PATH_WTMPX
 updwtmpx(_PATH_WTMPX, store);
+#endif
 return -errno;
 }
 
-- 
2.1.0

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


[systemd-devel] [RFC 13/25] shared/missing.h: check for missing strndupa

2014-09-18 Thread Emil Renner Berthing
---
 configure.ac |  3 ++-
 src/shared/missing.h | 11 +++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 1f2bbd0..3db0e24 100644
--- a/configure.ac
+++ b/configure.ac
@@ -301,9 +301,10 @@ LIBS="$save_LIBS"
 
 AC_CHECK_FUNCS([fanotify_init fanotify_mark])
 AC_CHECK_FUNCS([__secure_getenv secure_getenv])
-AC_CHECK_DECLS([gettid, pivot_root, canonicalize_file_name, name_to_handle_at, 
setns, LO_FLAGS_PARTSCAN],
+AC_CHECK_DECLS([gettid, pivot_root, canonicalize_file_name, strndupa, 
name_to_handle_at, setns, LO_FLAGS_PARTSCAN],
[], [], [[
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/src/shared/missing.h b/src/shared/missing.h
index 2379950..55e61f6 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -136,6 +136,17 @@ static inline char *canonicalize_file_name(const char 
*path) {
 }
 #endif
 
+#if !HAVE_DECL_STRNDUPA
+#define strndupa(s, n) \
+  ({ \
+const char *__old = (s); \
+size_t __len = strnlen(__old, (n)); \
+char *__new = (char *)alloca(__len + 1); \
+__new[__len] = '\0'; \
+(char *)memcpy(__new, __old, __len); \
+  })
+#endif
+
 #ifdef __x86_64__
 #  ifndef __NR_fanotify_init
 #define __NR_fanotify_init 300
-- 
2.1.0

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


[systemd-devel] [RFC 09/25] shared/socket-util: don't fail if libc doesn't support IDN

2014-09-18 Thread Emil Renner Berthing
---
 src/shared/socket-util.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
index e3e54e8..d4a1679 100644
--- a/src/shared/socket-util.c
+++ b/src/shared/socket-util.c
@@ -41,6 +41,16 @@
 #include "missing.h"
 #include "fileio.h"
 
+/* Don't fail if the standard library
+ * doesn't support IDN */
+#ifndef NI_IDN
+#define NI_IDN 0
+#endif
+
+#ifndef NI_IDN_USE_STD3_ASCII_RULES
+#define NI_IDN_USE_STD3_ASCII_RULES 0
+#endif
+
 int socket_address_parse(SocketAddress *a, const char *s) {
 char *e, *n;
 unsigned u;
-- 
2.1.0

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


[systemd-devel] [RFC 08/25] don't fail if GLOB_BRACE is not defined

2014-09-18 Thread Emil Renner Berthing
If the standard library doesn't provide brace
expansion users just won't get it.
---
 src/shared/util.c   | 6 ++
 src/tmpfiles/tmpfiles.c | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/src/shared/util.c b/src/shared/util.c
index 9157b2f..76899f5 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -86,6 +86,12 @@
 #include "virt.h"
 #include "def.h"
 
+/* Don't fail if the standard library
+ * doesn't provide brace expansion */
+#ifndef GLOB_BRACE
+#define GLOB_BRACE 0
+#endif
+
 int saved_argc = 0;
 char **saved_argv = NULL;
 
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index f9830c4..8e1b80a 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -55,6 +55,12 @@
 #include "build.h"
 #include "copy.h"
 
+/* Don't fail if the standard library
+ * doesn't provide brace expansion */
+#ifndef GLOB_BRACE
+#define GLOB_BRACE 0
+#endif
+
 /* This reads all files listed in /etc/tmpfiles.d/?*.conf and creates
  * them in the file system. This is intended to be used to create
  * properly owned directories beneath /tmp, /var/tmp, /run, which are
-- 
2.1.0

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


[systemd-devel] [RFC 10/25] shared/pty: fall back to kernel header for TIOCSIG

2014-09-18 Thread Emil Renner Berthing
---
 src/shared/pty.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/shared/pty.c b/src/shared/pty.c
index 2863da4..21a87e5 100644
--- a/src/shared/pty.c
+++ b/src/shared/pty.c
@@ -61,6 +61,11 @@
 #include 
 #include 
 
+/* If sys/ioctl.h doesn't provide TIOCSIG use the kernel header */
+#ifndef TIOCSIG
+#include 
+#endif
+
 #include "barrier.h"
 #include "macro.h"
 #include "pty.h"
-- 
2.1.0

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


[systemd-devel] [RFC 00/25] Compile against the musl libc

2014-09-18 Thread Emil Renner Berthing
Hi,

Around the internet one can read statements such as "systemd
is designed with glibc in mind" and "the systemd developers' idea
of a standard libc is one that has bug-for-bug compatibility with
glibc". So in a fit of naivety I decided to test this out and see
how much work it would take to make systemd work with musl.

The real reason is of course that I'd like to see systemd running
on my router and other small devices that usually run some OpenWRT
derivative.

This series makes systemd compile cleanly against musl 1.1.4 with
a minimal configuration and also fixes a few runtime errors. It is
only lightly tested and a few of patches could definitely be done
in a nicer, more generic way. Also I'd love to get even more stuff
working like eg. networkd and resolved. However I would like some
early feedback and see if this is something that could one day make
it upstream or I'm just wasting my time.

The first two patches are not strictly needed, but it makes the
compilation much quieter and they are correct according POSIX.

/Emil

Emil Renner Berthing (25):
  include poll.h rather than sys/poll.h
  include fcntl.h rather than sys/fcntl.h
  udev: link-config: remove unneded linux/netdevice.h include
  sd-rtnl: rtnl-message: remove unneeded linux includes
  shared/util.h: include sys/reg.h for __WORDSIZE
  shared/label.h: add missing stdio.h include
  shared/sparse-endian.h: add missing byteswap.h include
  don't fail if GLOB_BRACE is not defined
  shared/socket-util: don't fail if libc doesn't support IDN
  shared/pty: fall back to kernel header for TIOCSIG
  shared/missing.h: fall pack to insecure getenv
  shared/missing.h: check for missing canonicalize_file_name
  shared/missing.h: check for missing strndupa
  shared/missing.h: check for missing __compar_fn_t typedef
  shared/utmp-wtmp: don't fail if libc doesn't support utmpx/wtmpx
  add fallback parse_printf_format implementation
  dhcp-internal.h: add fallback IPTOS_CLASS_CS6 definition
  sd-ipv4all: fall back to random if no random_r
  mount-setup: skip relabelling when SELinux and SMACK not supported
  udevadm-hwdb: don't use glibc-specific qsort_r
  make sure basename that doesn't alter it's argument
  support POSIX strerror_r returning int
  mount: order options before other arguments to mount
  units: order options before other arguments
  add -z muldefs to linker flags

 Makefile.am|   4 +
 configure.ac   |  10 +-
 man/sd_journal_get_fd.xml  |   2 +-
 src/ask-password/ask-password.c|   2 +-
 src/bus-proxyd/bus-proxyd.c|   2 +-
 src/core/execute.c |   8 +-
 src/core/load-fragment.c   |   2 +-
 src/core/manager.c |   4 +-
 src/core/mount-setup.c |   4 +
 src/core/mount.c   |   8 +-
 src/core/unit.c|   6 +-
 src/delta/delta.c  |  14 +-
 src/initctl/initctl.c  |   2 +-
 src/journal/journal-send.c |  38 ++-
 src/journal/journalctl.c   |   2 +-
 src/journal/sd-journal.c   |   2 +-
 src/libsystemd-network/dhcp-internal.h |   4 +
 src/libsystemd-network/sd-ipv4ll.c |  25 +-
 src/libsystemd/sd-bus/bus-error.c  |  14 +-
 src/libsystemd/sd-bus/bus-socket.c |   2 +-
 src/libsystemd/sd-bus/sd-bus.c |   2 +-
 src/libsystemd/sd-login/sd-login.c |   2 +-
 src/libsystemd/sd-login/test-login.c   |   2 +-
 src/libsystemd/sd-network/sd-network.c |   2 +-
 src/libsystemd/sd-resolve/sd-resolve.c |   2 +-
 src/libsystemd/sd-rtnl/rtnl-message.c  |   6 -
 src/libudev/libudev-monitor.c  |   2 +-
 src/locale/localectl.c |   2 +-
 src/login/logind-inhibit.c |   2 +-
 src/login/logind-seat.c|   2 +-
 src/login/logind-session.c |   2 +-
 src/nspawn/nspawn.c|   2 +-
 src/readahead/readahead-collect.c  |   2 +-
 src/reply-password/reply-password.c|   2 +-
 src/resolve/resolved-manager.c |   2 +-
 src/shared/ask-password-api.c  |   2 +-
 src/shared/cgroup-show.c   |   4 +-
 src/shared/conf-files.c|   4 +-
 src/shared/install.c   |  14 +-
 src/shared/label.h |   1 +
 src/shared/log.c   |   2 +-
 src/shared/logs-show.c |   2 +-
 src/shared/missing.h   |  24 +-
 src/s

Re: [systemd-devel] [PATCH] ask-password: Add --do-echo to enable echoing the user input

2014-09-18 Thread David Sommerseth
On 17/09/14 17:52, "Jóhann B. Guðmundsson" wrote:
> 
> On 09/17/2014 12:26 PM, David Sommerseth wrote:
>> Hi,
>>
>> I've been playing with the systemd feature enabled in OpenVPN.  And I
>> propose this change to systemd-ask-password to avoid masking usernames.
>>   I tried looking for alternative ways querying for usernames through
>> systemd without finding a good solution.
>>
>> This patch has been tested locally on a slightly modified OpenVPN build
>> which calls systemd-ask-password with --do-echo when it queries the user
>> for usernames.
>>
>> If there are better ways how to solve this, please let me know and I'll
>> go that path instead.
>>
>>
> 
> Should this not be fixed upstream openvpn?

OpenVPN have already implemented support for systemd.  The issue is when
OpenVPN starts a config file where will ask the user for username and
password.  Without this systemd patch the result is that the username
isn't displayed as plain text but a bunch of stars - and kicking off
openvpn via systemctl fails.

Based on my systemd knowledge, the alternative is to _not_ use
systemd-ask-password at all, which makes it harder to start openvpn
tunnels via systemctl or at boot time.  And that will not be well
received among OpenVPN users.

If you think we're doing it wrong in OpenVPN, I'm willing to fix this.
As more and more distros move over to systemd, this is something we see
we need to fix in OpenVPN.


--
kind regards,

David Sommerseth

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


Re: [systemd-devel] cdrom_id opens device with O_EXCL, why?

2014-09-18 Thread David Herrmann
Hi again

On Thu, Sep 18, 2014 at 1:34 PM, David Herrmann  wrote:
> I'm putting Harald and Kay on CC, as they added O_EXCL to protect
> against parallel burning-sessions. Maybe they can tell you whether
> that is still needed today and whether we can drop it.

So my conception of O_EXCL was kinda wrong. O_EXCL on block devices
fails with EBUSY if, and only if, there's someone else also opening
the device with O_EXCL. You can still open it without O_EXCL. Now, the
kernel-internal mount helpers always keep O_EXCL for mounted block
devices. This way, user-space can open block devices via O_EXCL and be
sure no-one can mount it in parallel.

For your automounter, this means you should just drop the event on
EBUSY. If udev was the offender, you will get a follow-up event. If
fsck was the offender, you're screwed anyway as it takes ages to
complete (but fsck shouldn't be any problem for the automounter,
anyway). if anyone else is the offender, you have no idea what they
do, so you should just fail right away.

Regarding lazy-unmount: It'd require kernel support to notice such
usage in user-space. I don't plan on working on this (and nobody
really cares). But if there will be a kernel-interface, we'd gladly
accept patches to fix cdrom_id.

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


Re: [systemd-devel] [PATCH] Big endian and the size of the gcc builtin type bool from stdbool.h

2014-09-18 Thread Dr. Werner Fink
On Thu, Sep 18, 2014 at 01:29:26PM +0200, David Herrmann wrote:
> Hi
> 
> On Thu, Sep 18, 2014 at 12:57 PM, Dr. Werner Fink  wrote:
> >   linuxadmin:~ # uname -m
> >   s390x
> >   linuxadmin:~ # systemctl show multi-user.target | grep -E '=(yes|no)'
> >   CanStart=no
> >   CanStop=no
> >   CanReload=no
> >   CanIsolate=no
> >   StopWhenUnneeded=no
> >   RefuseManualStart=no
> >   RefuseManualStop=no
> >   AllowIsolate=no
> >   DefaultDependencies=no
> >   IgnoreOnIsolate=no
> >   IgnoreOnSnapshot=no
> >   NeedDaemonReload=no
> >   ConditionResult=no
> >   Transient=no
> 
> I have a fix for bus_print_property() which is used by "systemctl
> show". It used "bool" instead of "int". I will push it in a moment.

OK you're faster, thanks a lot :)

Werner

-- 
  "Having a smoking section in a restaurant is like having
  a peeing section in a swimming pool." -- Edward Burr


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


Re: [systemd-devel] [PATCH] Big endian and the size of the gcc builtin type bool from stdbool.h

2014-09-18 Thread Dr. Werner Fink
On Thu, Sep 18, 2014 at 01:20:47PM +0200, David Herrmann wrote:
> Hi
> 
> On Thu, Sep 18, 2014 at 12:57 PM, Dr. Werner Fink  wrote:
> > On Thu, Sep 18, 2014 at 12:43:00PM +0200, David Herrmann wrote:
> >> Hi
> >>
> >> On Thu, Sep 18, 2014 at 11:16 AM, Werner Fink  wrote:
> >> > On s390 the big endianness and cast from pointers of integers to
> >> > the type of bool leads to the funny status messages that e.g.
> >> > all targets are set to AllowIsolate=no even for multi-user.target.
> >> >
> >> > The gcc builtin type bool or _Bool has the size of one byte which
> >> > should be taken into account in sd_bus_message_read_basic() as well
> >> > as in bus_message_append_ap()
> >>
> >> We don't support "bool" in public APIs. sd-bus requires you to use
> >> "int" for boolean types. If a caller uses "bool", they must be fixed.
> >
> > Then I'd like to know why the header  together with the
> > therein provided type _Bool aka bool is used overall systemd. Also
> 
> We use stdbool internally quite a lot. Especially bit-fields are
> really nice if implemented as bool. We just don't use bool in public
> APIs. We also avoid it in combination with va_arg() and with pointers,
> as in both cases the behavior is non-obvious and often done wrong.

Hmmm ... I'm familiar with big endian (IMHO the natural byte order:)

> > it is systemctl which does use sd_bus_message_read_basic() to parse
> > the answer received over sd_bus of the status question send over
> > sd_bus?
> 
> All uses of sd-bus with "bool" are bugs and need to be fixed. See the
> history of bus-message.c:
> 
> commit 9bcbce4201afada1c0ad8ada0cbfbbf58a52a6a7
> Author: Kay Sievers 
> Date:   Tue Oct 22 03:27:38 2013 +0200
> 
> bus: avoid 'bool' storage when retrieving 'b' from the message
> 
> commit 102d8f8169427cb68cdebf5ee0f0e07788e9c2b2
> Author: Kay Sievers 
> Date:   Thu Nov 7 02:03:10 2013 +0100
> 
> consistently use "int" when retrieving "bool" from bus messages

The only problem which remains: on s390 the sd_bus_message_read_basic()
does it internal wrong (IMHO).  If a bool is internal used and send
over the dbus then the internal of sd_bus_message_read_basic()
or at least bus_print_property() should be able to handle this.

Werner

-- 
  "Having a smoking section in a restaurant is like having
  a peeing section in a swimming pool." -- Edward Burr


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


Re: [systemd-devel] cdrom_id opens device with O_EXCL, why?

2014-09-18 Thread David Herrmann
Hi

On Thu, Sep 18, 2014 at 1:02 PM, Hoyer, Marko (ADITG/SW2)
 wrote:
> Thx for the answer.
>
> The automounter is listening to the udev socket so it is actually waiting for 
> the
> event to be processed completely. But unfortunately, it appears that sequences
> of change events might come in a short time frame. So the automounter is 
> trying
> to mount the device triggered by the first one, while udevd is currently 
> processing
> the second one. That's what's happening actually in my case. Besides that the
> issue with cdrom_id not working in case of a lazy unmount (described in my
> second mail) seems to me to be a bit more critical.

The automounter could just ignore the udev event on EBUSY. That is, if
you get EBUSY, bail out (maybe print a debug message) and just do
nothing. If udev was the offending O_EXCL blocker, you can be sure to
get a follow-up event.

Regarding lazy-unmount: That's just ugly. I have no idea how to work
around that, sorry.

I'm putting Harald and Kay on CC, as they added O_EXCL to protect
against parallel burning-sessions. Maybe they can tell you whether
that is still needed today and whether we can drop it.

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


Re: [systemd-devel] [PATCH] Big endian and the size of the gcc builtin type bool from stdbool.h

2014-09-18 Thread David Herrmann
Hi

On Thu, Sep 18, 2014 at 12:57 PM, Dr. Werner Fink  wrote:
>   linuxadmin:~ # uname -m
>   s390x
>   linuxadmin:~ # systemctl show multi-user.target | grep -E '=(yes|no)'
>   CanStart=no
>   CanStop=no
>   CanReload=no
>   CanIsolate=no
>   StopWhenUnneeded=no
>   RefuseManualStart=no
>   RefuseManualStop=no
>   AllowIsolate=no
>   DefaultDependencies=no
>   IgnoreOnIsolate=no
>   IgnoreOnSnapshot=no
>   NeedDaemonReload=no
>   ConditionResult=no
>   Transient=no

I have a fix for bus_print_property() which is used by "systemctl
show". It used "bool" instead of "int". I will push it in a moment.

Thanks a lot for the report!
David
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] Big endian and the size of the gcc builtin type bool from stdbool.h

2014-09-18 Thread David Herrmann
Hi

On Thu, Sep 18, 2014 at 12:57 PM, Dr. Werner Fink  wrote:
> On Thu, Sep 18, 2014 at 12:43:00PM +0200, David Herrmann wrote:
>> Hi
>>
>> On Thu, Sep 18, 2014 at 11:16 AM, Werner Fink  wrote:
>> > On s390 the big endianness and cast from pointers of integers to
>> > the type of bool leads to the funny status messages that e.g.
>> > all targets are set to AllowIsolate=no even for multi-user.target.
>> >
>> > The gcc builtin type bool or _Bool has the size of one byte which
>> > should be taken into account in sd_bus_message_read_basic() as well
>> > as in bus_message_append_ap()
>>
>> We don't support "bool" in public APIs. sd-bus requires you to use
>> "int" for boolean types. If a caller uses "bool", they must be fixed.
>
> Then I'd like to know why the header  together with the
> therein provided type _Bool aka bool is used overall systemd. Also

We use stdbool internally quite a lot. Especially bit-fields are
really nice if implemented as bool. We just don't use bool in public
APIs. We also avoid it in combination with va_arg() and with pointers,
as in both cases the behavior is non-obvious and often done wrong.

> it is systemctl which does use sd_bus_message_read_basic() to parse
> the answer received over sd_bus of the status question send over
> sd_bus?

All uses of sd-bus with "bool" are bugs and need to be fixed. See the
history of bus-message.c:

commit 9bcbce4201afada1c0ad8ada0cbfbbf58a52a6a7
Author: Kay Sievers 
Date:   Tue Oct 22 03:27:38 2013 +0200

bus: avoid 'bool' storage when retrieving 'b' from the message

commit 102d8f8169427cb68cdebf5ee0f0e07788e9c2b2
Author: Kay Sievers 
Date:   Thu Nov 7 02:03:10 2013 +0100

consistently use "int" when retrieving "bool" from bus messages


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


Re: [systemd-devel] cdrom_id opens device with O_EXCL, why?

2014-09-18 Thread Hoyer, Marko (ADITG/SW2)
> -Original Message-
> From: David Herrmann [mailto:dh.herrm...@gmail.com]
> Sent: Thursday, September 18, 2014 10:31 AM
> To: Hoyer, Marko (ADITG/SW2)
> Cc: systemd-devel@lists.freedesktop.org
> Subject: Re: [systemd-devel] cdrom_id opens device with O_EXCL, why?
> 
> Hi
> 
> On Thu, Sep 18, 2014 at 8:22 AM, Hoyer, Marko (ADITG/SW2)  jv.com> wrote:
> > Hello together,
> >
> > I recently stumbled over cdrom_id opening the device with the O_EXCL flag
> set, if it is not currently mounted:
> >
> > "fd = open(node, O_RDONLY|O_NONBLOCK|(is_mounted(node) ? 0 : O_EXCL));"
> >
> > The effect of this is that automatically mounting a cdrom sometimes results
> in "resource busy", if "change" uevents of the devices are processed by udevd
> while the automounter (udisks or something different in my case) is currently
> trying to mount the device triggered by a previous "add" or "change" uevent.
> >
> > I've to questions to this issue. Maybe someone of you can help me:
> >
> > 1. Is there any particular reason why cdrom_id should open the device
> exclusively (especially since it is not opened exclusively when it is already
> mounted)?
> >
> > 2. If there is any good reason to keep this behavior: How is the best way
> for an automounter to deal with this? Retry? Something different?
> 
> This was introduced in:
> 
> commit 38a3cde11bc77af49a96245b8a8a0f2b583a344c
> Author: Kay Sievers 
> Date:   Thu Mar 18 11:14:32 2010 +0100
> 
> cdrom_id: open non-mounted optical media with O_EXCL
> 
> This should prevent confusing drives during CD burning sessions. Based
> on a patch from Harald Hoyer.
> 
> 
> According to this commit we use O_EXCL to not confuse burning-sessions that
> might run in parallel. Admittedly, burning-sessions should usually open the
> device themselves via O_EXCL, or lock critical sections via scsi, but I guess
> back in the days we had to work around bugs in other programs (or I may be
> missing something non-obvious; I'm not that much into scsi..).
> 
> Regarding what do to: If you deal with cdrom devices and get EBUSY, I'd simply
> ignore the device. In case of udev, you get a uevent once udev is done, and
> usually that means the device changed in some way so it's *good* you wait for
> it to be processed. So your automounter will get a uevent once udev is done
> and can then try to mount the device.
> 
> Thanks
> David

Thx for the answer.

The automounter is listening to the udev socket so it is actually waiting for 
the event to be processed completely. But unfortunately, it appears that 
sequences of change events might come in a short time frame. So the automounter 
is trying to mount the device triggered by the first one, while udevd is 
currently processing the second one. That's what's happening actually in my 
case. Besides that the issue with cdrom_id not working in case of a lazy 
unmount (described in my second mail) seems to me to be a bit more critical.



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


Re: [systemd-devel] [PATCH] Big endian and the size of the gcc builtin type bool from stdbool.h

2014-09-18 Thread Dr. Werner Fink
On Thu, Sep 18, 2014 at 12:43:00PM +0200, David Herrmann wrote:
> Hi
> 
> On Thu, Sep 18, 2014 at 11:16 AM, Werner Fink  wrote:
> > On s390 the big endianness and cast from pointers of integers to
> > the type of bool leads to the funny status messages that e.g.
> > all targets are set to AllowIsolate=no even for multi-user.target.
> >
> > The gcc builtin type bool or _Bool has the size of one byte which
> > should be taken into account in sd_bus_message_read_basic() as well
> > as in bus_message_append_ap()
> 
> We don't support "bool" in public APIs. sd-bus requires you to use
> "int" for boolean types. If a caller uses "bool", they must be fixed.

Then I'd like to know why the header  together with the
therein provided type _Bool aka bool is used overall systemd.  Also
it is systemctl which does use sd_bus_message_read_basic() to parse
the answer received over sd_bus of the status question send over
sd_bus?

  linuxadmin:~ # uname -m
  s390x
  linuxadmin:~ # systemctl show multi-user.target | grep -E '=(yes|no)'
  CanStart=no
  CanStop=no
  CanReload=no
  CanIsolate=no
  StopWhenUnneeded=no
  RefuseManualStart=no
  RefuseManualStop=no
  AllowIsolate=no
  DefaultDependencies=no
  IgnoreOnIsolate=no
  IgnoreOnSnapshot=no
  NeedDaemonReload=no
  ConditionResult=no
  Transient=no

> Thanks
> David

Werner

> > ---
> >  src/libsystemd/sd-bus/bus-message.c |   19 +++
> >  1 files changed, 15 insertions(+), 4 deletions(-)
> >
> > diff --git src/libsystemd/sd-bus/bus-message.c 
> > src/libsystemd/sd-bus/bus-message.c
> > index bfb14fc..b70d814 100644
> > --- src/libsystemd/sd-bus/bus-message.c
> > +++ src/libsystemd/sd-bus/bus-message.c
> > @@ -2263,14 +2263,25 @@ int bus_message_append_ap(
> >  r = sd_bus_message_append_basic(m, *t, &x);
> >  break;
> >  }
> > +case SD_BUS_TYPE_BOOLEAN: {
> > +if (sizeof(bool) == sizeof(uint32_t)) {
> > +uint32_t x;
> >
> > -case SD_BUS_TYPE_BOOLEAN:
> > +x = va_arg(ap, uint32_t);
> > +r = sd_bus_message_append_basic(m, *t, &x);
> > +} else {
> > +uint8_t x;
> > +
> > +x = (uint8_t) va_arg(ap, int);
> > +r = sd_bus_message_append_basic(m, *t, &x);
> > +}
> > +break;
> > +}
> >  case SD_BUS_TYPE_INT32:
> >  case SD_BUS_TYPE_UINT32:
> >  case SD_BUS_TYPE_UNIX_FD: {
> >  uint32_t x;
> >
> > -/* We assume a boolean is the same as int32_t */
> >  assert_cc(sizeof(int32_t) == sizeof(int));
> >
> >  x = va_arg(ap, uint32_t);
> > @@ -3233,7 +3244,7 @@ _public_ int sd_bus_message_read_basic(sd_bus_message 
> > *m, char type, void *p) {
> >
> >  case SD_BUS_TYPE_BOOLEAN:
> >  if (p)
> > -*(int*) p = !!*(uint8_t*) q;
> > +*(bool*) p = !!*(uint8_t*) q;
> >  break;
> >
> >  case SD_BUS_TYPE_INT16:
> > @@ -3343,7 +3354,7 @@ _public_ int sd_bus_message_read_basic(sd_bus_message 
> > *m, char type, void *p) {
> >
> >  case SD_BUS_TYPE_BOOLEAN:
> >  if (p)
> > -*(int*) p = !!*(uint32_t*) q;
> > +*(bool*) p = !!*(uint32_t*) q;
> >  break;
> >
> >  case SD_BUS_TYPE_INT16:
> > --
> > 1.7.7
-- 
  "Having a smoking section in a restaurant is like having
  a peeing section in a swimming pool." -- Edward Burr


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


Re: [systemd-devel] [PATCH] Big endian and the size of the gcc builtin type bool from stdbool.h

2014-09-18 Thread David Herrmann
Hi

On Thu, Sep 18, 2014 at 11:16 AM, Werner Fink  wrote:
> On s390 the big endianness and cast from pointers of integers to
> the type of bool leads to the funny status messages that e.g.
> all targets are set to AllowIsolate=no even for multi-user.target.
>
> The gcc builtin type bool or _Bool has the size of one byte which
> should be taken into account in sd_bus_message_read_basic() as well
> as in bus_message_append_ap()

We don't support "bool" in public APIs. sd-bus requires you to use
"int" for boolean types. If a caller uses "bool", they must be fixed.

Thanks
David

> ---
>  src/libsystemd/sd-bus/bus-message.c |   19 +++
>  1 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git src/libsystemd/sd-bus/bus-message.c 
> src/libsystemd/sd-bus/bus-message.c
> index bfb14fc..b70d814 100644
> --- src/libsystemd/sd-bus/bus-message.c
> +++ src/libsystemd/sd-bus/bus-message.c
> @@ -2263,14 +2263,25 @@ int bus_message_append_ap(
>  r = sd_bus_message_append_basic(m, *t, &x);
>  break;
>  }
> +case SD_BUS_TYPE_BOOLEAN: {
> +if (sizeof(bool) == sizeof(uint32_t)) {
> +uint32_t x;
>
> -case SD_BUS_TYPE_BOOLEAN:
> +x = va_arg(ap, uint32_t);
> +r = sd_bus_message_append_basic(m, *t, &x);
> +} else {
> +uint8_t x;
> +
> +x = (uint8_t) va_arg(ap, int);
> +r = sd_bus_message_append_basic(m, *t, &x);
> +}
> +break;
> +}
>  case SD_BUS_TYPE_INT32:
>  case SD_BUS_TYPE_UINT32:
>  case SD_BUS_TYPE_UNIX_FD: {
>  uint32_t x;
>
> -/* We assume a boolean is the same as int32_t */
>  assert_cc(sizeof(int32_t) == sizeof(int));
>
>  x = va_arg(ap, uint32_t);
> @@ -3233,7 +3244,7 @@ _public_ int sd_bus_message_read_basic(sd_bus_message 
> *m, char type, void *p) {
>
>  case SD_BUS_TYPE_BOOLEAN:
>  if (p)
> -*(int*) p = !!*(uint8_t*) q;
> +*(bool*) p = !!*(uint8_t*) q;
>  break;
>
>  case SD_BUS_TYPE_INT16:
> @@ -3343,7 +3354,7 @@ _public_ int sd_bus_message_read_basic(sd_bus_message 
> *m, char type, void *p) {
>
>  case SD_BUS_TYPE_BOOLEAN:
>  if (p)
> -*(int*) p = !!*(uint32_t*) q;
> +*(bool*) p = !!*(uint32_t*) q;
>  break;
>
>  case SD_BUS_TYPE_INT16:
> --
> 1.7.7
>
> ___
> 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


[systemd-devel] [PATCH] Big endian and the size of the gcc builtin type bool from stdbool.h

2014-09-18 Thread Werner Fink
On s390 the big endianness and cast from pointers of integers to
the type of bool leads to the funny status messages that e.g.
all targets are set to AllowIsolate=no even for multi-user.target.

The gcc builtin type bool or _Bool has the size of one byte which
should be taken into account in sd_bus_message_read_basic() as well
as in bus_message_append_ap()

---
 src/libsystemd/sd-bus/bus-message.c |   19 +++
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git src/libsystemd/sd-bus/bus-message.c 
src/libsystemd/sd-bus/bus-message.c
index bfb14fc..b70d814 100644
--- src/libsystemd/sd-bus/bus-message.c
+++ src/libsystemd/sd-bus/bus-message.c
@@ -2263,14 +2263,25 @@ int bus_message_append_ap(
 r = sd_bus_message_append_basic(m, *t, &x);
 break;
 }
+case SD_BUS_TYPE_BOOLEAN: {
+if (sizeof(bool) == sizeof(uint32_t)) {
+uint32_t x;
 
-case SD_BUS_TYPE_BOOLEAN:
+x = va_arg(ap, uint32_t);
+r = sd_bus_message_append_basic(m, *t, &x);
+} else {
+uint8_t x;
+
+x = (uint8_t) va_arg(ap, int);
+r = sd_bus_message_append_basic(m, *t, &x);
+}
+break;
+}
 case SD_BUS_TYPE_INT32:
 case SD_BUS_TYPE_UINT32:
 case SD_BUS_TYPE_UNIX_FD: {
 uint32_t x;
 
-/* We assume a boolean is the same as int32_t */
 assert_cc(sizeof(int32_t) == sizeof(int));
 
 x = va_arg(ap, uint32_t);
@@ -3233,7 +3244,7 @@ _public_ int sd_bus_message_read_basic(sd_bus_message *m, 
char type, void *p) {
 
 case SD_BUS_TYPE_BOOLEAN:
 if (p)
-*(int*) p = !!*(uint8_t*) q;
+*(bool*) p = !!*(uint8_t*) q;
 break;
 
 case SD_BUS_TYPE_INT16:
@@ -3343,7 +3354,7 @@ _public_ int sd_bus_message_read_basic(sd_bus_message *m, 
char type, void *p) {
 
 case SD_BUS_TYPE_BOOLEAN:
 if (p)
-*(int*) p = !!*(uint32_t*) q;
+*(bool*) p = !!*(uint32_t*) q;
 break;
 
 case SD_BUS_TYPE_INT16:
-- 
1.7.7

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


Re: [systemd-devel] cdrom_id opens device with O_EXCL, why?

2014-09-18 Thread David Herrmann
Hi

On Thu, Sep 18, 2014 at 8:22 AM, Hoyer, Marko (ADITG/SW2)
 wrote:
> Hello together,
>
> I recently stumbled over cdrom_id opening the device with the O_EXCL flag 
> set, if it is not currently mounted:
>
> "fd = open(node, O_RDONLY|O_NONBLOCK|(is_mounted(node) ? 0 : O_EXCL));"
>
> The effect of this is that automatically mounting a cdrom sometimes results 
> in "resource busy", if "change" uevents of the devices are processed by udevd 
> while the automounter (udisks or something different in my case) is currently 
> trying to mount the device triggered by a previous "add" or "change" uevent.
>
> I've to questions to this issue. Maybe someone of you can help me:
>
> 1. Is there any particular reason why cdrom_id should open the device 
> exclusively (especially since it is not opened exclusively when it is already 
> mounted)?
>
> 2. If there is any good reason to keep this behavior: How is the best way for 
> an automounter to deal with this? Retry? Something different?

This was introduced in:

commit 38a3cde11bc77af49a96245b8a8a0f2b583a344c
Author: Kay Sievers 
Date:   Thu Mar 18 11:14:32 2010 +0100

cdrom_id: open non-mounted optical media with O_EXCL

This should prevent confusing drives during CD burning sessions. Based
on a patch from Harald Hoyer.


According to this commit we use O_EXCL to not confuse burning-sessions
that might run in parallel. Admittedly, burning-sessions should
usually open the device themselves via O_EXCL, or lock critical
sections via scsi, but I guess back in the days we had to work around
bugs in other programs (or I may be missing something non-obvious; I'm
not that much into scsi..).

Regarding what do to: If you deal with cdrom devices and get EBUSY,
I'd simply ignore the device. In case of udev, you get a uevent once
udev is done, and usually that means the device changed in some way so
it's *good* you wait for it to be processed. So your automounter will
get a uevent once udev is done and can then try to mount the device.

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


Re: [systemd-devel] [PATCH] systemctl: fix resource leak CID #1237747

2014-09-18 Thread Daniel Mack
On 09/18/2014 02:56 AM, Cristian Rodríguez wrote:
> ..by simply moving the declaration of "unit" into the STRV_FOREACH
> loop as suggested by Andreas.
> ---
>  src/systemctl/systemctl.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
> index 88be871..9012128 100644
> --- a/src/systemctl/systemctl.c
> +++ b/src/systemctl/systemctl.c
> @@ -4449,7 +4449,6 @@ static int show(sd_bus *bus, char **args) {
>  }
>  
>  static int cat(sd_bus *bus, char **args) {
> -_cleanup_free_ char *unit = NULL;
>  _cleanup_strv_free_ char **names = NULL;
>  char **name;
>  bool first = true;
> @@ -4468,6 +4467,8 @@ static int cat(sd_bus *bus, char **args) {
>  _cleanup_bus_error_free_ sd_bus_error error = 
> SD_BUS_ERROR_NULL;
>  _cleanup_strv_free_ char **dropin_paths = NULL;
>  _cleanup_free_ char *fragment_path = NULL;
> +_cleanup_free_ char *unit = NULL;
> +
>  char **path;
>  
>  unit = unit_dbus_path_from_name(*name);
> 

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


Re: [systemd-devel] [PATCH] Fix resource leak (coverity CID 1237760)

2014-09-18 Thread Daniel Mack
On 09/17/2014 11:10 PM, Cristian Rodríguez wrote:
> ---
>  src/libsystemd/sd-bus/bus-kernel.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libsystemd/sd-bus/bus-kernel.c 
> b/src/libsystemd/sd-bus/bus-kernel.c
> index 505f335..b3cc996 100644
> --- a/src/libsystemd/sd-bus/bus-kernel.c
> +++ b/src/libsystemd/sd-bus/bus-kernel.c
> @@ -1446,9 +1446,11 @@ int bus_kernel_create_endpoint(const char *bus_name, 
> const char *ep_name, char *
>  }
>  
>  if (ep_path) {
> -asprintf(ep_path, "%s/%s", dirname(path), ep_name);
> -if (!*ep_path)
> +int r = asprintf(ep_path, "%s/%s", dirname(path), ep_name);
> +if (r == -1 || !*ep_path) {
> +safe_close(fd);
>  return -ENOMEM;
> +}
>  }
>  
>  return fd;
> 

Applied, thanks!

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


Re: [systemd-devel] [PATCH] sysctl: don't replace dots with slashes in prefix

2014-09-18 Thread Jan Synacek
David Herrmann  writes:
> Hi
>
> On Mon, Sep 15, 2014 at 2:00 PM, Jan Synacek  wrote:
>> David Herrmann  writes:
>>> Your original patch is right, too. But I'm not sure which one to
>>> prefer. Given that we export systemd-sysctl as rpm macro, I guess we
>>> have to go with your patch. Otherwise, we'd break ABI.
>>>
>>> Thanks and sorry for the confusion!
>>> David
>>
>> Not requiring /proc/sys prefixes and normalizing them totally makes
>> sense. I'm glad we cleared the confusion!
>
> I now pushed a fix to systemd master [1]. It makes sure to keep
> compatibility by treating arguments prefixed with /proc/sys as legacy
> arguments. All other arguments are properly converted and prefixed wit
> /proc/sys/ now.
>
> I also replaced the dot->slash conversion with normalize_sysctl().
> This effectively drops any conversion on legacy arguments as they
> start with a slash and thus are not converted (see the function for
> details). But this now allows you to specify sysctl names instead of
> paths and everything just works.
>
> I tested it with:
> systemd-sysctl --prefix /proc/sys/kernel --prefix net.ipv4 --prefix 
> net/ipv6
> and it worked as expected. It's turned into:
> systemd-sysctl --prefix /proc/sys/kernel --prefix
> /proc/sys/net/ipv4 --prefix proc/sys/net/ipv6
>
> If there's something left to do, please let me know.
>
> Thanks for the report! And again, sorry for the confusion.
> David
>
>
> [1] 
> http://cgit.freedesktop.org/systemd/systemd/commit/?id=0e1f579227b08832437a7ac2227c7e4007a89d23

Seems to be working fine, thanks again!

-- 
Jan Synacek
Software Engineer, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] cdrom_id opens device with O_EXCL, why?

2014-09-18 Thread Hoyer, Marko (ADITG/SW2)
> -Original Message-
> From: Hoyer, Marko (ADITG/SW2)
> Sent: Thursday, September 18, 2014 8:22 AM
> To: systemd-devel@lists.freedesktop.org
> Subject: cdrom_id opens device with O_EXCL, why?
> 
> Hello together,
> 
> I recently stumbled over cdrom_id opening the device with the O_EXCL flag set,
> if it is not currently mounted:
> 
> "fd = open(node, O_RDONLY|O_NONBLOCK|(is_mounted(node) ? 0 : O_EXCL));"
> 
> The effect of this is that automatically mounting a cdrom sometimes results in
> "resource busy", if "change" uevents of the devices are processed by udevd
> while the automounter (udisks or something different in my case) is currently
> trying to mount the device triggered by a previous "add" or "change" uevent.
> 
> I've to questions to this issue. Maybe someone of you can help me:
> 
> 1. Is there any particular reason why cdrom_id should open the device
> exclusively (especially since it is not opened exclusively when it is already
> mounted)?
> 
> 2. If there is any good reason to keep this behavior: How is the best way for
> an automounter to deal with this? Retry? Something different?
> 
> 
> Thx in advance for valuable input.
> 

There is one additional more general issue with the behavior of cdrom_id.

- Insert a cdrom and mount it.
- "cd" into the mounted subtree of the cdrom
- do an lazy unmount (umount -l /dev/sr0)

>From now on, cdrom_id will fail completely due to the following reasons:
- the bash which "cd"ed into the mounted sub tree creates busy i-nodes
- this keeps the kernel from releasing the /dev/sr0 node
- the lazy umount appears to the userspace as if nothing is mounted any more 
(no entry in /proc/self/mountinfo, which is evaluated by cdrom_id)
- due to this, cdrom_id tries to open the device exclusively, which fails
- after 20 retries, cdrom_id finally fails

The kernel itself is able to deal with this issue. Even though we have this 
busy i-nodes hanging around in the back, it allows mounting the cd drive again 
at a different position. So the only blocker seems to me is cdrom_id, failing 
opening the device exclusively.

Any comments?

Best regards

Marko Hoyer
Software Group II (ADITG/SW2)

Tel. +49 5121 49 6948

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