Re: [systemd-devel] [PATCH v9000 2/3] timedated: gather timezone from /etc/localtime sym target

2012-08-14 Thread Frederic Crozat
Le dimanche 12 août 2012 à 22:36 -0700, Shawn Landden a écrit :
 /etc/localtime - /usr/share/zoneinfo/...
 
 or
 
 /etc/localtime - ../usr/share/zoneinfo/...
 
 (note, ../usr is not the same if /etc is a symlink, as this isn't
 using canonicalize_file_name())
 
 keep other method for now, consider dropping later.
 
 Supporting relative links here are problematic as timezones in
 /usr/share/zoneinfo are often themselves symlinks (and symlinks to
 symlinks), so this implamentation only supports absolute symlinks
 /usr/share/zoneinfo/ and relative symlinks starting with
 ../usr/share/zoneinfo/
 
 From TODO (kay sievers):
 * kill /etc/timezone handling entirely? What does it provide?
   - /etc/localtime carries the same information already:
   $ ls -l /etc/localtime; cat /etc/timezone
   lrwxrwxrwx 1 root root 33 Jul 27 09:55 /etc/localtime - 
 /usr/share/zoneinfo/Europe/Berlin
   Europe/Berlin
   - systemd enforces /usr to be available at bootup, so we can
 enforce the use of the symlink
 ---
  src/timedate/timedated.c |   50 
 --
  1 file changed, 40 insertions(+), 10 deletions(-)
 
 diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
 index 09fd808..c3067c8 100644
 --- a/src/timedate/timedated.c
 +++ b/src/timedate/timedated.c
 @@ -74,6 +74,9 @@
  BUS_GENERIC_INTERFACES_LIST \
  org.freedesktop.timedate1\0
  
 +/* Must start and end with '/' */
 +#define ZONEINFO_PATH /usr/share/zoneinfo/
 +
  const char timedate_interface[] _introspect_(timedate1) = INTERFACE;
  
  typedef struct TZ {
 @@ -152,16 +155,14 @@ static void verify_timezone(void) {
  return;
  
  p = strappend(/usr/share/zoneinfo/, tz.zone);
^
it would be better to replace this with the macro you added
(ZONEINFO_PATH)

 -if (!p) {
 -log_oom();
 -return;
 -}
 +if (!p)
 +return (void)log_oom();

I would keep the way the log_oom / return was used initially and not
change it.


-- 
Frederic Crozat fcro...@suse.com
SUSE

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


Re: [systemd-devel] [PATCH v9000 2/3] timedated: gather timezone from /etc/localtime sym target

2012-08-14 Thread Frederic Crozat
Le mardi 14 août 2012 à 10:32 +0200, Frederic Crozat a écrit :
 Le dimanche 12 août 2012 à 22:36 -0700, Shawn Landden a écrit :
  /etc/localtime - /usr/share/zoneinfo/...
  
  or
  
  /etc/localtime - ../usr/share/zoneinfo/...
  
  (note, ../usr is not the same if /etc is a symlink, as this isn't
  using canonicalize_file_name())
  
  keep other method for now, consider dropping later.
  
  Supporting relative links here are problematic as timezones in
  /usr/share/zoneinfo are often themselves symlinks (and symlinks to
  symlinks), so this implamentation only supports absolute symlinks
  /usr/share/zoneinfo/ and relative symlinks starting with
  ../usr/share/zoneinfo/
  
  From TODO (kay sievers):
  * kill /etc/timezone handling entirely? What does it provide?
- /etc/localtime carries the same information already:
$ ls -l /etc/localtime; cat /etc/timezone
lrwxrwxrwx 1 root root 33 Jul 27 09:55 /etc/localtime - 
  /usr/share/zoneinfo/Europe/Berlin
Europe/Berlin
- systemd enforces /usr to be available at bootup, so we can
  enforce the use of the symlink
  ---
   src/timedate/timedated.c |   50 
  --
   1 file changed, 40 insertions(+), 10 deletions(-)
  
  diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
  index 09fd808..c3067c8 100644
  --- a/src/timedate/timedated.c
  +++ b/src/timedate/timedated.c
  @@ -74,6 +74,9 @@
   BUS_GENERIC_INTERFACES_LIST \
   org.freedesktop.timedate1\0
   
  +/* Must start and end with '/' */
  +#define ZONEINFO_PATH /usr/share/zoneinfo/
  +
   const char timedate_interface[] _introspect_(timedate1) = INTERFACE;
   
   typedef struct TZ {
  @@ -152,16 +155,14 @@ static void verify_timezone(void) {
   return;
   
   p = strappend(/usr/share/zoneinfo/, tz.zone);
 ^
 it would be better to replace this with the macro you added
 (ZONEINFO_PATH)

And I've found another occurrence of /usr/share/zoneinfo which would
need to be fixed.

-- 
Frederic Crozat fcro...@suse.com
SUSE

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


Re: [systemd-devel] [PATCH] timedated: gather timezone from /etc/localtime sym target

2012-08-14 Thread Frederic Crozat
Le mercredi 08 août 2012 à 18:51 +0200, Lennart Poettering a écrit :
 On Tue, 07.08.12 00:31, Shawn Landen (shawnland...@gmail.com) wrote:
 
  keep other method for now, consider dropping later.
  
  Supporting relative links here could be problematic as timezones in
  /usr/share/zoneinfo are often themselves symlinks (and symlinks to
  symlinks), so this implamentation only only support absolute links.
 
 Hmm, I am not entirely sure this is really the best thing to do. Always
 requiring a symlink for /etc/localtime breaks a couple of things: we
 can't just bind mount things over in an nspawn container, embedded
 devices have to ship /usr/share/zoneinfo/, which is probably something
 they might want to avoid.
 
 So, dunno, I think this is something to think about first, discuss the
 pros and cons. I see that just having this as symlink is much simpler,
 no doubt, but does it have more benefits? And possibly more
 disadvantages?

Well, I just found a major disavantage: openSUSE (and YaST) are not
using a symlink for /etc/localtime but a copy of the zoneinfo file (it
is probably coming from support of separate /usr, when mounting /usr
wasn't handled by initrd). So, this must be fixed to
support /etc/localtime being a copy, at least for reading informations
(currently, the code crashes, I'll see if I can fix it).

-- 
Frederic Crozat fcro...@suse.com
SUSE

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


Re: [systemd-devel] [PATCH] timedated: gather timezone from /etc/localtime sym target

2012-08-14 Thread Frederic Crozat
Le mardi 14 août 2012 à 11:20 +0200, Frederic Crozat a écrit :
 Le mercredi 08 août 2012 à 18:51 +0200, Lennart Poettering a écrit :
  On Tue, 07.08.12 00:31, Shawn Landen (shawnland...@gmail.com) wrote:
  
   keep other method for now, consider dropping later.
   
   Supporting relative links here could be problematic as timezones in
   /usr/share/zoneinfo are often themselves symlinks (and symlinks to
   symlinks), so this implamentation only only support absolute links.
  
  Hmm, I am not entirely sure this is really the best thing to do. Always
  requiring a symlink for /etc/localtime breaks a couple of things: we
  can't just bind mount things over in an nspawn container, embedded
  devices have to ship /usr/share/zoneinfo/, which is probably something
  they might want to avoid.
  
  So, dunno, I think this is something to think about first, discuss the
  pros and cons. I see that just having this as symlink is much simpler,
  no doubt, but does it have more benefits? And possibly more
  disadvantages?
 
 Well, I just found a major disavantage: openSUSE (and YaST) are not
 using a symlink for /etc/localtime but a copy of the zoneinfo file (it
 is probably coming from support of separate /usr, when mounting /usr
 wasn't handled by initrd). So, this must be fixed to
 support /etc/localtime being a copy, at least for reading informations
 (currently, the code crashes, I'll see if I can fix it).

After discussing with other SUSE fellows (bnc#773491), I'd say we should
just ignore when /etc/localtime is a hardlink (or a copy) to a timezone
data (since we don't have the name of the timezone in the file itself)
and use /etc/sysconfig/clock as fallback (when available). And when
updating timezone, /etc/localtime should be created as a symlink.

-- 
Frederic Crozat fcro...@suse.com
SUSE

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


[systemd-devel] systemd hackfest on Developer Conference 2013

2012-08-14 Thread Václav Pavlín
Developer Conference 2013 takes place in Brno on February next year. We
have an opportunity to organize Hackfest during/before the conference.

Conference should run during the weekend (Saturday and Sunday) so the
hackfest can take place these days or the days before (Wed, Thu, Fri),
so conference attendees will not miss presentations.

What we need to now:
* approximate number of hackfest attendees
* preferred days

Please, let us if you are interested to join the systemd hackfest and
when would you like to have it organized.

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


Re: [systemd-devel] [PATCH] timedated: gather timezone from /etc/localtime sym target

2012-08-14 Thread shawn
On Tue, 2012-08-14 at 11:20 +0200, Frederic Crozat wrote: 
 Le mercredi 08 août 2012 à 18:51 +0200, Lennart Poettering a écrit :
  On Tue, 07.08.12 00:31, Shawn Landen (shawnland...@gmail.com) wrote:
  
   keep other method for now, consider dropping later.
   
   Supporting relative links here could be problematic as timezones in
   /usr/share/zoneinfo are often themselves symlinks (and symlinks to
   symlinks), so this implamentation only only support absolute links.
  
  Hmm, I am not entirely sure this is really the best thing to do. Always
  requiring a symlink for /etc/localtime breaks a couple of things: we
  can't just bind mount things over in an nspawn container, embedded
  devices have to ship /usr/share/zoneinfo/, which is probably something
  they might want to avoid.
  
  So, dunno, I think this is something to think about first, discuss the
  pros and cons. I see that just having this as symlink is much simpler,
  no doubt, but does it have more benefits? And possibly more
  disadvantages?
 
 Well, I just found a major disavantage: openSUSE (and YaST) are not
 using a symlink for /etc/localtime but a copy of the zoneinfo file (it
 is probably coming from support of separate /usr, when mounting /usr
 wasn't handled by initrd). So, this must be fixed to
 support /etc/localtime being a copy, at least for reading informations
 (currently, the code crashes, I'll see if I can fix it).
 

This is because its trying to free() the initialized pointer t, after
readlink() returns EINVAL.
It just has to be initialized to NULL. I'll post a revised 2/3 in a sec.
Otherwise, its fallowing your recommendations. It is
creating /etc/localtime as an *absolute* too.

-- 
-Shawn Landden

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


[systemd-devel] [PATCH v9001 2/3] timedated: gather timezone from /etc/localtime sym target

2012-08-14 Thread Shawn Landden
/etc/localtime - /usr/share/zoneinfo/...

or

/etc/localtime - ../usr/share/zoneinfo/...

(note, ../usr is not the same if /etc is a symlink, as this isn't
using canonicalize_file_name())

keep other method for now, consider dropping later.

Supporting relative links here are problematic as timezones in
/usr/share/zoneinfo are often themselves symlinks (and symlinks to
symlinks), so this implamentation only supports absolute symlinks
/usr/share/zoneinfo/ and relative symlinks starting with
../usr/share/zoneinfo/

From TODO (kay sievers):
* kill /etc/timezone handling entirely? What does it provide?
  - /etc/localtime carries the same information already:
  $ ls -l /etc/localtime; cat /etc/timezone
  lrwxrwxrwx 1 root root 33 Jul 27 09:55 /etc/localtime - 
/usr/share/zoneinfo/Europe/Berlin
  Europe/Berlin
  - systemd enforces /usr to be available at bootup, so we can
enforce the use of the symlink
---
 src/timedate/timedated.c |   50 +-
 1 file changed, 41 insertions(+), 9 deletions(-)

diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 09fd808..ec913f6 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -74,6 +74,9 @@
 BUS_GENERIC_INTERFACES_LIST \
 org.freedesktop.timedate1\0
 
+/* Must start and end with '/' */
+#define ZONEINFO_PATH /usr/share/zoneinfo/
+
 const char timedate_interface[] _introspect_(timedate1) = INTERFACE;
 
 typedef struct TZ {
@@ -127,7 +130,7 @@ static bool valid_timezone(const char *name) {
 if (slash)
 return false;
 
-t = strappend(/usr/share/zoneinfo/, name);
+t = strappend(ZONEINFO_PATH, name);
 if (!t)
 return false;
 
@@ -151,17 +154,17 @@ static void verify_timezone(void) {
 if (!tz.zone)
 return;
 
-p = strappend(/usr/share/zoneinfo/, tz.zone);
+p = strappend(ZONEINFO_PATH, tz.zone);
 if (!p) {
 log_oom();
 return;
 }
 
-j = read_full_file(/etc/localtime, a, l);
 k = read_full_file(p, b, q);
-
 free(p);
 
+j = read_full_file(/etc/localtime, a, l);
+
 if (j  0 || k  0 || l != q || memcmp(a, b, l)) {
 log_warning(/etc/localtime and /etc/timezone out of sync.);
 free(tz.zone);
@@ -174,9 +177,34 @@ static void verify_timezone(void) {
 
 static int read_data(void) {
 int r;
+char *t = NULL;
 
 free_data();
 
+r = readlink_malloc(/etc/localtime, t);
+if (r  0) {
+if (r == -EINVAL)
+log_warning(/etc/localtime should be a symbolic link 
to a timezone data file in  ZONEINFO_PATH);
+else
+log_warning(Failed to get target of %s: %s, 
/etc/localtime, strerror(-r));
+} else {
+/* we only support the trivial relative link of 
(/etc/)..$ABSOLUTE */
+int rel_link_offset = startswith(t, ..) ? strlen(..) : 0;
+
+if (!startswith(t + rel_link_offset, ZONEINFO_PATH))
+log_warning(/etc/localtime should be a symbolic link 
to a timezone data file in  ZONEINFO_PATH);
+else {
+tz.zone = strdup(t + rel_link_offset + 
strlen(ZONEINFO_PATH));
+free(t);
+if (!tz.zone)
+return log_oom();
+
+goto have_timezone;
+}
+}
+
+free(t);
+
 r = read_one_line_file(/etc/timezone, tz.zone);
 if (r  0) {
 if (r != -ENOENT)
@@ -192,6 +220,7 @@ static int read_data(void) {
 #endif
 }
 
+have_timezone:
 if (isempty(tz.zone)) {
 free(tz.zone);
 tz.zone = NULL;
@@ -207,6 +236,7 @@ static int read_data(void) {
 static int write_data_timezone(void) {
 int r = 0;
 char *p;
+struct stat st;
 
 if (!tz.zone) {
 if (unlink(/etc/timezone)  0  errno != ENOENT)
@@ -218,19 +248,21 @@ static int write_data_timezone(void) {
 return r;
 }
 
-p = strappend(/usr/share/zoneinfo/, tz.zone);
+p = strappend(ZONEINFO_PATH, tz.zone);
 if (!p)
 return log_oom();
 
-r = symlink_or_copy_atomic(p, /etc/localtime);
+r = symlink_atomic(p, /etc/localtime);
 free(p);
 
 if (r  0)
 return r;
 
-r = write_one_line_file_atomic(/etc/timezone, tz.zone);
-if (r  0)
-return r;
+if (stat(/etc/timezone, st) == 0  S_ISREG(st.st_mode)) {
+r = write_one_line_file_atomic(/etc/timezone, tz.zone);
+if (r  0)
+return r;
+}
 
 return 0;
 }
-- 
1.7.9.5

___

[systemd-devel] killing udev for non-systemd systems

2012-08-14 Thread William Hubbs
Hey Lennart, Kay and all,

On Wed, Aug 01, 2012 at 06:58:39PM +0200, Lennart Poettering wrote:
 Well, we intent to continue to make it possible to run udevd outside of
 systemd. But that's about it. We will not polish that, or add new
 features to that or anything.
 
 OTOH we do polish behaviour of udev when used *within* systemd however,
 and that's our primary focus.
 
 And what we will certainly not do is compromise the uniform integration
 into systemd for some cosmetic improvements for non-systemd systems.
 
 (Yes, udev on non-systemd systems is in our eyes a dead end, in case you
 haven't noticed it yet. I am looking forward to the day when we can drop
 that support entirely.)

There are a number of reasons from what I see on my distro's development
list and from what I've seen insome patches proposed here, that everyone
isn't comfortable with systemd.

I thought the merge was more for administrative reasons, because there
is common source code between systemd and udev that you did not want to
provide as libraries.

Now though, with the attitude toward non-systemd systems that I see
above, I am starting to wonder.

You have taken a piece of software which is important to many linux
systems (udev) and merged it into an init system (systemd) which is not
used everywhere for a number of reasons. Now you are planning to kill
udev for systems that do not use systemd. Why is that? Why are you
saying that udev on non-systemd systems is a dead end?

Is there some alternative for non-systemd systems?

William



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


Re: [systemd-devel] killing udev for non-systemd systems

2012-08-14 Thread Colin Guthrie
'Twas brillig, and William Hubbs at 14/08/12 19:01 did gyre and gimble:
 You have taken a piece of software which is important to many linux
 systems (udev) and merged it into an init system (systemd) which is not
 used everywhere for a number of reasons. Now you are planning to kill
 udev for systems that do not use systemd. Why is that? Why are you
 saying that udev on non-systemd systems is a dead end?
 
 Is there some alternative for non-systemd systems?

I think you're over reacting here.

The comment about it being a dead end is likely more related to how
device management and service management are *very* closely linked
sometimes - especially if you want to do things properly and non-racy
without lots of good will sprinkled over things in the hope that they
glue together OK. So to get the most out of udev and do things properly
you *need* to integrate properly with the init system. That's what I
read from the dead end statement anyway.

While I'm sure Lennart and Kay are looking forward to the day they can
drop any semblance of support for a separate udev entirely, I doubt very
much it's any time in the next little while (although I'm always
prepared to be proved wrong).

And besides, even if they do it's easy enough to fork using git and
maintain a separate version while still sharing most of the code if that
floats your boat.

I suspect in a few years time we'll see a much more focused systemd
world anyway and the people who are not using it now for whatever reason
will see the light/drink the kool-aid :p

Col

-- 

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

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/

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


[systemd-devel] [PATCH 1/2] dev-setup: allow a path prefix for use in chroots

2012-08-14 Thread Dave Reisner
With this adjustment, we can reuse this code elsewhere, such as in
nspawn.
---
 src/core/mount-setup.c |  2 +-
 src/shared/dev-setup.c | 16 +---
 src/shared/dev-setup.h |  7 ++-
 src/udev/udevd.c   |  2 +-
 4 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
index e86a893..be11bb8 100644
--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -398,7 +398,7 @@ int mount_setup(bool loaded_policy) {
 /* Create a few default symlinks, which are normally created
  * by udevd, but some scripts might need them before we start
  * udevd. */
-dev_setup();
+dev_setup();
 
 /* Mark the root directory as shared in regards to mount
  * propagation. The kernel defaults to private, but we think
diff --git a/src/shared/dev-setup.c b/src/shared/dev-setup.c
index 0b3d648..759ecd7 100644
--- a/src/shared/dev-setup.c
+++ b/src/shared/dev-setup.c
@@ -50,7 +50,7 @@ static int symlink_and_label(const char *old_path, const char 
*new_path) {
 return r;
 }
 
-void dev_setup(void) {
+void dev_setup(const char *pathprefix) {
 const char *j, *k;
 
 static const char symlinks[] =
@@ -60,6 +60,16 @@ void dev_setup(void) {
 /proc/self/fd/1\0  /dev/stdout\0
 /proc/self/fd/2\0  /dev/stderr\0;
 
-NULSTR_FOREACH_PAIR(j, k, symlinks)
-symlink_and_label(j, k);
+NULSTR_FOREACH_PAIR(j, k, symlinks) {
+char *linkname;
+
+if (asprintf(linkname, %s/%s, pathprefix, k)  0) {
+log_oom();
+break;
+}
+
+symlink_and_label(j, linkname);
+
+free(linkname);
+}
 }
diff --git a/src/shared/dev-setup.h b/src/shared/dev-setup.h
index 5850758..320c0b3 100644
--- a/src/shared/dev-setup.h
+++ b/src/shared/dev-setup.h
@@ -1,7 +1,6 @@
 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
 
-#ifndef foodevsetuphfoo
-#define foodevsetuphfoo
+#pragma once
 
 /***
   This file is part of systemd.
@@ -22,6 +21,4 @@
   along with systemd; If not, see http://www.gnu.org/licenses/.
 ***/
 
-void dev_setup(void);
-
-#endif
+void dev_setup(const char *pathprefix);
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 23351ae..1bb15d8 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -1155,7 +1155,7 @@ int main(int argc, char *argv[])
 
 mkdir(/run/udev, 0755);
 
-dev_setup();
+dev_setup();
 static_dev_create_from_modules(udev);
 
 /* before opening new files, make sure std{in,out,err} fds are in a 
sane state */
-- 
1.7.11.4

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


[systemd-devel] [PATCH 2/2] nspawn: add /dev FD symlinks in container setup

2012-08-14 Thread Dave Reisner
This creates /dev/fd, /dev/stdin, /dev/stdout, /dev/stderr, and
/dev/core as symlinks to /proc on container creation. Except for
/dev/core, these are needed for shells like bash to be fully functional.
---
Supersedes my previous patch which duplicated the logic in dev_setup().

 src/nspawn/nspawn.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 7d188f0..40b9934 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -53,6 +53,7 @@
 #include path-util.h
 #include loopback-setup.h
 #include sd-id128.h
+#include dev-setup.h
 
 typedef enum LinkJournal {
 LINK_NO,
@@ -1204,6 +1205,8 @@ int main(int argc, char *argv[]) {
 if (copy_devnodes(arg_directory)  0)
 goto child_fail;
 
+dev_setup(arg_directory);
+
 if (setup_dev_console(arg_directory, console)  0)
 goto child_fail;
 
-- 
1.7.11.4

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