[systemd-devel] [PATCH] journalctl: add --reverse option to show the newest lines first

2013-03-01 Thread Lukas Nykryn
---
 man/journalctl.xml   |  8 +++
 src/journal/journalctl.c | 58 +++-
 2 files changed, 60 insertions(+), 6 deletions(-)

diff --git a/man/journalctl.xml b/man/journalctl.xml
index 5ed0e1f..ca940fe 100644
--- a/man/journalctl.xml
+++ b/man/journalctl.xml
@@ -185,6 +185,14 @@
 /varlistentry
 
 varlistentry
+termoption-r/option/term
+termoption--reverse/option/term
+
+listitemparaReverse output, so the newest
+entries are displayed first./para/listitem
+/varlistentry
+
+varlistentry
 termoption-o/option/term
 termoption--output=/option/term
 
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 9084509..4c9862f 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -77,6 +77,7 @@ static bool arg_since_set = false, arg_until_set = false;
 static const char *arg_unit = NULL;
 static const char *arg_field = NULL;
 static bool arg_catalog = false;
+static bool arg_reverse = false;
 
 static enum {
 ACTION_SHOW,
@@ -103,6 +104,7 @@ static int help(void) {
  -f --followFollow journal\n
  -n --lines[=INTEGER]   Number of journal entries to show\n
 --no-tail   Show all lines, even in follow mode\n
+ -r --reverse   Show the newest entries first\n
  -o --output=STRING Change journal output mode (short, 
short-monotonic,\n
 verbose, export, json, json-pretty, 
json-sse, cat)\n
  -x --catalog   Add message explanations where 
available\n
@@ -184,6 +186,7 @@ static int parse_argv(int argc, char *argv[]) {
 { catalog,  no_argument,   NULL, 'x'  },
 { list-catalog, no_argument,   NULL, ARG_LIST_CATALOG },
 { update-catalog,no_argument,  NULL, ARG_UPDATE_CATALOG 
},
+{ reverse,  no_argument,   NULL, 'r'  },
 { NULL,   0, NULL, 0}
 };
 
@@ -192,7 +195,7 @@ static int parse_argv(int argc, char *argv[]) {
 assert(argc = 0);
 assert(argv);
 
-while ((c = getopt_long(argc, argv, hfo:an::qmbD:p:c:u:F:x, options, 
NULL)) = 0) {
+while ((c = getopt_long(argc, argv, hfo:an::qmbD:p:c:u:F:xr, 
options, NULL)) = 0) {
 
 switch (c) {
 
@@ -424,6 +427,10 @@ static int parse_argv(int argc, char *argv[]) {
 arg_action = ACTION_UPDATE_CATALOG;
 break;
 
+case 'r':
+arg_reverse = true;
+break;
+
 default:
 log_error(Unknown option code %c, c);
 return -EINVAL;
@@ -443,6 +450,11 @@ static int parse_argv(int argc, char *argv[]) {
 return -EINVAL;
 }
 
+if (arg_follow  arg_reverse) {
+log_error(Please specify either --reverse= or --follow=, not 
both.);
+return -EINVAL;
+}
+
 return 1;
 }
 
@@ -997,10 +1009,12 @@ int main(int argc, char *argv[]) {
 log_error(Failed to seek to cursor: %s, 
strerror(-r));
 goto finish;
 }
+if (!arg_reverse)
+r = sd_journal_next(j);
+else
+r = sd_journal_previous(j);
 
-r = sd_journal_next(j);
-
-} else if (arg_since_set) {
+} else if (arg_since_set  !arg_reverse) {
 r = sd_journal_seek_realtime_usec(j, arg_since);
 if (r  0) {
 log_error(Failed to seek to date: %s, strerror(-r));
@@ -1008,6 +1022,14 @@ int main(int argc, char *argv[]) {
 }
 r = sd_journal_next(j);
 
+} else if (arg_until_set  arg_reverse) {
+r = sd_journal_seek_realtime_usec(j, arg_until);
+if (r  0) {
+log_error(Failed to seek to date: %s, strerror(-r));
+goto finish;
+}
+r = sd_journal_previous(j);
+
 } else if (arg_lines = 0) {
 r = sd_journal_seek_tail(j);
 if (r  0) {
@@ -1017,6 +1039,15 @@ int main(int argc, char *argv[]) {
 
 r = sd_journal_previous_skip(j, arg_lines);
 
+} else if (arg_reverse) {
+r = sd_journal_seek_tail(j);
+if (r  0) {
+log_error(Failed to seek to tail: %s, strerror(-r));
+

Re: [systemd-devel] systemd kiosk volatile $HOME

2013-03-01 Thread Lennart Poettering
On Wed, 27.02.13 06:47, systemdki...@yopmail.com (systemdki...@yopmail.com) 
wrote:

 Here's the question (systemd version 197).
 
  https://bbs.archlinux.org/viewtopic.php?pid=1237019
 
 Might the answer involve two units, a mount and a service? Thanks much.

I am not sure I get the full problem. But if this is about simply
mounting a tmpfs to /home at boot, and making sure rsync runs before the
first user can log in, then simple list the tmpfs in /etc/fstab and
create a service file like this in /etc/systemd/system/my-rsync.service:

[Unit]
Before=systemd-user-sessions.service

[Service]
Type=oneshot
ExecStart=/usr/bin/rsync ...

And then pull this in from multi-user.target:

ln -s /etc/systemd/system/my-rsync.service 
/etc/systemd/system/multi-user.target.wants/

And that should be it. systemd-user-sessions.service is a special
service that is run before all user sessions. It removes /run/nologin
and suchlike thus actually allowing user logins. If you run your stuff
before that service, then you can be sure it has to finish before the
first login takes place.

Lennart

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


Re: [systemd-devel] [PATCH] journalctl: add --reverse option to show the newest lines first

2013-03-01 Thread Lennart Poettering
On Fri, 01.03.13 10:27, Lukas Nykryn (lnyk...@redhat.com) wrote:

Thanks! Applied!

 ---
  man/journalctl.xml   |  8 +++
  src/journal/journalctl.c | 58 
 +++-
  2 files changed, 60 insertions(+), 6 deletions(-)
 
 diff --git a/man/journalctl.xml b/man/journalctl.xml
 index 5ed0e1f..ca940fe 100644
 --- a/man/journalctl.xml
 +++ b/man/journalctl.xml
 @@ -185,6 +185,14 @@
  /varlistentry
  
  varlistentry
 +termoption-r/option/term
 +termoption--reverse/option/term
 +
 +listitemparaReverse output, so the newest
 +entries are displayed 
 first./para/listitem
 +/varlistentry
 +
 +varlistentry
  termoption-o/option/term
  termoption--output=/option/term
  
 diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
 index 9084509..4c9862f 100644
 --- a/src/journal/journalctl.c
 +++ b/src/journal/journalctl.c
 @@ -77,6 +77,7 @@ static bool arg_since_set = false, arg_until_set = false;
  static const char *arg_unit = NULL;
  static const char *arg_field = NULL;
  static bool arg_catalog = false;
 +static bool arg_reverse = false;
  
  static enum {
  ACTION_SHOW,
 @@ -103,6 +104,7 @@ static int help(void) {
   -f --followFollow journal\n
   -n --lines[=INTEGER]   Number of journal entries to show\n
  --no-tail   Show all lines, even in follow 
 mode\n
 + -r --reverse   Show the newest entries first\n
   -o --output=STRING Change journal output mode (short, 
 short-monotonic,\n
  verbose, export, json, json-pretty, 
 json-sse, cat)\n
   -x --catalog   Add message explanations where 
 available\n
 @@ -184,6 +186,7 @@ static int parse_argv(int argc, char *argv[]) {
  { catalog,  no_argument,   NULL, 'x'  
 },
  { list-catalog, no_argument,   NULL, ARG_LIST_CATALOG 
 },
  { update-catalog,no_argument,  NULL, 
 ARG_UPDATE_CATALOG },
 +{ reverse,  no_argument,   NULL, 'r'  
 },
  { NULL,   0, NULL, 0}
  };
  
 @@ -192,7 +195,7 @@ static int parse_argv(int argc, char *argv[]) {
  assert(argc = 0);
  assert(argv);
  
 -while ((c = getopt_long(argc, argv, hfo:an::qmbD:p:c:u:F:x, 
 options, NULL)) = 0) {
 +while ((c = getopt_long(argc, argv, hfo:an::qmbD:p:c:u:F:xr, 
 options, NULL)) = 0) {
  
  switch (c) {
  
 @@ -424,6 +427,10 @@ static int parse_argv(int argc, char *argv[]) {
  arg_action = ACTION_UPDATE_CATALOG;
  break;
  
 +case 'r':
 +arg_reverse = true;
 +break;
 +
  default:
  log_error(Unknown option code %c, c);
  return -EINVAL;
 @@ -443,6 +450,11 @@ static int parse_argv(int argc, char *argv[]) {
  return -EINVAL;
  }
  
 +if (arg_follow  arg_reverse) {
 +log_error(Please specify either --reverse= or --follow=, 
 not both.);
 +return -EINVAL;
 +}
 +
  return 1;
  }
  
 @@ -997,10 +1009,12 @@ int main(int argc, char *argv[]) {
  log_error(Failed to seek to cursor: %s, 
 strerror(-r));
  goto finish;
  }
 +if (!arg_reverse)
 +r = sd_journal_next(j);
 +else
 +r = sd_journal_previous(j);
  
 -r = sd_journal_next(j);
 -
 -} else if (arg_since_set) {
 +} else if (arg_since_set  !arg_reverse) {
  r = sd_journal_seek_realtime_usec(j, arg_since);
  if (r  0) {
  log_error(Failed to seek to date: %s, 
 strerror(-r));
 @@ -1008,6 +1022,14 @@ int main(int argc, char *argv[]) {
  }
  r = sd_journal_next(j);
  
 +} else if (arg_until_set  arg_reverse) {
 +r = sd_journal_seek_realtime_usec(j, arg_until);
 +if (r  0) {
 +log_error(Failed to seek to date: %s, 
 strerror(-r));
 +goto finish;
 +}
 +r = sd_journal_previous(j);
 +
  } else if (arg_lines = 0) {
  r = sd_journal_seek_tail(j);
  if (r  0) {
 @@ -1017,6 +1039,15 @@ int main(int argc, char *argv[]) {
  
  r = sd_journal_previous_skip(j, 

Re: [systemd-devel] [PATCH] pager: add K to less environment

2013-03-01 Thread Lennart Poettering
On Wed, 27.02.13 16:26, Lukas Nykryn (lnyk...@redhat.com) wrote:

 Using less as a pager sometimes breaks terminal when output
 is interrupted by ctrl-c.
 Reproducer: run 'sudo journalctl' ctrl-c.
 Thanks mbr...@redhat.com for the solution.

Thanks! Applied!

 ---
  src/shared/pager.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/shared/pager.c b/src/shared/pager.c
 index 488a12c..5165d2b 100644
 --- a/src/shared/pager.c
 +++ b/src/shared/pager.c
 @@ -85,7 +85,7 @@ int pager_open(void) {
  dup2(fd[0], STDIN_FILENO);
  close_pipe(fd);
  
 -setenv(LESS, FRSX, 0);
 +setenv(LESS, FRSXK, 0);
  
  /* Make sure the pager goes away when the parent dies */
  if (prctl(PR_SET_PDEATHSIG, SIGTERM)  0)


Lennart

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


Re: [systemd-devel] systemctl enable in chroot

2013-03-01 Thread Lennart Poettering
On Mon, 25.02.13 17:32, Alexandre Kandalintsev (s...@messir.net) wrote:

 Hi!
 
 I see here that systemctl enable should work in chroot:
 http://0pointer.de/blog/projects/changing-roots
 
 However, what actually see is Failed to issue method call: Invalid
 argument. (probably due to unavailable dbus).

 There are a lot of bugreports around, one to mention:
 https://bugzilla.redhat.com/show_bug.cgi?id=856975

Well, that bug is about something else entirely.

 
 So there are two issues:
 1) absolutely non-informative error report
 
 2) If systemctl enable command just makes a few symlinks then why it
 fails?

I cannot reproduce this here. Which version are you running? Can you
reproduce this on current git?

 Is there any activity (like upstram bugreports) related to this issue?

Well, for that we'd first have to reproduce the issue.

Lennart

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


Re: [systemd-devel] [PATCH 1/2] fstab-generator: initrd - mount the entries in /etc/fstab.sys from the initramfs

2013-03-01 Thread Lennart Poettering
On Mon, 25.02.13 16:00, Tom Gundersen (t...@jklm.no) wrote:

Heya,

 This (together with the right unit files) is needed in the initramfs in order 
 to
 natively support mounting /usr (and friends) from the initramfs.
 
 The concept of /etc/fstab.sys is taken from dracut, but might be used 
 elsewhere
 too.

Hmm, I don't think fstab.sys ever existed outside of dracut, and I am
generally very conservative on introducing new standards in systemd
extending old stuff such as fstab. I mean, if we introduce new standards
then we should do that for really perfectly sound stuff. fstab is
certainly nice and simple, but perfectly sound? Not sure...

Also, besides / and /usr, is there anything else that would ever show up
in fstab.sys? If it's only these two, then it appears much nicer to me
to simply have two kernel cmdline options for these (we have one
anyway... for /). I mean, being generic and stuff is all cool, but let's
not make things too generic here, if there's no reason to.

 Two alternatives were considered, but decided against:
  * configure usr= on the kernel commandline in the same way as root= is.
However, this would be restricted to only the /usr mountpoint, and the
kernelcommandline is crowded enough as it is, so it seems more reasonable 
 to
store the configuration in /etc (as we can). Moreover, this logic would 
 allow
us to use more configuration sources from /etc in the future should that be
necessary.

But this sounds like something you need anyway, if you ever want to
support generic initrds that work everywhere, and whose sole source of
configuration is cmdline hence, right? With just one more option on the
kernel cmdline for usr= I don't really buy the too crowded
issue... Dunno. Do you see any further uses of this?

  * configure the 'sys-mounts' in /etc/fstab. This would require a heuristic to
decide which mounts sohuld be taken care of by the initramfs and which to 
 be
taken care of by the real init. I could not come up with a non-hacky way of
doing that. Perhaps there is use-case for mounting with one set of options 
 in
the initrd and remounting with a different set of options in the real init
(like can be done for the rootfs)? Keeping everything in fstab would make
that impossible.

Well, you could always introduce x-initrd as a mount option to set for
mounts, if you really want to be this generic, and then filter for
it. And also imply it for / and for /usr. But honestly, the usr= kernel
cmdline thingy sounds much simpler and sexier to me?

Lennart

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


Re: [systemd-devel] [PATCH 2/2] initrd: add unit files needed for basic systemd-in-initrd support

2013-03-01 Thread Lennart Poettering
On Mon, 25.02.13 16:00, Tom Gundersen (t...@jklm.no) wrote:

Two of the units definitely sound like good stuff to have in
systemd. But let's first discuss the fstab.sys issue. I am not convinced
about that one. Would still prefer to simply have root= and usr= on the
kernel cmdline and live without fstab.sys...

 This will:
  * mount all configured filesystems (typically the rootfs on /sysroot)
  * reload the configuration to pick up anything from the mounted fs (typically
/sysroot/etc/fstab.sys)
  * mount any newly configured filesystems (typically /usr on /sysroot/usr, if
applicable)
  * shut-down and clean-up any daemons running in the initramfs (typically 
 udevd)
  * switch-root to /sysroot and start the real init


 
 Cc: Harald Hoyer harald.ho...@gmail.com
 Cc: Dave Reisner d...@falconindy.com
 ---
  Makefile.am |  7 ++-
  units/initrd-cleanup.service| 18 ++
  units/initrd-parse-etc.service  | 19 +++
  units/initrd-switch-root.service| 19 +++
  units/initrd-switch-root.target | 16 
  units/initrd-udevadm-cleanup-db.service | 18 ++
  6 files changed, 96 insertions(+), 1 deletion(-)
  create mode 100644 units/initrd-cleanup.service
  create mode 100644 units/initrd-parse-etc.service
  create mode 100644 units/initrd-switch-root.service
  create mode 100644 units/initrd-switch-root.target
  create mode 100644 units/initrd-udevadm-cleanup-db.service
 
 diff --git a/Makefile.am b/Makefile.am
 index f0f0ebc..aa2164c 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -373,7 +373,12 @@ dist_systemunit_DATA = \
   units/systemd-ask-password-console.path \
   units/systemd-udevd-control.socket \
   units/systemd-udevd-kernel.socket \
 - units/system-update.target
 + units/system-update.target \
 + units/initrd-parse-etc.service \
 + units/initrd-cleanup.service \
 + units/initrd-switch-root.target \
 + units/initrd-udevadm-cleanup-db.service \
 + units/initrd-switch-root.service
  
  nodist_systemunit_DATA = \
   units/getty@.service \
 diff --git a/units/initrd-cleanup.service b/units/initrd-cleanup.service
 new file mode 100644
 index 000..8998696
 --- /dev/null
 +++ b/units/initrd-cleanup.service
 @@ -0,0 +1,18 @@
 +#  This file is part of systemd.
 +#
 +#  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.
 +
 +[Unit]
 +Description=Cleaning Up and Shutting Down Daemons
 +DefaultDependencies=no
 +ConditionPathExists=/etc/initrd-release
 +OnFailure=emergency.target
 +Requires=local-fs.target swap.target
 +After=local-fs.target swap.target
 +
 +[Service]
 +Type=oneshot
 +ExecStart=/usr/bin/systemctl --no-block isolate initrd-switch-root.target
 diff --git a/units/initrd-parse-etc.service b/units/initrd-parse-etc.service
 new file mode 100644
 index 000..4bfbb0f
 --- /dev/null
 +++ b/units/initrd-parse-etc.service
 @@ -0,0 +1,19 @@
 +#  This file is part of systemd.
 +#
 +#  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.
 +
 +[Unit]
 +Description=Reload Configuration from the Real Root
 +DefaultDependencies=no
 +Requires=local-fs.target swap.target
 +After=local-fs.target swap.target
 +OnFailure=emergency.target
 +ConditionPathExists=/etc/initrd-release
 +
 +[Service]
 +Type=oneshot
 +ExecStartPre=/usr/bin/systemctl daemon-reload
 +ExecStart=/usr/bin/systemctl --no-block start initrd-cleanup.service
 diff --git a/units/initrd-switch-root.service 
 b/units/initrd-switch-root.service
 new file mode 100644
 index 000..e076b39
 --- /dev/null
 +++ b/units/initrd-switch-root.service
 @@ -0,0 +1,19 @@
 +#  This file is part of systemd.
 +#
 +#  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.
 +
 +[Unit]
 +Description=Switch Root
 +DefaultDependencies=no
 +ConditionPathExists=/etc/initrd-release
 +OnFailure=emergency.target
 +AllowIsolate=yes
 +
 +[Service]
 +Type=oneshot
 +# we have to use --force here, otherwise systemd would umount /run
 +ExecStart=/usr/bin/systemctl --no-block --force switch-root /sysroot
 +KillMode=none
 diff --git a/units/initrd-switch-root.target b/units/initrd-switch-root.target
 new file mode 100644
 index 000..f706d29
 --- /dev/null
 +++ b/units/initrd-switch-root.target
 @@ -0,0 +1,16 @@
 +#  This file is part of systemd.
 +#
 +#  systemd is free software; you 

Re: [systemd-devel] [Hackfest] nspawn a container with isolated network interface

2013-03-01 Thread Lennart Poettering
On Fri, 22.02.13 16:23, Andreas Schultz (aschu...@tpip.net) wrote:

Heya!

 systemd-nspawn already allows you start a container with an
 all networking but lo disabled (--private-network).
 This experimental patch developed during Hackfest in Brno
 allows one to add up to 16 veth pairs to a containers with
 one end outside of the container and the other inside of the
 container.
 
 https://github.com/RoadRunnr/systemd/compare/master...nspawn-netif

Thanks! Sounds good in principle, definitely something we should have!

However, before we can merge this we really should convert this into
proper netlink code, rather than simply invoking the ip tool. We
already have netlink code in systemd, to configure the loopback device,
and doing the requests to create the veth device and assign it to the
namespace shouldn't be that hard, if we just use similar code bits.

Lennart

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


Re: [systemd-devel] [PATCH 2/2] initrd: add unit files needed for basic systemd-in-initrd support

2013-03-01 Thread Dave Reisner
On Fri, Mar 01, 2013 at 02:30:26PM +0100, Lennart Poettering wrote:
 On Mon, 25.02.13 16:00, Tom Gundersen (t...@jklm.no) wrote:
 
 Two of the units definitely sound like good stuff to have in
 systemd. But let's first discuss the fstab.sys issue. I am not convinced
 about that one. Would still prefer to simply have root= and usr= on the
 kernel cmdline and live without fstab.sys...
 

I'm not a fan of the fstab.sys idea either. I suggested to Tom that a
flag in fstab could be used instead -- something like x-initrd.mount
to denote mounts that need to be taken care of in early userspace.

  This will:
   * mount all configured filesystems (typically the rootfs on /sysroot)
   * reload the configuration to pick up anything from the mounted fs 
  (typically
 /sysroot/etc/fstab.sys)
   * mount any newly configured filesystems (typically /usr on /sysroot/usr, 
  if
 applicable)
   * shut-down and clean-up any daemons running in the initramfs (typically 
  udevd)
   * switch-root to /sysroot and start the real init
 
 
  
  Cc: Harald Hoyer harald.ho...@gmail.com
  Cc: Dave Reisner d...@falconindy.com
  ---
   Makefile.am |  7 ++-
   units/initrd-cleanup.service| 18 ++
   units/initrd-parse-etc.service  | 19 +++
   units/initrd-switch-root.service| 19 +++
   units/initrd-switch-root.target | 16 
   units/initrd-udevadm-cleanup-db.service | 18 ++
   6 files changed, 96 insertions(+), 1 deletion(-)
   create mode 100644 units/initrd-cleanup.service
   create mode 100644 units/initrd-parse-etc.service
   create mode 100644 units/initrd-switch-root.service
   create mode 100644 units/initrd-switch-root.target
   create mode 100644 units/initrd-udevadm-cleanup-db.service
  
  diff --git a/Makefile.am b/Makefile.am
  index f0f0ebc..aa2164c 100644
  --- a/Makefile.am
  +++ b/Makefile.am
  @@ -373,7 +373,12 @@ dist_systemunit_DATA = \
  units/systemd-ask-password-console.path \
  units/systemd-udevd-control.socket \
  units/systemd-udevd-kernel.socket \
  -   units/system-update.target
  +   units/system-update.target \
  +   units/initrd-parse-etc.service \
  +   units/initrd-cleanup.service \
  +   units/initrd-switch-root.target \
  +   units/initrd-udevadm-cleanup-db.service \
  +   units/initrd-switch-root.service
   
   nodist_systemunit_DATA = \
  units/getty@.service \
  diff --git a/units/initrd-cleanup.service b/units/initrd-cleanup.service
  new file mode 100644
  index 000..8998696
  --- /dev/null
  +++ b/units/initrd-cleanup.service
  @@ -0,0 +1,18 @@
  +#  This file is part of systemd.
  +#
  +#  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.
  +
  +[Unit]
  +Description=Cleaning Up and Shutting Down Daemons
  +DefaultDependencies=no
  +ConditionPathExists=/etc/initrd-release
  +OnFailure=emergency.target
  +Requires=local-fs.target swap.target
  +After=local-fs.target swap.target
  +
  +[Service]
  +Type=oneshot
  +ExecStart=/usr/bin/systemctl --no-block isolate initrd-switch-root.target
  diff --git a/units/initrd-parse-etc.service b/units/initrd-parse-etc.service
  new file mode 100644
  index 000..4bfbb0f
  --- /dev/null
  +++ b/units/initrd-parse-etc.service
  @@ -0,0 +1,19 @@
  +#  This file is part of systemd.
  +#
  +#  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.
  +
  +[Unit]
  +Description=Reload Configuration from the Real Root
  +DefaultDependencies=no
  +Requires=local-fs.target swap.target
  +After=local-fs.target swap.target
  +OnFailure=emergency.target
  +ConditionPathExists=/etc/initrd-release
  +
  +[Service]
  +Type=oneshot
  +ExecStartPre=/usr/bin/systemctl daemon-reload
  +ExecStart=/usr/bin/systemctl --no-block start initrd-cleanup.service
  diff --git a/units/initrd-switch-root.service 
  b/units/initrd-switch-root.service
  new file mode 100644
  index 000..e076b39
  --- /dev/null
  +++ b/units/initrd-switch-root.service
  @@ -0,0 +1,19 @@
  +#  This file is part of systemd.
  +#
  +#  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.
  +
  +[Unit]
  +Description=Switch Root
  +DefaultDependencies=no
  +ConditionPathExists=/etc/initrd-release
  +OnFailure=emergency.target
  +AllowIsolate=yes
  +
  +[Service]
  +Type=oneshot
  +# we have to use --force here, otherwise 

Re: [systemd-devel] [PATCH] query for user unit information in the journal

2013-03-01 Thread Lennart Poettering
On Thu, 21.02.13 16:39, Daniel Wallace (danielwall...@gtmanfred.com) wrote:

 Add --user-unit= to make it possible to query for user logs by the name
 of the service.

Thanks! Applied!
 ---
  man/journalctl.xml  | 11 +++
  shell-completion/systemd-bash-completion.sh |  5 -
  shell-completion/systemd-zsh-completion.zsh |  1 +
  src/journal/journalctl.c| 13 -
  4 files changed, 28 insertions(+), 2 deletions(-)
 
 diff --git a/man/journalctl.xml b/man/journalctl.xml
 index 5ed0e1f..09a96ac 100644
 --- a/man/journalctl.xml
 +++ b/man/journalctl.xml
 @@ -306,6 +306,17 @@
  /varlistentry
  
  varlistentry
 +termoption--user-unit=/option/term
 +
 +listitemparaShow data only of the
 +specified user session unit. This will
 +add a match for
 +literal_SYSTEMD_USER_UNIT=/literal
 +for the specified
 +unit./para/listitem
 +/varlistentry
 +
 +varlistentry
  termoption-p/option/term
  termoption--priority=/option/term
  
 diff --git a/shell-completion/systemd-bash-completion.sh 
 b/shell-completion/systemd-bash-completion.sh
 index 1132b3c..117dc55 100644
 --- a/shell-completion/systemd-bash-completion.sh
 +++ b/shell-completion/systemd-bash-completion.sh
 @@ -300,7 +300,7 @@ _journalctl() {
-h --help -l --local --new-id128 -m --merge 
 --no-pager
--no-tail -q --quiet --setup-keys --this-boot 
 --verify
--version --list-catalog --update-catalog'
 -   [ARG]='-D --directory -F --field -o --output -u 
 --unit'
 +   [ARG]='-D --directory -F --field -o --output -u 
 --unit --user-unit'
  [ARGUNKNOWN]='-c --cursor --interval -n --lines -p 
 --priority --since --until
--verify-key'
  )
 @@ -320,6 +320,9 @@ _journalctl() {
  --unit|-u)
  comps=$(journalctl -F '_SYSTEMD_UNIT')
  ;;
 +--user-unit)
 +comps=$(journalctl -F '_SYSTEMD_USER_UNIT')
 +;;
  *)
  return 0
  ;;
 diff --git a/shell-completion/systemd-zsh-completion.zsh 
 b/shell-completion/systemd-zsh-completion.zsh
 index 177a564..46e29b2 100644
 --- a/shell-completion/systemd-zsh-completion.zsh
 +++ b/shell-completion/systemd-zsh-completion.zsh
 @@ -70,6 +70,7 @@ _ctls()
  {-c,--cursor=}'[Start showing entries from specified 
 cursor]:cursors:_journal_fields __CURSORS' \
  {-b,--this-boot}'[Show data only from current boot]' \
  {-u,--unit=}'[Show data only from the specified 
 unit]:units:_journal_fields _SYSTEMD_UNIT' \
 +'--user-unit[Show data only from the specified user session 
 unit]:units:_journal_fields _SYSTEMD_USER_UNIT' \
  {-p,--priority=}'[Show only messages within the specified 
 priority range]:priority:_journal_fields PRIORITY' \
  {-f,--follow}'[Follow journal]' \
  {-n,--lines=}'[Number of journal entries to show]:integer' \
 diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
 index 0afeef9..bfea699 100644
 --- a/src/journal/journalctl.c
 +++ b/src/journal/journalctl.c
 @@ -75,6 +75,7 @@ static usec_t arg_interval = DEFAULT_FSS_INTERVAL_USEC;
  static usec_t arg_since, arg_until;
  static bool arg_since_set = false, arg_until_set = false;
  static const char *arg_unit = NULL;
 +static const char *arg_unit_type = NULL;
  static const char *arg_field = NULL;
  static bool arg_catalog = false;
  
 @@ -99,6 +100,7 @@ static int help(void) {
   -c --cursor=CURSOR Start showing entries from 
 specified cursor\n
   -b --this-boot Show data only from current boot\n
   -u --unit=UNIT Show data only from the specified 
 unit\n
 +--user-unit=UNITShow data only from the specified 
 user session unit\n
   -p --priority=RANGEShow only messages within the 
 specified priority range\n
   -f --followFollow journal\n
   -n --lines[=INTEGER]   Number of journal entries to show\n
 @@ -150,6 +152,7 @@ static int parse_argv(int argc, char *argv[]) {
  ARG_DISK_USAGE,
  ARG_SINCE,
  ARG_UNTIL,
 +ARG_USER_UNIT,
  ARG_LIST_CATALOG,
  

Re: [systemd-devel] PATCH: handle rbind mount as bind mounts

2013-03-01 Thread Lennart Poettering
On Thu, 21.02.13 16:09, Frederic Crozat (fcro...@suse.com) wrote:

 Hi all,
 
 attached patch fixes bug reported recently about systemd not handling
 rbind mount as bind mount.

Applied! Thanks!

Lennart

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


Re: [systemd-devel] Cannot add dependency job for unit... Cannot allocate memory

2013-03-01 Thread Lennart Poettering
On Thu, 21.02.13 09:48, Anthony Messina (amess...@messinet.com) wrote:

 I'm not sure if this is the right place to ask, so please direct me to the 
 proper list if it's not.  And byt the way, THANK YOU for systemd!  The more I 
 read and try, the simpler my systems get.
 
 Anyway, I'm writing due to an issue I'm seeing on a few of my Fedora 18 
 machines after I've created a unit file for instantiation that will acquire 
 Kerberos tickets for user-based services such as apache and mythtv, etc. to 
 access NFSv4.1 filesystems.  Any assistance would be appreciated, especially 
 with pointers on improving the unit file itself.  I have attached the dmesg 
 output after booting with systemd.log_level=debug systemd.log_target=kmsg
 
 Thanks in advance -A
 
 I am intermittently running into the error:
 Cannot add dependency job for unit k5start@mythtv.service, ignoring: Unit 
 k5start@mythtv.service failed to load: Cannot allocate memory. See system 
 logs 
 and 'systemctl status k5start@mythtv.service'
  for details.

Heya, this appears to be a problem with a specifier used in this unit
file. Something is using those %x %y %z specifiers in strings they
shouldn't be used. I have now commited a fix to git, to make the error
message about this more useful and not claim it was an OOM situation.

Lennart

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


[systemd-devel] [PATCH] cryptsetup-generator: Add JobTimeoutSec=0 for all known crypt devices

2013-03-01 Thread harald
From: Harald Hoyer har...@redhat.com

put JobTimeoutSec=0 in device-unit.d/JobTimeoutSec0.conf files

This helps with grabbing a cup of coffee while booting and not have the
crypto password dialog timeout and systemd in a failed state.
---
 src/cryptsetup/cryptsetup-generator.c | 62 +++
 1 file changed, 62 insertions(+)

diff --git a/src/cryptsetup/cryptsetup-generator.c 
b/src/cryptsetup/cryptsetup-generator.c
index 38a7cfa..55fc4b7 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -221,6 +221,68 @@ static int create_disk(
 goto fail;
 }
 
+if (!noauto  !nofail) {
+free(p);
+p = strjoin(arg_dest, /dev-mapper-, e, 
.device.d/JobTimeoutSec0.conf, NULL);
+if (!p) {
+r = log_oom();
+goto fail;
+}
+
+mkdir_parents_label(p, 0755);
+
+if (f)
+fclose(f);
+f = fopen(p, wxe);
+if (!f) {
+r = -errno;
+log_error(Failed to create unit file %s: %m, p);
+goto fail;
+}
+
+fprintf(f,
+# Automatically generated by 
systemd-cryptsetup-generator\n\n
+[Unit]\n
+JobTimeoutSec=0\n /* the binary handles timeouts 
anyway */
+);
+fflush(f);
+
+if (ferror(f)) {
+r = -errno;
+log_error(Failed to write file %s: %m, p);
+goto fail;
+}
+
+free(p);
+p = strjoin(arg_dest, /, d, .d/JobTimeoutSec0.conf, NULL);
+if (!p) {
+r = log_oom();
+goto fail;
+}
+
+mkdir_parents_label(p, 0755);
+
+f = fopen(p, wxe);
+if (!f) {
+r = -errno;
+log_error(Failed to create unit file %s: %m, p);
+goto fail;
+}
+
+fprintf(f,
+# Automatically generated by 
systemd-cryptsetup-generator\n\n
+[Unit]\n
+JobTimeoutSec=0\n /* the binary handles timeouts 
anyway */
+);
+fflush(f);
+
+if (ferror(f)) {
+r = -errno;
+log_error(Failed to write file %s: %m, p);
+goto fail;
+}
+}
+
 r = 0;
 
 fail:
-- 
1.8.1

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


[systemd-devel] [PATCH] fstab-generator: If we wait indefinitely for a mount, wait also for the device

2013-03-01 Thread harald
From: Harald Hoyer har...@redhat.com

Write out JobTimeoutSec=0 for the device the mountpoint (which does
not timeout) waits for.

This helps with grabbing a cup of coffee while booting and not have
the crypto password dialog timeout and systemd in a failed state.
---
 src/fstab-generator/fstab-generator.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/src/fstab-generator/fstab-generator.c 
b/src/fstab-generator/fstab-generator.c
index d4470f4..026d070 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -313,6 +313,32 @@ static int add_mount(const char *what, const char *where, 
const char *type, cons
 return r;
 
 if (r  0) {
+if (wait) {
+free(unit);
+unit = strjoin(arg_dest, /, device, 
.d/JobTimeoutSec0.conf, NULL);
+
+mkdir_parents_label(unit, 0755);
+
+fclose(f);
+f = fopen(unit, wxe);
+if (!f) {
+log_error(Failed to create 
unit file %s: %m, unit);
+return -errno;
+}
+
+fprintf(f,
+# Automatically generated by 
systemd-cryptsetup-generator\n\n
+[Unit]\n
+JobTimeoutSec=0\n
+);
+fflush(f);
+
+if (ferror(f)) {
+log_error(Failed to write 
file %s: %m, unit);
+return -errno;
+}
+}
+
 free(lnk);
 lnk = strjoin(arg_dest, /, device, 
.wants/, name, NULL);
 if (!lnk)
-- 
1.8.1

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


[systemd-devel] [PATCH] fstab-generator: default to ro

2013-03-01 Thread harald
From: Harald Hoyer har...@redhat.com

If no ro or rw is specified on the kernel command line, mount root
read-only on /sysroot by default
---
 src/fstab-generator/fstab-generator.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/fstab-generator/fstab-generator.c 
b/src/fstab-generator/fstab-generator.c
index 026d070..d83e73f 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -465,9 +465,11 @@ finish:
 static int parse_new_root_from_proc_cmdline(void) {
 char *w, *state;
 _cleanup_free_ char *what = NULL, *type = NULL, *opts = NULL, *line = 
NULL;
+char *tmp_word;
 int r;
 size_t l;
 bool wait = false;
+bool ro_rw = false;
 
 r = read_one_line_file(/proc/cmdline, line);
 if (r  0) {
@@ -482,7 +484,7 @@ static int parse_new_root_from_proc_cmdline(void) {
 /* root= and roofstype= may occur more than once, the last instance 
should take precedence.
  * In the case of multiple rootflags= the arguments should be 
concatenated */
 FOREACH_WORD_QUOTED(w, l, line, state) {
-char *word, *tmp_word;
+char *word;
 
 word = strndup(w, l);
 if (!word)
@@ -514,12 +516,22 @@ static int parse_new_root_from_proc_cmdline(void) {
 if (!opts)
 return log_oom();
 
+ro_rw = true;
+
 } else if (streq(word, rootwait))
 wait = true;
 
 free(word);
 }
 
+if (!ro_rw) {
+tmp_word = opts;
+opts = strjoin(opts, ,, ro, NULL);
+free(tmp_word);
+if (!opts)
+return log_oom();
+}
+
 if (what) {
 
 log_debug(Found entry what=%s where=/sysroot type=%s, what, 
type);
-- 
1.8.1

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


Re: [systemd-devel] [PATCH] core: reuse the same /tmp, /var/tmp and inaccessible dir

2013-03-01 Thread Lennart Poettering
On Wed, 20.02.13 14:50, Michal Sekletar (msekl...@redhat.com) wrote:

 All Execs within the service, will get mounted the same /tmp and /var/tmp
 directories, if service is configured with PrivateTmp=yes. Temporary
 directories are cleaned up by service itself, rather than relying on
 systemd-tmpfiles. Same logic applies also to inaccessible directories.

Hmm, looks good in principle, but I am don't grok why we need
ExecContext.bind_mounts? Can you elaborate?

Thanks,

Lennart

 ---
  man/systemd.exec.xml |   4 +-
  src/core/execute.c   |  78 --
  src/core/execute.h   |  18 +++-
  src/core/manager.c   |   6 ++
  src/core/manager.h   |   2 +
  src/core/mount.c |  29 -
  src/core/namespace.c | 291 
 ++-
  src/core/namespace.h |  26 +++--
  src/core/service.c   |  41 +++-
  src/core/socket.c|  31 +-
  src/core/swap.c  |  28 -
  src/test/test-ns.c   |  18 +++-
  12 files changed, 423 insertions(+), 149 deletions(-)
 
 diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml
 index 9c31baf..b1cd685 100644
 --- a/man/systemd.exec.xml
 +++ b/man/systemd.exec.xml
 @@ -1107,7 +1107,9 @@
  processes via
  filename/tmp/filename or
  filename/var/tmp/filename
 -impossible. Defaults to
 +impossible. All temporary data created
 +by service will be removed after service
 +is stopped. Defaults to
  false./para/listitem
  /varlistentry
  
 diff --git a/src/core/execute.c b/src/core/execute.c
 index b28962a..fabc0cd 100644
 --- a/src/core/execute.c
 +++ b/src/core/execute.c
 @@ -40,6 +40,7 @@
  #include sys/poll.h
  #include linux/seccomp-bpf.h
  #include glob.h
 +#include execinfo.h
  
  #ifdef HAVE_PAM
  #include security/pam_appl.h
 @@ -165,6 +166,21 @@ void exec_context_tty_reset(const ExecContext *context) {
  vt_disallocate(context-tty_path);
  }
  
 +void exec_context_tmp_dirs_serialize(const ExecContext *context, Unit *u, 
 FILE *f) {
 +assert(context);
 +assert(u);
 +assert(f);
 +
 +if (context-tmp_dir)
 +unit_serialize_item(u, f, tmp-dir, context-tmp_dir);
 +
 +if (context-var_tmp_dir)
 +unit_serialize_item(u, f, var-tmp-dir, 
 context-var_tmp_dir);
 +
 +if (context-inaccessible_dir)
 +unit_serialize_item(u, f, inaccessible-dir, 
 context-inaccessible_dir);
 +}
 +
  static int open_null_as(int flags, int nfd) {
  int fd, r;
  
 @@ -960,7 +976,7 @@ static int apply_seccomp(uint32_t *syscall_filter) {
  
  int exec_spawn(ExecCommand *command,
 char **argv,
 -   const ExecContext *context,
 +   ExecContext *context,
 int fds[], unsigned n_fds,
 char **environment,
 bool apply_permissions,
 @@ -1028,6 +1044,10 @@ int exec_spawn(ExecCommand *command,
  
  cgroup_attribute_apply_list(cgroup_attributes, cgroup_bondings);
  
 +r = setup_tmpdirs(context);
 +if (r  0)
 +return r;
 +
  pid = fork();
  if (pid  0)
  return -errno;
 @@ -1289,13 +1309,8 @@ int exec_spawn(ExecCommand *command,
  if (strv_length(context-read_write_dirs)  0 ||
  strv_length(context-read_only_dirs)  0 ||
  strv_length(context-inaccessible_dirs)  0 ||
 -context-mount_flags != 0 ||
 -context-private_tmp) {
 -err = setup_namespace(context-read_write_dirs,
 -  context-read_only_dirs,
 -  context-inaccessible_dirs,
 -  context-private_tmp,
 -  context-mount_flags);
 +context-mount_flags != 0 ) {
 +err = setup_namespace(context);
  if (err  0) {
  r = EXIT_NAMESPACE;
  goto fail_child;
 @@ -1522,7 +1537,46 @@ void exec_context_init(ExecContext *c) {
  c-timer_slack_nsec = (nsec_t) -1;
  }
  
 -void exec_context_done(ExecContext *c) {
 +static void exec_context_tmp_dirs_done(ExecContext *c) {
 +assert(c);
 +
 +if (c-tmp_dir) {
 +rm_rf_dangerous(c-tmp_dir, false, true, false);
 +free(c-tmp_dir);
 +c-tmp_dir = NULL;
 +}
 +
 +if (c-var_tmp_dir) {
 +rm_rf_dangerous(c-var_tmp_dir, false, true, false);
 +free(c-var_tmp_dir);
 +c-var_tmp_dir = NULL;
 +}
 +
 +   

Re: [systemd-devel] [PATCH 1/2] fstab-generator: initrd - mount the entries in /etc/fstab.sys from the initramfs

2013-03-01 Thread Tom Gundersen
On Fri, Mar 1, 2013 at 2:26 PM, Lennart Poettering
lenn...@poettering.net wrote:
 Also, besides / and /usr, is there anything else that would ever show up
 in fstab.sys? If it's only these two, then it appears much nicer to me
 to simply have two kernel cmdline options for these (we have one
 anyway... for /). I mean, being generic and stuff is all cool, but let's
 not make things too generic here, if there's no reason to.

I don't know how useful it is, but I have seen people asking for
support for subdirs of /usr as separate mounts. If we agree that
that's something we don't want to support by default that's fine with
me.

 Two alternatives were considered, but decided against:
  * configure usr= on the kernel commandline in the same way as root= is.
However, this would be restricted to only the /usr mountpoint, and the
kernelcommandline is crowded enough as it is, so it seems more reasonable 
 to
store the configuration in /etc (as we can). Moreover, this logic would 
 allow
us to use more configuration sources from /etc in the future should that 
 be
necessary.

 But this sounds like something you need anyway, if you ever want to
 support generic initrds that work everywhere, and whose sole source of
 configuration is cmdline hence, right? With just one more option on the
 kernel cmdline for usr= I don't really buy the too crowded
 issue... Dunno. Do you see any further uses of this?

I believe one instance where this might be useful would be to share
/usr/share between different architectures, but I suppose that could
have been solved by a specially crafted initrd and don't need to be
supported by default.

  * configure the 'sys-mounts' in /etc/fstab. This would require a heuristic 
 to
decide which mounts sohuld be taken care of by the initramfs and which to 
 be
taken care of by the real init. I could not come up with a non-hacky way 
 of
doing that. Perhaps there is use-case for mounting with one set of 
 options in
the initrd and remounting with a different set of options in the real init
(like can be done for the rootfs)? Keeping everything in fstab would make
that impossible.

 Well, you could always introduce x-initrd as a mount option to set for
 mounts, if you really want to be this generic, and then filter for
 it. And also imply it for / and for /usr. But honestly, the usr= kernel
 cmdline thingy sounds much simpler and sexier to me?

If we only want to support / and /usr, and don't care about stuff like
/usr/local or /usr/share on separate mounts, then going with usr=
makes sense to me. It would also make everything else much simpler (no
need to reload settings after mounting sysroot). I already wrote the
patch for usr=, so I'll send it out soon.

Harald, what do you think?

Cheers,

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


Re: [systemd-devel] [PATCH] fstab-generator: default to ro

2013-03-01 Thread Tom Gundersen
On Fri, Mar 1, 2013 at 3:13 PM,  har...@redhat.com wrote:
 If no ro or rw is specified on the kernel command line, mount root
 read-only on /sysroot by default

Is this consistent with what the kernel does if you don't have an initramfs?

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


Re: [systemd-devel] [PATCH] cryptsetup-generator: Add JobTimeoutSec=0 for all known crypt devices

2013-03-01 Thread Lennart Poettering
On Fri, 01.03.13 15:13, har...@redhat.com (har...@redhat.com) wrote:

 From: Harald Hoyer har...@redhat.com
 
 put JobTimeoutSec=0 in device-unit.d/JobTimeoutSec0.conf files
 
 This helps with grabbing a cup of coffee while booting and not have the
 crypto password dialog timeout and systemd in a failed state.

I am not sure I like this too much, since fstab generally doesn't list
things based on /dev/mapper, but via UUID= or suchlike, where this
brings no benefit...

 ---
  src/cryptsetup/cryptsetup-generator.c | 62 
 +++
  1 file changed, 62 insertions(+)
 
 diff --git a/src/cryptsetup/cryptsetup-generator.c 
 b/src/cryptsetup/cryptsetup-generator.c
 index 38a7cfa..55fc4b7 100644
 --- a/src/cryptsetup/cryptsetup-generator.c
 +++ b/src/cryptsetup/cryptsetup-generator.c
 @@ -221,6 +221,68 @@ static int create_disk(
  goto fail;
  }
  
 +if (!noauto  !nofail) {
 +free(p);
 +p = strjoin(arg_dest, /dev-mapper-, e, 
 .device.d/JobTimeoutSec0.conf, NULL);
 +if (!p) {
 +r = log_oom();
 +goto fail;
 +}
 +
 +mkdir_parents_label(p, 0755);
 +
 +if (f)
 +fclose(f);
 +f = fopen(p, wxe);
 +if (!f) {
 +r = -errno;
 +log_error(Failed to create unit file %s: %m, p);
 +goto fail;
 +}
 +
 +fprintf(f,
 +# Automatically generated by 
 systemd-cryptsetup-generator\n\n
 +[Unit]\n
 +JobTimeoutSec=0\n /* the binary handles timeouts 
 anyway */
 +);
 +fflush(f);
 +
 +if (ferror(f)) {
 +r = -errno;
 +log_error(Failed to write file %s: %m, p);
 +goto fail;
 +}
 +
 +free(p);
 +p = strjoin(arg_dest, /, d, .d/JobTimeoutSec0.conf, 
 NULL);
 +if (!p) {
 +r = log_oom();
 +goto fail;
 +}
 +
 +mkdir_parents_label(p, 0755);
 +
 +f = fopen(p, wxe);
 +if (!f) {
 +r = -errno;
 +log_error(Failed to create unit file %s: %m, p);
 +goto fail;
 +}
 +
 +fprintf(f,
 +# Automatically generated by 
 systemd-cryptsetup-generator\n\n
 +[Unit]\n
 +JobTimeoutSec=0\n /* the binary handles timeouts 
 anyway */
 +);
 +fflush(f);
 +
 +if (ferror(f)) {
 +r = -errno;
 +log_error(Failed to write file %s: %m, p);
 +goto fail;
 +}
 +}
 +
  r = 0;
  
  fail:


Lennart

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


[systemd-devel] [PATCHES] Rebased versions

2013-03-01 Thread Oleksii Shevchuk

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


[systemd-devel] [PATCH] [RFCv2] Set StopWhenUnneeded=no when unit unneeded, but forced

2013-03-01 Thread Oleksii Shevchuk
---
 src/core/dbus-unit.c  | 18 +++-
 src/core/job.c| 28 -
 src/core/job.h|  1 +
 src/core/load-fragment-gperf.gperf.m4 |  2 +-
 src/core/load-fragment.c  |  4 ++
 src/core/manager.c|  2 +-
 src/core/transaction.c| 78 +++
 src/core/transaction.h|  1 +
 src/core/unit.c   | 67 +++---
 src/core/unit.h   |  5 ++-
 10 files changed, 169 insertions(+), 37 deletions(-)

diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 7c23e1e..f40a52c 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -203,6 +203,22 @@ static int bus_unit_append_can_stop(DBusMessageIter *i, 
const char *property, vo
 return 0;
 }
 
+static int bus_unit_append_stop_when_unneeded(DBusMessageIter *i, const char 
*property, void *data) {
+Unit *u = data;
+dbus_bool_t b;
+
+assert(i);
+assert(property);
+assert(u);
+
+b = unit_stop_when_unneeded_state(u);
+
+if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, b))
+return -ENOMEM;
+
+return 0;
+}
+
 static int bus_unit_append_can_reload(DBusMessageIter *i, const char 
*property, void *data) {
 Unit *u = data;
 dbus_bool_t b;
@@ -1298,7 +1314,7 @@ const BusProperty bus_unit_properties[] = {
 { CanReload,bus_unit_append_can_reload, b, 0 },
 { CanIsolate,   bus_unit_append_can_isolate,b, 0 },
 { Job,  bus_unit_append_job, (uo), 0 },
-{ StopWhenUnneeded, bus_property_append_bool,   b, 
offsetof(Unit, stop_when_unneeded) },
+{ StopWhenUnneeded, bus_unit_append_stop_when_unneeded, b, 0 },
 { RefuseManualStart,bus_property_append_bool,   b, 
offsetof(Unit, refuse_manual_start)},
 { RefuseManualStop, bus_property_append_bool,   b, 
offsetof(Unit, refuse_manual_stop) },
 { AllowIsolate, bus_property_append_bool,   b, 
offsetof(Unit, allow_isolate)  },
diff --git a/src/core/job.c b/src/core/job.c
index 90de550..1735e91 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -297,12 +297,14 @@ void job_dump(Job *j, FILE*f, const char *prefix) {
 %s\tAction: %s - %s\n
 %s\tState: %s\n
 %s\tForced: %s\n
-%s\tIrreversible: %s\n,
+%s\tIrreversible: %s\n
+%s\tTransaction Root: %s\n,
 prefix, j-id,
 prefix, j-unit-id, job_type_to_string(j-type),
 prefix, job_state_to_string(j-state),
 prefix, yes_no(j-override),
-prefix, yes_no(j-irreversible));
+prefix, yes_no(j-irreversible),
+prefix, yes_no(j-root));
 }
 
 /*
@@ -514,6 +516,21 @@ int job_run_and_invalidate(Job *j) {
 switch (j-type) {
 
 case JOB_START:
+/* Check once again */
+if (unit_unneeded(j-unit)) {
+if (j-root  j-override) {
+log_debug(Setup StopWhenUnneeded=no 
for unit %s just before activation,
+  j-unit-id);
+j-unit-stop_when_unneeded_runtime = 
false;
+} else {
+log_debug(Don't start unit %s as it 
unneeded, j-unit-id);
+/* unit_notify used for dropping 
already started unneeded dependencies */
+unit_notify(j-unit, UNIT_ACTIVATING, 
UNIT_FAILED, false);
+r = 0;
+break;
+}
+}
+
 r = unit_start(j-unit);
 
 /* If this unit cannot be started, then simply wait */
@@ -954,6 +971,7 @@ int job_serialize(Job *j, FILE *f, FDSet *fds) {
 fprintf(f, job-id=%u\n, j-id);
 fprintf(f, job-type=%s\n, job_type_to_string(j-type));
 fprintf(f, job-state=%s\n, job_state_to_string(j-state));
+fprintf(f, job-root=%s\n, yes_no(j-root));
 fprintf(f, job-override=%s\n, yes_no(j-override));
 fprintf(f, job-irreversible=%s\n, yes_no(j-irreversible));
 fprintf(f, job-sent-dbus-new-signal=%s\n, 
yes_no(j-sent_dbus_new_signal));
@@ -1017,6 +1035,12 @@ int job_deserialize(Job *j, FILE *f, FDSet *fds) {
 log_debug(Failed to parse job state %s, v);
 else
 j-state = s;
+  

[systemd-devel] [PATCH] [RFCv3] Optionally save core dumps as plain files

2013-03-01 Thread Oleksii Shevchuk
Introduce configuration file: /etc/systemd/coredump.conf with
configurable uid/gid parameters, optional backends to journal
and files, per storage size limits
---
 Makefile-man.am  |   1 +
 Makefile.am  |  13 +-
 man/coredump.conf.xml| 149 +++
 src/core/manager.c   |   1 +
 src/journal/coredump-gperf.gperf |  23 ++
 src/journal/coredump.c   | 554 ---
 src/journal/coredump.conf|  16 ++
 src/journal/coredump.h   |  61 +
 src/journal/journald-server.c|   3 +-
 src/journal/journald-server.h|   2 +-
 10 files changed, 724 insertions(+), 99 deletions(-)
 create mode 100644 man/coredump.conf.xml
 create mode 100644 src/journal/coredump-gperf.gperf
 create mode 100644 src/journal/coredump.conf
 create mode 100644 src/journal/coredump.h

diff --git a/Makefile-man.am b/Makefile-man.am
index d02fff0..870e8ce 100644
--- a/Makefile-man.am
+++ b/Makefile-man.am
@@ -8,6 +8,7 @@ MANPAGES += \
man/hostname.5 \
man/journalctl.1 \
man/journald.conf.5 \
+   man/coredump.conf.5 \
man/kernel-command-line.7 \
man/kernel-install.8 \
man/locale.conf.5 \
diff --git a/Makefile.am b/Makefile.am
index 790e501..c819e30 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2628,7 +2628,8 @@ nodist_systemunit_DATA += \
units/systemd-journal-flush.service
 
 dist_pkgsysconf_DATA += \
-   src/journal/journald.conf
+   src/journal/journald.conf \
+   src/journal/coredump.conf
 
 pkgconfiglib_DATA += \
src/journal/libsystemd-journal.pc
@@ -2647,10 +2648,12 @@ EXTRA_DIST += \
src/journal/libsystemd-journal.sym \
units/systemd-journald.service.in \
units/systemd-journal-flush.service.in \
-   src/journal/journald-gperf.gperf
+   src/journal/journald-gperf.gperf \
+   src/journal/coredump-gperf.gperf
 
 CLEANFILES += \
-   src/journal/journald-gperf.c
+   src/journal/journald-gperf.c \
+   src/journal/coredump-gperf.c
 
 # 
--
 if HAVE_MICROHTTPD
@@ -2694,10 +2697,12 @@ EXTRA_DIST += \
 # 
--
 if ENABLE_COREDUMP
 systemd_coredump_SOURCES = \
-   src/journal/coredump.c
+   src/journal/coredump.c \
+   src/journal/coredump-gperf.c
 
 systemd_coredump_LDADD = \
libsystemd-journal-internal.la \
+   libsystemd-id128-internal.la \
libsystemd-label.la \
libsystemd-shared.la
 
diff --git a/man/coredump.conf.xml b/man/coredump.conf.xml
new file mode 100644
index 000..de605b5
--- /dev/null
+++ b/man/coredump.conf.xml
@@ -0,0 +1,149 @@
+?xml version='1.0'? !--*-nxml-*--
+?xml-stylesheet type=text/xsl 
href=http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl;?
+!DOCTYPE refentry PUBLIC -//OASIS//DTD DocBook XML V4.2//EN
+http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd;
+
+!--
+  This file is part of systemd.
+
+  Copyright 2013 Lennart Poettering
+ Oleksii Shevchuk
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see http://www.gnu.org/licenses/.
+--
+
+refentry id=coredump.conf
+refentryinfo
+titlecoredump.conf/title
+productnamesystemd/productname
+
+authorgroup
+author
+contribDeveloper/contrib
+firstnameLennart/firstname
+surnamePoettering/surname
+emaillenn...@poettering.net/email
+/author
+author
+contribDeveloper/contrib
+firstnameOleksii/firstname
+surnameShevchuk/surname
+emailalx...@gmail.com/email
+/author
+/authorgroup
+/refentryinfo
+
+refmeta
+refentrytitlecoredump.conf/refentrytitle
+manvolnum5/manvolnum
+/refmeta
+
+refnamediv
+refnamecoredump.conf/refname
+refpurposeCoredump utility configuration file/refpurpose
+/refnamediv
+
+refsynopsisdiv
+

Re: [systemd-devel] [PATCH] cryptsetup-generator: Add JobTimeoutSec=0 for all known crypt devices

2013-03-01 Thread Harald Hoyer
Am 01.03.2013 15:22, schrieb Lennart Poettering:
 On Fri, 01.03.13 15:13, har...@redhat.com (har...@redhat.com) wrote:
 
 From: Harald Hoyer har...@redhat.com

 put JobTimeoutSec=0 in device-unit.d/JobTimeoutSec0.conf files

 This helps with grabbing a cup of coffee while booting and not have the
 crypto password dialog timeout and systemd in a failed state.
 
 I am not sure I like this too much, since fstab generally doesn't list
 things based on /dev/mapper, but via UUID= or suchlike, where this
 brings no benefit...

Well, then only merge the second part without dev-mapper?
p = strjoin(arg_dest, /, d, .d/JobTimeoutSec0.conf, NULL);


 
 ---
  src/cryptsetup/cryptsetup-generator.c | 62 
 +++
  1 file changed, 62 insertions(+)

 diff --git a/src/cryptsetup/cryptsetup-generator.c 
 b/src/cryptsetup/cryptsetup-generator.c
 index 38a7cfa..55fc4b7 100644
 --- a/src/cryptsetup/cryptsetup-generator.c
 +++ b/src/cryptsetup/cryptsetup-generator.c
 @@ -221,6 +221,68 @@ static int create_disk(
  goto fail;
  }
  
 +if (!noauto  !nofail) {
 +free(p);
 +p = strjoin(arg_dest, /dev-mapper-, e, 
 .device.d/JobTimeoutSec0.conf, NULL);
 +if (!p) {
 +r = log_oom();
 +goto fail;
 +}
 +
 +mkdir_parents_label(p, 0755);
 +
 +if (f)
 +fclose(f);
 +f = fopen(p, wxe);
 +if (!f) {
 +r = -errno;
 +log_error(Failed to create unit file %s: %m, p);
 +goto fail;
 +}
 +
 +fprintf(f,
 +# Automatically generated by 
 systemd-cryptsetup-generator\n\n
 +[Unit]\n
 +JobTimeoutSec=0\n /* the binary handles timeouts 
 anyway */
 +);
 +fflush(f);
 +
 +if (ferror(f)) {
 +r = -errno;
 +log_error(Failed to write file %s: %m, p);
 +goto fail;
 +}
 +
 +free(p);
 +p = strjoin(arg_dest, /, d, .d/JobTimeoutSec0.conf, 
 NULL);
 +if (!p) {
 +r = log_oom();
 +goto fail;
 +}
 +
 +mkdir_parents_label(p, 0755);
 +
 +f = fopen(p, wxe);
 +if (!f) {
 +r = -errno;
 +log_error(Failed to create unit file %s: %m, p);
 +goto fail;
 +}
 +
 +fprintf(f,
 +# Automatically generated by 
 systemd-cryptsetup-generator\n\n
 +[Unit]\n
 +JobTimeoutSec=0\n /* the binary handles timeouts 
 anyway */
 +);
 +fflush(f);
 +
 +if (ferror(f)) {
 +r = -errno;
 +log_error(Failed to write file %s: %m, p);
 +goto fail;
 +}
 +}
 +
  r = 0;
  
  fail:
 
 
 Lennart
 

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


Re: [systemd-devel] [PATCH] fstab-generator: If we wait indefinitely for a mount, wait also for the device

2013-03-01 Thread Lennart Poettering
On Fri, 01.03.13 15:13, har...@redhat.com (har...@redhat.com) wrote:

 From: Harald Hoyer har...@redhat.com
 
 Write out JobTimeoutSec=0 for the device the mountpoint (which does
 not timeout) waits for.
 
 This helps with grabbing a cup of coffee while booting and not have
 the crypto password dialog timeout and systemd in a failed state.

Hmm, this hooks into wait, which is initialized from the kernel
cmdline rootwait? What are the precise semantics of the kernel there
regarding this flag, in a non-initrd case? We probably should mimic the
kernel here is good as we can...

So, in the non-initrd case: what does rootwait do on the kernel cmdline?
And what happens if it is not used?

 ---
  src/fstab-generator/fstab-generator.c | 26 ++
  1 file changed, 26 insertions(+)
 
 diff --git a/src/fstab-generator/fstab-generator.c 
 b/src/fstab-generator/fstab-generator.c
 index d4470f4..026d070 100644
 --- a/src/fstab-generator/fstab-generator.c
 +++ b/src/fstab-generator/fstab-generator.c
 @@ -313,6 +313,32 @@ static int add_mount(const char *what, const char 
 *where, const char *type, cons
  return r;
  
  if (r  0) {
 +if (wait) {
 +free(unit);
 +unit = strjoin(arg_dest, /,
 device, .d/JobTimeoutSec0.conf, NULL);


Hmm, we probably should always prefix drop-in snippets we generate with
50-, so that people can easily order their stuff before/after what we
write here.

 +
 +mkdir_parents_label(unit, 0755);
 +
 +fclose(f);
 +f = fopen(unit, wxe);
 +if (!f) {
 +log_error(Failed to create 
 unit file %s: %m, unit);
 +return -errno;
 +}
 +
 +fprintf(f,
 +# Automatically generated 
 by systemd-cryptsetup-generator\n\n
 +[Unit]\n
 +JobTimeoutSec=0\n
 +);
 +fflush(f);
 +
 +if (ferror(f)) {
 +log_error(Failed to write 
 file %s: %m, unit);
 +return -errno;
 +}


Hmm, probably something to use write_one_line_file() for. (Which should
probably be renamed, given that it is useful for writing multi-line
files, too...)

 +}
 +
  free(lnk);
  lnk = strjoin(arg_dest, /, device, 
 .wants/, name, NULL);
  if (!lnk)

Lennart

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


Re: [systemd-devel] [PATCH] fstab-generator: If we wait indefinitely for a mount, wait also for the device

2013-03-01 Thread Harald Hoyer
Am 01.03.2013 15:30, schrieb Lennart Poettering:
 On Fri, 01.03.13 15:13, har...@redhat.com (har...@redhat.com) wrote:
 
 From: Harald Hoyer har...@redhat.com

 Write out JobTimeoutSec=0 for the device the mountpoint (which does
 not timeout) waits for.

 This helps with grabbing a cup of coffee while booting and not have
 the crypto password dialog timeout and systemd in a failed state.
 
 Hmm, this hooks into wait, which is initialized from the kernel
 cmdline rootwait? What are the precise semantics of the kernel there
 regarding this flag, in a non-initrd case? We probably should mimic the
 kernel here is good as we can...
 
 So, in the non-initrd case: what does rootwait do on the kernel cmdline?
 And what happens if it is not used?

rootwait[KNL] Wait (indefinitely) for root device to show up.
Useful for devices that are detected asynchronously
(e.g. USB and MMC devices).

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


[systemd-devel] [PATCH] core: fix running jobs counters after reload/reexec

2013-03-01 Thread Michal Schmidt
All active units will call unit_notify() during coldplug, so we just
make sure we're counting from zero again and get the correct result for
n_on_console.

For n_running_jobs we likewise reset it to zero and then count
the running jobs as we encounter them in deserialization.
---
 src/core/manager.c | 3 +++
 src/core/unit.c| 8 +++-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/core/manager.c b/src/core/manager.c
index 5527e9d..4242398 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -678,6 +678,9 @@ static void manager_clear_jobs_and_units(Manager *m) {
 
 assert(hashmap_isempty(m-jobs));
 assert(hashmap_isempty(m-units));
+
+m-n_on_console = 0;
+m-n_running_jobs = 0;
 }
 
 void manager_free(Manager *m) {
diff --git a/src/core/unit.c b/src/core/unit.c
index 601be60..2f0ac00 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1360,11 +1360,6 @@ void unit_notify(Unit *u, UnitActiveState os, 
UnitActiveState ns, bool reload_su
 if (UNIT_IS_INACTIVE_OR_FAILED(os) != UNIT_IS_INACTIVE_OR_FAILED(ns)) {
 ExecContext *ec = unit_get_exec_context(u);
 if (ec  exec_context_may_touch_console(ec)) {
-/* XXX The counter may get out of sync if the admin 
edits
- * TTY-related unit file properties and issues a 
daemon-reload
- * while the unit is active. No big deal though, 
because
- * it influences only the printing of boot/shutdown
- * status messages. */
 if (UNIT_IS_INACTIVE_OR_FAILED(ns))
 m-n_on_console--;
 else
@@ -2446,6 +2441,9 @@ int unit_deserialize(Unit *u, FILE *f, FDSet *fds) {
 return r;
 }
 
+if (j-state == JOB_RUNNING)
+u-manager-n_running_jobs++;
+
 r = job_install_deserialized(j);
 if (r  0) {
 hashmap_remove(u-manager-jobs, 
UINT32_TO_PTR(j-id));
-- 
1.8.1.4

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


Re: [systemd-devel] [PATCH] fstab-generator: If we wait indefinitely for a mount, wait also for the device

2013-03-01 Thread Lennart Poettering
On Fri, 01.03.13 15:33, Harald Hoyer (har...@redhat.com) wrote:

 
 Am 01.03.2013 15:30, schrieb Lennart Poettering:
  On Fri, 01.03.13 15:13, har...@redhat.com (har...@redhat.com) wrote:
  
  From: Harald Hoyer har...@redhat.com
 
  Write out JobTimeoutSec=0 for the device the mountpoint (which does
  not timeout) waits for.
 
  This helps with grabbing a cup of coffee while booting and not have
  the crypto password dialog timeout and systemd in a failed state.
  
  Hmm, this hooks into wait, which is initialized from the kernel
  cmdline rootwait? What are the precise semantics of the kernel there
  regarding this flag, in a non-initrd case? We probably should mimic the
  kernel here is good as we can...
  
  So, in the non-initrd case: what does rootwait do on the kernel cmdline?
  And what happens if it is not used?
 
 rootwait[KNL] Wait (indefinitely) for root device to show up.
 Useful for devices that are detected asynchronously
 (e.g. USB and MMC devices).

Yeah, that's what I read, too, but I cannot make sense of it. See above:
what is different from when it is not used? Or to be precise: what does
the kernel precisely do when rootwait is *not* passed?

Lennart

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


Re: [systemd-devel] [systemd-commits] src/shared

2013-03-01 Thread Zbigniew Jędrzejewski-Szmek
On Fri, Mar 01, 2013 at 05:17:35AM -0800, Lennart Poettering wrote:
 path-lookup: downgrade again the messages where we log for units
 
 This partially reverts 7ad94c716d6403233d04c4d37cb14df958c9b65d.
 
 After that commit commands such as systemctl enable and friends
 printed the search path information multiple times in its output, which
 is ugly.
 
 If we want the search paths to be printed at a higher log level, then we
 should do this in PID 1 only, i.e. split the printing out of the normal
 path lookup logic and invoke that explicitly from PID 1 but not in the
 auxiliary tools.
I'll take care of this.

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


Re: [systemd-devel] [PATCH] fstab-generator: If we wait indefinitely for a mount, wait also for the device

2013-03-01 Thread Carlos Silva
On Fri, Mar 1, 2013 at 1:37 PM, Lennart Poettering
lenn...@poettering.netwrote:

   So, in the non-initrd case: what does rootwait do on the kernel
 cmdline?
   And what happens if it is not used?
 
  rootwait[KNL] Wait (indefinitely) for root device to
 show up.
  Useful for devices that are detected
 asynchronously
  (e.g. USB and MMC devices).

 Yeah, that's what I read, too, but I cannot make sense of it. See above:
 what is different from when it is not used? Or to be precise: what does
 the kernel precisely do when rootwait is *not* passed?


Hi,

AFAIK, without rootwait, it just tries to mount root and execute init
failing if the device isn't there.
With rootwait, it *waits* for the device to become available before
mounting root.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] fstab-generator: If we wait indefinitely for a mount, wait also for the device

2013-03-01 Thread Tom Gundersen
On Fri, Mar 1, 2013 at 3:37 PM, Lennart Poettering
lenn...@poettering.net wrote:
 On Fri, 01.03.13 15:33, Harald Hoyer (har...@redhat.com) wrote:


 Am 01.03.2013 15:30, schrieb Lennart Poettering:
  On Fri, 01.03.13 15:13, har...@redhat.com (har...@redhat.com) wrote:
 
  From: Harald Hoyer har...@redhat.com
 
  Write out JobTimeoutSec=0 for the device the mountpoint (which does
  not timeout) waits for.
 
  This helps with grabbing a cup of coffee while booting and not have
  the crypto password dialog timeout and systemd in a failed state.
 
  Hmm, this hooks into wait, which is initialized from the kernel
  cmdline rootwait? What are the precise semantics of the kernel there
  regarding this flag, in a non-initrd case? We probably should mimic the
  kernel here is good as we can...
 
  So, in the non-initrd case: what does rootwait do on the kernel cmdline?
  And what happens if it is not used?

 rootwait[KNL] Wait (indefinitely) for root device to show up.
 Useful for devices that are detected asynchronously
 (e.g. USB and MMC devices).

 Yeah, that's what I read, too, but I cannot make sense of it. See above:
 what is different from when it is not used? Or to be precise: what does
 the kernel precisely do when rootwait is *not* passed?

When rootwait is not passed the kernel calls sys_mount() immediately
(after the equivalent of udevadm settle) assuming the device will be
there, failing if it is not. Otherwise, if rootwait is called, the
kernel will wait (possibly indefinitely) for the device to appear
before attempting to mount it.

Setting JobTimeout=0 on the device seems correct to me.

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


Re: [systemd-devel] [PATCH] fstab-generator: default to ro

2013-03-01 Thread Harald Hoyer
Am 01.03.2013 15:20, schrieb Tom Gundersen:
 On Fri, Mar 1, 2013 at 3:13 PM,  har...@redhat.com wrote:
 If no ro or rw is specified on the kernel command line, mount root
 read-only on /sysroot by default
 
 Is this consistent with what the kernel does if you don't have an initramfs?
 
 -t
 

#  /tt
sh: /tt: Read-only file system

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


Re: [systemd-devel] [PATCH] fstab-generator: default to ro

2013-03-01 Thread Tom Gundersen
On Fri, Mar 1, 2013 at 4:56 PM, Harald Hoyer har...@redhat.com wrote:
 Am 01.03.2013 15:20, schrieb Tom Gundersen:
 On Fri, Mar 1, 2013 at 3:13 PM,  har...@redhat.com wrote:
 If no ro or rw is specified on the kernel command line, mount root
 read-only on /sysroot by default

 Is this consistent with what the kernel does if you don't have an initramfs?

 -t


 #  /tt
 sh: /tt: Read-only file system

 yes

Cool. +1 from me then.

I had a look at the kernel sources, the default root mount options is
MS_RDONLY  | MS_SILENT. Should we be passing silent as well to
stay compatible? I don't know what the downside would be, except that
there does not appear to be a way to switch back to loud from the
kernel commandline.

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


Re: [systemd-devel] [PATCH] fstab-generator: default to ro

2013-03-01 Thread Harald Hoyer
Am 01.03.2013 17:21, schrieb Tom Gundersen:
 On Fri, Mar 1, 2013 at 4:56 PM, Harald Hoyer har...@redhat.com wrote:
 Am 01.03.2013 15:20, schrieb Tom Gundersen:
 On Fri, Mar 1, 2013 at 3:13 PM,  har...@redhat.com wrote:
 If no ro or rw is specified on the kernel command line, mount root
 read-only on /sysroot by default

 Is this consistent with what the kernel does if you don't have an initramfs?

 -t


 #  /tt
 sh: /tt: Read-only file system

 yes
 
 Cool. +1 from me then.
 
 I had a look at the kernel sources, the default root mount options is
 MS_RDONLY  | MS_SILENT. Should we be passing silent as well to
 stay compatible? I don't know what the downside would be, except that
 there does not appear to be a way to switch back to loud from the
 kernel commandline.
 
 -t
 

Now, the only thing missing is generating systemd-fsck@.service Wants and
After for sysroot.mount and sysroot-usr.mount.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] fstab-generator: default to ro

2013-03-01 Thread Tom Gundersen
On Fri, Mar 1, 2013 at 5:25 PM, Harald Hoyer har...@redhat.com wrote:
 Now, the only thing missing is generating systemd-fsck@.service Wants and
 After for sysroot.mount and sysroot-usr.mount.

Hm, I didn't look at that yet. Mostly because I use btrfs, but also
because I don't know what would be the heuristic to use. We don't have
a passno, so how do we know when we want to fsck (almost always) and
when not (when using btrfs)?

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


Re: [systemd-devel] [PATCH] fstab-generator: default to ro

2013-03-01 Thread Lennart Poettering
On Fri, 01.03.13 15:13, har...@redhat.com (har...@redhat.com) wrote:

 From: Harald Hoyer har...@redhat.com
 
 If no ro or rw is specified on the kernel command line, mount root
 read-only on /sysroot by default

This sounds good, in order to stay in sync with the initrd-less kernel
logic. Please commit!

 ---
  src/fstab-generator/fstab-generator.c | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)
 
 diff --git a/src/fstab-generator/fstab-generator.c 
 b/src/fstab-generator/fstab-generator.c
 index 026d070..d83e73f 100644
 --- a/src/fstab-generator/fstab-generator.c
 +++ b/src/fstab-generator/fstab-generator.c
 @@ -465,9 +465,11 @@ finish:
  static int parse_new_root_from_proc_cmdline(void) {
  char *w, *state;
  _cleanup_free_ char *what = NULL, *type = NULL, *opts = NULL, *line 
 = NULL;
 +char *tmp_word;
  int r;
  size_t l;
  bool wait = false;
 +bool ro_rw = false;
  
  r = read_one_line_file(/proc/cmdline, line);
  if (r  0) {
 @@ -482,7 +484,7 @@ static int parse_new_root_from_proc_cmdline(void) {
  /* root= and roofstype= may occur more than once, the last instance 
 should take precedence.
   * In the case of multiple rootflags= the arguments should be 
 concatenated */
  FOREACH_WORD_QUOTED(w, l, line, state) {
 -char *word, *tmp_word;
 +char *word;
  
  word = strndup(w, l);
  if (!word)
 @@ -514,12 +516,22 @@ static int parse_new_root_from_proc_cmdline(void) {
  if (!opts)
  return log_oom();
  
 +ro_rw = true;
 +
  } else if (streq(word, rootwait))
  wait = true;
  
  free(word);
  }
  
 +if (!ro_rw) {
 +tmp_word = opts;
 +opts = strjoin(opts, ,, ro, NULL);
 +free(tmp_word);
 +if (!opts)
 +return log_oom();
 +}
 +
  if (what) {
  
  log_debug(Found entry what=%s where=/sysroot type=%s, 
 what, type);


Lennart

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


Re: [systemd-devel] [PATCH] cryptsetup-generator: Add JobTimeoutSec=0 for all known crypt devices

2013-03-01 Thread Lennart Poettering
On Fri, 01.03.13 15:22, Lennart Poettering (lenn...@poettering.net) wrote:

 
 On Fri, 01.03.13 15:13, har...@redhat.com (har...@redhat.com) wrote:
 
  From: Harald Hoyer har...@redhat.com
  
  put JobTimeoutSec=0 in device-unit.d/JobTimeoutSec0.conf files
  
  This helps with grabbing a cup of coffee while booting and not have the
  crypto password dialog timeout and systemd in a failed state.
 
 I am not sure I like this too much, since fstab generally doesn't list
 things based on /dev/mapper, but via UUID= or suchlike, where this
 brings no benefit...

As discussed by phone: the I think this first part actually could go in,
it won't fix all problems, but at least those for folks which refer to
the crypt devices via /dev/mapper/ links.

Before merging this should probably be changed to use
write_one_line_file(), and the file name should probably be changed to
50-job-timeout-sec.conf or so...

The second part shouldn't go in, I think. Instead we should get you a
global configurable default timeout, via kernel cmdline and config file.

 
  ---
   src/cryptsetup/cryptsetup-generator.c | 62 
  +++
   1 file changed, 62 insertions(+)
  
  diff --git a/src/cryptsetup/cryptsetup-generator.c 
  b/src/cryptsetup/cryptsetup-generator.c
  index 38a7cfa..55fc4b7 100644
  --- a/src/cryptsetup/cryptsetup-generator.c
  +++ b/src/cryptsetup/cryptsetup-generator.c
  @@ -221,6 +221,68 @@ static int create_disk(
   goto fail;
   }
   
  +if (!noauto  !nofail) {
  +free(p);
  +p = strjoin(arg_dest, /dev-mapper-, e, 
  .device.d/JobTimeoutSec0.conf, NULL);
  +if (!p) {
  +r = log_oom();
  +goto fail;
  +}
  +
  +mkdir_parents_label(p, 0755);
  +
  +if (f)
  +fclose(f);
  +f = fopen(p, wxe);
  +if (!f) {
  +r = -errno;
  +log_error(Failed to create unit file %s: %m, p);
  +goto fail;
  +}
  +
  +fprintf(f,
  +# Automatically generated by 
  systemd-cryptsetup-generator\n\n
  +[Unit]\n
  +JobTimeoutSec=0\n /* the binary handles timeouts 
  anyway */
  +);
  +fflush(f);
  +
  +if (ferror(f)) {
  +r = -errno;
  +log_error(Failed to write file %s: %m, p);
  +goto fail;
  +}
  +
  +free(p);
  +p = strjoin(arg_dest, /, d, .d/JobTimeoutSec0.conf, 
  NULL);
  +if (!p) {
  +r = log_oom();
  +goto fail;
  +}
  +
  +mkdir_parents_label(p, 0755);
  +
  +f = fopen(p, wxe);
  +if (!f) {
  +r = -errno;
  +log_error(Failed to create unit file %s: %m, p);
  +goto fail;
  +}
  +
  +fprintf(f,
  +# Automatically generated by 
  systemd-cryptsetup-generator\n\n
  +[Unit]\n
  +JobTimeoutSec=0\n /* the binary handles timeouts 
  anyway */
  +);
  +fflush(f);
  +
  +if (ferror(f)) {
  +r = -errno;
  +log_error(Failed to write file %s: %m, p);
  +goto fail;
  +}
  +}
  +
   r = 0;
   
   fail:
 
 
 Lennart
 


Lennart

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


Re: [systemd-devel] [PATCH] fstab-generator: If we wait indefinitely for a mount, wait also for the device

2013-03-01 Thread Lennart Poettering
On Fri, 01.03.13 16:32, Tom Gundersen (t...@jklm.no) wrote:

   Hmm, this hooks into wait, which is initialized from the kernel
   cmdline rootwait? What are the precise semantics of the kernel there
   regarding this flag, in a non-initrd case? We probably should mimic the
   kernel here is good as we can...
  
   So, in the non-initrd case: what does rootwait do on the kernel cmdline?
   And what happens if it is not used?
 
  rootwait[KNL] Wait (indefinitely) for root device to show 
  up.
  Useful for devices that are detected asynchronously
  (e.g. USB and MMC devices).
 
  Yeah, that's what I read, too, but I cannot make sense of it. See above:
  what is different from when it is not used? Or to be precise: what does
  the kernel precisely do when rootwait is *not* passed?
 
 When rootwait is not passed the kernel calls sys_mount() immediately
 (after the equivalent of udevadm settle) assuming the device will be
 there, failing if it is not. Otherwise, if rootwait is called, the
 kernel will wait (possibly indefinitely) for the device to appear
 before attempting to mount it.
 
 Setting JobTimeout=0 on the device seems correct to me.

I don't really agree. The difference between the kernel and the initrd
in this regard is that the initrd can offer the user a shell, he can
debug things with. The naked kernel cannot do this. If the root device
doesn't show up we should give the user a shell, so we should timeout
this.

Now, without rootwait the kernel currently just does the equivalent of
udev settle by default, and then oopses. This will give the user some
feedback, and might be incompatible with some really slow USB devices
and such like. By passing rootwait it would wait indefinitely, if i
understood this correctly, and it wouldn't generate any message (or
would it?) Ideally, I'd actually like to see a configurable timeout:
i.e. wait for 5min, then give up, and print a msg and oops, or so...

In the meantime I am leaning towards suggesting that people should
always use rootwait, since if i can choose between kernel crashed
hard, and things might still unfuck themselves if we are lucky, then
I'd always choose the latter, if you understand what I mean...

But anyway, to bring this back to the original question: I think we
really should time-out looking for the root dir, and generate an error,
and give the user the option for a shell, that's better than just
sitting there forever, and sticking the head in the sand.

The only time we want to turn off the timeouts, is really when we are
waiting for user input, which is specific to cryptsetup stuff, which
this patch isn't about...

Lennart

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


Re: [systemd-devel] [PATCH] fstab-generator: default to ro

2013-03-01 Thread Harald Hoyer
Am 01.03.2013 17:37, schrieb Lennart Poettering:
 On Fri, 01.03.13 15:13, har...@redhat.com (har...@redhat.com) wrote:
 
 From: Harald Hoyer har...@redhat.com

 If no ro or rw is specified on the kernel command line, mount root
 read-only on /sysroot by default
 
 This sounds good, in order to stay in sync with the initrd-less kernel
 logic. Please commit!
 

committed.

Btw, strjoin() should really handle empty strings as the first argument.

strjoin(NULL, ,, TEST) should result in TEST .. shouldn't it?

strjoin(, ,, TEST) ?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] fstab-generator: default to ro

2013-03-01 Thread Lennart Poettering
On Fri, 01.03.13 17:56, Harald Hoyer (har...@redhat.com) wrote:

 
 Am 01.03.2013 17:37, schrieb Lennart Poettering:
  On Fri, 01.03.13 15:13, har...@redhat.com (har...@redhat.com) wrote:
  
  From: Harald Hoyer har...@redhat.com
 
  If no ro or rw is specified on the kernel command line, mount root
  read-only on /sysroot by default
  
  This sounds good, in order to stay in sync with the initrd-less kernel
  logic. Please commit!
  
 
 committed.
 
 Btw, strjoin() should really handle empty strings as the first argument.
 
 strjoin(NULL, ,, TEST) should result in TEST .. shouldn't it?
 
 strjoin(, ,, TEST) ?

We use NULL as the sentinel here for the varargs list. It just stupidly
concatenates the strings you pass it, one after the other, until we hit
NULL. If you pass NULL as first arg, then we'd just stop there...

There's strempty() which turns NULL into ?

Lennart

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


[systemd-devel] [PATCH 1/2] fstab-generator: mount /usr in the initrd if specified on /proc/cmdline

2013-03-01 Thread Tom Gundersen
This allows us to treat /usr exactly the same as /. Namely, its options
may be given on the kernel commandline rather than, say, being included in
the initramfs or being read from the rootfs.

The new options are: usr=, usrfstype=, usrwait=, usrflags=, which have
analogous semantics to their root counterparts. Moreover, the 'ro' and
'rw' options apply to root and usr both.

If someone has a desire to support separate /usr without an initramfs (and
witohut split-usr), they could easily add support for these options to the
kernel.

Cc: Harald Hoyer harald.ho...@gmail.com
Cc: Dave Reisner d...@falconindy.com
---
 src/fstab-generator/fstab-generator.c | 96 +--
 1 file changed, 68 insertions(+), 28 deletions(-)

diff --git a/src/fstab-generator/fstab-generator.c 
b/src/fstab-generator/fstab-generator.c
index 5c34de1..a2ab585 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -438,10 +438,12 @@ finish:
 
 static int parse_new_root_from_proc_cmdline(void) {
 char *w, *state;
-_cleanup_free_ char *what = NULL, *type = NULL, *opts = NULL, *line = 
NULL;
-int r;
+_cleanup_free_ char *line = NULL;
+_cleanup_free_ char *root_what = NULL, *root_type = NULL, *root_opts = 
NULL;
+_cleanup_free_ char *usr_what = NULL, *usr_type = NULL, *usr_opts = 
NULL;
+bool root_wait = false, usr_wait = false;
+int r = 0, k;
 size_t l;
-bool wait = false;
 
 r = read_one_line_file(/proc/cmdline, line);
 if (r  0) {
@@ -449,13 +451,16 @@ static int parse_new_root_from_proc_cmdline(void) {
 return 0;
 }
 
-opts = strdup(ro);
-type = strdup(auto);
-if (!opts || !type)
+root_opts = strdup(ro);
+root_type = strdup(auto);
+usr_opts = strdup(ro);
+usr_type = strdup(auto);
+if (!root_opts || !root_type || !usr_opts || !usr_type)
 return log_oom();
 
-/* root= and roofstype= may occur more than once, the last instance 
should take precedence.
- * In the case of multiple rootflags= the arguments should be 
concatenated */
+   /* root=, usr=, roofstype=and usrfstype=  may occur more than once, the 
last
+ * instance should take precedence. In the case of multiple rootflags= 
or
+ * usrflags= the arguments should be concatenated */
 FOREACH_WORD_QUOTED(w, l, line, state) {
 char *word, *tmp_word;
 
@@ -464,49 +469,84 @@ static int parse_new_root_from_proc_cmdline(void) {
 return log_oom();
 
 else if (startswith(word, root=)) {
-free(what);
-what = fstab_node_to_udev_node(word+5);
-if (!what)
+free(root_what);
+root_what = fstab_node_to_udev_node(word+5);
+if (!root_what)
+return log_oom();
+
+} else if (startswith(word, usr=)) {
+free(usr_what);
+usr_what = fstab_node_to_udev_node(word+4);
+if (!usr_what)
 return log_oom();
 
 } else if (startswith(word, rootfstype=)) {
-free(type);
-type = strdup(word + 11);
-if (!type)
+free(root_type);
+root_type = strdup(word + 11);
+if (!root_type)
+return log_oom();
+
+} else if (startswith(word, usrfstype=)) {
+free(usr_type);
+usr_type = strdup(word + 10);
+if (!usr_type)
 return log_oom();
 
 } else if (startswith(word, rootflags=)) {
-tmp_word = opts;
-opts = strjoin(opts, ,, word + 10, NULL);
+tmp_word = root_opts;
+root_opts = strjoin(root_opts, ,, word + 10, NULL);
+free(tmp_word);
+if (!root_opts)
+return log_oom();
+
+} else if (startswith(word, usrflags=)) {
+tmp_word = usr_opts;
+usr_opts = strjoin(usr_opts, ,, word + 9, NULL);
 free(tmp_word);
-if (!opts)
+if (!usr_opts)
 return log_oom();
 
 } else if (streq(word, ro) || streq(word, rw)) {
-tmp_word = opts;
-opts = strjoin(opts, ,, word, NULL);
+tmp_word = root_opts;
+root_opts = strjoin(root_opts, ,, word, 

Re: [systemd-devel] [PATCH] fstab-generator: default to ro

2013-03-01 Thread Harald Hoyer
Am 01.03.2013 18:00, schrieb Lennart Poettering:
 On Fri, 01.03.13 17:56, Harald Hoyer (har...@redhat.com) wrote:
 

 Am 01.03.2013 17:37, schrieb Lennart Poettering:
 On Fri, 01.03.13 15:13, har...@redhat.com (har...@redhat.com) wrote:

 From: Harald Hoyer har...@redhat.com

 If no ro or rw is specified on the kernel command line, mount root
 read-only on /sysroot by default

 This sounds good, in order to stay in sync with the initrd-less kernel
 logic. Please commit!


 committed.

 Btw, strjoin() should really handle empty strings as the first argument.

 strjoin(NULL, ,, TEST) should result in TEST .. shouldn't it?

 strjoin(, ,, TEST) ?
 
 We use NULL as the sentinel here for the varargs list. It just stupidly
 concatenates the strings you pass it, one after the other, until we hit
 NULL. If you pass NULL as first arg, then we'd just stop there...
 
 There's strempty() which turns NULL into ?
 
 Lennart
 

Still:
strjoin(, ,, TEST) returns ,TEST then..
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/2] fstab-generator: mount /usr in the initrd if specified on /proc/cmdline

2013-03-01 Thread Tom Gundersen
On Fri, Mar 1, 2013 at 6:15 PM, Tom Gundersen t...@jklm.no wrote:
 This allows us to treat /usr exactly the same as /. Namely, its options
 may be given on the kernel commandline rather than, say, being included in
 the initramfs or being read from the rootfs.

 The new options are: usr=, usrfstype=, usrwait=, usrflags=, which have
 analogous semantics to their root counterparts. Moreover, the 'ro' and
 'rw' options apply to root and usr both.

 If someone has a desire to support separate /usr without an initramfs (and
 witohut split-usr), they could easily add support for these options to the
 kernel.

 Cc: Harald Hoyer harald.ho...@gmail.com
 Cc: Dave Reisner d...@falconindy.com

Scratch this. We will go with marking mounts as x-initrd.mount=1 (or
something like that) in /etc/fstab instead.

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


[systemd-devel] [PATCH 1/5] systemd-python: add missing check for return of PyDict_SetItem in _reader.c

2013-03-01 Thread Lukas Nykryn
---
 src/python-systemd/_reader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c
index 7f200d5..d3d45cc 100644
--- a/src/python-systemd/_reader.c
+++ b/src/python-systemd/_reader.c
@@ -208,7 +208,7 @@ static PyObject* Reader_get_next(Reader *self, PyObject 
*args)
 if (r  0)
 goto error;
 
-PyDict_SetItem(dict, key, tmp_list);
+r = PyDict_SetItem(dict, key, tmp_list);
 if (r  0)
 goto error;
 }
-- 
1.7.11.7

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


[systemd-devel] [PATCH 3/5] tpmfiles: add missing parenthesis

2013-03-01 Thread Lukas Nykryn
---
 src/tmpfiles/tmpfiles.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 6b3f70e..ba22073 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -321,7 +321,7 @@ static int dir_cleanup(
 if (age = cutoff)
 continue;
 
-if (!i-type == IGNORE_DIRECTORY_PATH || 
!streq(dent-d_name, p)) {
+if (!(i-type == IGNORE_DIRECTORY_PATH || 
!streq(dent-d_name, p))) {
 log_debug(rmdir '%s'\n, sub_path);
 
 if (unlinkat(dirfd(d), dent-d_name, 
AT_REMOVEDIR)  0) {
-- 
1.7.11.7

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


[systemd-devel] [PATCH 5/5] manager: print p and then free it

2013-03-01 Thread Lukas Nykryn
---
 src/core/manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/core/manager.c b/src/core/manager.c
index ec12a75..5d1959e 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -2473,9 +2473,9 @@ static int create_generator_dir(Manager *m, char 
**generator, const char *name)
 return log_oom();
 
 if (!mkdtemp(p)) {
-free(p);
 log_error(Failed to create generator directory %s: 
%m,
   p);
+free(p);
 return -errno;
 }
 }
-- 
1.7.11.7

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


[systemd-devel] [PATCH 2/5] systemctl: check if iterator was initialized succesfully

2013-03-01 Thread Lukas Nykryn
---
 src/systemctl/systemctl.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index c67c6c9..99286cf 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -2084,7 +2084,11 @@ static int get_cgroup_attr(DBusConnection *bus, char 
**args) {
 if (r  0)
 return r;
 
-dbus_message_iter_init(reply, iter);
+if (!dbus_message_iter_init(reply, iter)) {
+log_error(Failed to initialize iterator.);
+return -EIO;
+}
+
 r = bus_parse_strv_iter(iter, list);
 if (r  0) {
 log_error(Failed to parse value list.);
-- 
1.7.11.7

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


[systemd-devel] coverity patches

2013-03-01 Thread Lukáš Nykrýn



0001-systemd-python-add-missing-check-for-return-of-PyDic.patch
Description: Binary data


0002-systemctl-check-if-iterator-was-initialized-succesfu.patch
Description: Binary data


0003-tpmfiles-add-missing-parenthesis.patch
Description: Binary data


0004-systemd-analyze-free-unit_times-only-if-it-is-not-NU.patch
Description: Binary data


0005-manager-print-p-and-then-free-it.patch
Description: Binary data
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] fstab-generator: default to ro

2013-03-01 Thread Lennart Poettering
On Fri, 01.03.13 18:21, Harald Hoyer (harald.ho...@gmail.com) wrote:

 
 Am 01.03.2013 18:00, schrieb Lennart Poettering:
  On Fri, 01.03.13 17:56, Harald Hoyer (har...@redhat.com) wrote:
  
 
  Am 01.03.2013 17:37, schrieb Lennart Poettering:
  On Fri, 01.03.13 15:13, har...@redhat.com (har...@redhat.com) wrote:
 
  From: Harald Hoyer har...@redhat.com
 
  If no ro or rw is specified on the kernel command line, mount root
  read-only on /sysroot by default
 
  This sounds good, in order to stay in sync with the initrd-less kernel
  logic. Please commit!
 
 
  committed.
 
  Btw, strjoin() should really handle empty strings as the first argument.
 
  strjoin(NULL, ,, TEST) should result in TEST .. shouldn't it?
 
  strjoin(, ,, TEST) ?
  
  We use NULL as the sentinel here for the varargs list. It just stupidly
  concatenates the strings you pass it, one after the other, until we hit
  NULL. If you pass NULL as first arg, then we'd just stop there...
  
  There's strempty() which turns NULL into ?
  
  Lennart
  
 
 Still:
 strjoin(, ,, TEST) returns ,TEST then..

No, that call will crash, since you forgot the NULL sentinel. Examples:

strjoin(, ,, TEST, NULL) → ,TEST
strjoin(a, b, c, NULL) → abc
strjoin(a, b, c, d, NULL) → abcd
strjoin(a, b, c, d, e, NULL) → abcde
strjoin(NULL) → 
strjoin(, , , NULL) → 
strjoin(abc, xyz, NULL) → abcxyz
strjoin(abc, NULL, xyz) → abc

That's just trivially simple concatenation, ending at the first
NULL. Not sure what you expect instead?

Lennart

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


Re: [systemd-devel] [PATCH] fstab-generator: If we wait indefinitely for a mount, wait also for the device

2013-03-01 Thread Tom Gundersen
On Fri, Mar 1, 2013 at 5:49 PM, Lennart Poettering
lenn...@poettering.net wrote:
 When rootwait is not passed the kernel calls sys_mount() immediately
 (after the equivalent of udevadm settle) assuming the device will be
 there, failing if it is not. Otherwise, if rootwait is called, the
 kernel will wait (possibly indefinitely) for the device to appear
 before attempting to mount it.

 Setting JobTimeout=0 on the device seems correct to me.

 I don't really agree. The difference between the kernel and the initrd
 in this regard is that the initrd can offer the user a shell, he can
 debug things with. The naked kernel cannot do this. If the root device
 doesn't show up we should give the user a shell, so we should timeout
 this.

Yeah, when using systemd 'rootwait' is not really that useful, as we
can do better.

 Now, without rootwait the kernel currently just does the equivalent of
 udev settle by default, and then oopses. This will give the user some
 feedback, and might be incompatible with some really slow USB devices
 and such like. By passing rootwait it would wait indefinitely, if i
 understood this correctly, and it wouldn't generate any message (or
 would it?)

It prints Waiting for root device... but nothing after that.

 Ideally, I'd actually like to see a configurable timeout:
 i.e. wait for 5min, then give up, and print a msg and oops, or so...

Well, there is rootdelay=, but that just waits for the fixed amount
before even trying to mount, so that's not really helpful. Except for
that the kernel can't really do what we want here.

 In the meantime I am leaning towards suggesting that people should
 always use rootwait, since if i can choose between kernel crashed
 hard, and things might still unfuck themselves if we are lucky, then
 I'd always choose the latter, if you understand what I mean...

Hm, yeah without an initramfs that is probably the least of two evils.

 But anyway, to bring this back to the original question: I think we
 really should time-out looking for the root dir, and generate an error,
 and give the user the option for a shell, that's better than just
 sitting there forever, and sticking the head in the sand.

Well, with systemd in the initramfs this is exactly what happens
without rootwait: we get the standard systemd timeout before giving
up and giving the user a shell. With rootwait and Harald's patch we
will wait indefinitely like what the kernel does (unless I'm
misunderstanding something), which of course is less useful for the
reasons you give, so most people probably don't want to use this.

 The only time we want to turn off the timeouts, is really when we are
 waiting for user input, which is specific to cryptsetup stuff, which
 this patch isn't about...

I suppose the ideal situation would be to allow rootwait=5min, but
that won't be compatible with initrd-less boot, so I'm not really in
favor of that.

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


Re: [systemd-devel] [PATCH] fstab-generator: default to ro

2013-03-01 Thread Harald Hoyer
Am 01.03.2013 18:38, schrieb Harald Hoyer:
 Am 01.03.2013 18:31, schrieb Lennart Poettering:
 On Fri, 01.03.13 18:21, Harald Hoyer (harald.ho...@gmail.com) wrote:


 Am 01.03.2013 18:00, schrieb Lennart Poettering:
 On Fri, 01.03.13 17:56, Harald Hoyer (har...@redhat.com) wrote:


 Am 01.03.2013 17:37, schrieb Lennart Poettering:
 On Fri, 01.03.13 15:13, har...@redhat.com (har...@redhat.com) wrote:

 From: Harald Hoyer har...@redhat.com

 If no ro or rw is specified on the kernel command line, mount root
 read-only on /sysroot by default

 This sounds good, in order to stay in sync with the initrd-less kernel
 logic. Please commit!

 q
 committed.

 Btw, strjoin() should really handle empty strings as the first argument.

 strjoin(NULL, ,, TEST) should result in TEST .. shouldn't it?

 strjoin(, ,, TEST) ?

 We use NULL as the sentinel here for the varargs list. It just stupidly
 concatenates the strings you pass it, one after the other, until we hit
 NULL. If you pass NULL as first arg, then we'd just stop there...

 There's strempty() which turns NULL into ?

 Lennart


 Still:
 strjoin(, ,, TEST) returns ,TEST then..

 No, that call will crash, since you forgot the NULL sentinel. Examples:

 strjoin(, ,, TEST, NULL) → ,TEST
 strjoin(a, b, c, NULL) → abc
 strjoin(a, b, c, d, NULL) → abcd
 strjoin(a, b, c, d, e, NULL) → abcde
 strjoin(NULL) → 
 strjoin(, , , NULL) → 
 strjoin(abc, xyz, NULL) → abcxyz
 strjoin(abc, NULL, xyz) → abc

 That's just trivially simple concatenation, ending at the first
 NULL. Not sure what you expect instead?

 Lennart

 
 Oops :) had the wrong thing in my mind :)
 
 join an array of strings with a separator
 

strv_join()

I should not commit code having a cold.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] fstab-generator: default to ro

2013-03-01 Thread Lennart Poettering
On Fri, 01.03.13 18:38, Harald Hoyer (harald.ho...@gmail.com) wrote:

  Btw, strjoin() should really handle empty strings as the first argument.
 
  strjoin(NULL, ,, TEST) should result in TEST .. shouldn't it?
 
  strjoin(, ,, TEST) ?
 
  We use NULL as the sentinel here for the varargs list. It just stupidly
  concatenates the strings you pass it, one after the other, until we hit
  NULL. If you pass NULL as first arg, then we'd just stop there...
 
  There's strempty() which turns NULL into ?
 
  Lennart
 
 
  Still:
  strjoin(, ,, TEST) returns ,TEST then..
  
  No, that call will crash, since you forgot the NULL sentinel. Examples:
  
  strjoin(, ,, TEST, NULL) → ,TEST
  strjoin(a, b, c, NULL) → abc
  strjoin(a, b, c, d, NULL) → abcd
  strjoin(a, b, c, d, e, NULL) → abcde
  strjoin(NULL) → 
  strjoin(, , , NULL) → 
  strjoin(abc, xyz, NULL) → abcxyz
  strjoin(abc, NULL, xyz) → abc
  
  That's just trivially simple concatenation, ending at the first
  NULL. Not sure what you expect instead?
  
  Lennart
  
 
 Oops :) had the wrong thing in my mind :)
 
 join an array of strings with a separator

Ah, I see. Might make sense to have a strjoin_sep() or so which takes as
first arg the separator string to place between each arg. So far we
didn't need that anywhere... But if this is useful it would totally make
sense to add to src/shared/util.[ch]...

Lennart

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


Re: [systemd-devel] [PATCH] fstab-generator: If we wait indefinitely for a mount, wait also for the device

2013-03-01 Thread Lennart Poettering
On Fri, 01.03.13 18:38, Tom Gundersen (t...@jklm.no) wrote:

 
 On Fri, Mar 1, 2013 at 5:49 PM, Lennart Poettering
 lenn...@poettering.net wrote:
  When rootwait is not passed the kernel calls sys_mount() immediately
  (after the equivalent of udevadm settle) assuming the device will be
  there, failing if it is not. Otherwise, if rootwait is called, the
  kernel will wait (possibly indefinitely) for the device to appear
  before attempting to mount it.
 
  Setting JobTimeout=0 on the device seems correct to me.
 
  I don't really agree. The difference between the kernel and the initrd
  in this regard is that the initrd can offer the user a shell, he can
  debug things with. The naked kernel cannot do this. If the root device
  doesn't show up we should give the user a shell, so we should timeout
  this.
 
 Yeah, when using systemd 'rootwait' is not really that useful, as we
 can do better.

Harald, do you mind if I revert your patch that added rootwait support
to fstab generator? What's the precise benefit of supporting that in the
initrd?

Lennart

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


Re: [systemd-devel] [systemd-commits] 42 commits - configure.ac Makefile.am man/.gitignore README src/journal src/python-systemd

2013-03-01 Thread Steven Hiscocks

On 01/03/13 01:23, Zbigniew Jędrzejewski-Szmek wrote:

On Thu, Feb 28, 2013 at 05:15:05PM -0800, Zbigniew Jędrzejewski-Szmek wrote:

  Makefile.am |   80 +++
  README  |7
  configure.ac|1
  man/.gitignore  |1
  src/journal/journalctl.c|9
  src/python-systemd/.gitignore   |2
  src/python-systemd/_journal.c   |2
  src/python-systemd/_reader.c|  774 

  src/python-systemd/docs/conf.py |  288 +
  src/python-systemd/docs/id128.rst   |   38 +
  src/python-systemd/docs/index.rst   |   22 +
  src/python-systemd/docs/journal.rst |   49 ++
  src/python-systemd/id128.c  |  162 +++
  src/python-systemd/journal.py   |  299 -
  src/python-systemd/pyutil.c |   30 +
  src/python-systemd/pyutil.h |   29 +
  16 files changed, 1752 insertions(+), 41 deletions(-)

New commits:
commit 37d3ab1b7e114f0fb6dfb2e7273569b42794b76a
Merge: 54c31a7 7f41820
Author: Zbigniew J??drzejewski-Szmek zbys...@in.waw.pl
Date:   Thu Feb 28 19:53:42 2013 -0500

 Merge branch 'python-systemd-reader'

 * python-systemd-reader:
   python-systemd: rename Journal to Reader
   build-sys: upload python documentation to freedesktop.org
   systemd-python: add Journal class for reading journal
   python: build html docs using sphinx
   journalct: also print Python code in --new-id
   python: utilize uuid.UUID in logging
   python: add systemd.id128 module
   ... and 34 other commits

 In short: python module systemd.id128 is added, and existing
 systemd.journal gains a new class systemd.journal.Reader, which can be
 used to iterate over journal entries. Documentation is provided, and
 accessible under e.g.
 pydoc3 systemd.journal.Reader
 or
 firefox http://www.freedesktop.org/software/systemd/man/python-systemd/

Hi Steven,
as you can see, I merged your module into the master branch. Any
additional cleanup can be done in the main tree. Thank you for the
module!

Zbyszek

Brilliant. Thank you for your patience, input and contributions. As you 
may have noticed I'm a bit of a novice when it comes to C and the python 
C-API,so you assistance was greatly appreciated.


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


Re: [systemd-devel] [Question] How to specify LimitCORE=infinity for all the daemon processes?

2013-03-01 Thread Lennart Poettering
On Thu, 21.02.13 09:53, HATAYAMA Daisuke (d.hatay...@jp.fujitsu.com) wrote:

 So, I've already understood we can get daemon processes. My question
 is how to configure for each daemon to have unlimited in their soft
 limit by one configuration in systemd framework.

Hmm, I am not following here. If I set DefaultLimitCORE=infinity in
/etc/systemd/system.conf and reboot all my system services are run with
RLIMIT_CORE set to infinity as grep 'Max core' /proc/*/limits proves
me. So this works correctly here. But it doesn't for you? Is that the
problem here?

 BTW, I heard systemd-coredump for the first time. Does this mean some
 particular feature of systemd concerning core dump?

It's an optional feature (and not enabled in Fedora/RHEL), that allows
systemd to store coredumps that happen on the system in the
journal...

Lennart

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


Re: [systemd-devel] [PATCH] fstab-generator: If we wait indefinitely for a mount, wait also for the device

2013-03-01 Thread Harald Hoyer
wasn't me...

commit 5e398e546ea65751e6a774daf828fe06f74434a2
Author: Tom Gundersen t...@jklm.no
Date:   Fri Nov 23 03:41:13 2012 +0100

fstab-generator: generate new_root.mount in initrd



On Fri, Mar 1, 2013 at 6:50 PM, Lennart Poettering
lenn...@poettering.netwrote:

 On Fri, 01.03.13 18:38, Tom Gundersen (t...@jklm.no) wrote:

 
  On Fri, Mar 1, 2013 at 5:49 PM, Lennart Poettering
  lenn...@poettering.net wrote:
   When rootwait is not passed the kernel calls sys_mount() immediately
   (after the equivalent of udevadm settle) assuming the device will be
   there, failing if it is not. Otherwise, if rootwait is called, the
   kernel will wait (possibly indefinitely) for the device to appear
   before attempting to mount it.
  
   Setting JobTimeout=0 on the device seems correct to me.
  
   I don't really agree. The difference between the kernel and the initrd
   in this regard is that the initrd can offer the user a shell, he can
   debug things with. The naked kernel cannot do this. If the root device
   doesn't show up we should give the user a shell, so we should timeout
   this.
 
  Yeah, when using systemd 'rootwait' is not really that useful, as we
  can do better.

 Harald, do you mind if I revert your patch that added rootwait support
 to fstab generator? What's the precise benefit of supporting that in the
 initrd?

 Lennart

 --
 Lennart Poettering - Red Hat, Inc.
 ___
 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] masked services and a lot of warnings

2013-03-01 Thread Lennart Poettering
On Sun, 17.02.13 18:33, Reindl Harald (h.rei...@thelounge.net) wrote:

 can we gat rid of this messages somehow?
 i know that they are masked and can not be started
 this as the reason to mask them
 
 nobody needs upower on a virtual machine because
 he connects via SSH and opens a X application with
 X-Forwarding
 
 Feb 17 17:32:21 buildserver dbus-daemon[450]: dbus[450]: [system] Activation 
 via systemd failed for unit
 'upower.service': Unit upower.service is masked.
 Feb 17 17:32:21 buildserver dbus-daemon[450]: dbus[450]: [system] Activating 
 via systemd: service
 name='org.freedesktop.UPower' unit='upower.service'
 Feb 17 17:32:21 buildserver dbus-daemon[450]: dbus[450]: [system] Activation 
 via systemd failed for unit
 'upower.service': Unit upower.service is masked.
 Feb 17 17:32:24 buildserver dbus-daemon[450]: dbus[450]: [system] Activating 
 via systemd: service
 name='org.freedesktop.UPower' unit='upower.service'
 Feb 17 17:32:24 buildserver dbus[450]: [system] Activating via systemd: 
 service name='org.freedesktop.UPower'
 unit='upower.service'
 Feb 17 17:32:24 buildserver dbus[450]: [system] Activation via systemd failed 
 for unit 'upower.service': Unit
 upower.service is masked.
 Feb 17 17:32:24 buildserver dbus[450]: [system] Activating via systemd: 
 service name='org.freedesktop.UPower'
 unit='upower.service'
 Feb 17 17:32:24 buildserver dbus[450]: [system] Activation via systemd failed 
 for unit 'upower.service': Unit
 upower.service is masked.
 Feb 17 17:32:24 buildserver dbus-daemon[450]: dbus[450]: [system] Activation 
 via systemd failed for unit
 'upower.service': Unit upower.service is masked.
 Feb 17 17:32:24 buildserver dbus-daemon[450]: dbus[450]: [system] Activating 
 via systemd: service
 name='org.freedesktop.UPower' unit='upower.service'
 Feb 17 17:32:24 buildserver dbus-daemon[450]: dbus[450]: [system] Activation 
 via systemd failed for unit
 'upower.service': Unit upower.service is masked.

These are messages from dbus-daemon. Could you please file a bug against
D-Bus on fdo, requesting that these log messages are downgraded/turned off?

Lennart

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


Re: [systemd-devel] systemd-fsck change fsck arguments to -a - -y

2013-03-01 Thread Lennart Poettering
On Mon, 18.02.13 11:52, Karel Zak (k...@redhat.com) wrote:

 
 On Wed, Feb 13, 2013 at 03:32:46AM +0100, Lennart Poettering wrote:
Hmm, I wonder if -a or -y is the way to go. Karel, as util-linux/fsck
maintainer, do you have an opinion whether we should use -a or -y for
automatic, non-interactive fscking? Is -a obsolete and -y the future?
   
This is gray zone... there is not explicit standard or conclusion
that -a (or -p) or -y is supported by all fsck.type checkers.

Anyway, it seems that -a is supported on more places.
 
  I did small investigation and result:
 
  extN: -a -y
 
  reaiser: -a -y
 
  vfat: -a -y
 
  minix:  -a
 
  cramfs: I'm going to improve fsck.cramfs to accept -a and -y
 
  xfs: fsck.xfs is dummy shell script, does nothing, accepts everything:-)
 
  btrfs: has --repair, it seems like synonym for -a (I'll ask for more
 details at btrfs lists)
 
  ntfs (-3g): does not support options at all

Definitely sounds like the best to stick to -a then in systemd's fsck
invoking tool...

Lennart

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


Re: [systemd-devel] encrypted swap

2013-03-01 Thread Lennart Poettering
On Mon, 18.02.13 22:59, Stefan G. Weichinger (li...@xunil.at) wrote:

 
 Am 14.02.2013 00:23, schrieb Stefan G. Weichinger:
  
  I see an issue with systemd-197 on one of my gentoo systems.
  
  Encrypted swap doesn't get enabled correctly as mentioned below.
  
  In the git-repo of systemd I read in the TODO-file:
  
  swap units that are activated by one name but shown in the kernel
  under another are semi-broken
  
  Might that be related to the behavior I see?

Unlikely.

  # cat /etc/crypttab
 
  swap 
  /dev/disk/by-id/ata-INTEL_SSDSA2M080G2GC_CVPO015404LR080JGN-part5 
  /dev/urandom swap,cipher=aes-cbc-essiv:sha256,size=256
 
  # grep swap /etc/fstab /dev/mapper/swapnoneswapdefaults
  0 0
 
  AFAI understand these 2 lines should be enough to let systemd 
  generate its relevant unit-files etc.

Correct.

 *bump*
 
 Would someone be so kind to give me some kind of pointer or information?

Can you provide the log where this happens? Boot with
systemd.log_level=debug and provide us with the journalctl output around
where this problem happens.

Lennart

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


Re: [systemd-devel] [PATCH 1/2] fstab-generator: initrd - mount the entries in /etc/fstab.sys from the initramfs

2013-03-01 Thread Harald Hoyer
On Fri, Mar 1, 2013 at 3:16 PM, Tom Gundersen t...@jklm.no wrote:

 On Fri, Mar 1, 2013 at 2:26 PM, Lennart Poettering
 lenn...@poettering.net wrote:
  Also, besides / and /usr, is there anything else that would ever show up
  in fstab.sys? If it's only these two, then it appears much nicer to me
  to simply have two kernel cmdline options for these (we have one
  anyway... for /). I mean, being generic and stuff is all cool, but let's
  not make things too generic here, if there's no reason to.

 I don't know how useful it is, but I have seen people asking for
 support for subdirs of /usr as separate mounts. If we agree that
 that's something we don't want to support by default that's fine with
 me.

  Two alternatives were considered, but decided against:
   * configure usr= on the kernel commandline in the same way as root= is.
 However, this would be restricted to only the /usr mountpoint, and
 the
 kernelcommandline is crowded enough as it is, so it seems more
 reasonable to
 store the configuration in /etc (as we can). Moreover, this logic
 would allow
 us to use more configuration sources from /etc in the future should
 that be
 necessary.
 
  But this sounds like something you need anyway, if you ever want to
  support generic initrds that work everywhere, and whose sole source of
  configuration is cmdline hence, right? With just one more option on the
  kernel cmdline for usr= I don't really buy the too crowded
  issue... Dunno. Do you see any further uses of this?

 I believe one instance where this might be useful would be to share
 /usr/share between different architectures, but I suppose that could
 have been solved by a specially crafted initrd and don't need to be
 supported by default.

   * configure the 'sys-mounts' in /etc/fstab. This would require a
 heuristic to
 decide which mounts sohuld be taken care of by the initramfs and
 which to be
 taken care of by the real init. I could not come up with a non-hacky
 way of
 doing that. Perhaps there is use-case for mounting with one set of
 options in
 the initrd and remounting with a different set of options in the
 real init
 (like can be done for the rootfs)? Keeping everything in fstab would
 make
 that impossible.
 
  Well, you could always introduce x-initrd as a mount option to set for
  mounts, if you really want to be this generic, and then filter for
  it. And also imply it for / and for /usr. But honestly, the usr= kernel
  cmdline thingy sounds much simpler and sexier to me?

 If we only want to support / and /usr, and don't care about stuff like
 /usr/local or /usr/share on separate mounts, then going with usr=
 makes sense to me. It would also make everything else much simpler (no
 need to reload settings after mounting sysroot). I already wrote the
 patch for usr=, so I'll send it out soon.

 Harald, what do you think?


x-initrd or x-initrd.mount sounds good, but I would imply x-initrd
for /usr if noauto is not set.

/etc/fstab.sys could just be copied to /etc/fstab in the initramfs. For the
rest x-initrd can be used easily.

Main usage is for things, which get mounted in the initramfs, survive the
switch-root and cannot be remounted with different options, because they
are busy.

/dev/shm and /run come to my mind.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/2] fstab-generator: initrd - mount the entries in /etc/fstab.sys from the initramfs

2013-03-01 Thread Harald Hoyer
On Fri, Mar 1, 2013 at 3:16 PM, Tom Gundersen t...@jklm.no 
mailto:t...@jklm.no
wrote:

On Fri, Mar 1, 2013 at 2:26 PM, Lennart Poettering
lenn...@poettering.net mailto:lenn...@poettering.net wrote:
 Also, besides / and /usr, is there anything else that would ever show up
 in fstab.sys? If it's only these two, then it appears much nicer to me
 to simply have two kernel cmdline options for these (we have one
 anyway... for /). I mean, being generic and stuff is all cool, but let's
 not make things too generic here, if there's no reason to.

I don't know how useful it is, but I have seen people asking for
support for subdirs of /usr as separate mounts. If we agree that
that's something we don't want to support by default that's fine with
me.

 Two alternatives were considered, but decided against:
  * configure usr= on the kernel commandline in the same way as root= is.
However, this would be restricted to only the /usr mountpoint, and the
kernelcommandline is crowded enough as it is, so it seems more
reasonable to
store the configuration in /etc (as we can). Moreover, this logic
would allow
us to use more configuration sources from /etc in the future should
that be
necessary.

 But this sounds like something you need anyway, if you ever want to
 support generic initrds that work everywhere, and whose sole source of
 configuration is cmdline hence, right? With just one more option on the
 kernel cmdline for usr= I don't really buy the too crowded
 issue... Dunno. Do you see any further uses of this?

I believe one instance where this might be useful would be to share
/usr/share between different architectures, but I suppose that could
have been solved by a specially crafted initrd and don't need to be
supported by default.

  * configure the 'sys-mounts' in /etc/fstab. This would require a
heuristic to
decide which mounts sohuld be taken care of by the initramfs and which
to be
taken care of by the real init. I could not come up with a non-hacky
way of
doing that. Perhaps there is use-case for mounting with one set of
options in
the initrd and remounting with a different set of options in the real 
init
(like can be done for the rootfs)? Keeping everything in fstab would 
make
that impossible.

 Well, you could always introduce x-initrd as a mount option to set for
 mounts, if you really want to be this generic, and then filter for
 it. And also imply it for / and for /usr. But honestly, the usr= kernel
 cmdline thingy sounds much simpler and sexier to me?

If we only want to support / and /usr, and don't care about stuff like
/usr/local or /usr/share on separate mounts, then going with usr=
makes sense to me. It would also make everything else much simpler (no
need to reload settings after mounting sysroot). I already wrote the
patch for usr=, so I'll send it out soon.

Harald, what do you think?

 
x-initrd or x-initrd.mount sounds good, but I would imply x-initrd for
/usr if noauto is not set.

/etc/fstab.sys could just be copied to /etc/fstab in the initramfs. For the rest
x-initrd can be used easily.

Main usage is for things, which get mounted in the initramfs, survive the
switch-root and cannot be remounted with different options, because they are 
busy.

/dev/shm and /run come to my mind.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 2/2] initrd: add unit files needed for basic systemd-in-initrd support

2013-03-01 Thread Harald Hoyer
On Fri, Mar 1, 2013 at 2:37 PM, Dave Reisner d...@falconindy.com
mailto:d...@falconindy.com wrote:


I'm not a fan of the fstab.sys idea either. I suggested to Tom that a
flag in fstab could be used instead -- something like x-initrd.mount
to denote mounts that need to be taken care of in early userspace.


sounds good, but I would imply x-initrd.mount for /usr if noauto is not 
set.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] fstab-generator: If we wait indefinitely for a mount, wait also for the device

2013-03-01 Thread Harald Hoyer
On Fri, Mar 1, 2013 at 6:50 PM, Lennart Poettering lenn...@poettering.net
mailto:lenn...@poettering.net wrote:

On Fri, 01.03.13 18:38, Tom Gundersen (t...@jklm.no mailto:t...@jklm.no) 
wrote:


 On Fri, Mar 1, 2013 at 5:49 PM, Lennart Poettering
 lenn...@poettering.net mailto:lenn...@poettering.net wrote:
  When rootwait is not passed the kernel calls sys_mount() immediately
  (after the equivalent of udevadm settle) assuming the device will be
  there, failing if it is not. Otherwise, if rootwait is called, the
  kernel will wait (possibly indefinitely) for the device to appear
  before attempting to mount it.
 
  Setting JobTimeout=0 on the device seems correct to me.
 
  I don't really agree. The difference between the kernel and the initrd
  in this regard is that the initrd can offer the user a shell, he can
  debug things with. The naked kernel cannot do this. If the root device
  doesn't show up we should give the user a shell, so we should timeout
  this.

 Yeah, when using systemd 'rootwait' is not really that useful, as we
 can do better.

Harald, do you mind if I revert your patch that added rootwait support
to fstab generator? What's the precise benefit of supporting that in the
initrd?


Yes, but I didn't add rootwait

commit 5e398e546ea65751e6a774daf828fe06f74434a2
Author: Tom Gundersen t...@jklm.no mailto:t...@jklm.no
Date:   Fri Nov 23 03:41:13 2012 +0100

fstab-generator: generate new_root.mount in initrd



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


Re: [systemd-devel] [PATCH 1/2] fstab-generator: mount /usr in the initrd if specified on /proc/cmdline

2013-03-01 Thread Tom Gundersen
On Fri, Mar 1, 2013 at 6:54 PM, Lennart Poettering
lenn...@poettering.net wrote:
 I am tempted to say that we should only have one way and one way only to
 do this. I.e. forget about the usr= idea on the kernel
 cmdline. Instead, fstab-generator should just always look into
 /etc/fstab and mount everything from there. When run from an initrd
 environment it should also look into /sysroot/etc/fstab and mount
 everything marked x-initrd.mount (plus, as a special implied magic,
 /usr listed in there even if it lacks this new option). Of course, when
 reading from /sysroot/etc/fstab the dest path of each mount should
 always be prefixed with /sysroot/.

Yeah, this is all clear. I'll resend in a few days (about to do some
travelling so will be a bit delayed).

Thanks to everyone for all their comments.

Cheers,

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


Re: [systemd-devel] [PATCH 1/2] fstab-generator: initrd - mount the entries in /etc/fstab.sys from the initramfs

2013-03-01 Thread Lennart Poettering
On Fri, 01.03.13 19:42, Harald Hoyer (harald.ho...@gmail.com) wrote:

  If we only want to support / and /usr, and don't care about stuff like
  /usr/local or /usr/share on separate mounts, then going with usr=
  makes sense to me. It would also make everything else much simpler (no
  need to reload settings after mounting sysroot). I already wrote the
  patch for usr=, so I'll send it out soon.
 
  Harald, what do you think?
 
 x-initrd or x-initrd.mount sounds good, but I would imply x-initrd
 for /usr if noauto is not set.

Given that we might end up adding other options in the x-initrd
namespace later on we should stick to x-initrd.mount here I think. And
yes, I too would imply this for /usr.

 /etc/fstab.sys could just be copied to /etc/fstab in the initramfs. For the
 rest x-initrd can be used easily.

Hmm, but the mount destination paths in the initrd would be very
different in the initrd (where everything would be prefixed with
/sysroot), then in the host? Not following? I'd actually like fstab.sys
to go away or at least stay something dracut specific...

 Main usage is for things, which get mounted in the initramfs, survive the
 switch-root and cannot be remounted with different options, because they
 are busy.
 
 /dev/shm and /run come to my mind.

On the final systemd, we already remount /run with the options in
/etc/fstab, and this can be done while the mount is active, fine, for
all options I am aware off, which one do you expect to break with
busy?

/dev/shm is a different case, if this comes pre-mounted from the initrd,
then we currently won't update it at all, and we have no good story
about it so far...

Lennart

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


Re: [systemd-devel] [PATCH 3/5] tpmfiles: add missing parenthesis

2013-03-01 Thread Zbigniew Jędrzejewski-Szmek
On Fri, Mar 01, 2013 at 06:29:59PM +0100, Lukas Nykryn wrote:
 ---
  src/tmpfiles/tmpfiles.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
 index 6b3f70e..ba22073 100644
 --- a/src/tmpfiles/tmpfiles.c
 +++ b/src/tmpfiles/tmpfiles.c
 @@ -321,7 +321,7 @@ static int dir_cleanup(
  if (age = cutoff)
  continue;
  
 -if (!i-type == IGNORE_DIRECTORY_PATH || 
 !streq(dent-d_name, p)) {
 +if (!(i-type == IGNORE_DIRECTORY_PATH || 
 !streq(dent-d_name, p))) {
After the change we have:
  if (i-type != I_D_P  streq(d_name, p))

Shouldn't we instead have
  if (i-type != I_D_P || strneq(d_name, p))
?

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


Re: [systemd-devel] [PATCH 1/5] systemd-python: add missing check for return of PyDict_SetItem in _reader.c

2013-03-01 Thread Zbigniew Jędrzejewski-Szmek
On Fri, Mar 01, 2013 at 06:29:57PM +0100, Lukas Nykryn wrote:
 ---
  src/python-systemd/_reader.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c
 index 7f200d5..d3d45cc 100644
 --- a/src/python-systemd/_reader.c
 +++ b/src/python-systemd/_reader.c
 @@ -208,7 +208,7 @@ static PyObject* Reader_get_next(Reader *self, PyObject 
 *args)
  if (r  0)
  goto error;
  
 -PyDict_SetItem(dict, key, tmp_list);
 +r = PyDict_SetItem(dict, key, tmp_list);
  if (r  0)
  goto error;
  }
Applied. Thanks!

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


Re: [systemd-devel] [PATCH 4/5] systemd-analyze: free unit_times only if it is not NULL

2013-03-01 Thread Zbigniew Jędrzejewski-Szmek
On Fri, Mar 01, 2013 at 06:30:00PM +0100, Lukas Nykryn wrote:
 ---
  src/analyze/systemd-analyze.c | 8 +---
  1 file changed, 5 insertions(+), 3 deletions(-)
 
 diff --git a/src/analyze/systemd-analyze.c b/src/analyze/systemd-analyze.c
 index b7e1670..7603cc0 100644
 --- a/src/analyze/systemd-analyze.c
 +++ b/src/analyze/systemd-analyze.c
 @@ -237,9 +237,11 @@ static int acquire_time_data(DBusConnection *bus, struct 
 unit_times **out)
  *out = unit_times;
  return c;
  fail:
 -for (; c = 0; c--)
 -free(unit_times[c].name);
 -free(unit_times);
 +if (unit_times) {
 +for (; c = 0; c--)
 +free(unit_times[c].name);
 +free(unit_times);
 +}
  return r;
  }
Applied.

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


Re: [systemd-devel] [PATCH 5/5] manager: print p and then free it

2013-03-01 Thread Zbigniew Jędrzejewski-Szmek
On Fri, Mar 01, 2013 at 06:30:01PM +0100, Lukas Nykryn wrote:
 ---
  src/core/manager.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/core/manager.c b/src/core/manager.c
 index ec12a75..5d1959e 100644
 --- a/src/core/manager.c
 +++ b/src/core/manager.c
 @@ -2473,9 +2473,9 @@ static int create_generator_dir(Manager *m, char 
 **generator, const char *name)
  return log_oom();
  
  if (!mkdtemp(p)) {
 -free(p);
  log_error(Failed to create generator directory %s: 
 %m,
p);
 +free(p);
  return -errno;
  }
  }
Applied.

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


Re: [systemd-devel] [PATCH 2/5] systemctl: check if iterator was initialized succesfully

2013-03-01 Thread Zbigniew Jędrzejewski-Szmek
On Fri, Mar 01, 2013 at 06:29:58PM +0100, Lukas Nykryn wrote:
 ---
  src/systemctl/systemctl.c | 6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)
 
 diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
 index c67c6c9..99286cf 100644
 --- a/src/systemctl/systemctl.c
 +++ b/src/systemctl/systemctl.c
 @@ -2084,7 +2084,11 @@ static int get_cgroup_attr(DBusConnection *bus, char 
 **args) {
  if (r  0)
  return r;
  
 -dbus_message_iter_init(reply, iter);
 +if (!dbus_message_iter_init(reply, iter)) {
 +log_error(Failed to initialize iterator.);
 +return -EIO;
 +}
 +
  r = bus_parse_strv_iter(iter, list);
  if (r  0) {
  log_error(Failed to parse value list.);
Applied.

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


Re: [systemd-devel] Cannot add dependency job for unit... Cannot allocate memory

2013-03-01 Thread Anthony Messina
On Friday, March 01, 2013 02:57:47 PM Lennart Poettering wrote:
 On Thu, 21.02.13 09:48, Anthony Messina (amess...@messinet.com) wrote:
  I'm not sure if this is the right place to ask, so please direct me to
  the 
  proper list if it's not.  And byt the way, THANK YOU for systemd!  The
  more I  read and try, the simpler my systems get.
 
  
 
  Anyway, I'm writing due to an issue I'm seeing on a few of my Fedora 18 
  machines after I've created a unit file for instantiation that will
  acquire  Kerberos tickets for user-based services such as apache and
  mythtv, etc. to access NFSv4.1 filesystems.  Any assistance would be
  appreciated, especially with pointers on improving the unit file
  itself.  I have attached the dmesg output after booting with
  systemd.log_level=debug systemd.log_target=kmsg
  
 
  Thanks in advance -A
 
  
 
  I am intermittently running into the error:
  Cannot add dependency job for unit k5start@mythtv.service, ignoring:
  Unit 
  k5start@mythtv.service failed to load: Cannot allocate memory. See system
  logs  and 'systemctl status k5start@mythtv.service'
 
   for details.
 
 Heya, this appears to be a problem with a specifier used in this unit
 file. Something is using those %x %y %z specifiers in strings they
 shouldn't be used. I have now commited a fix to git, to make the error
 message about this more useful and not claim it was an OOM situation.
 
 Lennart

Thanks Lennart.  Maybe this can make it into the next Fedora 18 RPM and I can 
test it some more.  -A

-- 
Anthony - http://messinet.com - http://messinet.com/~amessina/gallery
8F89 5E72 8DF0 BCF0 10BE 9967 92DC 35DC B001 4A4E


signature.asc
Description: This is a digitally signed message part.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel