Re: [systemd-devel] Passing variables from udev to unit

2014-03-14 Thread Peter Hutterer
On Fri, Mar 14, 2014 at 06:27:26AM +0400, Andrey Borzenkov wrote:
 В Fri, 14 Mar 2014 08:53:45 +1000
 Peter Hutterer peter.hutte...@who-t.net пишет:
 
  Hey,
  
  I have a service file wacom-inputattach@.service that is started from a udev
  rule:
  
SUBSYSTEM==tty|pnp, KERNEL==ttyS[0-9]*, ATTRS{id}==WACf*,
TAG+=systemd, ENV{SYSTEMD_WANTS}+=wacom-inputattach@%k.service
  
  and the service file then runs:
  
ExecStart=/usr/bin/inputattach -w8001 /dev/%I
  
  That works fine, but now I need to pass a second parameter into the service
  file. Ideally I want to run something like:
  
ExecStart=/usr/bin/inputattach --baud $BAUD -w8001 /dev/%I
  
  I can set the baud rate based on ATTRS{id} in the udev rule, I just don't
  know if there is a way to pass this to the service file. Is there a way to
  do this or do I need to write a wrapper?
 
 
 One possibility would be to generate 
 /run/systemd/system/wacom-inputattach@%k.service.d/baud.conf that
 contains
 
 [Service]
 BAUD=9600
 
 But this requires systemd reload and may generate burst of reload
 requests if there are multiple devices. May be wrapper is simpler.

thanks, I'll look into that. there should only ever be one of these devices
and they're built-in, so that shouldn't matter too much (in fact it'd
probably be possible to generate this file only once, but that's too much
effort to figure out).

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


Re: [systemd-devel] Help regarding service dependency

2014-03-14 Thread Amit Saha


- Original Message -
 From: Andrey Borzenkov arvidj...@gmail.com
 To: Amit Saha as...@redhat.com
 Cc: systemd Mailing List systemd-devel@lists.freedesktop.org
 Sent: Friday, March 14, 2014 12:35:44 PM
 Subject: Re: [systemd-devel] Help regarding service dependency
 
 В Thu, 13 Mar 2014 21:25:34 -0400 (EDT)
 Amit Saha as...@redhat.com пишет:
 
  Hello,
  
  We have service1 which starts in default.target, and we want it to start
  After service2
  (systemd-readahead-done) which starts after the default.target is reached.
  So, I think what would happen in this case is the After=service2 for
  service1 is ignored
  and it is started before service2 since the default.target must be reached.
  
 
 There is no ordering dependencies between default.target and individual
 units; default.target is simply a way to define what is started using
 Wants. So it should work.

Thanks for your reply.

I am not sure I follow you when you say there is no ordering dependency between
default.target and individual units. Let's say default.target.wants/ 
have N services. What happens when you have a service, service2 whose 
unit file has After=default.target in it?  When does it start? 

And, let's now introduce service1 which has:

[Install]   

WantedBy=default.target 
 

How do the services, service1 and service2 start relative to each other and the 
services in 
default.target.wants?   

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


Re: [systemd-devel] [PATCH] machine-id: add --root option to operate on an alternate fs tree

2014-03-14 Thread Koen Kooi

Op 14 mrt. 2014, om 05:43 heeft Greg KH gre...@linuxfoundation.org het 
volgende geschreven:

 This makes it possible to initialize the /etc/machine-id file on an
 arbitrary filesystem hierarchy.  This helps systems that wish to run
 this at image creation time in a subdirectory, or from initramfs before
 pivot-root is called.

