[systemd-devel] why systemd-udevd log to dmesg?

2012-08-08 Thread Alexey Shabalin
After run dmesg i can see
[434765.990649] systemd-udevd[1186]: invalid rule
'/etc/udev/rules.d/90-alsa-tools-firmware.rules:11'
[485891.443571] systemd-udevd[1186]: invalid rule
'/etc/udev/rules.d/90-alsa-tools-firmware.rules:11'

Yes, i know about invalid rule. (need change BUS to SUBSYSTEM)
Issue - why in dmesg?
I expected to see in syslog only.

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


Re: [systemd-devel] List all available units

2012-08-08 Thread Václav Pavlín
As I noted here:

https://bugzilla.redhat.com/show_bug.cgi?id=790768#c12

this patch doesn't solve my issue. But I think it can be solved in
either systemctl or autocomlete script. 

If we decide to change behaviour of systemctl, the approach, I described
here, can be used. If you prefer to edit autocomplete script, it can be
done with merge of sytemctl output of list-units and list-unit-files and
then pipe to uniq.

Vaclav

Jóhann B. Guðmundsson píše v Út 07. 08. 2012 v 15:21 +:
 On 08/07/2012 02:35 PM, Václav Pavlín wrote:
  https://bugzilla.redhat.com/show_bug.cgi?id=790768
 
 I thought Harald had already fixed this one but perhaps Lennart never 
 committed it.
 
 See [1].
 
 JBG
 
 
 1.http://lists.freedesktop.org/archives/systemd-devel/2012-February/004573.html
 ___
 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] why systemd-udevd log to dmesg?

2012-08-08 Thread Kay Sievers
On Wed, Aug 8, 2012 at 10:07 AM, Alexey Shabalin a.shaba...@gmail.com wrote:
 After run dmesg i can see
 [434765.990649] systemd-udevd[1186]: invalid rule
 '/etc/udev/rules.d/90-alsa-tools-firmware.rules:11'
 [485891.443571] systemd-udevd[1186]: invalid rule
 '/etc/udev/rules.d/90-alsa-tools-firmware.rules:11'

 Yes, i know about invalid rule. (need change BUS to SUBSYSTEM)
 Issue - why in dmesg?
 I expected to see in syslog only.

It doesn't do that here, it's all in the journal only.

We should only write the udev startup and the network interface
renaming messages to kmsg, nothing else unless asked for.

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


Re: [systemd-devel] why systemd-udevd log to dmesg?

2012-08-08 Thread Alexey Shabalin
2012/8/8 Kay Sievers :
 On Wed, Aug 8, 2012 at 10:07 AM, Alexey Shabalin  wrote:
 After run dmesg i can see
 [434765.990649] systemd-udevd[1186]: invalid rule
 '/etc/udev/rules.d/90-alsa-tools-firmware.rules:11'
 [485891.443571] systemd-udevd[1186]: invalid rule
 '/etc/udev/rules.d/90-alsa-tools-firmware.rules:11'

 Yes, i know about invalid rule. (need change BUS to SUBSYSTEM)
 Issue - why in dmesg?
 I expected to see in syslog only.

 It doesn't do that here, it's all in the journal only.

 We should only write the udev startup and the network interface
 renaming messages to kmsg, nothing else unless asked for.

Thanks for the answer.
There are more havy cases.
Lots of messages like these:
[  829.590573] systemd-udevd[7033]: failed to execute
'/lib/udev/socket:@/org/freedesktop/hal/udev_event'
'socket:@/org/freedesktop/hal/udev_event': No such file or directory

And system have big LA.
I know that udev_monitor_new_from_socket() is no longer supported, and
i know that necessary to remove old packages like hal and DeviceKit.

Whether the udev can behave quieter? Without a heavy LA? Do not write
to dmesg. Write to syslog is not often.

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


Re: [systemd-devel] How to handle loop mounts?

2012-08-08 Thread Mike Kazantsev
On Tue, 07 Aug 2012 18:13:46 -0400
Eelco Dolstra eelco.dols...@logicblox.com wrote:

 Hi,
 
 I have an /etc/fstab that contains the following line:
 
   /disk1.img /disk1 ext4 loop 0 2
 
 where /disk1.img is a regular file containing an ext4 filesystem.  Systemd 
 fails
 to mount /disk1 if I run systemctl start disk1.mount:
 
...

Same thing seem to work here:

  dd if=/dev/zero of=looptest bs=1M count=100 
  losetup /dev/loop0 looptest
  mkfs.ext4 /dev/loop0
  losetup -D
  echo '/root/looptest /mnt/tmp ext4 loop' /etc/fstab
  mount /mnt/tmp
  systemctl status mnt-tmp.mount
  mnt-tmp.mount - /mnt/tmp
  Loaded: loaded
  Active: active (mounted) since Wed, 08 Aug 2012 18:21:04 +0600; 5s ago
   Where: /mnt/tmp
What: /dev/loop0
  CGroup: name=systemd:/system/mnt-tmp.mount

Maybe you have older systemd version (186 here), or your setup is more
complicated than that (haven't tested crypttab, but you seem to imply
that above doesn't work as well)?


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


Re: [systemd-devel] How to handle loop mounts?

2012-08-08 Thread Eelco Dolstra
Hi,

On 08/08/12 08:24, Mike Kazantsev wrote:

 I have an /etc/fstab that contains the following line:

   /disk1.img /disk1 ext4 loop 0 2

 where /disk1.img is a regular file containing an ext4 filesystem.  Systemd 
 fails
 to mount /disk1 if I run systemctl start disk1.mount:

 ...
 
 Same thing seem to work here:
 
   dd if=/dev/zero of=looptest bs=1M count=100 
   losetup /dev/loop0 looptest
   mkfs.ext4 /dev/loop0
   losetup -D
   echo '/root/looptest /mnt/tmp ext4 loop' /etc/fstab

Ah!  This did work.  It turns out that the problem is actually caused by having
a non-zero fs_passno field in /etc/fstab.  I.e.

  /disk1.img /disk1 ext4 loop 0 0

works, while

  /disk1.img /disk1 ext4 loop 0 2

hangs because systemd adds a dependency on systemd-f...@disk1.img.service, which
in turn has a dependency on the non-existent disk1.img.device.

Now for this ext4 example I can live without running fsck, but in general loop
filesystems may require fsck.  Any ideas on how to fix this?

Also, there doesn't seem to be a workaround for using loop devices with
crypttab.  Example:

$ dd if=/dev/zero of=/disk2.img bs=1M count=100
$ cryptsetup luksFormat /disk2.img
...
$ echo 'crypted /disk2.img - timeout=60'  /etc/crypttab
$ systemctl daemon-reload
$ systemctl start cryptsetup.target
(hangs)
$ systemctl list-jobs --full
 JOB UNIT  TYPESTATE
8534 cryptsetup.target start   waiting
8535 systemd-cryptsetup@crypted.service start   waiting
8538 disk2.img.device  start   running
8539 dev-mapper-crypted.device start   running
$ journalctl
...
Aug 08 15:33:51 machine systemd[1]: Job disk2.img.device/start timed out.
Aug 08 15:33:51 machine systemd[1]: Job cryptsetup.target/start failed with
result 'dependency'.
...

(I'm running systemd 187 BTW.)

-- 
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] List all available units

2012-08-08 Thread Michal Schmidt

On 08/08/2012 10:21 AM, Václav Pavlín wrote:

If we decide to change behaviour of systemctl, the approach, I described
here, can be used. If you prefer to edit autocomplete script, it can be
done with merge of sytemctl output of list-units and list-unit-files and
then pipe to uniq.


A lot of users find the behaviour of systemctl --all confusing. If you 
can find a nice way to make it display even not-currently-loaded units, 
it would make them happy. And I assume the autocomplete would start 
working as expected too.

See https://bugzilla.redhat.com/show_bug.cgi?id=748512

Michal

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


Re: [systemd-devel] why systemd-udevd log to dmesg?

2012-08-08 Thread Lennart Poettering
On Wed, 08.08.12 19:59, Alexey Shabalin (a.shaba...@gmail.com) wrote:

 
 2012/8/8 Lennart Poettering :
  On Wed, 08.08.12 12:07, Alexey Shabalin wrote:
 
  After run dmesg i can see
  [434765.990649] systemd-udevd[1186]: invalid rule
  '/etc/udev/rules.d/90-alsa-tools-firmware.rules:11'
  [485891.443571] systemd-udevd[1186]: invalid rule
  '/etc/udev/rules.d/90-alsa-tools-firmware.rules:11'
 
  Yes, i know about invalid rule. (need change BUS to SUBSYSTEM)
  Issue - why in dmesg?
  I expected to see in syslog only.
 
  Which udev/systemd versin is this? As mentioned by Kay we don't write
  gerneal log output to kmsg anymore. It's all going to the journal now.
 
 udev-187, without systemd (with SysV)

Ah, in newer systemd versions we default to journal logging, and if that
is not available fall back to kmsg.

You can set SYSTEMD_LOG_TARGET=syslog as env var if you want to redirect
that to syslog.

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] Automatic unmount of inactive automounted dir?

2012-08-08 Thread Lennart Poettering
On Tue, 07.08.12 16:45, Dave Reisner (d...@falconindy.com) wrote:

 On Tue, Aug 07, 2012 at 04:23:05PM -0400, Maddy, Noel wrote:
  I have a number of network shares automounted through systemd's automount.
  
  How do I make them automatically unmount after a given period of inactivity?
  
  Thanks,
  
  Noel
  
 
 This isn't currently supported. See the previous discussion:
 
 http://www.mail-archive.com/systemd-devel@lists.freedesktop.org/msg04916.html

Yupp, it's on the TODO list. Will hack on this one day myself, but in
the meantime I am happy to accept a patch!

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] How to handle loop mounts?

2012-08-08 Thread Lennart Poettering
On Wed, 08.08.12 09:52, Eelco Dolstra (eelco.dols...@logicblox.com) wrote:

 
 Hi,
 
 On 08/08/12 08:24, Mike Kazantsev wrote:
 
  I have an /etc/fstab that contains the following line:
 
/disk1.img /disk1 ext4 loop 0 2
 
  where /disk1.img is a regular file containing an ext4 filesystem.  Systemd 
  fails
  to mount /disk1 if I run systemctl start disk1.mount:
 
  ...
  
  Same thing seem to work here:
  
dd if=/dev/zero of=looptest bs=1M count=100 
losetup /dev/loop0 looptest
mkfs.ext4 /dev/loop0
losetup -D
echo '/root/looptest /mnt/tmp ext4 loop' /etc/fstab
 
 Ah!  This did work.  It turns out that the problem is actually caused by 
 having
 a non-zero fs_passno field in /etc/fstab.  I.e.
 
   /disk1.img /disk1 ext4 loop 0 0
 
 works, while
 
   /disk1.img /disk1 ext4 loop 0 2
 
 hangs because systemd adds a dependency on systemd-f...@disk1.img.service, 
 which
 in turn has a dependency on the non-existent disk1.img.device.

Hmm, so there is a fundamental problem here. The mount command is what
creates the loopback device and what then eventually does the mount, but
it is systemd that would need to do the fsck in between. This can't
work. Also, the loop device name is undefined, since this takes the
first free device available, which means the name is completely
undefined and hence we have a hard time creating the right dependencies
for it.

Not sure what we can do about this. We probably have to implement proper
loopback support inside of systemd, so that we set up the loopback
device on our own, so that we can order the fsck between that and the
actual mount, but that's not trivial to do and needs some care to be
taken. Umm...

I have added this to the TODO list now.

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] docs/gudev

2012-08-08 Thread Zbigniew Jędrzejewski-Szmek
On 08/08/2012 06:19 PM, Kay Sievers wrote:
  docs/gudev/Makefile.am |8 
  1 file changed, 8 insertions(+)
 
 New commits:
 commit 29a00c41b8085596c8d5bba00cc758c38069ab48
 Author: Kay Sievers k...@vrfy.org
 Date:   Wed Aug 8 18:16:50 2012 +0200
 
 gudev: docs - work around the broken gtk-doc mess
 
 gtk-doc add CFLAGS/LDFLAGS multiple times to the gcc command line,
 which breaks options that must be listed only once.
 
 For now, clear CFLAGS/LDFLAGS for the intermediate documentation
 binary.
 
 diff --git a/docs/gudev/Makefile.am b/docs/gudev/Makefile.am
 index 586dd8d..152cd3c 100644
 --- a/docs/gudev/Makefile.am
 +++ b/docs/gudev/Makefile.am
 @@ -72,6 +72,14 @@ content_files = version.xml
  # e.g. expand_content_files=running.sgml
  expand_content_files=
  
 +# Hack, hack. You silly gtk-doc, you must not add  CFLAGS multiple
 +# times when calling gcc; it surely can not work with options that must
 +# be listed only once.
 +# Kill CFLAGS here because gtk-doc thinks adding CFLAGS to CC _and_ also
 +# adding CFLAGS itself again would work.
 +CFLAGS=
 +LDFLAGS=
Hi,
are you sure that this works as expected? Quoting info make:

An argument that contains `=' specifies the value of a variable: `V=X'
sets the value of the variable V to X.  If you specify a value in this
way, all ordinary assignments of the same variable in the makefile are
ignored; we say they have been overridden by the command line
argument.

So I expect e.g. 'make CFLAGS=...' to cause your override to be ignored.
I think you have to do
  override CFLAGS=
to have certain effect.

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


Re: [systemd-devel] List all available units

2012-08-08 Thread Lennart Poettering
On Tue, 07.08.12 16:35, Václav Pavlín (vpav...@redhat.com) wrote:

 Hi everyone,
 
 I started to work on these two bugs (if I solve the first one, the
 second one will be almost solved as well):
 
 https://bugzilla.redhat.com/show_bug.cgi?id=748512
 https://bugzilla.redhat.com/show_bug.cgi?id=790768
 
 My idea is to get list of loaded units, then list of unit files and then
 get info for units, which are in file list, but not in list of loaded
 units. Then I can print info for all units available in the system
 (whether they are loaded or not).

I am not sure we should include the units from list-unit-files in the
output of list-units, as this would increase the output quite a bit,
and would be hardly helpful in many cases, and slow.

There are differences between the concepts of loaded unit and unit file
on disk. Some units do not exist as unit files, some unit files don't
exist as units. Some files exist in many instances, and so on. 

Yes, it probably make sense to have a way to generate a list of all
units and all unit files, and merge it in some way, but I am not sure
that should be exposed as list-units nor as list-unit-files. Also,
this option is necessarily slow, since (like list-unit-files) goes to
disk and parses a lot of files, hence this is nothing we should confront
the user with on first sight, but only on explicit request.

So, dunno, I am not entirely sure how to expose this best. We probably
should get the interface right, and agree how this would be exposed to
the user, before we actually think about implementing it. Neither of the
three options I currently see (extend systemctl list-units, extend
systemctl list-unit-files, add a new systemctl verb) are that
pretty in my eyes.

If we present the user with a list like this we probably should show a
tree view of some kind since the unit file getty@.service might get
instantiated a couple of times as getty@tty1.service and so on, and
hence is in a tree-like relationship. 

Michal, Kay, do you have any suggestions how we should expose this?

Another option would be to add a notice about systemctl
list-unit-files in the footer of systemctl list-units. That should
already be a big imprvoement, since most people probably interrpet the
current advice of using --all like this.

Another option would be to add systemctl complete as hidden option for
usage only by bash completion, that does the merging.

 I would extract code responsible for loading unit_infos from
 systemctl.c/list_units to the function (so it will be reusable) and do
 the same with the systemctl.c/lis_unit_files.
 
 I would like to use hashmap to store loaded units, because it will be
 faster, than using array, to check it against unit file list. With this
 it would be nice to use hashmap directly in functions list_units and
 output_units_list, so I don't have to move data from array to hashmap
 and back to array.

Yes, storing this in a hashmap does make sense. But really, before we
get hacking we should think about the UI of this.

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] systemctl: cleanup dbus code.

2012-08-08 Thread Peeters Simon
2012/8/7 Peeters Simon peeters.si...@gmail.com:
 added a new function: bus_method_call_with_reply which does:
  dbus_message_new_method_call()
  dbus_message_append_args()
  dbus_connection_send_with_reply_and_block()
  and the needed error handling
 ---
  src/systemctl/systemctl.c | 1290 
 ++---
  1 file changed, 400 insertions(+), 890 deletions(-)

hmm, came to the conclusion that this function belongs in dbus-common
so that other parts of systemd can use it to.

The following changes since commit b2c9cbafb8b1a2742978e1faf37fbb3cf4fb5d44:

  units: remove prefdm (2012-08-07 17:08:31 +0200)

are available in the git repository at:

  git://github.com/SimonPe/systemd.git cleanup

for you to fetch changes up to b9c26b413497a0014ac2058a0ec04849a83df1ea:

  logind: use bus_method_call_with_reply() where posible (2012-08-08
17:20:04 +0200)


Simon Peeters (6):
  systemctl: add bus_method_call_with_reply
  systemctl: use bus_method_call_with_reply() where posible
  move bus_method_call_with_reply() to dbus-common
  loginctl: use bus_method_call_with_reply() where posible
  update-utmp: use bus_method_call_with_reply() where posible
  logind: use bus_method_call_with_reply() where posible

 src/login/inhibit.c   |   69 ++--
 src/login/loginctl.c  |  653 +-
 src/login/logind-dbus.c   |   31 +-
 src/login/logind.c|   47 +--
 src/shared/dbus-common.c  |   73 +
 src/shared/dbus-common.h  |   10 +
 src/systemctl/systemctl.c | 1249
-
 src/update-utmp/update-utmp.c |  118 +++
 8 files changed, 650 insertions(+), 1600 deletions(-)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] systemctl: cleanup dbus code.

2012-08-08 Thread Lennart Poettering
On Wed, 08.08.12 18:36, Peeters Simon (peeters.si...@gmail.com) wrote:

Thanks! Love it! Merged!
 
 2012/8/7 Peeters Simon peeters.si...@gmail.com:
  added a new function: bus_method_call_with_reply which does:
   dbus_message_new_method_call()
   dbus_message_append_args()
   dbus_connection_send_with_reply_and_block()
   and the needed error handling
  ---
   src/systemctl/systemctl.c | 1290 
  ++---
   1 file changed, 400 insertions(+), 890 deletions(-)
 
 hmm, came to the conclusion that this function belongs in dbus-common
 so that other parts of systemd can use it to.
 
 The following changes since commit b2c9cbafb8b1a2742978e1faf37fbb3cf4fb5d44:
 
   units: remove prefdm (2012-08-07 17:08:31 +0200)
 
 are available in the git repository at:
 
   git://github.com/SimonPe/systemd.git cleanup
 
 for you to fetch changes up to b9c26b413497a0014ac2058a0ec04849a83df1ea:
 
   logind: use bus_method_call_with_reply() where posible (2012-08-08
 17:20:04 +0200)
 
 
 Simon Peeters (6):
   systemctl: add bus_method_call_with_reply
   systemctl: use bus_method_call_with_reply() where posible
   move bus_method_call_with_reply() to dbus-common
   loginctl: use bus_method_call_with_reply() where posible
   update-utmp: use bus_method_call_with_reply() where posible
   logind: use bus_method_call_with_reply() where posible
 
  src/login/inhibit.c   |   69 ++--
  src/login/loginctl.c  |  653 +-
  src/login/logind-dbus.c   |   31 +-
  src/login/logind.c|   47 +--
  src/shared/dbus-common.c  |   73 +
  src/shared/dbus-common.h  |   10 +
  src/systemctl/systemctl.c | 1249
 -
  src/update-utmp/update-utmp.c |  118 +++
  8 files changed, 650 insertions(+), 1600 deletions(-)
 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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] timedated: gather timezone from /etc/localtime sym target

2012-08-08 Thread Lennart Poettering
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?

Lennart

 ---
  src/timedate/timedated.c |   28 
  1 file changed, 28 insertions(+)
 
 diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
 index 09fd808..456e409 100644
 --- a/src/timedate/timedated.c
 +++ b/src/timedate/timedated.c
 @@ -24,6 +24,7 @@
  #include errno.h
  #include string.h
  #include unistd.h
 +#include sys/stat.h
  
  #include util.h
  #include strv.h
 @@ -174,9 +175,35 @@ static void verify_timezone(void) {
  
  static int read_data(void) {
  int r;
 +struct stat st;
  
  free_data();
  
 +r = lstat(/etc/localtime, st);
 +if (r  0) {
 +log_warning(lstat() of %s failed: %m, /etc/localtime);
 +} else if (!S_ISLNK(st.st_mode)) {
 +log_warning(/etc/localtime should be an absolute symlink to 
 a timezone data file in /usr/share/zoneinfo/);
 +} else {
 +char *t;
 +
 +r = readlink_malloc(/etc/localtime, t);
 +if (r  0) {
 +log_warning(Failed to get target of %s: %m, 
 /etc/localtime);
 +} else if (!startswith(t, /usr/share/zoneinfo/)) {
 +log_warning(/etc/localtime should be an absolute 
 symlink to a timezone data file in /usr/share/zoneinfo/);
 +} else {
 +tz.zone = strdup(t + strlen(/usr/share/zoneinfo/));
 +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 +219,7 @@ static int read_data(void) {
  #endif
  }
  
 +have_timezone:
  if (isempty(tz.zone)) {
  free(tz.zone);
  tz.zone = NULL;


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] systemd: Fail a service if it exceeds its start limit

2012-08-08 Thread Lennart Poettering
On Mon, 06.08.12 15:30, Eelco Dolstra (eelco.dols...@logicblox.com) wrote:

 Previously, if a service configured to restart automatically exceeds
 its start limit, it entered the inactive/dead state.  That seems
 wrong to me, since there is nothing to indicate to the user that the
 service has failed.  This patch causes it to enter the failed state
 instead.

This definitely makes a lot of sense, but probably should look a bit
differently. i.e. I figure we should go through service_enter_dead()
instead, and we should introduce a new ServiceResult value for this
(SERVICE_FAILURE_START_LIMIT or so?), so that people can distinguish
this error condition from others?

 ---
  src/core/service.c | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/src/core/service.c b/src/core/service.c
 index 1c127bd..eafdbe5 100644
 --- a/src/core/service.c
 +++ b/src/core/service.c
 @@ -2487,6 +2487,7 @@ static int service_start(Unit *u) {
  r = service_start_limit_test(s);
  if (r  0) {
  service_notify_sockets_dead(s, true);
 +service_set_state(s, SERVICE_FAILED);
  return r;
  }
  


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] docs/gudev

2012-08-08 Thread Zbigniew Jędrzejewski-Szmek
On 08/08/2012 06:31 PM, Kay Sievers wrote:
 On Wed, Aug 8, 2012 at 6:26 PM, Zbigniew Jędrzejewski-Szmek
 zbys...@in.waw.pl wrote:
 +# Hack, hack. You silly gtk-doc, you must not add  CFLAGS multiple
 +# times when calling gcc; it surely can not work with options that must
 +# be listed only once.
 +# Kill CFLAGS here because gtk-doc thinks adding CFLAGS to CC _and_ also
 +# adding CFLAGS itself again would work.
 +CFLAGS=
 +LDFLAGS=
 Hi,
 are you sure that this works as expected? Quoting info make:
 
 An argument that contains `=' specifies the value of a variable: `V=X'
 sets the value of the variable V to X.  If you specify a value in this
 way, all ordinary assignments of the same variable in the makefile are
 ignored; we say they have been overridden by the command line
 argument.
 
 So I expect e.g. 'make CFLAGS=...' to cause your override to be ignored.
 I think you have to do
   override CFLAGS=
 to have certain effect.
 
 Could be that it does not work on the cmdline, I only tried
 ./configure, which seems to work fine with the assignment and which
 fails otherwise.
I just made a simple test, and indeed flags added to gcc on the
command-line are not erased. I'll add 'override', but I want to check if
it works with the real flags. Hence a question: which gcc flags cannot
be used twice?

Zbyszek

 Just add this if you think it's better, more reliable; I never used override.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Set environment variable system-wide

2012-08-08 Thread Lennart Poettering
On Mon, 06.08.12 15:17, Daniel Drake (d...@laptop.org) wrote:

 
 On Mon, Aug 6, 2012 at 3:09 PM, Kay Sievers k...@vrfy.org wrote:
  systemctl set-environment ... ?
 
 Maybe thats what I read about.
 
 In this case I'm looking to set it in early boot though, so that it
 affects all spawned processes from the very start. Is there a nice way
 of doing this?

This has been requested before, and we do support this for locale
settings (which are ultimately env vars), but I am very conservative
about adding a generic way to set system-wide env vars at boot from a
config file.

  But it's in almost all use cases wrong to use anything like that isn't
  broken unix legacy that expects it that way.
 
 I'm having trouble parsing that sentence. In this case I'm looking for
 a clean way to set PYTHONOPTIMIZE system wide (to enable Python's
 optimized bytecode usage).

I don't think anything can be considered clean if it involves setting
system-wide env vars. There must be another way to teach Python
optimization system-wide...

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] systemd powersaving feature

2012-08-08 Thread Federico Di Pierro
Hi!
I'm usign systemd on arch, and i'm really happy with it.
Today upower 0.9.18 has been released, with systemd support (it will
suspend/hibernate using systemctl suspend/hibernate instead of pm-utils).
I was only wondering: the only thing systemd can't do, right now, is the
pm-powersave part of pm-utils. Will it ever be a part of systemd? I mean,
i'd like to have systemd running powersaving script while on ac or on
battery (that is what pm-powersave does).
So we all will get rid of pm-utils (never liked it ;)  )
Thanks for your hard work!
Bye!
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] use Out of memory. consistantly (or with \n)

2012-08-08 Thread Kay Sievers
On Wed, Aug 8, 2012 at 7:02 PM, Lennart Poettering
lenn...@poettering.net wrote:
 On Mon, 06.08.12 11:43, shawn (shawnland...@gmail.com) wrote:

 -case '?':
 -return -EINVAL;
 -
  default:
 -log_error(Unknown option code %c, c);
 +log_error(Unknown option code '%c', c);
  return -EINVAL;
  }

 Hmm, but this would result in one message by getopt() itself and one by
 us in case the user uses an unknown switch, no?

 I'd like to turn off that getopt() internal message, but I am not sure
 there is a way

leading : in optstring?

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


Re: [systemd-devel] Re-exec()ing services for 'systemctl restart' ?

2012-08-08 Thread Lennart Poettering
On Mon, 06.08.12 16:52, Daniel P. Berrange (berra...@redhat.com) wrote:

 For libvirt, we (will soon) have a daemon (virtlockd) which maintains
 exclusive fcntl() based locks on disk images/devices, on behalf of both
 libvirtd and any running QEMU or LXC instances. This is a safety critical
 daemon (hence separate from libvirtd), to the extent that if the daemon
 stops / crashes, the entire host should be immediately fenced using a
 kernel watchdog and/or hardware power control device.
 
 We still want to be able to restart this daemon during RPM upgrades to
 newer versions, but we can't use a normal stop+start sequence, because
 that will loose locks for any active VMs. Thus the daemon has the ability
 to re-exec() itself triggered by SIGUSR1, preserving its critical state.
 I've read the manpages for .service, .exec, etc but I've not seen any
 reference to changing config such that
 
   # systemctl restart virtdlockd.service
 
 will simply send SIGUSR1 to the process, instead of stopping it and then
 starting it again. Obviously I could make the RPM %post send SIGUSR1
 directly and ignore systemctl, but that doesn't help admins who just
 expect to use systemctl. So I want to know if there is a recommended
 way to handle this kind of use case ?