Awesome, this saves me an nspawn invocation in my deploy scripts!


 
 diff --git a/man/systemd-machine-id-setup.xml 
 b/man/systemd-machine-id-setup.xml
 index 5c34b345d012..b879b40b997d 100644
 --- a/man/systemd-machine-id-setup.xml
 +++ b/man/systemd-machine-id-setup.xml
 @@ -96,6 +96,14 @@
 paraThe following options are understood:/para
 
 variablelist
 +varlistentry
 +termoption--root=ROOT/option/term
 +listitemparaTakes a directory path
 +as an argument. All paths will be
 +prefixed with the given alternate ROOT
 +path, including config search paths.
 +/para/listitem
 +/varlistentry
 xi:include href=standard-options.xml 
 xpointer=help /
 xi:include href=standard-options.xml 
 xpointer=version /
 /variablelist
 diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
 index 1b55da7e56b8..7d52b468a11a 100644
 --- a/src/core/machine-id-setup.c
 +++ b/src/core/machine-id-setup.c
 @@ -59,18 +59,22 @@ static int shorten_uuid(char destination[36], const char 
 *source) {
 return -EINVAL;
 }
 
 -static int generate(char id[34]) {
 -int fd, r;
 +static int generate(char id[34], const char *root) {
 +int fd, r = 0;
 unsigned char *p;
 sd_id128_t buf;
 char *q;
 ssize_t k;
 const char *vm_id;
 +char *dbus_machine_id;
 
 assert(id);
 
 +if (asprintf(dbus_machine_id, %s/var/lib/dbus/machine-id, root)  
 0)
 +return log_oom();
 +
 /* First, try reading the D-Bus machine id, unless it is a symlink */
 -fd = open(/var/lib/dbus/machine-id, 
 O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
 +fd = open(dbus_machine_id, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
 if (fd = 0) {
 k = loop_read(fd, id, 33, false);
 close_nointr_nofail(fd);
 @@ -83,7 +87,7 @@ static int generate(char id[34]) {
 id[33] = 0;
 
 log_info(Initializing machine ID from D-Bus 
 machine ID.);
 -return 0;
 +goto finish;
 }
 }
 }
 @@ -105,7 +109,8 @@ static int generate(char id[34]) {
 r = shorten_uuid(id, uuid);
 if (r = 0) {
 log_info(Initializing machine ID 
 from KVM UUID.);
 -return 0;
 +r = 0;
 +goto finish;
 }
 }
 }
 @@ -124,7 +129,8 @@ static int generate(char id[34]) {
 r = shorten_uuid(id, e);
 if (r = 0) {
 log_info(Initializing machine ID 
 from container UUID.);
 -return 0;
 +r = 0;
 +goto finish;
 }
 }
 }
 @@ -134,7 +140,7 @@ static int generate(char id[34]) {
 r = sd_id128_randomize(buf);
 if (r  0) {
 log_error(Failed to open /dev/urandom: %s, strerror(-r));
 -return r;
 +goto finish;
 }
 
 for (p = buf.bytes, q = id; p  buf.bytes + sizeof(buf); p++, q += 2) 
 {
 @@ -147,15 +153,27 @@ static int generate(char id[34]) {
 
 log_info(Initializing machine ID from random generator.);
 
 -return 0;
 +finish:
 +free(dbus_machine_id);
 +return r;
 }
 
 -int machine_id_setup(void) {
 +int machine_id_setup(const char *root) {
 _cleanup_close_ int fd = -1;
 -int r;
 +int r = 0;
 bool writable = false;
 struct stat st;
 char id[34]; /* 32 + \n + \0 */
 +char *etc_machine_id = NULL;
 +char *run_machine_id = NULL;
 +
 +if (asprintf(etc_machine_id, %s/etc/machine-id, root)  0)
 +return log_oom();
 +
 +if (asprintf(run_machine_id, %s/run/machine-id, root)  0) {
 +r = log_oom();
 +goto finish;
 +}
 
 RUN_WITH_UMASK() 

Re: [systemd-devel] [PATCH] Do not cache use_smack() value unless /sys is mounted

2014-03-14 Thread Łukasz Stelmach
It was 2014-03-11 wto 05:12, when Lennart Poettering wrote:
 On Fri, 28.02.14 17:09, Łukasz Stelmach (l.stelm...@samsung.com) wrote:

 use_smack() is called very early via mkdir_p_label(). This happens
 before /sys is mounted and hence before the authoritative information
 about smack is even available. To prevent caching of the invalid value
 check whether /sys/fs exists.

 Hmm, it appears to me that we probably shouldn't invoke mkdir_p_label()
 that early? Do you know which invocation this is?

mount_one() called from mount_setup_early() at src/core/mount-setup.c

 It sounds really wrong trying to relabel a dir before the policy is
 actually loaded...

mount_one() is used for both mount_setup() and mount_setup_early() and
distinguishing them would look odd.


 ---
  src/shared/smack-util.c |3 +++
  1 file changed, 3 insertions(+)
 
 diff --git a/src/shared/smack-util.c b/src/shared/smack-util.c
 index df194e0..96f365c 100644
 --- a/src/shared/smack-util.c
 +++ b/src/shared/smack-util.c
 @@ -33,6 +33,9 @@ bool use_smack(void) {
  #ifdef HAVE_SMACK
  static int use_smack_cached = -1;
  
 +if (use_smack_cached  0  access(/sys/fs/, F_OK)  0)
 +return false;
 +
  if (use_smack_cached  0)
  use_smack_cached = access(/sys/fs/smackfs/, F_OK) = 0;
  


 Lennart

-- 
Łukasz Stelmach
Samsung RD Institute Poland
Samsung Electronics


pgpfRTSItQ0FA.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] machine-id: add --root option to operate on an alternate fs tree

2014-03-14 Thread Tom Gundersen
On Fri, Mar 14, 2014 at 5:43 AM, Greg KH gre...@linuxfoundation.org wrote:
 This makes it possible to initialize the /etc/machine-id file on an
 arbitrary filesystem hierarchy.  This helps systems that wish to run
 this at image creation time in a subdirectory, or from initramfs before
 pivot-root is called.

Thanks. Applied, with a little tweak: I used the _cleanup_free_
macros. Please have a look in case I messed something up.

Cheers,

Tom

 diff --git a/man/systemd-machine-id-setup.xml 
 b/man/systemd-machine-id-setup.xml
 index 5c34b345d012..b879b40b997d 100644
 --- a/man/systemd-machine-id-setup.xml
 +++ b/man/systemd-machine-id-setup.xml
 @@ -96,6 +96,14 @@
  paraThe following options are understood:/para

  variablelist
 +varlistentry
 +termoption--root=ROOT/option/term
 +listitemparaTakes a directory path
 +as an argument. All paths will be
 +prefixed with the given alternate ROOT
 +path, including config search paths.
 +/para/listitem
 +/varlistentry
  xi:include href=standard-options.xml 
 xpointer=help /
  xi:include href=standard-options.xml 
 xpointer=version /
  /variablelist
 diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
 index 1b55da7e56b8..7d52b468a11a 100644
 --- a/src/core/machine-id-setup.c
 +++ b/src/core/machine-id-setup.c
 @@ -59,18 +59,22 @@ static int shorten_uuid(char destination[36], const char 
 *source) {
  return -EINVAL;
  }

 -static int generate(char id[34]) {
 -int fd, r;
 +static int generate(char id[34], const char *root) {
 +int fd, r = 0;
  unsigned char *p;
  sd_id128_t buf;
  char *q;
  ssize_t k;
  const char *vm_id;
 +char *dbus_machine_id;

  assert(id);

 +if (asprintf(dbus_machine_id, %s/var/lib/dbus/machine-id, root)  
 0)
 +return log_oom();
 +
  /* First, try reading the D-Bus machine id, unless it is a symlink */
 -fd = open(/var/lib/dbus/machine-id, 
 O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
 +fd = open(dbus_machine_id, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
  if (fd = 0) {
  k = loop_read(fd, id, 33, false);
  close_nointr_nofail(fd);
 @@ -83,7 +87,7 @@ static int generate(char id[34]) {
  id[33] = 0;

  log_info(Initializing machine ID from D-Bus 
 machine ID.);
 -return 0;
 +goto finish;
  }
  }
  }
 @@ -105,7 +109,8 @@ static int generate(char id[34]) {
  r = shorten_uuid(id, uuid);
  if (r = 0) {
  log_info(Initializing machine ID 
 from KVM UUID.);
 -return 0;
 +r = 0;
 +goto finish;
  }
  }
  }
 @@ -124,7 +129,8 @@ static int generate(char id[34]) {
  r = shorten_uuid(id, e);
  if (r = 0) {
  log_info(Initializing machine ID 
 from container UUID.);
 -return 0;
 +r = 0;
 +goto finish;
  }
  }
  }
 @@ -134,7 +140,7 @@ static int generate(char id[34]) {
  r = sd_id128_randomize(buf);
  if (r  0) {
  log_error(Failed to open /dev/urandom: %s, strerror(-r));
 -return r;
 +goto finish;
  }

  for (p = buf.bytes, q = id; p  buf.bytes + sizeof(buf); p++, q += 
 2) {
 @@ -147,15 +153,27 @@ static int generate(char id[34]) {

  log_info(Initializing machine ID from random generator.);

 -return 0;
 +finish:
 +free(dbus_machine_id);
 +return r;
  }

 -int machine_id_setup(void) {
 +int machine_id_setup(const char *root) {
  _cleanup_close_ int fd = -1;
 -int r;
 +int r = 0;
  bool writable = false;
  struct stat st;
  char id[34]; /* 32 + \n + \0 */
 +char *etc_machine_id = NULL;
 +char *run_machine_id = NULL;
 +
 +if (asprintf(etc_machine_id, %s/etc/machine-id, root)  0)
 +return log_oom();
 +
 +if (asprintf(run_machine_id, %s/run/machine-id, root)  0) {
 +r = 

Re: [systemd-devel] [PATCH 2/3] tmpfiles: Add --root option to operate on an alternate fs tree.

2014-03-14 Thread Zbigniew Jędrzejewski-Szmek
On Thu, Mar 13, 2014 at 09:32:13PM -0700, Michael Marineau wrote:
 This makes it possible to initialize or cleanup an arbitrary filesystem
 hierarchy in the same way that it would be during system boot.
 ---
  src/tmpfiles/tmpfiles.c | 27 ---
  1 file changed, 24 insertions(+), 3 deletions(-)
Pushed all 3, except that I squashed 2/3 and 3/3 since they form the same 
logical change.

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


Re: [systemd-devel] [HEADS-UP] Discoverable Partitions Spec

2014-03-14 Thread Lennart Poettering
On Fri, 14.03.14 14:49, Koen Kooi (koen.k...@linaro.org) wrote:

  It would be good if in the long run OS installers could adopt this and
  use the right partition type GUIDs automatically, to make this discovery
  work. For now however, you need to manually change the GPT type GUIDs of
  your installation if you want to make use of this scheme.
 
 So how do I get UUIDs allocated for 32bit and 64bit ARM?

Do you use GPT on ARM?

I have now added them to the spec and systemd, since people kept asking
all the time...

They are not too useful though for avoiding root= on the kernel cmdline,
since we only look for root disks on the ESP partition, and EFI isn't
that real on ARM...

But it might be useful for systemd-nspawn -i, and thus I added it
now. 

I wonder if I should just add one for each arch we support, to put an
end to the story...

Lennart

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


Re: [systemd-devel] [HEADS-UP] Discoverable Partitions Spec

2014-03-14 Thread Koen Kooi

Op 14 mrt. 2014, om 15:23 heeft Lennart Poettering lenn...@poettering.net het 
volgende geschreven:

 On Fri, 14.03.14 14:49, Koen Kooi (koen.k...@linaro.org) wrote:
 
 It would be good if in the long run OS installers could adopt this and
 use the right partition type GUIDs automatically, to make this discovery
 work. For now however, you need to manually change the GPT type GUIDs of
 your installation if you want to make use of this scheme.
 
 So how do I get UUIDs allocated for 32bit and 64bit ARM?
 
 Do you use GPT on ARM?

The short answer: yes. 

 I have now added them to the spec and systemd, since people kept asking
 all the time...
 
 They are not too useful though for avoiding root= on the kernel cmdline,
 since we only look for root disks on the ESP partition, and EFI isn't
 that real on ARM...

ARM ltd. likes to pretend arm64 will be UEFI+ACPI only, but yes, it's not that 
real yet. Having said that, what prompted this was the discussion of the 
portable container format, which mandates an ESP partition. If we're going to 
do that on arm we should also make sure to supports this partition spec :)

regards,

Koen

 But it might be useful for systemd-nspawn -i, and thus I added it
 now. 
 
 I wonder if I should just add one for each arch we support, to put an
 end to the story...
 
 Lennart
 
 -- 
 Lennart Poettering, Red Hat

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


Re: [systemd-devel] [PATCH] machine-id: add --root option to operate on an alternate fs tree

2014-03-14 Thread Greg KH
On Fri, Mar 14, 2014 at 12:47:53PM +0100, Tom Gundersen wrote:
 On Fri, Mar 14, 2014 at 5:43 AM, Greg KH gre...@linuxfoundation.org wrote:
  This makes it possible to initialize the /etc/machine-id file on an
  arbitrary filesystem hierarchy.  This helps systems that wish to run
  this at image creation time in a subdirectory, or from initramfs before
  pivot-root is called.
 
 Thanks. Applied, with a little tweak: I used the _cleanup_free_
 macros.

Ah, nice, I forgot about that feature.

 Please have a look in case I messed something up.

Looks great, thanks for merging it.

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


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

2014-03-14 Thread Michael Olbrich
It's HAVE_SPLIT_USR not HAVE_SPLIT_USER
---
 src/network/networkd-manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index c730e71..ea414b1 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -33,7 +33,7 @@ const char* const network_dirs[] = {
 /etc/systemd/network,
 /run/systemd/network,
 /usr/lib/systemd/network,
-#ifdef HAVE_SPLIT_USER
+#ifdef HAVE_SPLIT_USR
 /lib/systemd/network,
 #endif
 NULL};
-- 
1.9.0

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


Re: [systemd-devel] [PATCH] networkd: fix typo

2014-03-14 Thread Tom Gundersen
On Fri, Mar 14, 2014 at 6:19 PM, Michael Olbrich
m.olbr...@pengutronix.de wrote:
 It's HAVE_SPLIT_USR not HAVE_SPLIT_USER

Applied. Thanks!

  src/network/networkd-manager.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
 index c730e71..ea414b1 100644
 --- a/src/network/networkd-manager.c
 +++ b/src/network/networkd-manager.c
 @@ -33,7 +33,7 @@ const char* const network_dirs[] = {
  /etc/systemd/network,
  /run/systemd/network,
  /usr/lib/systemd/network,
 -#ifdef HAVE_SPLIT_USER
 +#ifdef HAVE_SPLIT_USR
  /lib/systemd/network,
  #endif
  NULL};
 --
 1.9.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 2/4] libsystemd-network: Add hangcheck timer for DHCP client test

2014-03-14 Thread Tom Gundersen
On Thu, Mar 13, 2014 at 12:01 PM, Patrik Flykt
patrik.fl...@linux.intel.com wrote:
 ---
  src/libsystemd-network/test-dhcp-client.c | 16 
  1 file changed, 16 insertions(+)

 diff --git a/src/libsystemd-network/test-dhcp-client.c 
 b/src/libsystemd-network/test-dhcp-client.c
 index cfc75ae..9509eec 100644
 --- a/src/libsystemd-network/test-dhcp-client.c
 +++ b/src/libsystemd-network/test-dhcp-client.c
 @@ -44,6 +44,15 @@ static bool verbose = false;
  static int test_fd[2];
  static test_callback_recv_t callback_recv;
  static be32_t xid;
 +static sd_event_source *test_hangcheck;
 +
 +static int test_dhcp_hangcheck(sd_event_source *s, uint64_t usec,
 +   void *userdata)
 +{
 +assert(false);

I guess this should be assert_se() ?

 +
 +return 0;
 +}

  static void test_request_basic(sd_event *e)
  {
 @@ -419,6 +428,7 @@ static int test_addr_acq_recv_discover(size_t size, 
 DHCPMessage *discover)

  static void test_addr_acq(sd_event *e)
  {
 +usec_t time_now = now(CLOCK_MONOTONIC);
  sd_dhcp_client *client;
  int res, r;

 @@ -440,11 +450,17 @@ static void test_addr_acq(sd_event *e)

  callback_recv = test_addr_acq_recv_discover;

 +assert_se(sd_event_add_monotonic(e, test_hangcheck,
 + time_now + 2 * USEC_PER_SEC, 0,
 + test_dhcp_hangcheck, NULL) = 0);
 +
  res = sd_dhcp_client_start(client);
  assert_se(res == 0 || res == -EINPROGRESS);

  sd_event_loop(e);

 +test_hangcheck = sd_event_source_unref(test_hangcheck);
 +
  sd_dhcp_client_set_callback(client, NULL, NULL);
  sd_dhcp_client_stop(client);
  sd_dhcp_client_free(client);
 --
 1.8.5.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