This is fundamentally difficult to implement, simply because restarting
a service also means that the services binding to it need restarting
too. And the ordering of that gets impossible if the stop/start sequence
is atomic because it is done internally in the service, and cannot be
split into two steps that we can order freely against each other.

So, I fear we cannot really add this for you. As Kay suggested
systemctl kill is probably your best choice here, or maybe systemctl
reload.

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] timedated: gather timezone from /etc/localtime sym target

2012-08-08 Thread Kay Sievers
On Wed, Aug 8, 2012 at 6:51 PM, Lennart Poettering
lenn...@poettering.net wrote:
 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,

Just mount the symlink pointing to /usr/share/zoneinfo/ in the
container, or possibly to a copy of localtime stored the container's
/run, if there isn't anything in the container's zoneinfo?

 embedded
 devices have to ship /usr/share/zoneinfo/, which is probably something
 they might want to avoid.

I wouldn't see much of a problem if we can't determine the time zone
text in exotic and custom setups. If we don't have stuff available to
link to from /etc, we just leave it alone.

 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?

Stuff in /etc invites to manual edit and administration. Two files,
with very different names, describing the very same thing, which need
to be in sync, are so bad, that in the end, there is no real question
here, I guess. :)

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


Re: [systemd-devel] systemd powersaving feature

2012-08-08 Thread Lennart Poettering
On Wed, 08.08.12 18:54, Federico Di Pierro (nierr...@gmail.com) wrote:

 Hi!
 I'm usign systemd on arch, and i'm really happy with it.
 Today upower 0.9.18 has been released, with systemd support (it will
 suspend/hibernate using systemctl suspend/hibernate instead of pm-utils).
 I was only wondering: the only thing systemd can't do, right now, is the
 pm-powersave part of pm-utils. Will it ever be a part of systemd? I mean,
 i'd like to have systemd running powersaving script while on ac or on
 battery (that is what pm-powersave does).
 So we all will get rid of pm-utils (never liked it ;)  )

What precisely does that script do?

In general we try to follow the logic of what is good on battery is
probably good on AC too, and try to minimize the differences between
these modes.

Or in other words: what does the powersave thing do that we don't do
anyway? And why wouldn't we do that on AC too?

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] Question regarding ConditionPathExists= and systemctl status

2012-08-08 Thread Lennart Poettering
On Mon, 06.08.12 10:16, Holger Freyther (hol...@freyther.de) wrote:

 Hi,
 
 I have launched systemd --user, created a bts.service file, added
 'ConditionPathExists=' in the Unit section of my service. Then I
 launched my service with 'systemctl --user start ...' and  as the
 path does not exist, the condition_test fails and the service is not
 started.
 
 Next I tried to figure out if I my users would be able to understand
 why the service was not started. This appears to be not possible.
 
 The first part is that the Unit only holds condition_result and does
 not store which test failed. E.g. if a Unit has multiple tests it
 is not possible to know which test has failed. The debug output will
 simply state that one condition has failed. The second issue is that
 after the Unit has been garbage collected(???) the condition_result
 is gone and will not be restored. My users would have to query the
 status fast enough to maybe see the condition failure in the status.
 
 Do you consider these issues worth fixing? Is this due running 
 systemd as a user?

So yupp, we currently do not store which conditions failed. It probably
makes sense to store that and expose it on the bus. (added this to the
TODO list now).

Whether we should GC the units or not is a problematic issue. We used to
keep more services around, but nowadays we GC services much more
aggressively. It's always a bit of a balance between what is
interesting and let's save some memory, and the question where we
choose good defaults.

In a way RemainAfterExit=yes could be used to keep a service around even
on success, but that's a bit of a hack.

So, dunno, I am open to suggestions here...

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] use Out of memory. consistantly (or with \n)

2012-08-08 Thread Kay Sievers
On Wed, Aug 8, 2012 at 7:09 PM, Lennart Poettering
lenn...@poettering.net wrote:
 On Wed, 08.08.12 19:06, Kay Sievers (k...@vrfy.org) wrote:


 On Wed, Aug 8, 2012 at 7:02 PM, Lennart Poettering
 lenn...@poettering.net wrote:
  On Mon, 06.08.12 11:43, shawn (shawnland...@gmail.com) wrote:
 
  -case '?':
  -return -EINVAL;
  -
   default:
  -log_error(Unknown option code %c, c);
  +log_error(Unknown option code '%c', c);
   return -EINVAL;
   }
 
  Hmm, but this would result in one message by getopt() itself and one by
  us in case the user uses an unknown switch, no?
 
  I'd like to turn off that getopt() internal message, but I am not sure
  there is a way

 leading : in optstring?

 Nah, that just changes whether '?' is returned as error char.

Nah, it also suppresses the error.

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


Re: [systemd-devel] Set environment variable system-wide

2012-08-08 Thread Daniel Drake
On Wed, Aug 8, 2012 at 10:56 AM, Lennart Poettering
lenn...@poettering.net wrote:
 I don't think anything can be considered clean if it involves setting
 system-wide env vars. There must be another way to teach Python
 optimization system-wide...

I have yet to find the other way that you mention.
Anyway, I can agree that this is more of a python problem than a systemd one.

Thanks for the info!

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


Re: [systemd-devel] [PATCH] service: allow service to inhibit respawn with special return code

2012-08-08 Thread Lennart Poettering
On Mon, 06.08.12 17:16, Lukáš Nykrýn (lnyk...@redhat.com) wrote:

 Again thanks for review. Here is modified patch.
 If you think that it would be better to add signal stuff before
 accepting this patch I will not disagree.

 +r = set_put(*set, INT_TO_PTR(val));

Hmm, so I was about to merge this, but there is a problem here: exit
code 0 is added to the set as NULL, and that's what we return if
something is *not* in the set. So we'll always mishandle exit code 0
like this.

We probably need some code here that just adds one to all exit codes, so
that we can safely distuingish exit code 0 from not in this set. And
that probably means the parsing function needs to be renamed a bit, to
include plus_one or so...

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] timedated: gather timezone from /etc/localtime sym target

2012-08-08 Thread Tom Gundersen
On Wed, Aug 8, 2012 at 6:51 PM, Lennart Poettering
lenn...@poettering.net wrote:
 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?

I'd very much like /etc/timezone to go away.

Mainly due to two reasons: /etc/localtime and /etc/timezone are likely
to get out-of-sync (we have the same problem now in Arch where the
timezone is stored in /etc/rc.conf rather than in /etc/timezone and it
brings us nothing but grief). Also, if /etc/localtime is not a symlink
we would need to update it every time the timezone package is updated,
this would of course be possible, but it seems unnecessary.

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


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

2012-08-08 Thread Shawn Landen
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.

v2 - Add ZONEINFO_PATH
   - Restructured the patch so its very straight forward to remove
support for the old methods. (some log_warning()s should then be converted
to log_error() too)
---
 src/timedate/timedated.c |   34 ++
 1 file changed, 34 insertions(+)

diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 09fd808..01d01b6 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -24,6 +24,7 @@
 #include errno.h
 #include string.h
 #include unistd.h
+#include sys/stat.h
 
 #include util.h
 #include strv.h
@@ -74,6 +75,10 @@
 BUS_GENERIC_INTERFACES_LIST \
 org.freedesktop.timedate1\0
 
+#ifndef ZONEINFO_PATH
+#  define ZONEINFO_PATH /usr/share/zoneinfo/
+#endif
+
 const char timedate_interface[] _introspect_(timedate1) = INTERFACE;
 
 typedef struct TZ {
@@ -174,9 +179,37 @@ static void verify_timezone(void) {
 
 static int read_data(void) {
 int r;
+struct stat st;
 
 free_data();
 
+r = lstat(/etc/localtime, st);
+if (r  0) {
+log_warning(lstat() of %s failed: %m, /etc/localtime);
+} else if (!S_ISLNK(st.st_mode)) {
+log_warning(/etc/localtime should be an absolute symlink to a 
timezone data file in %s, ZONEINFO_PATH);
+} else {
+char *t;
+
+r = readlink_malloc(/etc/localtime, t);
+if (r  0) {
+log_warning(Failed to get target of %s: %m, 
/etc/localtime);
+} else if (!startswith(t, ZONEINFO_PATH)) {
+log_warning(/etc/localtime should be an absolute 
symlink to a timezone data file in %s, ZONEINFO_PATH);
+} else {
+tz.zone = strdup(t + strlen(ZONEINFO_PATH));
+if (!tz.zone) {
+free(t);
+return log_oom();
+}
+
+free(t);
+goto have_timeone;
+}
+
+free(t);
+}
+
 r = read_one_line_file(/etc/timezone, tz.zone);
 if (r  0) {
 if (r != -ENOENT)
@@ -192,6 +225,7 @@ static int read_data(void) {
 #endif
 }
 
+have_timezone:
 if (isempty(tz.zone)) {
 free(tz.zone);
 tz.zone = NULL;
-- 
1.7.10.4

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


[systemd-devel] [PATCH] build-sys: use more generic regular expression to generate syscall-list.txt correctly

2012-08-08 Thread Huang Hang
Currently MIPS and ARM define syscall numbers for multiple ABI in one
asm/unistd.h. The #define statements for each syscall are formated as:

 #define __NR_sc_name (BASE_OFFSET + sc_number)

Thus we need a more generic regular expression to match these in awk.

Signed-off-by: Huang Hang seakag...@gmail.com
---
 Makefile.am |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 278da18..2191f78 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1030,7 +1030,7 @@ BUILT_SOURCES += \

 src/core/syscall-list.txt: Makefile
$(AM_V_at)$(MKDIR_P) $(dir $@)
-   $(AM_V_GEN)$(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include
sys/syscall.h -  /dev/null | $(AWK) '/^#define[ \t]+__NR_[^ ]+[
\t]+[0-9]/ { sub(/__NR_/, , $$2); print $$2; }'  $@
+   $(AM_V_GEN)$(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include
sys/syscall.h -  /dev/null | $(AWK) '/^#define[ \t]+__NR_[^ ]+[
\t]+\(?.*[0-9]+.*\)?/ { sub(/__NR_/, , $$2); print $$2; }'  $@

 src/core/syscall-from-name.gperf: src/core/syscall-list.txt Makefile
$(AM_V_at)$(MKDIR_P) $(dir $@)
-- 
1.7.8.6
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] build-sys: use more generic regular expression to generate syscall-list.txt correctly

2012-08-08 Thread Lennart Poettering
On Thu, 09.08.12 04:04, Huang Hang (seakag...@gmail.com) wrote:

 Currently MIPS and ARM define syscall numbers for multiple ABI in one
 asm/unistd.h. The #define statements for each syscall are formated as:
 
  #define __NR_sc_name (BASE_OFFSET + sc_number)
 
 Thus we need a more generic regular expression to match these in awk.
 
 Signed-off-by: Huang Hang seakag...@gmail.com
 ---
  Makefile.am |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/Makefile.am b/Makefile.am
 index 278da18..2191f78 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -1030,7 +1030,7 @@ BUILT_SOURCES += \
 
  src/core/syscall-list.txt: Makefile
   $(AM_V_at)$(MKDIR_P) $(dir $@)
 - $(AM_V_GEN)$(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include
 sys/syscall.h -  /dev/null | $(AWK) '/^#define[ \t]+__NR_[^ ]+[
 \t]+[0-9]/ { sub(/__NR_/, , $$2); print $$2; }'  $@
 + $(AM_V_GEN)$(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include
 sys/syscall.h -  /dev/null | $(AWK) '/^#define[ \t]+__NR_[^ ]+[
 \t]+\(?.*[0-9]+.*\)?/ { sub(/__NR_/, , $$2); print $$2; }'  $@
 
  src/core/syscall-from-name.gperf: src/core/syscall-list.txt Makefile
   $(AM_V_at)$(MKDIR_P) $(dir $@)

This patch got corrupted due to linebreaks. Please resend without broken
lines! 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] [PATCH] timedated: gather timezone from /etc/localtime sym target

2012-08-08 Thread Lennart Poettering
On Wed, 08.08.12 19:29, 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.
 
 v2 - Add ZONEINFO_PATH
- Restructured the patch so its very straight forward to remove
 support for the old methods. (some log_warning()s should then be converted
 to log_error() too)
 ---
  src/timedate/timedated.c |   34 ++
  1 file changed, 34 insertions(+)
 
 diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
 index 09fd808..01d01b6 100644
 --- a/src/timedate/timedated.c
 +++ b/src/timedate/timedated.c
 @@ -24,6 +24,7 @@
  #include errno.h
  #include string.h
  #include unistd.h
 +#include sys/stat.h
  
  #include util.h
  #include strv.h
 @@ -74,6 +75,10 @@
  BUS_GENERIC_INTERFACES_LIST \
  org.freedesktop.timedate1\0
  
 +#ifndef ZONEINFO_PATH
 +#  define ZONEINFO_PATH /usr/share/zoneinfo/
 +#endif
 +
  const char timedate_interface[] _introspect_(timedate1) = INTERFACE;
  
  typedef struct TZ {
 @@ -174,9 +179,37 @@ static void verify_timezone(void) {
  
  static int read_data(void) {
  int r;
 +struct stat st;
  
  free_data();
  
 +r = lstat(/etc/localtime, st);
 +if (r  0) {
 +log_warning(lstat() of %s failed: %m, /etc/localtime);
 +} else if (!S_ISLNK(st.st_mode)) {
 +log_warning(/etc/localtime should be an absolute symlink to 
 a timezone data file in %s, ZONEINFO_PATH);
 +} else {

Coding style: if blocks containing only one line are generally written
without {} in the systemd codebase.

 +char *t;
 +
 +r = readlink_malloc(/etc/localtime, t);

Please invoke this call right-away, don't bother with the lstat() as
readlink() will return EINVAL anyway if it isn't a symbolic link what
you are reading. It's good to have this as atomic as possible...

Maybe use readlink_and_make_absolute() here? Or even
readlink_and_canonicalize()? That's the one-stop solution to getting a
useful file name out of a symlink...

Hmm, I think it would make sense to write /etc/timezone only if it
already exists.

Also, we probably should drop the man page timezone(5) at the same time,
as we are not pushing that anymore then. But maybe we should add
localtime(5) instead which explains the semantics of the symlink?

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] (resend) build-sys: use more generic regular expression to generate syscall-list.txt correctly.

2012-08-08 Thread Huang Hang
Currently MIPS and ARM define syscall numbers for multiple ABI in one
asm/unistd.h. The #define statments for each syscall are formated as:

 #define __NR_scname (BASE_OFFSET + sc_number)

Thus we need a more generic regular expression to match these in awk.

Signed-off-by: Huang Hang seakag...@gmail.com
---
 Makefile.am |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 278da18..2191f78 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1030,7 +1030,7 @@ BUILT_SOURCES += \
 
 src/core/syscall-list.txt: Makefile
$(AM_V_at)$(MKDIR_P) $(dir $@)
-   $(AM_V_GEN)$(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include sys/syscall.h 
-  /dev/null | $(AWK) '/^#define[ \t]+__NR_[^ ]+[ \t]+[0-9]/ { sub(/__NR_/, 
, $$2); print $$2; }'  $@
+   $(AM_V_GEN)$(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include sys/syscall.h 
-  /dev/null | $(AWK) '/^#define[ \t]+__NR_[^ ]+[ \t]+\(?.*[0-9]+.*\)?/ { 
sub(/__NR_/, , $$2); print $$2; }'  $@
 
 src/core/syscall-from-name.gperf: src/core/syscall-list.txt Makefile
$(AM_V_at)$(MKDIR_P) $(dir $@)
-- 
1.7.8.6

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


Re: [systemd-devel] [PATCH] build-sys: use more generic regular expression to generate syscall-list.txt correctly

2012-08-08 Thread Huang Hang
Sorry for the trouble. Just resent using git format-patch and git send-email.

Should be OK this time.

On Thu, Aug 9, 2012 at 4:47 AM, Lennart Poettering
lenn...@poettering.net wrote:
 On Thu, 09.08.12 04:04, Huang Hang (seakag...@gmail.com) wrote:

 Currently MIPS and ARM define syscall numbers for multiple ABI in one
 asm/unistd.h. The #define statements for each syscall are formated as:

  #define __NR_sc_name (BASE_OFFSET + sc_number)

 Thus we need a more generic regular expression to match these in awk.

 Signed-off-by: Huang Hang seakag...@gmail.com
 ---
  Makefile.am |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

 diff --git a/Makefile.am b/Makefile.am
 index 278da18..2191f78 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -1030,7 +1030,7 @@ BUILT_SOURCES += \

  src/core/syscall-list.txt: Makefile
   $(AM_V_at)$(MKDIR_P) $(dir $@)
 - $(AM_V_GEN)$(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include
 sys/syscall.h -  /dev/null | $(AWK) '/^#define[ \t]+__NR_[^ ]+[
 \t]+[0-9]/ { sub(/__NR_/, , $$2); print $$2; }'  $@
 + $(AM_V_GEN)$(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include
 sys/syscall.h -  /dev/null | $(AWK) '/^#define[ \t]+__NR_[^ ]+[
 \t]+\(?.*[0-9]+.*\)?/ { sub(/__NR_/, , $$2); print $$2; }'  $@

  src/core/syscall-from-name.gperf: src/core/syscall-list.txt Makefile
   $(AM_V_at)$(MKDIR_P) $(dir $@)

 This patch got corrupted due to linebreaks. Please resend without broken
 lines! Thanks!

 Lennart

 --
 Lennart Poettering - Red Hat, Inc.



-- 
Best regards,
Huang Hang
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] service: allow service to inhibit respawn with special return code

2012-08-08 Thread Jóhann B. Guðmundsson

On 08/08/2012 05:30 PM, Lennart Poettering wrote:

On Tue, 07.08.12 16:01, David Strauss (da...@davidstrauss.net) wrote:


On Sat, Aug 4, 2012 at 4:46 AM, Lennart Poettering
lenn...@poettering.net wrote:

(But please, don't implement this bit just yet, let's wait for somebody
actually needing this. Note though, that Upstart actually does have
functionality like this).

There are broken daemons like the cluster support in node.js that
return non-zero on clean shutdowns. While this is broken behavior, it
seems the systemd standard is to support broken/non-standard behavior
with optional settings. (That is, the default in systemd is a
well-behaved application.)

Hmm, I was kinda waiting for use cases like this. i.e. before we add an
option to reconfigure what clean exits are I wanted an explicit request
for it, so that we don't end up adding something that is actually
unncessary.

Added this to the TODO list now.


Should not this be fixed in the daemon instead of worked around in systemd?

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


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

2012-08-08 Thread shawnlandden
From: Shawn Landen shawnland...@gmail.com

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.
---
 src/timedate/timedated.c |   30 ++
 1 file changed, 30 insertions(+)

diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 09fd808..d0812fa 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -24,6 +24,7 @@
 #include errno.h
 #include string.h
 #include unistd.h
+#include sys/stat.h
 
 #include util.h
 #include strv.h
@@ -74,6 +75,11 @@
 BUS_GENERIC_INTERFACES_LIST \
 org.freedesktop.timedate1\0
 
+/* Must start and end with '/' */
+#ifndef ZONEINFO_PATH
+#  define ZONEINFO_PATH /usr/share/zoneinfo/
+#endif
+
 const char timedate_interface[] _introspect_(timedate1) = INTERFACE;
 
 typedef struct TZ {
@@ -174,9 +180,32 @@ static void verify_timezone(void) {
 
 static int read_data(void) {
 int r;
+struct stat st;
+char *t;
 
 free_data();
 
+r = readlink_malloc(/etc/localtime, t);
+if (r  0) {
+if (errno == EINVAL)
+log_warning(/etc/localtime should be an absolute 
symlink to a timezone data file in %s, ZONEINFO_PATH);
+else
+log_warning(Failed to get target of %s: %m, 
/etc/localtime);
+} else if (!startswith(t, ZONEINFO_PATH))
+log_warning(/etc/localtime should be an absolute symlink to a 
timezone data file in %s, ZONEINFO_PATH);
+else {
+tz.zone = strdup(t + strlen(ZONEINFO_PATH));
+if (!tz.zone) {
+free(t);
+return log_oom();
+}
+
+free(t);
+goto have_timeone;
+}
+
+free(t);
+
 r = read_one_line_file(/etc/timezone, tz.zone);
 if (r  0) {
 if (r != -ENOENT)
@@ -192,6 +221,7 @@ static int read_data(void) {
 #endif
 }
 
+have_timezone:
 if (isempty(tz.zone)) {
 free(tz.zone);
 tz.zone = NULL;
-- 
1.7.10.4

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


Re: [systemd-devel] [PATCH] service: allow service to inhibit respawn with special return code

2012-08-08 Thread Zbigniew Jędrzejewski-Szmek
On 08/08/2012 11:14 PM, Jóhann B. Guðmundsson wrote:
 On 08/08/2012 05:30 PM, Lennart Poettering wrote:
 On Tue, 07.08.12 16:01, David Strauss (da...@davidstrauss.net) wrote:

 On Sat, Aug 4, 2012 at 4:46 AM, Lennart Poettering
 lenn...@poettering.net wrote:
 (But please, don't implement this bit just yet, let's wait for somebody
 actually needing this. Note though, that Upstart actually does have
 functionality like this).
 There are broken daemons like the cluster support in node.js that
 return non-zero on clean shutdowns. While this is broken behavior, it
 seems the systemd standard is to support broken/non-standard behavior
 with optional settings. (That is, the default in systemd is a
 well-behaved application.)
 Hmm, I was kinda waiting for use cases like this. i.e. before we add an
 option to reconfigure what clean exits are I wanted an explicit request
 for it, so that we don't end up adding something that is actually
 unncessary.

 Added this to the TODO list now.
 
 Should not this be fixed in the daemon instead of worked around in systemd?
In principle yes, but some of the daemons that are broken are pretty
heavy-weight: sshd [1], java [2].

[1] http://lists.freedesktop.org/archives/systemd-devel/2011-March/001656.html
[2] 
http://lists.freedesktop.org/archives/systemd-devel/2011-December/004069.html

I'm all for fixing things upstream, but sometimes it's hard.

Zbyszek
___
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-08 Thread shawn
On Wed, 2012-08-08 at 22:56 +0200, Lennart Poettering wrote: 
   static int read_data(void) {
   int r;
  +struct stat st;
   
   free_data();
   
  +r = lstat(/etc/localtime, st);
  +if (r  0) {
  +log_warning(lstat() of %s failed: %m, /etc/localtime);
  +} else if (!S_ISLNK(st.st_mode)) {
  +log_warning(/etc/localtime should be an absolute symlink 
  to a timezone data file in %s, ZONEINFO_PATH);
  +} else {
 
 Coding style: if blocks containing only one line are generally written
 without {} in the systemd codebase.
fixed 
 
  +char *t;
  +
  +r = readlink_malloc(/etc/localtime, t);
 
 Please invoke this call right-away, don't bother with the lstat() as
 readlink() will return EINVAL anyway if it isn't a symbolic link what
 you are reading. It's good to have this as atomic as possible...
using the EINVAL behavior made it much cleaner, just realized i forgot
to
remove sys/stat.h 
 
 Maybe use readlink_and_make_absolute() here? Or even
 readlink_and_canonicalize()? That's the one-stop solution to getting a
 useful file name out of a symlink...
The problem is that canonicalize resolves symlinks inside
of /usr/share/zoneinfo
as is mentioned in the changelog, which ruins the detection of the
timezone.

A hack could be to use
char *o;
...
readlink_and_make_absolute(/etc/localtime, t);
..
if (!(o = strstr(t, ZONEINFO_PATH)))
...
strdup(o + strlen(ZONEINFO_PATH));

which would make it work for relative symlinks that do not reside
somewhere in /usr,
but seems really nasty over just requiring an absolute symlink. 
 
 Hmm, I think it would make sense to write /etc/timezone only if it
 already exists.
I'll look into this, but if its doing that this is a differn't bug that
already exists in the current version when built for Fedora. 
 
 Also, we probably should drop the man page timezone(5) at the same time,
 as we are not pushing that anymore then. But maybe we should add
 localtime(5) instead which explains the semantics of the symlink?
Considering that it must be an absolute symlink in the only sane way I
can think to implement it, and that at least Debian currently ship it as
a normal file, I think that would
be sensible.



Does anyone have a sensible way in which to allow symlinks here? The
complicated ways in which .. works when directories are themselves
symlinks makes me think this is something too complicated.

-- 
-Shawn Landden

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


[systemd-devel] [PATCH] (resend) build-sys: use more generic regular expression to generate syscall-list.txt correctly

2012-08-08 Thread Huang Hang
Currently MIPS and ARM define syscall numbers for multiple ABI in one
asm/unistd.h. The #define statments for each syscall are formated as:

 #define __NR_scname (BASE_OFFSET + sc_number)

Thus we need a more generic regular expression to match these in awk.

Signed-off-by: Huang Hang seakag...@gmail.com
---
 Makefile.am |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index da0b6f5..ad8f71d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1030,7 +1030,7 @@ BUILT_SOURCES += \
 
 src/core/syscall-list.txt: Makefile
$(AM_V_at)$(MKDIR_P) $(dir $@)
-   $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include 
sys/syscall.h -  /dev/null | $(AWK) '/^#define[ \t]+__NR_[^ ]+[ \t]+[0-9]/ { 
sub(/__NR_/, , $$2); print $$2; }'  $@
+   $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include 
sys/syscall.h -  /dev/null | $(AWK) '/^#define[ \t]+__NR_[^ ]+[ 
\t]+\(?.*[0-9]+.*\)?/ { sub(/__NR_/, , $$2); print $$2; }'  $@
 
 src/core/syscall-from-name.gperf: src/core/syscall-list.txt Makefile
$(AM_V_at)$(MKDIR_P) $(dir $@)
-- 
1.7.1

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


Re: [systemd-devel] [PATCH] (resend) build-sys: use more generic regular expression to generate syscall-list.txt correctly.

2012-08-08 Thread Huang Hang
It happened that a recent commit
276c54e7995493e59853a448a2d2c3b499b8a7de changed the line of code I
was trying to fix :(

Just rework the patch based on the latest master.

Thanks

On Thu, Aug 9, 2012 at 5:57 AM, Lennart Poettering
lenn...@poettering.net wrote:
 On Thu, 09.08.12 05:10, Huang Hang (seakag...@gmail.com) wrote:

 Currently MIPS and ARM define syscall numbers for multiple ABI in one
 asm/unistd.h. The #define statments for each syscall are formated as:

  #define __NR_scname (BASE_OFFSET + sc_number)

 Thus we need a more generic regular expression to match these in awk.

 Hmm, that doesn't apply to current git?

 Lennart

 --
 Lennart Poettering - Red Hat, Inc.



-- 
Best regards,
Huang Hang
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Question about After/Before of services

2012-08-08 Thread WANG Chao

Hi, list

As you see in the subject, this question comes from a lazy guy like me, 
who doesn't read the systemd source code at all :P


The silly question is if A is configured to 'Wants:B' and 'After:B', 
will A start exactly after B is finished or after B is started?


If A is started after B is started (still parallel somehow), is there 
anything I can do to control A to be started right after B is done?




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