Re: [systemd-devel] udev and dm inotify problems

2015-07-28 Thread Oleksii Shevchuk

>
> Most likely you built your LVM/dm userspace without proper udev
> support, or left support in there that creates device nodes on its
> own.
>
> Nowadays with devtmpfs device nodes are created exclusively by the
> kernel and userspace should never create a single device node. If your
> LVM/DM tools still do, then they have been built with incorrect
> build-time settings.
>
> Note that LVM/DM issues are probably better discussed at the LVM/DM
> mls than here...
>
> Lennart

The problem was that I had outdated libudev library in /lib. God knows
how that was happend. 

Thanks to all for support.

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


Re: [systemd-devel] udev and dm inotify problems

2015-07-26 Thread Oleksii Shevchuk
Andrei Borzenkov  writes:

> So that it the problem. Does it happen if you use cryptsetup directly?

Yes, with cryptsetup behavior is the same.

I have cryptsetup (1.6.7) and lvm2 (2.02.116).

Btw, does your system behave differently?

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


Re: [systemd-devel] udev and dm inotify problems

2015-07-26 Thread Oleksii Shevchuk
Andrei Borzenkov  writes:

>
> Could you verify with e.g. inotifywatch whether inotify event was
> generated by kernel?
>

It turns out, that for some reason I have several dm devices:

# ls -l /dev/mapper/
crw-rw 1 root dialout  10, 236 ??? 25 09:52 control
brw--- 1 root root254,  12 ??? 25 09:52 _dev_dm_5
lrwxrwxrwx 1 root root   7 ??? 25 09:52 Media-Doc -> ../dm-3
lrwxrwxrwx 1 root root   7 ??? 25 09:52 Media-Music -> ../dm-1
lrwxrwxrwx 1 root root   7 ??? 25 09:52 Media-Tmp -> ../dm-2
lrwxrwxrwx 1 root root   7 ??? 25 09:52 OS-home -> ../dm-5
lrwxrwxrwx 1 root root   7 ??? 25 09:52 OS-kernel -> ../dm-7
lrwxrwxrwx 1 root root   7 ??? 25 09:52 OS-portage -> ../dm-4
lrwxrwxrwx 1 root root   7 ??? 25 09:52 OS-prefix -> ../dm-8
brw--- 1 root root254,   0 ??? 25 09:52 OS-root
lrwxrwxrwx 1 root root   8 ??? 25 09:52 OS-Software -> ../dm-10
lrwxrwxrwx 1 root root   7 ??? 25 09:52 OS-var -> ../dm-9
lrwxrwxrwx 1 root root   7 ??? 25 09:52 OS-VM -> ../dm-6
brw--- 1 root root254,  11 ??? 26 11:36 swap << SWAP is here

Also I have separate device - /dev/dm-11, with same major/minor.

inotifywait get CLOSE_WRITE events only when the same device file is used.

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


[systemd-devel] udev and dm inotify problems

2015-07-24 Thread Oleksii Shevchuk
Hi list.

I ran into the strange problem.
After creating encrypted swap (with crypttab) boot hangs. That happens
because systemd waits for dev-mapper-swap.device.

Udev doesn't report that this device active, because SYSTEMD_READY
environment set to "0".

That happens because "change" event was not generated.

"Change" event was not generated, because udev doesn't receive inotify
event after mkswap closes device.

I come to this after verifying manually these steps:
1. Set udev log_level to debug
2. Attach device with systemd-cryptsetup
3. Verify that inotify for device was added (no errors in debug log,
   device in /run/udev/watch). Also I attach strace to systemd-udev.
4. Run mkswap /dev/mapper/swap
5. Check, that there was no any activity by systemd-udev (according to
   strace - no event, according to the logs - no processing)

After figuring out this, I double check systemd requirements with
/README.txt

I'm running linux-4.1.3, systemd (c11ae0bacee4ab835526a7408f619a754b3b848e)
Also I have this in config

CONFIG_FHANDLE=y
CONFIG_CGROUPS=y
CONFIG_CGROUP_SCHED=y
CONFIG_FAIR_GROUP_SCHED=y
CONFIG_CHECKPOINT_RESTORE=y
CONFIG_NET_NS=y
CONFIG_EPOLL=y
CONFIG_SIGNALFD=y
CONFIG_TIMERFD=y
CONFIG_SECCOMP_FILTER=y
CONFIG_BLK_DEV_BSG=y
CONFIG_EFI_PARTITION=y
CONFIG_SECCOMP=y
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
CONFIG_DMIID=y
CONFIG_EXT3_FS_POSIX_ACL=y
CONFIG_EXT4_FS_POSIX_ACL=y
CONFIG_REISERFS_FS_POSIX_ACL=y
CONFIG_XFS_POSIX_ACL=y
CONFIG_BTRFS_FS_POSIX_ACL=y
CONFIG_F2FS_FS_POSIX_ACL=y
CONFIG_FS_POSIX_ACL=y
CONFIG_INOTIFY_USER=y
CONFIG_AUTOFS4_FS=m
CONFIG_PROC_FS=y
CONFIG_SYSFS=y
CONFIG_TMPFS_POSIX_ACL=y
CONFIG_TMPFS_XATTR=y
CONFIG_EFIVAR_FS=m
CONFIG_SCHED_DEBUG=y
CONFIG_SCHEDSTATS=y

I use next workaround:

cat /etc/systemd/system/systemd-cryptsetup@swap.service.d/override.conf 
[Service]
ExecStartPost=/usr/bin/udevadm trigger -t devices -p SYSTEMD_READY=0

So.. What I should check to make all that run properly?

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


[systemd-devel] bootctl SIGSEGV

2015-02-27 Thread Oleksii Shevchuk
# bootctl
Segmentation fault (core dumped)
# gdb bootctl
GNU gdb (Gentoo 7.9 vanilla) 7.9
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from bootctl...Reading symbols from
/usr/lib64/debug//usr/bin/bootctl.debug...done.
done.
(gdb) r
Starting program: /usr/bin/bootctl
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
bootctl_main.2553 (argc=, argv=) at
/tmp/portage/sys-apps/systemd-/work/systemd-/src/boot/bootctl.c:1333
1333efi_tilt_backslashes(loader_path);
(gdb) bt
#0  bootctl_main.2553 (argc=, argv=) at
/tmp/portage/sys-apps/systemd-/work/systemd-/src/boot/bootctl.c:1333
#1  0x7e25 in main (argc=, argv=)
at
/tmp/portage/sys-apps/systemd-/work/systemd-/src/boot/bootctl.c:1404
(gdb)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] pam_mount + mount.crypt regression

2015-02-27 Thread Oleksii Shevchuk
Hi,

Looks like this patch works for me.

// wbr
// Oleksii

2015-02-27 10:25 GMT+02:00 Martin Pitt :

> Hey Oleksii,
>
> Oleksii Shevchuk [2015-02-14 10:11 +0200]:
> > This patch 06e9783e2cc12eb6514e80c7f0014295f59b breaks pam_mount for
> me.
> > Without reverting it, systemd umounts encrypted drive, mounted with
> > dm-crypt/mount.crypt/pam_mount immediately.
> >
> > I double checked, that backing device is exported to systemd:
> > sys-devices-virtual-block-dm\x2d10.device loaded active plugged
> > /sys/devices/virtual/block/dm-10
>
> Can you please try the patch here:
>
>
> http://lists.freedesktop.org/archives/systemd-devel/2015-February/028812.html
>
> if it doesn't help, can you please describe how to reproduce this, and
> put a debug-enabled journal output from that boot, please?
>
> Thanks,
>
> Martin
> --
> Martin Pitt| http://www.piware.de
> Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] pam_mount + mount.crypt regression

2015-02-14 Thread Oleksii Shevchuk
Hi,

This patch 06e9783e2cc12eb6514e80c7f0014295f59b breaks pam_mount for me.
Without reverting it, systemd umounts encrypted drive, mounted with
dm-crypt/mount.crypt/pam_mount immediately.

I double checked, that backing device is exported to systemd:
sys-devices-virtual-block-dm\x2d10.device loaded active plugged
/sys/devices/virtual/block/dm-10


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


[systemd-devel] systemd-networkd + VLANs problems

2014-02-07 Thread Oleksii Shevchuk
Hello, list.

So, I try to use VLANs feature introduced to systemd-networkd/git two
weeks ago (54abf461d6b10dc270c4bb2aeac65f240ff1c5cd).

I want to have next layout:

Links:

1. Eth
1.1 Vlan1 
1.2 Vlan2 (Ring1)
2. Bridge (Ring0)
2.1 Vlan2

Networks:

1. Vlan1
2. Bridge

So, I try next configs:

> cat Ring0.netdev
[NetDev]
Name=br0
Kind=bridge

> cat Ring1.netdev
[NetDev]
Name=vlan2
Kind=vlan

[VLAN]
Id=2

> cat LocalLink.network
[Match]
Name=vlan2

[Network]
Bridge=br0

.. and some other .network configs with IP configuration.

At this point, nothing works -- no vlan links were created. So, I grep
sources, and find out the Network.VLAN option (note - missing in man
page). So I add some more configs:

> cat Switch1.network
[Match]
Name=net1

[Network]
VLAN=vlan1

> cat Switch2.network
[Match]
Name=net1

[Network]
VLAN=vlan2

At this point I have successfully running/configured vlan1, but not
vlan2.

Then I manually create and up vlan2 with iproute2. At this point device
were up, but systemd-networkd didn't put it to bridge.

So, the question is: how should I configure this layout with two vlans
on one ethernet, where one of vlans is bridged?

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


Re: [systemd-devel] systemd + logind possible deadlock

2013-12-16 Thread Oleksii Shevchuk
> Are you suggesting O_SNDTIMEO doesn't work for you? Normally it should
> simply cause the send() to fail if the receiver doesn't take the packet
> within some time.

I don't take much investigation into this, but looks like
systemd-journald dead for some reason, and stay in zombie state, because
of systemd locking. Maybe send returned -1, but for some reason this
doesn't change things a bit - systemd is inaccessible my systemctl, and
it doesn't do any work. 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd + logind possible deadlock

2013-12-16 Thread Oleksii Shevchuk
> It's not hangin', just pretendin' :) What y'all think about a little
> patch like this?

Probably this is better than nothing, but will it fix anything? That
stuff hangs not for 1 minute, but forever
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] systemd + logind possible deadlock

2013-12-14 Thread Oleksii Shevchuk
> strace -p 1

stat("/sys", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/sys/class/tty/console/active", O_RDONLY|O_CLOEXEC) = 19
fstat(19, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7fbab0d58000
read(19, "ttyS0 tty0\n", 4096)  = 11
close(19)   = 0
munmap(0x7fbab0d58000, 4096)= 0
open("/sys/class/tty/tty0/active", O_RDONLY|O_CLOEXEC) = 19
fstat(19, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7fbab0d58000
read(19, "tty7\n", 4096)= 5
close(19)   = 0
munmap(0x7fbab0d58000, 4096)= 0
sendmsg(15, {msg_name(0)=NULL, 
msg_iov(9)=[{"PRIORITY=6\nSYSLOG_FACILITY=3\nCOD"..., 184}, 
{"UNIT=SOL.service", 16}, {"\n", 1}, {"MESSAGE_ID=39f53479d3a045ac8e117"..., 
43}, {"\n", 1}, {"RESULT=done", 11}, {"\n", 1}, {"MESSAGE=Started SOL.", 20}, 
{"\n", 1}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL^CProcess 1 detached
 

root  1280  0.1  0.0  0 0 ?Zs   дек08  10:16 
[systemd-journal] 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [HEADS-UP] PID 1 now ported to libsystemd-bus

2013-11-21 Thread Oleksii Shevchuk
Segfaults fixed, but:

systemd-logind[2167]: Failed to start session scope session-3.scope: Invalid 
arguments 'ssa(sv)' to call 
org.freedesktop.systemd1.Manager:StartTransientUnit, expecting 
'ssa(sv)a(sa(sv))'. org.freedesktop.DBus.Error.InvalidArgs 
lightdm[2594]: pam_systemd(lightdm:session): Failed to create session: Invalid 
argument 
lightdm[2168]: ** (process:2594): WARNING **: Failed to open login1 session: 
GDBus.Error:org.freedesktop.login1.NoSessionForPID: PID 2594 does not belong to 
any known session
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [HEADS-UP] PID 1 now ported to libsystemd-bus

2013-11-20 Thread Oleksii Shevchuk
> I just pushed a huge patch that ports the last remaining bit from
> libdbus to libsystemd-bus: PID 1 itself. It's a large patch, touching a
> lot of code. I did quite a bit of (personal and automated) testing but
> given how large this is I am sure I broke something. So, please, be
> careful around git for now, test it please, and don't be too surprised
> if it is a bit rougher than usual, thanks!

Segfaults on boot for me, after/at restoring hwrand. But leaks go away.
Will test at weekend..
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Systemd / PID 1 leak

2013-11-19 Thread Oleksii Shevchuk
> Valgrind

Any methodology for pid 1 valgrinding? How to start/gather information
for example?

Do you have any setup for that? Maybe I can clone it
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Systemd / PID 1 leak

2013-11-19 Thread Oleksii Shevchuk
Systemd system instance (not the user one) is leaking for me.

WinterMute # while :; do systemctl daemon-reload; ps v 1; done
  PID TTY  STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
1 ?Rs 0:01 48  1000 30535  4244  0.0 
/usr/lib/systemd/systemd
  PID TTY  STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
1 ?Rs 0:01 48  1000 30795  4488  0.0 
/usr/lib/systemd/systemd
  PID TTY  STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
1 ?Rs 0:01 48  1000 31023  4708  0.0 
/usr/lib/systemd/systemd
  PID TTY  STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
1 ?Rs 0:01 48  1000 31023  4776  0.0 
/usr/lib/systemd/systemd
  PID TTY  STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
1 ?Rs 0:01 48  1000 31247  4936  0.0 
/usr/lib/systemd/systemd

  PID TTY  STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
1 ?Rs 0:05 48  1000 44827 18096  0.2 
/usr/lib/systemd/systemd
  PID TTY  STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
1 ?Rs 0:05 48  1000 44895 18128  0.2 
/usr/lib/systemd/systemd
  PID TTY  STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
1 ?Rs 0:05 48  1000 44895 18168  0.2 
/usr/lib/systemd/systemd
  PID TTY  STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
1 ?Rs 0:05 48  1000 44999 18248  0.2 
/usr/lib/systemd/systemd
^C
WinterMute # systemctl daemon-reexec
WinterMute # ps v 1
  PID TTY  STAT   TIME  MAJFL   TRS   DRS   RSS %MEM COMMAND
1 ?Ss 0:05 48  1000 22027  3740  0.0 
/usr/lib/systemd/systemd --system --deserialize 21

Any suggestions how to find the problem?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Regression: systemd-logind failure after migration to internal dbus impl

2013-11-09 Thread Oleksii Shevchuk
> FYI, systemd-logind is still broken as for
> 86198b2788e56fd05959c2dce670d1646bf99bcd.
> Current symptoms: After leaving S3 logind doesn't sent notifications
> about leaving sleep mode. Instead, it goes to failure state:

So, the problem is: sd_event_run(m->event, us) at manager_run@login.c
returns -114, and logind exits. 

Probably either logind should be more tolerant to such errors, or
something should be fixed in systemd-bus code. Dunno what -114 means
(EALREADY? wtf?) 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Regression: systemd-logind failure after migration to internal dbus impl

2013-11-07 Thread Oleksii Shevchuk
FYI, systemd-logind is still broken as for
86198b2788e56fd05959c2dce670d1646bf99bcd.
Current symptoms: After leaving S3 logind doesn't sent notifications
about leaving sleep mode. Instead, it goes to failure state:

systemd[1]: systemd-logind.service: main process exited, code=exited, 
status=1/FAILURE
systemd[1]: Unit systemd-logind.service entered failed state.
systemd[1]: systemd-logind.service holdoff time over, scheduling restart.
systemd[1]: Stopping Login Service...
systemd[1]: Starting Login Service...
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] [RFCv2] Configurable Timeouts/Restarts default values

2013-11-04 Thread Oleksii Shevchuk
https://bugs.freedesktop.org/show_bug.cgi?id=71132

Patch adds DefaultTimeoutStartSec, DefaultTimeoutStopSec, DefaultRestartSec
configuration options to manager configuration file.
---
 man/systemd-system.conf.xml | 12 
 man/systemd.mount.xml   |  4 ++--
 man/systemd.service.xml |  6 --
 man/systemd.socket.xml  |  4 ++--
 man/systemd.swap.xml|  4 ++--
 src/core/device.c   |  2 +-
 src/core/main.c |  9 +
 src/core/manager.h  |  3 +++
 src/core/mount.c|  2 +-
 src/core/scope.c|  2 +-
 src/core/service.c  |  6 +++---
 src/core/socket.c   |  2 +-
 src/core/swap.c |  2 +-
 src/core/system.conf|  3 +++
 src/core/user.conf  |  3 +++
 15 files changed, 48 insertions(+), 16 deletions(-)

diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml
index e8cf8a9..f64fb91 100644
--- a/man/systemd-system.conf.xml
+++ b/man/systemd-system.conf.xml
@@ -95,6 +95,18 @@
 
 
 
+  
DefaultTimeoutStartSec=
+  
DefaultTimeoutStopSec=
+  DefaultRestartSec=
+
+  
+Configures the default time to wait for start, 
stop and restart.
+For non service units 
DefaultTimeoutStartSec=
+sets default for TimeoutSec= 
value.
+  
+
+
+
 CPUAffinity=
 
 Configures the initial
diff --git a/man/systemd.mount.xml b/man/systemd.mount.xml
index 217289a..bed2975 100644
--- a/man/systemd.mount.xml
+++ b/man/systemd.mount.xml
@@ -260,8 +260,8 @@
 Takes a unit-less value in seconds, or
 a time span value such as "5min
 20s". Pass 0 to disable the timeout
-logic. Defaults to
-90s.
+logic. Default value is setted up in manager 
configuration
+file via 
DefaultTimeoutStart=.
 
 
 
diff --git a/man/systemd.service.xml b/man/systemd.service.xml
index b1e3af2..0cb3d9e 100644
--- a/man/systemd.service.xml
+++ b/man/systemd.service.xml
@@ -524,7 +524,8 @@
 Takes a unit-less value in seconds, or a
 time span value such as "5min
 20s". Pass 0 to disable the timeout
-logic. Defaults to 90s, except when
+logic. Defaults to 
TimeoutStartSec= in
+manager configuration file, except when
 Type=oneshot is
 used in which case the timeout
 is disabled by default.
@@ -545,7 +546,8 @@
 Takes a unit-less value in seconds, or a
 time span value such as "5min
 20s". Pass 0 to disable the timeout
-logic. Defaults to 90s.
+logic. Defaults to 
TimeoutStartSec= in
+manager configuration file.
 
 
 
diff --git a/man/systemd.socket.xml b/man/systemd.socket.xml
index 8c88d9f..1c78562 100644
--- a/man/systemd.socket.xml
+++ b/man/systemd.socket.xml
@@ -679,8 +679,8 @@
 Takes a unit-less value in seconds, or
 a time span value such as "5min
 20s". Pass 0 to disable the timeout
-logic. Defaults to
-90s.
+logic. Defaults to 
TimeoutStartSec= in
+manager configuration file.
 
 
 
diff --git a/man/systemd.swap.xml b/man/systemd.swap.xml
index 813ae6c..13f6c84 100644
--- a/man/systemd.swap.xml
+++ b/man/systemd.swap.xml
@@ -186,8 +186,8 @@
 Takes a unit-less value in seconds, or
 a time span value such as "5min
 20s". Pass 0 to disable the timeout
-logic. Defaults to
-90s.
+logic. Defaults to 
TimeoutStartSec= in
+manager configuration file.
 
 
 
diff --git a/src/core/device.c b/src/core/device.c
index 0595015..6fc4c95 100644
--- a/src/core/device.c
+++ b/src/core/device.c

[systemd-devel] [PATCH] [RFC] Configurable Timeouts/Restarts default values

2013-11-04 Thread Oleksii Shevchuk
https://bugs.freedesktop.org/show_bug.cgi?id=71132

Patch adds DefaultTimeoutStartSec, DefaultTimeoutStopSec, DefaultRestartSec
configuration options to manager configuration file.
---
 src/core/device.c| 2 +-
 src/core/main.c  | 9 +
 src/core/manager.h   | 3 +++
 src/core/mount.c | 2 +-
 src/core/scope.c | 2 +-
 src/core/service.c   | 6 +++---
 src/core/socket.c| 2 +-
 src/core/swap.c  | 2 +-
 src/core/system.conf | 3 +++
 src/core/user.conf   | 3 +++
 10 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/src/core/device.c b/src/core/device.c
index 0595015..6fc4c95 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -70,7 +70,7 @@ static void device_init(Unit *u) {
  * indefinitely for plugged in devices, something which cannot
  * happen for the other units since their operations time out
  * anyway. */
-UNIT(d)->job_timeout = DEFAULT_TIMEOUT_USEC;
+UNIT(d)->job_timeout = u->manager->default_timeout_start_usec;
 
 UNIT(d)->ignore_on_isolate = true;
 UNIT(d)->ignore_on_snapshot = true;
diff --git a/src/core/main.c b/src/core/main.c
index 5d30893..b21fb49 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -90,6 +90,9 @@ static bool arg_switched_root = false;
 static char ***arg_join_controllers = NULL;
 static ExecOutput arg_default_std_output = EXEC_OUTPUT_JOURNAL;
 static ExecOutput arg_default_std_error = EXEC_OUTPUT_INHERIT;
+static usec_t arg_default_restart_usec = DEFAULT_RESTART_USEC;
+static usec_t arg_default_timeout_start_usec = DEFAULT_TIMEOUT_USEC;
+static usec_t arg_default_timeout_stop_usec = DEFAULT_TIMEOUT_USEC;
 static usec_t arg_runtime_watchdog = 0;
 static usec_t arg_shutdown_watchdog = 10 * USEC_PER_MINUTE;
 static char **arg_default_environment = NULL;
@@ -636,6 +639,9 @@ static int parse_config_file(void) {
 { "Manager", "CPUAffinity",   
config_parse_cpu_affinity2, 0, NULL},
 { "Manager", "DefaultStandardOutput", config_parse_output, 
  0, &arg_default_std_output  },
 { "Manager", "DefaultStandardError",  config_parse_output, 
  0, &arg_default_std_error   },
+{ "Manager", "DefaultTimeoutStartSec", config_parse_sec,   
  0, &arg_default_timeout_start_usec },
+{ "Manager", "DefaultTimeoutStopSec", config_parse_sec,
  0, &arg_default_timeout_stop_usec  },
+{ "Manager", "DefaultRestartSec", config_parse_sec,
  0, &arg_default_restart_usec  },
 { "Manager", "JoinControllers",   
config_parse_join_controllers, 0, &arg_join_controllers },
 { "Manager", "RuntimeWatchdogSec",config_parse_sec,
  0, &arg_runtime_watchdog},
 { "Manager", "ShutdownWatchdogSec",   config_parse_sec,
  0, &arg_shutdown_watchdog   },
@@ -1518,6 +1524,9 @@ int main(int argc, char *argv[]) {
 m->confirm_spawn = arg_confirm_spawn;
 m->default_std_output = arg_default_std_output;
 m->default_std_error = arg_default_std_error;
+m->default_restart_usec = arg_default_restart_usec;
+m->default_timeout_start_usec = arg_default_timeout_start_usec;
+m->default_timeout_stop_usec = arg_default_timeout_stop_usec;
 m->runtime_watchdog = arg_runtime_watchdog;
 m->shutdown_watchdog = arg_shutdown_watchdog;
 m->userspace_timestamp = userspace_timestamp;
diff --git a/src/core/manager.h b/src/core/manager.h
index ffcca48..c704d0e 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -230,6 +230,9 @@ struct Manager {
 
 ExecOutput default_std_output, default_std_error;
 
+usec_t default_restart_usec, default_timeout_start_usec,
+default_timeout_stop_usec;
+
 struct rlimit *rlimit[RLIMIT_NLIMITS];
 
 /* non-zero if we are reloading or reexecuting, */
diff --git a/src/core/mount.c b/src/core/mount.c
index 88563b3..0c15b99 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -131,7 +131,7 @@ static void mount_init(Unit *u) {
 assert(u);
 assert(u->load_state == UNIT_STUB);
 
-m->timeout_usec = DEFAULT_TIMEOUT_USEC;
+m->timeout_usec = u->manager->default_timeout_start_usec;
 m->directory_mode = 0755;
 
 exec_context_init(&m->exec_context);
diff --git a/src/core/scope.c b/src/core/scope.c
index 50e5dba..5d249ec 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -46,7 +46,7 @@ static void scope_init(Unit *u) {
 assert(u);
 assert(u->load_state == UNIT_STUB);
 
-s->timeout_stop_usec = DEFAULT_TIMEOUT_USEC;
+s->timeout_stop_usec = u->manager->default_timeout_start_usec;
 
 watch_init(&s->timer_watch);
 
diff --git a/src/core/service.c b/src/core/service.c
index ce75757..d11de79 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -124,9 +124,9 @@ static void service_init(Unit *u) {
   

[systemd-devel] systemctl status -> sigsegv

2013-10-14 Thread Oleksii Shevchuk
> systemctl --system status smartd.service
smartd.service - Self Monitoring and Reporting Technology (SMART) Daemon
   Loaded: loaded (/usr/lib64/systemd/system/smartd.service; enabled)
   Active: active (running) since Пн 2013-10-14 11:19:05 EEST; 12h ago
 Main PID: 2112 (smartd)
   CGroup: /system.slice/smartd.service
   └─2112 /usr/sbin/smartd -n
Assertion 'n_pids > 0' failed at 
/tmp/portage/sys-apps/systemd-/work/systemd-/src/shared/cgroup-show.c:47,
 function show_pid_array(). Aborting.
zsh: abort (core dumped)  systemctl --system status smartd.service

Possible fix:

diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c
index 979fa8f..5c55313 100644
--- a/src/shared/cgroup-show.c
+++ b/src/shared/cgroup-show.c
@@ -263,7 +263,8 @@ static int show_extra_pids(const char *controller, const 
char *path, const char
 copy[j++] = pids[i];
 }
 
-show_pid_array(copy, j, prefix, n_columns, true, false, false, flags);
+   if (j)
+   show_pid_array(copy, j, prefix, n_columns, true, false, false, 
flags);
 
 return 0;
 }
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Create a new logind session from a systemd --user unit

2013-08-04 Thread Oleksii Shevchuk
What about logind/polkit? I.e. if i start nm-applet from systemd@user,
than polkit doesn't authenticate it, as it not belong to active session
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd --user broken

2013-07-27 Thread Oleksii Shevchuk
> For most other things: there are actually very few things that should
> use the environment as a data store and to pass around
> config/policy/runtime information; it's just a too broken and static
> model that should no be used in this century.

Probably yes. But who and when will reimplement all the stuff? Ok,
active session detection can be easily changed within systemd/logind
(probably) to active user detection, but what about DISPLAY= (the
problem of selecting default console for new instances)?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd --user broken

2013-07-27 Thread Oleksii Shevchuk
> It is, and always was, designed as a --user daemon, just like the name
> suggests, not as a session daemon. With the upcoming kdbus work,
> systemd --user will be the creator and owner of the user's bus, and
> there can and should only be one per user and no per session.

I understand this. But.. That's sad, when really good user expierence
throwed away. Have no idea what to do with per-user daemon, that is
unattached to any session.

> Apps/services are per user, right, not per session.

Currently most apps are per-session, or at least heavily linked with
it (connected to keychain manager, i/o console etc)

> Right, it's nothing that works out of the box today, but we will get
> there.

Is there any place where I can get info about expected end point of that
process?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd --user broken

2013-07-27 Thread Oleksii Shevchuk

> It all needs still some work how things should work in the end

Unfortunately, with shared session daemon there is no way to have
display session managed by systemd -- too many problems should be
solved. Mainly with attaching services to active seat/session (for
polkit), environment propagation and so on..
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] Fix assertions while disabling unexisting target units

2013-07-14 Thread Oleksii Shevchuk

> Can you be a bit more explicit, how was this condition triggered?

1. enable templated target (blahbah@something.target)
2. make mistake and disable that as service (systemctl disable
   blahbah@something)
3. enjoy SIGABRT
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] Fix assertions while disabling unexisting target units

2013-07-14 Thread Oleksii Shevchuk
---
 src/shared/install.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/install.c b/src/shared/install.c
index 1161068..c1a5ce0 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -1414,7 +1414,7 @@ static int install_context_mark_for_removal(
 assert_se(hashmap_move_one(c->have_installed, c->will_install, 
i->name) == 0);
 
 q = unit_file_search(c, i, paths, root_dir, false);
-if (q == -ENOENT) {
+if (q == -ENOENT && i->path) {
 /* do nothing */
 } else if (q < 0) {
 if (r >= 0)
-- 
1.8.2.1

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


[systemd-devel] kmod-static-nodes.service doesn't care about udev?

2013-07-11 Thread Oleksii Shevchuk
Latest innovation with kmod-static-nodes.service introduce next issues with

1. default distro paths
2. interacting with rest configuration

So, what is the problem.

kmod-static-nodes.service.in:

ExecStartPre=/usr/bin/mkdir -p /run/tmpfiles.d

> /usr/bin/mkdir 
zsh: no such file or directory: /usr/bin/mkdir

That is not that big deal, because that should be replaced with tmpfiles.d
conf file with lowest prioirty, but shows some kind of problem -
different distros has utilites in different places. That is not the
problem, because we have pathname resolution IEEE standard and core system
rely on it. But not the systemd. Ok, maybe that makes some sence for
ExecStart services, but do we really need that in
ExecStartPre/ExecStartPost? Maybe some syntax shugar should be
introduced like ExecStartPre=* <- run with /bin/sh?

The next one - kmod doesn't care about udev rules. So, I have something
like this in udev rules:
KERNEL=="fuse", MODE="0666"

and in autogenerated with kmod:
c /dev/fuse 0600 - - - 10:229

The last one has priority. So, either kmod-static-nodes.service should
be started before udev, or some new logic should be introduces somewhere
to prevent that destructive behavior.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] cgroups: chown user slices

2013-07-11 Thread Oleksii Shevchuk
> pam_gnome_keyring needs to be in the pam stack for "systemd-shared" of
> course.

pam_gnome_keyring needs authinfo to unlock login keychain. Will that be
passed to new systemd instance? 

> Which environment would that be? 

When systemd fully runs session, than that will be full profile
environment + environment setted by login manager.

For example, DM should setup DISPLAY variable.

> Can you elaborate? Where exactly does it hang?

Some kind of debugging environment should be setted up before that. With
shared user instance user@.service hangs alot. Sometimes session scopes
rests in timeouts, when user session terminated without systemctl --user
exit. Looks like logind/pam_systemd doesn't kill something.  

I have some units in user session with KillMode=process. Maybe that matters
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] cgroups: chown user slices

2013-07-11 Thread Oleksii Shevchuk
> Yeah, you need to set some env vars currently. The idea however is that
> the X/dbus libraries learn to look into XDG_RUNTIME_DIR on their own.

I tried to make it work without success -- result is unusable. So, one
of the issues - pam_systemd doesn't forward environment to child
process. Without that things like pam_gnome_keyring (probably) can work
only with awfull workarounds.

> Nobody needs to wait for systemd --user exits. It will just exist in the
> background as long as the user is logged in and will go away as soon as
> he logs out entirely. It is refernce counted by the login sessions. 

Second one is absence of "following" mode or so. So here is the problem:
login manager forks Xsession initialization and terminates the greeter
(and session) when it exits. If daemon running in background, some
waiting mechainsm should be invented. And again, new environment should
be propagated to shared instance (and if session stops, should be
deinitialized). So, to migrate, either some new daemon should be written
to do all that stuff, or dm managers should be reworked.

Do we really need such complexity?

Maybe old behavior can be offered as the option for those of us, who
really uses user session, at least till the moment, when mainstream will
be ready for migration? 

// Btw, there are some minor issues with proper
deinitialization|stopping -- PID 1 rests in timeouts while shutdown..
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] cgroups: chown user slices

2013-07-11 Thread Oleksii Shevchuk
Ok. I trying to use current git. Nothing works for me. I.e. systemd --user
starts, but I couldn't connect to it, because it doesn't connect to 
d-bus (because dbus socket doesn't exists and systemd doesn't start dbus.socket
probably). systemd starts X services, but they couldn't establish X connection.

Generally I couldn't get the idea behind recent changes. How that supposed
to work at all? How that
1) will interract with login managers (i.e. waits for systemd --user
exits, selects proper starting unit or so)
2) will setup environment from user profile
3) will setup temporary files for user temporary folder (dbus folder,
for example)
4) will work with different login paths (ssh, local VT login, X login)

Now i have lightdm that explicity starts systemd --user as session
process. With Marc-Antoine patch that still works ok, so I will fall 
back to it and wait for some clarifications
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] cgroups: chown user slices

2013-07-10 Thread Oleksii Shevchuk
> (Note
> that this means systemd --user will only work when run from
> user@.service, as access to the cgroup tree is *not* granted for normal
> sessions directly.)

So, how sessions should work now? Before that I started systemd --user
as main session process, and when it exited, session exited too. How
should I wait for session end now?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Latest systemd-logind reorganization and user session

2013-07-02 Thread Oleksii Shevchuk
Just for info

Latest commits (01.07) broke systemd user session. Looks like user
slices doesn't chowned, so 'systemd --user' exits with permission
denied.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] [RFCv7] Optionally save core dumps as plain files

2013-05-21 Thread Oleksii Shevchuk
> > For security reasons. It will be better if user will not have access to
> > own cores by default (situation is the same with journal backend in
> > upstream now).

> Why?

When apps like gpg/lastpass/whatelse-with-passwords crashes, then user probably
will not be very happy to have all that data accessible as is. Distros
like ubuntu even disable ptrace by default for non-root users

> But at the moment, I guess what you have is not too bad because we at
> least will honor quota for non-root users; my main concern was filling
> up even the ext4 reserved space for example.

Probably it isn't, because core fds created with root:systemd-journald, like
journal files
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] [RFCv7] Optionally save core dumps as plain files

2013-05-21 Thread Oleksii Shevchuk
> Ideally for this case it'd be a pipe; that way we avoid writing a
> potentially large file to disk only to write a smaller version again.

I thought about that. With cores there is no way to do transparent
piping with postproc. All tools mmap cores, so in real world they will 
be dumped anyway..

We dump core before preprocessing to tmpfs, btw.

> Maybe it would make sense to just use the process owner
> by default? Why does preprocessing happen before dropping creds?

For security reasons. It will be better if user will not have access to
own cores by default (situation is the same with journal backend in
upstream now).

> Why does preprocessing happen before dropping creds

Processing done in separate process with dropped creds

> In general you have a lack of error logging...it'd be nice to at least
> log if the preprocess command fails (or coredumps!), because the kernel
> won't coredump anything with an rlimit of 1 which systemd-coredump and
> any process it spawns will have.

Yeah, I'll add some, if idea with temporary files will be accepted in
general.

> Anyways, in the big picture there's one feature we should probably have
> before landing this, which is some sort of free-space detection like
> journald has.  

Cores rotation mechainsm or just avoiding to write new cores?

> At least if the system administrator has set up quotas, we should
> probably ensure the files are charged against the dumping user's quota.
> At the moment we're charging them to "nobody", right?

At the moment cores dumped and processed at tmpfs with nobody, then
copied from user creds to journal and with systemd-journal creds to fs.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2013-05-14 Thread Oleksii Shevchuk
Introduce configuration file: /etc/systemd/coredump.conf with
configurable core dumps backend storages (journal/file/both/none),
per storage size limits and preprocessing.

Default filestorage choosed as /run/log/coredump or /var/log/coredump
with next reason:
1. These files produced with systemd component
2. These files registered with journal

Main differences between v7 and v6:
1. As Colin suggested, create-then-drop policy used when storing to
   files.

2. {/var/,/run}/log/coredump/MACHINE-ID folder will be created with
   root:systemd-journal owner and drwxr-s-- permissions.

3. Trivial preprocessing support added. For example:

   PreprocessFile=gzip -9 <%i>%o
   PreprocessJournal=gdb -nw --batch --quiet --silent --ex 'thread \
   apply all bt' --core %i %e > %o

   This will save to file storage compressed cores and backtraces to
   journal COREDUMP= section.

4. Copying "optimizations" removed for now. Now core always stored
   to temporary folder, then optionaly preprocessed to temporary
   files, then temporary files copied to storage.

Weak places:
   coredump.c:495

   To prevent copying of large memory segments, I contruct virtual
   space manually. Probably it will not work as expected in some cases,
   so recomendations and comments needed..
---
 Makefile-man.am  |   1 +
 Makefile.am  |  14 +-
 man/coredump.conf.xml| 217 +++
 src/core/manager.c   |   1 +
 src/journal/coredump-gperf.gperf |  24 ++
 src/journal/coredump.c   | 764 ---
 src/journal/coredump.conf|  18 +
 src/journal/coredump.h   |  89 +
 src/journal/journald-server.h|   2 +-
 9 files changed, 992 insertions(+), 138 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 481423a..e3ff8dd 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 eb85c8d..96e5bc3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2908,7 +2908,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
@@ -2927,10 +2928,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
@@ -2975,10 +2978,13 @@ EXTRA_DIST += \
 # 
--
 if ENABLE_COREDUMP
 systemd_coredump_SOURCES = \
-   src/journal/coredump.c
+   src/shared/specifier.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..491b9d0
--- /dev/null
+++ b/man/coredump.conf.xml
@@ -0,0 +1,217 @@
+ 
+http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl";?>
+http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd";>
+
+
+
+
+
+coredump.conf
+systemd
+
+
+
+Developer
+Lennart
+Poettering
+lenn...@poettering.net
+
+
+    Developer
+Oleksii
+Shevchuk
+alx...@gmail.com
+
+
+
+
+
+coredump.conf
+5
+
+
+
+coredump.conf
+Core dump utility configuration file
+
+
+
+/etc/systemd/coredump.conf
+
+
+
+Description
+
+This files configures sever

Re: [systemd-devel] [PATCH] [RFCv6] Optionally save core dumps as plain files

2013-05-14 Thread Oleksii Shevchuk
Colin Walters  writes:

> So...what do you think about dropping the User/Group settings,
> having /var/log/coredump have the same permissions as the journal?  I.e.
> owned by root:root and with an ACL for access by adm or whatever?

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


Re: [systemd-devel] [PATCH] [RFCv6] Optionally save core dumps as plain files

2013-04-30 Thread Oleksii Shevchuk
> If it needs review, I could probably do that sometime this week.  Or is
> it blocked on the "large binary blobs should go in the journal" issue?

I don't think it's really blocked, so I will be glad to have review :)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2013-04-30 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

Default filestorage choosed as /run/log/coredump or /var/log/coredump
with next reason:
1. These files produced with systemd component
2. These files registered with journal
---
 Makefile-man.am  |   1 +
 Makefile.am  |  13 +-
 man/coredump.conf.xml| 142 ++
 src/core/manager.c   |   1 +
 src/journal/coredump-gperf.gperf |  22 ++
 src/journal/coredump.c   | 567 +++
 src/journal/coredump.conf|  15 ++
 src/journal/coredump.h   |  51 
 src/journal/journald-server.h|   2 +-
 9 files changed, 703 insertions(+), 111 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 4f14a6a..c442201 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 9e0f5fb..e985bb6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2881,7 +2881,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
@@ -2900,10 +2901,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
@@ -2948,10 +2951,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..8ab92c1
--- /dev/null
+++ b/man/coredump.conf.xml
@@ -0,0 +1,142 @@
+ 
+http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl";?>
+http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd";>
+
+
+
+
+
+coredump.conf
+systemd
+
+
+
+Developer
+Lennart
+Poettering
+lenn...@poettering.net
+
+
+Developer
+    Oleksii
+Shevchuk
+alx...@gmail.com
+
+
+
+
+
+coredump.conf
+5
+
+
+
+coredump.conf
+Core dump utility configuration file
+
+
+
+/etc/systemd/coredump.conf
+
+
+
+Description
+
+This files configures several parameters of the
+systemd-coredump utility.
+
+
+
+
+Options
+
+All options are configured in the
+[Coredump] section:
+
+
+
+
+User=
+Group=
+
+Enforce UID/GID of
+systemd-coredump while 
loading
+and storing coredump. If not set, then uid/gid 
of
+crashed process will be used. This can be used
+for allowing user or group of users
+to have access to system core dumps.
+
+
+
+
+FileStorage=
+
+One of
+volatile and,
+  

Re: [systemd-devel] [PATCH 1/2] Report about syntax error in extended format

2013-04-17 Thread Oleksii Shevchuk
Zbigniew Jędrzejewski-Szmek  writes:

> I have now pushed a change that adds UNIT= or USER_UNIT= to most
> syntax error messages. This patch mostly follows Oleksii's approach,
> but extends it to all syntax parsing functions.
>

For the last time I tried to use next approach: I added reporting
callback to all parser functions. That was enough, because *userdata
contains all nessesary information about call (because it's used by
caller to store parsed data to). That makes further extentions less
expensive..

> The 'issues' patch can now easily go on top, by hooking into
> log_syntax_internal.

What is supposed way to hook with log_syntax_internal? Address unit data by 
name?
conf-parser called not only for parsing unit files, but configuration
files of services too..

Probably I'll replace *unit with *reporter and move log_struct calling to
the callback owner instead. 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2013-04-13 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

Default filestorage choosed as /run/log/coredump or /var/log/coredump
with next reason:
1. These files produced with systemd component
2. These files registered with journal
---
 Makefile-man.am  |   1 +
 Makefile.am  |  13 +-
 man/coredump.conf.xml| 142 ++
 src/core/manager.c   |   1 +
 src/journal/coredump-gperf.gperf |  22 ++
 src/journal/coredump.c   | 558 ---
 src/journal/coredump.conf|  15 ++
 src/journal/coredump.h   |  51 
 src/journal/journald-server.h|   2 +-
 9 files changed, 706 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 0e08eb5..d39a0e7 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 ec81f53..771eb49 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2851,7 +2851,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
@@ -2870,10 +2871,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
@@ -2918,10 +2921,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..8ab92c1
--- /dev/null
+++ b/man/coredump.conf.xml
@@ -0,0 +1,142 @@
+ 
+http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl";?>
+http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd";>
+
+
+
+
+
+coredump.conf
+systemd
+
+
+
+Developer
+Lennart
+Poettering
+lenn...@poettering.net
+
+
+Developer
+    Oleksii
+Shevchuk
+alx...@gmail.com
+
+
+
+
+
+coredump.conf
+5
+
+
+
+coredump.conf
+Core dump utility configuration file
+
+
+
+/etc/systemd/coredump.conf
+
+
+
+Description
+
+This files configures several parameters of the
+systemd-coredump utility.
+
+
+
+
+Options
+
+All options are configured in the
+[Coredump] section:
+
+
+
+
+User=
+Group=
+
+Enforce UID/GID of
+systemd-coredump while 
loading
+and storing coredump. If not set, then uid/gid 
of
+crashed process will be used. This can be used
+for allowing user or group of users
+to have access to system core dumps.
+
+
+
+
+FileStorage=
+
+One of
+volatile and,
+  

[systemd-devel] [PATCH] [RFC] Add DropIn paths to status message

2013-04-05 Thread Oleksii Shevchuk
> dctl status null.target
null.target - NYAN
   Loaded: loaded (/home/alxchk/.config/systemd/user/null.target; disabled)
  Drop-In: /home/alxchk/.config/systemd/user/null.target.d
   └─ descr.conf, install-1.conf, install.conf
   /etc/systemd/user/null.target.d
   └─ test.conf
   Active: active since Пт 2013-04-05 20:42:13 EEST; 1min 58s ago
---
 src/systemctl/systemctl.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index a7c2eef..a7b541d 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -2225,6 +2225,8 @@ typedef struct UnitStatusInfo {
 const char *source_path;
 const char *default_control_group;
 
+char **dropin_paths;
+
 const char *load_error;
 const char *result;
 
@@ -2331,6 +2333,34 @@ static void print_status_info(UnitStatusInfo *i) {
 printf(" %*s: %s%s%s\n",
maxlen, "Loaded", on, strna(i->load_state), off);
 
+if (!strv_isempty(i->dropin_paths)) {
+char ** dropin;
+char * dir = NULL;
+bool last = false;
+
+STRV_FOREACH(dropin, i->dropin_paths) {
+if (! dir || last) {
+printf("  %*s ", maxlen, dir ? "" : 
"Drop-In:");
+
+free(dir);
+
+if (path_get_parent(*dropin, &dir) < 0) {
+log_oom();
+return;
+}
+
+printf("%s\n %*s  %s ", dir, maxlen, "",
+   draw_special_char(DRAW_TREE_RIGHT));
+}
+
+last = ! (*(dropin + 1) && startswith(*(dropin + 1), 
dir));
+
+printf("%s%s", path_get_file_name(*dropin), last ? 
"\n" : ", ");
+}
+
+free(dir);
+}
+
 ss = streq_ptr(i->active_state, i->sub_state) ? NULL : i->sub_state;
 
 if (streq_ptr(i->active_state, "failed")) {
@@ -2771,6 +2801,11 @@ static int status_property(const char *name, 
DBusMessageIter *iter, UnitStatusIn
 
 return 0;
 
+} else if (dbus_message_iter_get_element_type(iter) == 
DBUS_TYPE_STRING && streq(name, "DropInPaths")) {
+int r = bus_parse_strv_iter(iter, &i->dropin_paths);
+if (r < 0)
+return r;
+
 } else if (dbus_message_iter_get_element_type(iter) == 
DBUS_TYPE_STRING &&
streq(name, "Documentation")) {
 
@@ -3106,6 +3141,7 @@ static int show_one(const char *verb, DBusConnection 
*bus, const char *path, boo
 }
 
 strv_free(info.documentation);
+strv_free(info.dropin_paths);
 strv_free(info.listen);
 
 if (!streq_ptr(info.active_state, "active") &&
-- 
1.8.1.2

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


[systemd-devel] [PATCH] [RFC] Add DropIn paths to status message

2013-04-05 Thread Oleksii Shevchuk
> dctl status null.target
null.target - NYAN
   Loaded: loaded (/home/alxchk/.config/systemd/user/null.target; disabled)
   DropIn: /home/alxchk/.config/systemd/user/null.target.d
└─( descr.conf; install-1.conf; install.conf )
   /etc/systemd/user/null.target.d
└─( test.conf )
   Active: active since Пт 2013-04-05 18:59:13 EEST; 1min 10s ago
---
 src/systemctl/systemctl.c | 63 +++
 1 file changed, 63 insertions(+)

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index a7c2eef..bcc284a 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -2225,6 +2225,8 @@ typedef struct UnitStatusInfo {
 const char *source_path;
 const char *default_control_group;
 
+char **dropin_paths;
+
 const char *load_error;
 const char *result;
 
@@ -2331,6 +2333,48 @@ static void print_status_info(UnitStatusInfo *i) {
 printf(" %*s: %s%s%s\n",
maxlen, "Loaded", on, strna(i->load_state), off);
 
+if (strv_length(i->dropin_paths) > 0) {
+char ** dropin;
+char * last_dir = NULL;
+bool last = false;
+
+STRV_FOREACH(dropin, i->dropin_paths) {
+const char *dp;
+
+if (! last_dir || last) {
+char *dd;
+
+printf("  %*s ", maxlen, last_dir ? "" : 
"DropIn:");
+
+free(last_dir);
+last_dir = strdup(*dropin);
+
+if (! last_dir) {
+log_oom();
+return;
+}
+
+dd = strrchr(last_dir, '/');
+
+assert(dd);
+
+*dd = '\0';
+
+printf("%s\n %*s\t%s( ", last_dir, maxlen, "",
+   draw_special_char(DRAW_TREE_RIGHT));
+}
+
+last = ! (*(dropin + 1) && startswith(*(dropin + 1), 
last_dir));
+
+dp = strrchr(*dropin, '/');
+assert(dp);
+
+printf("%s%s", dp + 1, last ? " )\n" : "; ");
+}
+
+free(last_dir);
+}
+
 ss = streq_ptr(i->active_state, i->sub_state) ? NULL : i->sub_state;
 
 if (streq_ptr(i->active_state, "failed")) {
@@ -2771,6 +2815,24 @@ static int status_property(const char *name, 
DBusMessageIter *iter, UnitStatusIn
 
 return 0;
 
+} else if (dbus_message_iter_get_element_type(iter) == 
DBUS_TYPE_STRING && streq(name, "DropInPaths")) {
+
+DBusMessageIter sub;
+
+dbus_message_iter_recurse(iter, &sub);
+while (dbus_message_iter_get_arg_type(&sub) == 
DBUS_TYPE_STRING) {
+const char *s;
+int r;
+
+dbus_message_iter_get_basic(&sub, &s);
+
+r = strv_extend(&i->dropin_paths, s);
+if (r < 0)
+return r;
+
+dbus_message_iter_next(&sub);
+}
+
 } else if (dbus_message_iter_get_element_type(iter) == 
DBUS_TYPE_STRING &&
streq(name, "Documentation")) {
 
@@ -3106,6 +3168,7 @@ static int show_one(const char *verb, DBusConnection 
*bus, const char *path, boo
 }
 
 strv_free(info.documentation);
+strv_free(info.dropin_paths);
 strv_free(info.listen);
 
 if (!streq_ptr(info.active_state, "active") &&
-- 
1.8.1.2

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


[systemd-devel] [PATCH] [RFC] Add DropIn paths to status message

2013-04-05 Thread Oleksii Shevchuk
 > dctl status null.target
null.target - NYAN
   Loaded: loaded (/home/alxchk/.config/systemd/user/null.target; disabled)
   DropIn: /home/alxchk/.config/systemd/user/null.target.d
├─descr.conf
├─install-1.conf
└─install.conf
   /etc/systemd/user/null.target.d
└─test.conf
   Active: inactive (dead)
---
 src/systemctl/systemctl.c | 66 +++
 1 file changed, 66 insertions(+)

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index a7c2eef..45688d0 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -2225,6 +2225,8 @@ typedef struct UnitStatusInfo {
 const char *source_path;
 const char *default_control_group;
 
+char **dropin_paths;
+
 const char *load_error;
 const char *result;
 
@@ -2285,6 +2287,7 @@ static void print_status_info(UnitStatusInfo *i) {
 arg_full * OUTPUT_FULL_WIDTH;
 int maxlen = 8; /* a value that'll suffice most of the time */
 char **t, **t2;
+unsigned dropins_count = 0;
 
 assert(i);
 
@@ -2331,6 +2334,50 @@ static void print_status_info(UnitStatusInfo *i) {
 printf(" %*s: %s%s%s\n",
maxlen, "Loaded", on, strna(i->load_state), off);
 
+dropins_count = strv_length(i->dropin_paths);
+if (dropins_count > 0) {
+char ** dropin;
+char * last_dir = NULL;
+bool last = false;
+
+STRV_FOREACH(dropin, i->dropin_paths) {
+const char *dp;
+
+if (! last_dir || last) {
+char *dd;
+
+printf("  %*s ", maxlen, last_dir ? "" : 
"DropIn:");
+
+free(last_dir);
+last_dir = strdup(*dropin);
+
+if (! last_dir) {
+log_oom();
+return;
+}
+
+dd = strrchr(last_dir, '/');
+
+assert(dd);
+
+*dd = '\0';
+
+printf("%s\n", last_dir);
+}
+
+last = ! (*(dropin+1) && startswith(*(dropin+1), 
last_dir));
+
+dp = strrchr(*dropin, '/');
+assert(dp);
+
+printf(" %*s\t%s%s\n", maxlen, "",
+   draw_special_char(last ? DRAW_TREE_RIGHT : 
DRAW_TREE_BRANCH),
+   dp + 1);
+}
+
+free(last_dir);
+}
+
 ss = streq_ptr(i->active_state, i->sub_state) ? NULL : i->sub_state;
 
 if (streq_ptr(i->active_state, "failed")) {
@@ -2771,6 +2818,24 @@ static int status_property(const char *name, 
DBusMessageIter *iter, UnitStatusIn
 
 return 0;
 
+} else if (dbus_message_iter_get_element_type(iter) == 
DBUS_TYPE_STRING && streq(name, "DropInPaths")) {
+
+DBusMessageIter sub;
+
+dbus_message_iter_recurse(iter, &sub);
+while (dbus_message_iter_get_arg_type(&sub) == 
DBUS_TYPE_STRING) {
+const char *s;
+int r;
+
+dbus_message_iter_get_basic(&sub, &s);
+
+r = strv_extend(&i->dropin_paths, s);
+if (r < 0)
+return r;
+
+dbus_message_iter_next(&sub);
+}
+
 } else if (dbus_message_iter_get_element_type(iter) == 
DBUS_TYPE_STRING &&
streq(name, "Documentation")) {
 
@@ -3106,6 +3171,7 @@ static int show_one(const char *verb, DBusConnection 
*bus, const char *path, boo
 }
 
 strv_free(info.documentation);
+strv_free(info.dropin_paths);
 strv_free(info.listen);
 
 if (!streq_ptr(info.active_state, "active") &&
-- 
1.8.1.2

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


Re: [systemd-devel] dbus user services using the session bus

2013-04-03 Thread Oleksii Shevchuk
> Would you be willing to contribute some of these (the dbus activation
> units for instance) back to user-session-units? There are quite a few
> folks using work based on user-session-units (a few distro's package
> it) and getting these in a central repository would help a lot of
> folks.

I have some bicycled units here, but I don't think they can be useful
for anyone not me..

http://hg.alxchk.me/units/src/

The main problem with units for user sessions, is that they are too tied
to the owner's behaviour.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/2] Report about syntax error in extended format

2013-04-01 Thread Oleksii Shevchuk
> The working assumption in systemd is that the journal is available,
> can can be used. So it storing messages in systemd (patch 2/2) goes against
> current design.

I thought about that, but that is not right I think. Journal is not the
place to store the state. It can be rotated, It can be disabled at all. For
example, we store ExitFailure status in unit state, not in journal. I
think that is important to store messages like these in objects itself.

> Also:
> why not use one MESSAGE_ID? The messages are in the same format with the
> same meaning, and their severity can be filtered separately.

Yes, now I think that MESSAGE_ID should be the same

> FILE,LINE are about the *origin* of the message, so something
> different should be used for the *object* (CONFIG_FILE,CONFIG_LINE?).
Agree
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] [RFCv4] Add Listen* to dbus properties

2013-04-01 Thread Oleksii Shevchuk
sockets.socket - Test
  Loaded: loaded (/home/alxchk/.config/systemd/user/sockets.socket; 
static)
  Active: inactive (dead)
  Listen: Stream: /tmp/stream1
  Stream: @stream4
  Stream: [::]:
  Stream: 127.0.0.2:9996
  Stream: [::1]:9996
  Datagram: /tmp/stream2
  Datagram: @stream5
  Datagram: [::]:9998
  Datagram: 127.0.0.2:9995
  Datagram: [::1]:9995
  SequentialPacket: @stream6
  SequentialPacket: /tmp/stream3
  FIFO: /tmp/fifo1
  Special: /dev/input/event9
  Netlink: kobject-uevent 0
  MessageQueue: /msgqueue1
---
 src/core/dbus-socket.c| 66 ++
 src/core/socket.c | 22 
 src/core/socket.h |  2 ++
 src/systemctl/systemctl.c | 67 +++
 4 files changed, 157 insertions(+)

diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c
index 2092a63..1dfd6c6 100644
--- a/src/core/dbus-socket.c
+++ b/src/core/dbus-socket.c
@@ -63,6 +63,7 @@
 "  \n" \
 "  \n" \
 "  \n" \
+"  \n"\
 "  \n"\
 "  \n" \
 "  \n" \
@@ -98,6 +99,70 @@ const char bus_socket_invalidating_properties[] =
 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_bind_ipv6_only, 
socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_socket_result, 
socket_result, SocketResult);
 
+static int bus_socket_append_listen(DBusMessageIter *i, const char *property, 
void *data) {
+
+Unit *u = data;
+SocketPort *p;
+Socket *s = SOCKET(u);
+DBusMessageIter array, stru;
+
+assert(data);
+assert(property);
+assert(s);
+
+if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "(ss)", 
&array))
+return log_oom();
+
+LIST_FOREACH(port, p, s->ports) {
+const char * type = socket_port_type_to_string(p);
+
+if (!dbus_message_iter_open_container(&array, 
DBUS_TYPE_STRUCT, NULL, &stru))
+return log_oom();
+
+if (!dbus_message_iter_append_basic(&stru, DBUS_TYPE_STRING, 
&type))
+return log_oom();
+
+switch (p->type) {
+case SOCKET_SOCKET: {
+int r;
+_cleanup_free_ char *a = NULL;
+char *k;
+
+r = socket_address_print(&p->address, &a);
+if (r && !k)
+k = strerror(-errno);
+else
+k = a;
+
+if (!dbus_message_iter_append_basic(&stru, 
DBUS_TYPE_STRING, &k))
+return log_oom();
+}
+break;
+
+
+case SOCKET_SPECIAL:
+case SOCKET_MQUEUE:
+case SOCKET_FIFO:
+if (!dbus_message_iter_append_basic(&stru, 
DBUS_TYPE_STRING, &p->path))
+return log_oom();
+
+break;
+
+default:
+if (!dbus_message_iter_append_basic(&stru, 
DBUS_TYPE_STRING, &type))
+return -ENOMEM;
+}
+
+if (!dbus_message_iter_close_container(&array, &stru))
+return -ENOMEM;
+}
+
+if (!dbus_message_iter_close_container(i, &array))
+return -ENOMEM;
+
+return 0;
+}
+
 static const BusProperty bus_socket_properties[] = {
 { "BindIPv6Only",   bus_socket_append_bind_ipv6_only,  "s", 
offsetof(Socket, bind_ipv6_only)  },
 { "Backlog",bus_property_append_unsigned,  "u", 
offsetof(Socket, backlog) },
@@ -123,6 +188,7 @@ static const BusProperty bus_socket_properties[] = {
 { "Broadcast",  bus_property_append_bool,  "b", 
offsetof(Socket, broadcast)   },
 { "PassCredentials",bus_property_append_bool,  "b", 
offsetof(Socket, pass_cred)   },
 { "PassSecurity",   bus_property_append_bool,  "b", 
offsetof(Socket, pass_sec)},
+{ "Listen", bus_socket_append_listen,  "a(ss)", 0, 
   },
 { "Mark",   bus_property_append_int,   "i", 
offsetof(Socket, mark)},
 { "MaxConnections", bus_property_append_unsigned,  "u", 
offsetof(Socket, max_connections) },
  

[systemd-devel] [PATCH] [RFCv3] Add Listen* to dbus properties

2013-04-01 Thread Oleksii Shevchuk
> dctl status sockets.socket
sockets.socket - Test
  Loaded: loaded (/home/alxchk/.config/systemd/user/sockets.socket; static)
  Active: inactive (dead)
  Listen: Unix/TCP: /tmp/stream1
  Unix/UDP: /tmp/stream2
  Unix/PKT: /tmp/stream3
  Unix/TCP: @stream4
  Unix/UDP: @stream5
  Unix/PKT: @stream6
  IPv6/TCP: [::]:
  IPv6/UDP: [::]:9998
  IPv4/TCP: 127.0.0.2:9996
  IPv4/UDP: 127.0.0.2:9995
  IPv6/TCP: [::1]:9996
  IPv6/UDP: [::1]:9995
  FIFO: /tmp/fifo1
   Special: /dev/input/event9
---
 src/core/dbus-socket.c| 79 +++
 src/core/dbus-unit.h  |  1 +
 src/core/socket.c | 33 
 src/core/socket.h |  3 ++
 src/systemctl/systemctl.c | 69 +
 5 files changed, 185 insertions(+)

diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c
index 2092a63..eb2a595 100644
--- a/src/core/dbus-socket.c
+++ b/src/core/dbus-socket.c
@@ -63,6 +63,7 @@
 "  \n" \
 "  \n" \
 "  \n" \
+"  \n"\
 "  \n"\
 "  \n" \
 "  \n" \
@@ -98,6 +99,83 @@ const char bus_socket_invalidating_properties[] =
 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_bind_ipv6_only, 
socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_socket_result, 
socket_result, SocketResult);
 
+static int bus_socket_append_listen(DBusMessageIter *i, const char *property, 
void *data) {
+
+Unit *u = data;
+SocketPort *p;
+Socket *s = SOCKET(u);
+DBusMessageIter array, stru;
+
+assert(data);
+assert(property);
+assert(s);
+
+if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "(ss)", 
&array))
+return log_oom();
+
+LIST_FOREACH(port, p, s->ports) {
+char *t;
+const char * type = socket_address_type_to_string(p);
+
+if (!dbus_message_iter_open_container(&array, 
DBUS_TYPE_STRUCT, NULL, &stru))
+return log_oom();
+
+if (type)
+t = strjoin(socket_port_type_to_string(p), "/", type, 
NULL);
+else
+t = strdup(socket_port_type_to_string(p));
+
+if (!t)
+return log_oom();
+
+if (!dbus_message_iter_append_basic(&stru, DBUS_TYPE_STRING, 
&t)) {
+free(t);
+return log_oom();
+}
+
+free(t);
+
+switch (p->type) {
+case SOCKET_SOCKET: {
+int r;
+_cleanup_free_ char *a = NULL;
+char *k;
+
+r = socket_address_print(&p->address, &a);
+if (r && !k)
+k = strerror(-errno);
+else
+k = a;
+
+if (!dbus_message_iter_append_basic(&stru, 
DBUS_TYPE_STRING, &k))
+return log_oom();
+}
+break;
+
+
+case SOCKET_SPECIAL:
+case SOCKET_MQUEUE:
+case SOCKET_FIFO:
+if (!dbus_message_iter_append_basic(&stru, 
DBUS_TYPE_STRING, &p->path))
+return log_oom();
+
+break;
+
+default:
+if (!dbus_message_iter_append_basic(&stru, 
DBUS_TYPE_STRING, &t))
+return -ENOMEM;
+}
+
+if (!dbus_message_iter_close_container(&array, &stru))
+return -ENOMEM;
+}
+
+if (!dbus_message_iter_close_container(i, &array))
+return -ENOMEM;
+
+return 0;
+}
+
 static const BusProperty bus_socket_properties[] = {
 { "BindIPv6Only",   bus_socket_append_bind_ipv6_only,  "s", 
offsetof(Socket, bind_ipv6_only)  },
 { "Backlog",bus_property_append_unsigned,  "u", 
offsetof(Socket, backlog) },
@@ -123,6 +201,7 @@ static const BusProperty bus_socket_properties[] = {
 { "Broadcast",  bus_property_append_bool,  "b", 
offsetof(Socket, broadcast)   },
 { "PassCredentials",bus_property_append_bool,  "b", 
offsetof(Socket, pass_cred)   },
 { "PassSecurity",   bus_property_append_bool,  "b", 
offsetof(Socket, pass_sec)},
+{ "Listen", bus_socket_append_listen,  "a(ss)", 0, 
   

[systemd-devel] [PATCH] [RFCv2] Add Listen* to dbus properties

2013-04-01 Thread Oleksii Shevchuk
> dctl status mpd.socket
mpd.socket - MPD sockets
  Loaded: loaded (/home/alxchk/.config/systemd/user/mpd.socket; enabled)
  Active: inactive (dead)
  Listen: TCP/Unix: /home/alxchk/.config/mpd/socket
  TCP/IPv6: [::]:6600
---
 src/core/dbus-socket.c| 74 +++
 src/core/dbus-unit.h  |  1 +
 src/core/socket.c | 33 +
 src/core/socket.h |  3 ++
 src/systemctl/systemctl.c | 69 +++
 5 files changed, 180 insertions(+)

diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c
index 2092a63..66f69cd 100644
--- a/src/core/dbus-socket.c
+++ b/src/core/dbus-socket.c
@@ -63,6 +63,7 @@
 "  \n" \
 "  \n" \
 "  \n" \
+"  \n"\
 "  \n"\
 "  \n" \
 "  \n" \
@@ -98,6 +99,78 @@ const char bus_socket_invalidating_properties[] =
 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_bind_ipv6_only, 
socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_socket_result, 
socket_result, SocketResult);
 
+static int bus_socket_append_listen(DBusMessageIter *i, const char *property, 
void *data) {
+
+Unit *u = data;
+SocketPort *p;
+Socket *s = SOCKET(u);
+DBusMessageIter array, stru;
+
+assert(data);
+assert(property);
+assert(s);
+
+if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "(ss)", 
&array))
+return log_oom();
+
+LIST_FOREACH(port, p, s->ports) {
+char *t;
+
+if (!dbus_message_iter_open_container(&array, 
DBUS_TYPE_STRUCT, NULL, &stru))
+return log_oom();
+
+if (asprintf(&t, "%s/%s", socket_address_type_to_string(p),
+socket_port_type_to_string(p)) < 0)
+return log_oom();
+
+if (!dbus_message_iter_append_basic(&stru, DBUS_TYPE_STRING, 
&t)) {
+free(t);
+return log_oom();
+}
+
+free(t);
+
+switch (p->type) {
+case SOCKET_SOCKET: {
+int r;
+_cleanup_free_ char *a = NULL;
+char *k;
+
+r = socket_address_print(&p->address, &a);
+if (r && !k)
+k = strerror(-errno);
+else
+k = a;
+
+if (!dbus_message_iter_append_basic(&stru, 
DBUS_TYPE_STRING, &k))
+return log_oom();
+}
+break;
+
+
+case SOCKET_SPECIAL:
+case SOCKET_MQUEUE:
+case SOCKET_FIFO:
+if (!dbus_message_iter_append_basic(&stru, 
DBUS_TYPE_STRING, &p->path))
+return log_oom();
+
+break;
+
+default:
+if (!dbus_message_iter_append_basic(&stru, 
DBUS_TYPE_STRING, &t))
+return -ENOMEM;
+}
+
+if (!dbus_message_iter_close_container(&array, &stru))
+return -ENOMEM;
+}
+
+if (!dbus_message_iter_close_container(i, &array))
+return -ENOMEM;
+
+return 0;
+}
+
 static const BusProperty bus_socket_properties[] = {
 { "BindIPv6Only",   bus_socket_append_bind_ipv6_only,  "s", 
offsetof(Socket, bind_ipv6_only)  },
 { "Backlog",bus_property_append_unsigned,  "u", 
offsetof(Socket, backlog) },
@@ -123,6 +196,7 @@ static const BusProperty bus_socket_properties[] = {
 { "Broadcast",  bus_property_append_bool,  "b", 
offsetof(Socket, broadcast)   },
 { "PassCredentials",bus_property_append_bool,  "b", 
offsetof(Socket, pass_cred)   },
 { "PassSecurity",   bus_property_append_bool,  "b", 
offsetof(Socket, pass_sec)},
+{ "Listen", bus_socket_append_listen,  "a(ss)", 0, 
   },
 { "Mark",   bus_property_append_int,   "i", 
offsetof(Socket, mark)},
 { "MaxConnections", bus_property_append_unsigned,  "u", 
offsetof(Socket, max_connections) },
 { "NConnections",   bus_property_append_unsigned,  "u", 
offsetof(Socket, n_connections)   },
diff --git a/src/core/dbus-unit.h b/src/core/dbus-unit.h
index 34980b0..e4c5666 100644
--- a/src/core/dbus-unit.h
+++ b/src/core/dbus-unit.h
@@ -88,6 +88,7 @@

Re: [systemd-devel] [PATCH] [RFCv2] Add drop-in support for [Install] section

2013-04-01 Thread Oleksii Shevchuk
> > > unit_load_dropin does also a loop over aliases (SET_FOREACH(t, u->names, 
> > > i)).
> > > unit_load_dropin_file does not. Isn't this an ommision?
> > 
> > We don't do that for [Install] anyway
> Isn't this a bug?

That's hard question.. Probably not. Aliased units shouldn't be the source
of install info, as for me
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] [RFCv3] Introspect and monitor dropin configuration

2013-04-01 Thread Oleksii Shevchuk
---
 src/core/dbus-unit.c   |  1 +
 src/core/dbus-unit.h   |  1 +
 src/core/load-dropin.c | 60 ++
 src/core/load-dropin.h |  1 +
 src/core/unit.c| 32 ++-
 src/core/unit.h|  2 ++
 6 files changed, 77 insertions(+), 20 deletions(-)

diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index dc7d1f1..f413386 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -1284,6 +1284,7 @@ const BusProperty bus_unit_properties[] = {
 { "SubState", bus_unit_append_sub_state,  "s", 0 },
 { "FragmentPath", bus_property_append_string, "s", 
offsetof(Unit, fragment_path),  true },
 { "SourcePath",   bus_property_append_string, "s", 
offsetof(Unit, source_path),true },
+{ "DropinPaths",  bus_property_append_strv,  "as", 
offsetof(Unit, dropin_paths),   true },
 { "UnitFileState",bus_unit_append_file_state, "s", 0 },
 { "InactiveExitTimestamp",bus_property_append_usec,   "t", 
offsetof(Unit, inactive_exit_timestamp.realtime)   },
 { "InactiveExitTimestampMonotonic", bus_property_append_usec, "t", 
offsetof(Unit, inactive_exit_timestamp.monotonic)  },
diff --git a/src/core/dbus-unit.h b/src/core/dbus-unit.h
index 34980b0..e4c5666 100644
--- a/src/core/dbus-unit.h
+++ b/src/core/dbus-unit.h
@@ -88,6 +88,7 @@
 "  \n" \
 "  \n" \
 "  \n" \
+"  \n" \
 "  \n" \
 "  \n" \
 "  \n" \
diff --git a/src/core/load-dropin.c b/src/core/load-dropin.c
index 95c9a38..6a57532 100644
--- a/src/core/load-dropin.c
+++ b/src/core/load-dropin.c
@@ -137,12 +137,44 @@ static int process_dir(Unit *u, const char *unit_path, 
const char *name, const c
 return 0;
 }
 
-int unit_load_dropin(Unit *u) {
+char ** unit_find_dropin_paths(Unit *u) {
 Iterator i;
 char *t;
 _cleanup_strv_free_ char **strv = NULL;
+char **configs = NULL;
 int r;
 
+assert(u);
+
+SET_FOREACH(t, u->names, i) {
+char **p;
+
+STRV_FOREACH(p, u->manager->lookup_paths.unit_path) {
+/* This loads the drop-in config snippets */
+r = process_dir(u, *p, t, ".d", 
_UNIT_DEPENDENCY_INVALID, &strv);
+if (r < 0)
+return NULL;
+}
+}
+
+if (!strv_isempty(strv)) {
+r = conf_files_list_strv(&configs, ".conf", NULL, (const 
char**) strv);
+if (r < 0) {
+log_error("Failed to get list of configuration files: 
%s", strerror(-r));
+strv_free(configs);
+return NULL;
+}
+
+}
+
+return configs;
+}
+
+int unit_load_dropin(Unit *u) {
+Iterator i;
+char *t, **f;
+_cleanup_strv_free_ char **strv = NULL;
+int r;
 
 assert(u);
 
@@ -159,30 +191,20 @@ int unit_load_dropin(Unit *u) {
 r = process_dir(u, *p, t, ".requires", UNIT_REQUIRES, 
NULL);
 if (r < 0)
 return r;
-
-/* This loads the drop-in config snippets */
-r = process_dir(u, *p, t, ".d", 
_UNIT_DEPENDENCY_INVALID, &strv);
-if (r < 0)
-return r;
 }
 }
 
-if (!strv_isempty(strv)) {
-_cleanup_strv_free_ char **files = NULL;
-char **f;
+u->dropin_paths = unit_find_dropin_paths(u);
+if (! u->dropin_paths)
+return 0;
 
-r = conf_files_list_strv(&files, ".conf", NULL, (const char**) 
strv);
-if (r < 0) {
-log_error("Failed to get list of configuration files: 
%s", strerror(-r));
+STRV_FOREACH(f, u->dropin_paths) {
+r = config_parse(*f, NULL, UNIT_VTABLE(u)->sections, 
config_item_perf_lookup, (void*) load_fragment_gperf_lookup, false, u);
+if (r < 0)
 return r;
-}
-
-STRV_FOREACH(f, files) {
-r = config_parse(*f, NULL, UNIT_VTABLE(u)->sections, 
config_item_perf_lookup, (void*) load_fragment_gperf_lookup, false, u);
-if (r < 0)
-return r;
-}
 }
 
+u->dropin_mtime = now(CLOCK_REALTIME);
+
 return 0;
 }
diff --git a/src/core/load-dropin.h b/src/core/load-dropin.h
index 1d2fafe..277bff3 100644
--- a/src/core/load-dropin.h
+++ b/src/core/load-dropin.h
@@ -25,4 +25,5 @@
 
 /* Read service data supplementary drop-in directories */
 
+char 

Re: [systemd-devel] [HEADSUP] New module ‘libc’ in systemd git

2013-04-01 Thread Oleksii Shevchuk
I'll post news about it in our regional linux site :)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/2] Report about syntax error in extended format

2013-04-01 Thread Oleksii Shevchuk
---
 src/shared/conf-parser.c | 86 ++--
 src/shared/conf-parser.h |  3 ++
 2 files changed, 57 insertions(+), 32 deletions(-)

diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index c2cf5a6..60a6b35 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -35,6 +35,28 @@
 #include "set.h"
 #include "exit-status.h"
 
+static int log_syntax(const char * file, unsigned line, bool error, const char 
*description, ...) {
+_cleanup_free_ char *buf = NULL;
+
+va_list arg_descr, arg_copy;
+
+va_start(arg_descr, description);
+va_copy(arg_copy, arg_descr);
+if (vasprintf(&buf, description, arg_copy) < 0) {
+va_end(arg_descr);
+return log_oom();
+}
+va_end(arg_descr);
+
+return log_struct(error ? LOG_ERR : LOG_WARNING,
+  "MESSAGE=[%s:%d]: %s", file, line, buf,
+  "MESSAGE_ID=%s\n", error ? CONF_PARSER_ERROR : 
CONF_PARSER_WARNING,
+  "FILE=%s\n", file,
+  "LINE=%u\n", line,
+  "ERROR=%s\n", buf,
+  NULL);
+}
+
 int config_item_table_lookup(
 void *table,
 const char *section,
@@ -145,7 +167,7 @@ static int next_assignment(
 
 /* Warn about unknown non-extension fields. */
 if (!relaxed && !startswith(lvalue, "X-"))
-log_info("[%s:%u] Unknown lvalue '%s' in section '%s'. 
Ignoring.", filename, line, lvalue, section);
+log_syntax(filename, line, false, "Unknown lvalue '%s' in 
section '%s'", lvalue, section);
 
 return 0;
 }
@@ -199,7 +221,7 @@ static int parse_line(
 assert(k > 0);
 
 if (l[k-1] != ']') {
-log_error("[%s:%u] Invalid section header.", filename, 
line);
+log_syntax(filename, line, true, "Invalid section 
header");
 return -EBADMSG;
 }
 
@@ -209,8 +231,8 @@ static int parse_line(
 
 if (sections && !nulstr_contains(sections, n)) {
 
-if (!relaxed)
-log_info("[%s:%u] Unknown section '%s'. 
Ignoring.", filename, line, n);
+if (! relaxed)
+log_syntax(filename, line, false, "Unknown 
section '%s'. Ignoring.", n);
 
 free(n);
 *section = NULL;
@@ -225,14 +247,14 @@ static int parse_line(
 if (sections && !*section) {
 
 if (!relaxed)
-log_info("[%s:%u] Assignment outside of section. 
Ignoring.", filename, line);
+log_syntax(filename, line, false, "Assignment outside 
of section. Ignoring.");
 
 return 0;
 }
 
 e = strchr(l, '=');
 if (!e) {
-log_error("[%s:%u] Missing '='.", filename, line);
+log_syntax(filename, line, true, "Missing '='.");
 return -EBADMSG;
 }
 
@@ -274,7 +296,7 @@ int config_parse(
 f = fopen(filename, "re");
 if (!f) {
 r = -errno;
-log_error("Failed to open configuration file '%s': 
%s", filename, strerror(-r));
+log_error("Failed to open configuration file '%s': 
%s", filename, strerror(-errno));
 goto finish;
 }
 
@@ -379,7 +401,7 @@ int config_parse_int(
 
 r = safe_atoi(rvalue, i);
 if (r < 0) {
-log_error("[%s:%u] Failed to parse numeric value, ingoring: 
%s", filename, line, rvalue);
+log_syntax(filename, line, true, "Failed to parse numeric 
value '%s'. Ingoring.", rvalue);
 return 0;
 }
 
@@ -406,7 +428,7 @@ int config_parse_long(
 
 r = safe_atoli(rvalue, i);
 if (r < 0) {
-log_error("[%s:%u] Failed to parse numeric value, ignoring: 
%s", filename, line, rvalue);
+log_syntax(filename, line, true, "Failed to parse numeric 
value, ignoring: %s", rvalue);
 return 0;
 }
 
@@ -433,7 +455,7 @@ int config_parse_uint64(
 
 r = safe_atou64(rvalue, u);
 if (r < 0) {
-log_error("[%s:%u] Failed to parse numeric value, ignoring: 
%s", filename, line, rvalue);
+log_syntax(filename, line, true, "Failed to parse numeric 
value, ignoring: %s", rvalue);
 return 0;
 }
 
@@ -460,7 +482,7 @@ int config_parse_unsigned(
 
 r = safe_atou(rvalue, u);
 if (r < 0) {
-log_error("[%s:%u] Failed to parse numeric value: %s", 
filename, line, rvalue);
+log_syntax(filename, line, true, "Failed to parse numeric 
value: %s", rvalue);
 return r;

[systemd-devel] [PATCH] [RFC] Show listen addresses in status output

2013-03-31 Thread Oleksii Shevchuk
---
 src/systemctl/systemctl.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 328b91b..0ad5112 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -2254,6 +2254,7 @@ typedef struct UnitStatusInfo {
 unsigned n_accepted;
 unsigned n_connections;
 bool accept;
+char **listen;
 
 /* Device */
 const char *sysfs_path;
@@ -2386,6 +2387,19 @@ static void print_status_info(UnitStatusInfo *i) {
 }
 }
 
+if (!strv_isempty(i->listen)) {
+char **t;
+bool first = true;
+
+STRV_FOREACH(t, i->listen) {
+if (first) {
+printf("\t  Listen: %s\n", *t);
+first = false;
+} else
+printf("\t  %s\n", *t);
+}
+}
+
 if (i->accept)
 printf("\tAccepted: %u; Connected: %u\n", i->n_accepted, 
i->n_connections);
 
@@ -2757,6 +2771,27 @@ static int status_property(const char *name, 
DBusMessageIter *iter, UnitStatusIn
 
 dbus_message_iter_next(&sub);
 }
+
+} else if (dbus_message_iter_get_element_type(iter) == 
DBUS_TYPE_STRING &&
+   startswith(name, "Listen")) {
+DBusMessageIter sub;
+
+dbus_message_iter_recurse(iter, &sub);
+while (dbus_message_iter_get_arg_type(&sub) == 
DBUS_TYPE_STRING) {
+const char *s;
+char **l;
+
+dbus_message_iter_get_basic(&sub, &s);
+
+l = strv_append(i->listen, s);
+if (!l)
+return -ENOMEM;
+
+strv_free(i->listen);
+i->listen = l;
+
+dbus_message_iter_next(&sub);
+}
 }
 
 break;
-- 
1.8.1.2

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


[systemd-devel] [PATCH] [RFCv2] Introspect and monitor dropin configuration

2013-03-31 Thread Oleksii Shevchuk
---
 src/core/dbus-unit.c   |  1 +
 src/core/load-dropin.c | 60 ++
 src/core/load-dropin.h |  1 +
 src/core/unit.c| 32 ++-
 src/core/unit.h|  2 ++
 5 files changed, 76 insertions(+), 20 deletions(-)

diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index dc7d1f1..f413386 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -1284,6 +1284,7 @@ const BusProperty bus_unit_properties[] = {
 { "SubState", bus_unit_append_sub_state,  "s", 0 },
 { "FragmentPath", bus_property_append_string, "s", 
offsetof(Unit, fragment_path),  true },
 { "SourcePath",   bus_property_append_string, "s", 
offsetof(Unit, source_path),true },
+{ "DropinPaths",  bus_property_append_strv,  "as", 
offsetof(Unit, dropin_paths),   true },
 { "UnitFileState",bus_unit_append_file_state, "s", 0 },
 { "InactiveExitTimestamp",bus_property_append_usec,   "t", 
offsetof(Unit, inactive_exit_timestamp.realtime)   },
 { "InactiveExitTimestampMonotonic", bus_property_append_usec, "t", 
offsetof(Unit, inactive_exit_timestamp.monotonic)  },
diff --git a/src/core/load-dropin.c b/src/core/load-dropin.c
index 95c9a38..6a57532 100644
--- a/src/core/load-dropin.c
+++ b/src/core/load-dropin.c
@@ -137,12 +137,44 @@ static int process_dir(Unit *u, const char *unit_path, 
const char *name, const c
 return 0;
 }
 
-int unit_load_dropin(Unit *u) {
+char ** unit_find_dropin_paths(Unit *u) {
 Iterator i;
 char *t;
 _cleanup_strv_free_ char **strv = NULL;
+char **configs = NULL;
 int r;
 
+assert(u);
+
+SET_FOREACH(t, u->names, i) {
+char **p;
+
+STRV_FOREACH(p, u->manager->lookup_paths.unit_path) {
+/* This loads the drop-in config snippets */
+r = process_dir(u, *p, t, ".d", 
_UNIT_DEPENDENCY_INVALID, &strv);
+if (r < 0)
+return NULL;
+}
+}
+
+if (!strv_isempty(strv)) {
+r = conf_files_list_strv(&configs, ".conf", NULL, (const 
char**) strv);
+if (r < 0) {
+log_error("Failed to get list of configuration files: 
%s", strerror(-r));
+strv_free(configs);
+return NULL;
+}
+
+}
+
+return configs;
+}
+
+int unit_load_dropin(Unit *u) {
+Iterator i;
+char *t, **f;
+_cleanup_strv_free_ char **strv = NULL;
+int r;
 
 assert(u);
 
@@ -159,30 +191,20 @@ int unit_load_dropin(Unit *u) {
 r = process_dir(u, *p, t, ".requires", UNIT_REQUIRES, 
NULL);
 if (r < 0)
 return r;
-
-/* This loads the drop-in config snippets */
-r = process_dir(u, *p, t, ".d", 
_UNIT_DEPENDENCY_INVALID, &strv);
-if (r < 0)
-return r;
 }
 }
 
-if (!strv_isempty(strv)) {
-_cleanup_strv_free_ char **files = NULL;
-char **f;
+u->dropin_paths = unit_find_dropin_paths(u);
+if (! u->dropin_paths)
+return 0;
 
-r = conf_files_list_strv(&files, ".conf", NULL, (const char**) 
strv);
-if (r < 0) {
-log_error("Failed to get list of configuration files: 
%s", strerror(-r));
+STRV_FOREACH(f, u->dropin_paths) {
+r = config_parse(*f, NULL, UNIT_VTABLE(u)->sections, 
config_item_perf_lookup, (void*) load_fragment_gperf_lookup, false, u);
+if (r < 0)
 return r;
-}
-
-STRV_FOREACH(f, files) {
-r = config_parse(*f, NULL, UNIT_VTABLE(u)->sections, 
config_item_perf_lookup, (void*) load_fragment_gperf_lookup, false, u);
-if (r < 0)
-return r;
-}
 }
 
+u->dropin_mtime = now(CLOCK_REALTIME);
+
 return 0;
 }
diff --git a/src/core/load-dropin.h b/src/core/load-dropin.h
index 1d2fafe..277bff3 100644
--- a/src/core/load-dropin.h
+++ b/src/core/load-dropin.h
@@ -25,4 +25,5 @@
 
 /* Read service data supplementary drop-in directories */
 
+char ** unit_find_dropin_paths(Unit *u);
 int unit_load_dropin(Unit *u);
diff --git a/src/core/unit.c b/src/core/unit.c
index 7111679..75a49d5 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -408,6 +408,7 @@ void unit_free(Unit *u) {
 strv_free(u->documentation);
 free(u->fragment_path);
 f

Re: [systemd-devel] [PATCH] [RFCv2] Add drop-in support for [Install] section

2013-03-31 Thread Oleksii Shevchuk
> unit_load_dropin does also a loop over aliases (SET_FOREACH(t, u->names, i)).
> unit_load_dropin_file does not. Isn't this an ommision?

We don't do that for [Install] anyway
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] Add Listen* to dbus properties

2013-03-31 Thread Oleksii Shevchuk
---
 src/core/dbus-socket.c | 54 ++
 1 file changed, 54 insertions(+)

diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c
index 2092a63..1dfac6d 100644
--- a/src/core/dbus-socket.c
+++ b/src/core/dbus-socket.c
@@ -63,6 +63,10 @@
 "  \n" \
 "  \n" \
 "  \n" \
+"  \n"
\
+"  \n"   
 \
+"  \n"\
+"  \n"\
 "  \n"\
 "  \n" \
 "  \n" \
@@ -98,6 +102,52 @@ const char bus_socket_invalidating_properties[] =
 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_bind_ipv6_only, 
socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_socket_result, 
socket_result, SocketResult);
 
+static int bus_socket_append_listen(DBusMessageIter *i, const char *property, 
void *data) {
+Unit *u = data;
+SocketPort *p;
+Socket *s = SOCKET(u);
+DBusMessageIter sub;
+
+assert(data);
+assert(s);
+
+if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "s", &sub))
+return -ENOMEM;
+
+LIST_FOREACH(port, p, s->ports) {
+
+if ((p->type == SOCKET_SOCKET) && (streq(property, 
"ListenSocket"))) {
+char *t, *k;
+int r;
+
+r = socket_address_print(&p->address, &t);
+if (r && !k)
+k = strerror(-errno);
+else
+k = t;
+
+if (!dbus_message_iter_append_basic(&sub, 
DBUS_TYPE_STRING, &k))
+return -ENOMEM;
+
+free(t);
+} else if ((p->type == SOCKET_SPECIAL) && (streq(property, 
"ListenSpecial"))) {
+if (!dbus_message_iter_append_basic(&sub, 
DBUS_TYPE_STRING, &p->path))
+return -ENOMEM;
+} else if ((p->type == SOCKET_MQUEUE) && (streq(property, 
"ListenMessageQueue"))) {
+if (!dbus_message_iter_append_basic(&sub, 
DBUS_TYPE_STRING, &p->path))
+return -ENOMEM;
+} else if ((p->type == SOCKET_FIFO)  && (streq(property, 
"ListenFIFO"))) {
+if (!dbus_message_iter_append_basic(&sub, 
DBUS_TYPE_STRING, &p->path))
+return -ENOMEM;
+}
+}
+
+if (!dbus_message_iter_close_container(i, &sub))
+return -ENOMEM;
+
+return 0;
+}
+
 static const BusProperty bus_socket_properties[] = {
 { "BindIPv6Only",   bus_socket_append_bind_ipv6_only,  "s", 
offsetof(Socket, bind_ipv6_only)  },
 { "Backlog",bus_property_append_unsigned,  "u", 
offsetof(Socket, backlog) },
@@ -123,6 +173,10 @@ static const BusProperty bus_socket_properties[] = {
 { "Broadcast",  bus_property_append_bool,  "b", 
offsetof(Socket, broadcast)   },
 { "PassCredentials",bus_property_append_bool,  "b", 
offsetof(Socket, pass_cred)   },
 { "PassSecurity",   bus_property_append_bool,  "b", 
offsetof(Socket, pass_sec)},
+{ "ListenSocket",   bus_socket_append_listen, "as", 0, 
   },
+{ "ListenSpecial",  bus_socket_append_listen, "as", 0, 
   },
+{ "ListenMessageQueue", bus_socket_append_listen, "as", 0, 
   },
+{ "ListenFIFO", bus_socket_append_listen, "as", 0, 
   },
 { "Mark",   bus_property_append_int,   "i", 
offsetof(Socket, mark)},
 { "MaxConnections", bus_property_append_unsigned,  "u", 
offsetof(Socket, max_connections) },
 { "NConnections",   bus_property_append_unsigned,  "u", 
offsetof(Socket, n_connections)   },
-- 
1.8.1.2

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


[systemd-devel] [PATCH] [RFC] Introspect and monitor dropin configuration

2013-03-31 Thread Oleksii Shevchuk
---
 src/core/dbus-unit.c   |  1 +
 src/core/load-dropin.c | 60 ++
 src/core/load-dropin.h |  1 +
 src/core/unit.c| 21 ++
 src/core/unit.h|  2 ++
 5 files changed, 66 insertions(+), 19 deletions(-)

diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index dc7d1f1..f413386 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -1284,6 +1284,7 @@ const BusProperty bus_unit_properties[] = {
 { "SubState", bus_unit_append_sub_state,  "s", 0 },
 { "FragmentPath", bus_property_append_string, "s", 
offsetof(Unit, fragment_path),  true },
 { "SourcePath",   bus_property_append_string, "s", 
offsetof(Unit, source_path),true },
+{ "DropinPaths",  bus_property_append_strv,  "as", 
offsetof(Unit, dropin_paths),   true },
 { "UnitFileState",bus_unit_append_file_state, "s", 0 },
 { "InactiveExitTimestamp",bus_property_append_usec,   "t", 
offsetof(Unit, inactive_exit_timestamp.realtime)   },
 { "InactiveExitTimestampMonotonic", bus_property_append_usec, "t", 
offsetof(Unit, inactive_exit_timestamp.monotonic)  },
diff --git a/src/core/load-dropin.c b/src/core/load-dropin.c
index 95c9a38..8925f29 100644
--- a/src/core/load-dropin.c
+++ b/src/core/load-dropin.c
@@ -137,12 +137,44 @@ static int process_dir(Unit *u, const char *unit_path, 
const char *name, const c
 return 0;
 }
 
-int unit_load_dropin(Unit *u) {
+char ** unit_find_dropin_paths(Unit *u) {
 Iterator i;
 char *t;
 _cleanup_strv_free_ char **strv = NULL;
+char ** configs = NULL;
 int r;
 
+assert(u);
+
+SET_FOREACH(t, u->names, i) {
+char **p;
+
+STRV_FOREACH(p, u->manager->lookup_paths.unit_path) {
+/* This loads the drop-in config snippets */
+r = process_dir(u, *p, t, ".d", 
_UNIT_DEPENDENCY_INVALID, &strv);
+if (r < 0)
+return NULL;
+}
+}
+
+if (!strv_isempty(strv)) {
+r = conf_files_list_strv(&configs, ".conf", NULL, (const 
char**) strv);
+if (r < 0) {
+log_error("Failed to get list of configuration files: 
%s", strerror(-r));
+strv_free(configs);
+return NULL;
+}
+
+}
+
+return configs;
+}
+
+int unit_load_dropin(Unit *u) {
+Iterator i;
+char *t, **f;
+_cleanup_strv_free_ char **strv = NULL;
+int r;
 
 assert(u);
 
@@ -159,30 +191,20 @@ int unit_load_dropin(Unit *u) {
 r = process_dir(u, *p, t, ".requires", UNIT_REQUIRES, 
NULL);
 if (r < 0)
 return r;
-
-/* This loads the drop-in config snippets */
-r = process_dir(u, *p, t, ".d", 
_UNIT_DEPENDENCY_INVALID, &strv);
-if (r < 0)
-return r;
 }
 }
 
-if (!strv_isempty(strv)) {
-_cleanup_strv_free_ char **files = NULL;
-char **f;
+u->dropin_paths = unit_find_dropin_paths(u);
+if (! u->dropin_paths)
+return 0;
 
-r = conf_files_list_strv(&files, ".conf", NULL, (const char**) 
strv);
-if (r < 0) {
-log_error("Failed to get list of configuration files: 
%s", strerror(-r));
+STRV_FOREACH(f, u->dropin_paths) {
+r = config_parse(*f, NULL, UNIT_VTABLE(u)->sections, 
config_item_perf_lookup, (void*) load_fragment_gperf_lookup, false, u);
+if (r < 0)
 return r;
-}
-
-STRV_FOREACH(f, files) {
-r = config_parse(*f, NULL, UNIT_VTABLE(u)->sections, 
config_item_perf_lookup, (void*) load_fragment_gperf_lookup, false, u);
-if (r < 0)
-return r;
-}
 }
 
+u->dropin_mtime = now(CLOCK_REALTIME);
+
 return 0;
 }
diff --git a/src/core/load-dropin.h b/src/core/load-dropin.h
index 1d2fafe..277bff3 100644
--- a/src/core/load-dropin.h
+++ b/src/core/load-dropin.h
@@ -25,4 +25,5 @@
 
 /* Read service data supplementary drop-in directories */
 
+char ** unit_find_dropin_paths(Unit *u);
 int unit_load_dropin(Unit *u);
diff --git a/src/core/unit.c b/src/core/unit.c
index 7111679..87605d6 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -408,6 +408,7 @@ void unit_free(Unit *u) {
 strv_free(u->documentation);
 free(u->fragment_path);
 free(u->s

Re: [systemd-devel] [PATCH] [RFCv2] Add drop-in support for [Install] section

2013-03-31 Thread Oleksii Shevchuk
> Can it be unified with unit_load_dropin()? 

I think it can't =\

Or unit_load_dropin will require full rewrite then. The main problem is
context: [Install] section processed in code that can be runned without
systemd daemon (src/shared)..
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] Add AllowIsolate=yes to snapshots

2013-03-31 Thread Oleksii Shevchuk
---
 TODO| 2 --
 src/core/snapshot.c | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/TODO b/TODO
index 3bf442b..584646b 100644
--- a/TODO
+++ b/TODO
@@ -47,8 +47,6 @@ Fedora 19:
 
 Features:
 
-* snapshots really should be isolatable, but currently aren't.
-
 * seems that when we follow symlinks to units we prefer the symlink
   destination path over /etc and /usr. We shouldn't do that. Instead
   /etc should always override /run+/usr and also any symlink
diff --git a/src/core/snapshot.c b/src/core/snapshot.c
index 5c2a319..a3f5e90 100644
--- a/src/core/snapshot.c
+++ b/src/core/snapshot.c
@@ -256,6 +256,7 @@ int snapshot_create(Manager *m, const char *name, bool 
cleanup, DBusError *e, Sn
 }
 
 SNAPSHOT(u)->cleanup = cleanup;
+u->allow_isolate = true;
 *_s = SNAPSHOT(u);
 
 return 0;
-- 
1.8.1.2

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


[systemd-devel] [PATCH] [RFCv2] Add drop-in support for [Install] section

2013-03-31 Thread Oleksii Shevchuk
---
 src/shared/install.c | 55 +---
 1 file changed, 52 insertions(+), 3 deletions(-)

diff --git a/src/shared/install.c b/src/shared/install.c
index 2555a36..2f3ce7f 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -983,7 +983,51 @@ static int config_parse_user(
 return 0;
 }
 
+static int unit_file_load_dropin(
+LookupPaths *paths,
+InstallContext *c,
+InstallInfo *info,
+const char *path,
+const ConfigTableItem items[]) {
+
+char **p;
+
+assert(c);
+assert(info);
+assert(path);
+assert(paths);
+assert(items);
+
+STRV_FOREACH(p, paths->unit_path) {
+_cleanup_strv_free_ char **files = NULL;
+_cleanup_free_ char *t = NULL;
+char **f;
+int r;
+
+t = strjoin(*p, "/", path_get_file_name(path), ".d", NULL);
+if (!t)
+return log_oom();
+
+r = conf_files_list(&files, ".conf", NULL, t, NULL);
+if (r < 0) {
+log_debug("Failed to get list of configuration files: 
%s: %s", *p, strerror(-r));
+continue;
+}
+
+STRV_FOREACH(f, files) {
+r = config_parse(*f, NULL, NULL, 
config_item_table_lookup, (void*) items, true, info);
+if (r < 0) {
+log_error("Failed to parse drop-in %s:", *f);
+return r;
+}
+}
+}
+
+return 0;
+}
+
 static int unit_file_load(
+LookupPaths *paths,
 InstallContext *c,
 InstallInfo *info,
 const char *path,
@@ -1005,6 +1049,7 @@ static int unit_file_load(
 assert(c);
 assert(info);
 assert(path);
+assert(paths);
 
 fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY|(allow_symlink ? 0 : 
O_NOFOLLOW));
 if (fd < 0)
@@ -1020,6 +1065,10 @@ static int unit_file_load(
 if (r < 0)
 return r;
 
+r = unit_file_load_dropin(paths, c, info, path, items);
+if (r < 0)
+return r;
+
 return
 strv_length(info->aliases) +
 strv_length(info->wanted_by) +
@@ -1041,7 +1090,7 @@ static int unit_file_search(
 assert(paths);
 
 if (info->path)
-return unit_file_load(c, info, info->path, allow_symlink);
+return unit_file_load(paths, c, info, info->path, 
allow_symlink);
 
 assert(info->name);
 
@@ -1056,7 +1105,7 @@ static int unit_file_search(
 if (!path)
 return -ENOMEM;
 
-r = unit_file_load(c, info, path, allow_symlink);
+r = unit_file_load(paths, c, info, path, allow_symlink);
 
 if (r >= 0)
 info->path = path;
@@ -1086,7 +1135,7 @@ static int unit_file_search(
 }
 
 /* let's try to load template unit */
-r = unit_file_load(c, info, template_path, 
allow_symlink);
+r = unit_file_load(paths, c, info, 
template_path, allow_symlink);
 if (r >= 0) {
 info->path = strdup(template_path);
 if (!info->path) {
-- 
1.8.1.2

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


[systemd-devel] [PATCH] [RFC] Add drop-in support for [Install] section

2013-03-31 Thread Oleksii Shevchuk
---
 src/shared/install.c | 54 +---
 1 file changed, 51 insertions(+), 3 deletions(-)

diff --git a/src/shared/install.c b/src/shared/install.c
index 2555a36..001b265 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -983,7 +983,50 @@ static int config_parse_user(
 return 0;
 }
 
+static int unit_file_load_dropin(
+LookupPaths *paths,
+InstallContext *c,
+InstallInfo *info,
+const char *path,
+const ConfigTableItem items[]) {
+
+char **p;
+
+assert(c);
+assert(info);
+assert(path);
+assert(paths);
+assert(items);
+
+STRV_FOREACH(p, paths->unit_path) {
+_cleanup_strv_free_ char **files = NULL;
+_cleanup_free_ char *t = NULL;
+char **f, *n;
+int r;
+
+n = path_get_file_name(path);
+t = strjoin(*p, "/", n, ".d", NULL);
+
+r = conf_files_list(&files, ".conf", NULL, t, NULL);
+if (r < 0) {
+log_debug("Failed to get list of configuration files: 
%s: %s", *p, strerror(-r));
+continue;
+}
+
+STRV_FOREACH(f, files) {
+r = config_parse(*f, NULL, NULL, 
config_item_table_lookup, (void*) items, true, info);
+if (r < 0) {
+log_error("Failed to parse drop-in %s:", *f);
+return r;
+}
+}
+}
+
+return 0;
+}
+
 static int unit_file_load(
+LookupPaths *paths,
 InstallContext *c,
 InstallInfo *info,
 const char *path,
@@ -1005,6 +1048,7 @@ static int unit_file_load(
 assert(c);
 assert(info);
 assert(path);
+assert(paths);
 
 fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY|(allow_symlink ? 0 : 
O_NOFOLLOW));
 if (fd < 0)
@@ -1020,6 +1064,10 @@ static int unit_file_load(
 if (r < 0)
 return r;
 
+r = unit_file_load_dropin(paths, c, info, path, items);
+if (r < 0)
+return r;
+
 return
 strv_length(info->aliases) +
 strv_length(info->wanted_by) +
@@ -1041,7 +1089,7 @@ static int unit_file_search(
 assert(paths);
 
 if (info->path)
-return unit_file_load(c, info, info->path, allow_symlink);
+return unit_file_load(paths, c, info, info->path, 
allow_symlink);
 
 assert(info->name);
 
@@ -1056,7 +1104,7 @@ static int unit_file_search(
 if (!path)
 return -ENOMEM;
 
-r = unit_file_load(c, info, path, allow_symlink);
+r = unit_file_load(paths, c, info, path, allow_symlink);
 
 if (r >= 0)
 info->path = path;
@@ -1086,7 +1134,7 @@ static int unit_file_search(
 }
 
 /* let's try to load template unit */
-r = unit_file_load(c, info, template_path, 
allow_symlink);
+r = unit_file_load(paths, c, info, 
template_path, allow_symlink);
 if (r >= 0) {
 info->path = strdup(template_path);
 if (!info->path) {
-- 
1.8.1.2

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


Re: [systemd-devel] [PATCH] condition: add option ConditionArchitecture

2013-03-29 Thread Oleksii Shevchuk
> Well, we can discuss extending ExecStartPre=

ExecStartPre= is not about that anyway, because it can be used only in
.service units. 

> but I am pretty sure we shouldn't involve the process forking state
> machine in the condition logic.

I don't like it too. But can we have other alternatives? Some way ( or
policy ) for extending without systemd patching should be provided,
maybe. I think about using .target as conditions, like
on-battery.target, network@XXX.target, arch@XXX.target, etc with some
other way to push them on. 

Personally I use this approach now (for example, I don't use
ConditionACPower, but battery.target and low-battery.target, which are pushed
by third-party daemon).
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] condition: add option ConditionArchitecture

2013-03-29 Thread Oleksii Shevchuk
> Ideas?

Just provide ConditionExec=. People should build their own checkers. You
still can implement several as stand-alone executables maybe..
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] [RFCv8] Add sync timer to journal server

2013-03-25 Thread Oleksii Shevchuk
Add option to force journal sync with fsync. Default timeout is 5min.
Interval configured via SyncIntervalSec option at journal.conf. Synced
journal files will be marked as OFFLINE.

Manual sync can be performed via sending SIGUSR1.
---
 man/journald.conf.xml|  10 
 src/journal/journal-file.c   |  63 +-
 src/journal/journal-file.h   |   2 +
 src/journal/journald-gperf.gperf |   1 +
 src/journal/journald-server.c| 112 +--
 src/journal/journald-server.h|   6 +++
 src/journal/journald.conf|   1 +
 7 files changed, 179 insertions(+), 16 deletions(-)

diff --git a/man/journald.conf.xml b/man/journald.conf.xml
index 0797deb..0b9de65 100644
--- a/man/journald.conf.xml
+++ b/man/journald.conf.xml
@@ -322,6 +322,16 @@
 seconds. 
 
 
+
+
+
SyncIntervalSec=
+
+The timeout before syncing 
journal
+data to disk. After syncing journal files have
+OFFLINE state. Default timeout is 5 minutes.
+
+
+
 
 
ForwardToSyslog=
 ForwardToKMsg=
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 13fc8ed..5b077be 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -68,6 +68,50 @@
 /* How many entries to keep in the entry array chain cache at max */
 #define CHAIN_CACHE_MAX 20
 
+int journal_file_set_online(JournalFile *f) {
+assert(f);
+
+if (!f->writable)
+return -EPERM;
+
+if (!(f->fd >= 0 && f->header))
+return -EINVAL;
+
+switch(f->header->state) {
+case STATE_ONLINE:
+return 0;
+
+case STATE_OFFLINE:
+f->header->state = STATE_ONLINE;
+fsync(f->fd);
+return 0;
+
+default:
+return -EINVAL;
+}
+}
+
+int journal_file_set_offline(JournalFile *f) {
+assert(f);
+
+if (!f->writable)
+return -EPERM;
+
+if (!(f->fd >= 0 && f->header))
+return -EINVAL;
+
+if (f->header->state != STATE_ONLINE)
+return 0;
+
+fsync(f->fd);
+
+f->header->state = STATE_OFFLINE;
+
+fsync(f->fd);
+
+return 0;
+}
+
 void journal_file_close(JournalFile *f) {
 assert(f);
 
@@ -81,16 +125,10 @@ void journal_file_close(JournalFile *f) {
 if (f->mmap && f->fd >= 0)
 mmap_cache_close_fd(f->mmap, f->fd);
 
-if (f->writable && f->fd >= 0)
-fdatasync(f->fd);
-
-if (f->header) {
-/* Mark the file offline. Don't override the archived state if 
it already is set */
-if (f->writable && f->header->state == STATE_ONLINE)
-f->header->state = STATE_OFFLINE;
+journal_file_set_offline(f);
 
+if (f->header)
 munmap(f->header, PAGE_ALIGN(sizeof(Header)));
-}
 
 if (f->fd >= 0)
 close_nointr_nofail(f->fd);
@@ -177,7 +215,7 @@ static int journal_file_refresh_header(JournalFile *f) {
 
 f->header->boot_id = boot_id;
 
-f->header->state = STATE_ONLINE;
+journal_file_set_online(f);
 
 /* Sync the online state to disk */
 msync(f->header, PAGE_ALIGN(sizeof(Header)), MS_SYNC);
@@ -457,6 +495,10 @@ int journal_file_append_object(JournalFile *f, int type, 
uint64_t size, Object *
 assert(offset);
 assert(ret);
 
+r = journal_file_set_online(f);
+if (r < 0)
+return r;
+
 p = le64toh(f->header->tail_object_offset);
 if (p == 0)
 p = le64toh(f->header->header_size);
@@ -1267,9 +1309,6 @@ int journal_file_append_entry(JournalFile *f, const 
dual_timestamp *ts, const st
 assert(f);
 assert(iovec || n_iovec == 0);
 
-if (!f->writable)
-return -EPERM;
-
 if (!ts) {
 dual_timestamp_get(&_ts);
 ts = &_ts;
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index cdbc8e4..0eab501 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -106,6 +106,8 @@ int journal_file_open(
 JournalFile *template,
 JournalFile **ret);
 
+int journal_file_set_offline(JournalFile *f);
+int journal_file_set_online(JournalFile *f);
 void journal_file_close(JournalFile *j);
 
 int journal_file_open_reliably(
diff --git a/src/journal/journald-gperf.gperf b/src/journal/journald-gperf.gperf
index 1baef14..57b45f9 100644
--- a/src/journal/journald-gperf

[systemd-devel] [PATCH] [RFCv7] Add sync timer to journal server

2013-03-23 Thread Oleksii Shevchuk
Add option to force journal sync with fsync. Default timeout is 5min.
Interval configured via SyncIntervalSec option at journal.conf. Synced
journal files will be marked as OFFLINE.

Manual sync can be performed via sending SIGUSR1.
---
 man/journald.conf.xml|  10 
 src/journal/journal-file.c   |  61 -
 src/journal/journal-file.h   |   2 +
 src/journal/journald-gperf.gperf |   1 +
 src/journal/journald-server.c| 112 +--
 src/journal/journald-server.h|   6 +++
 src/journal/journald.conf|   1 +
 7 files changed, 177 insertions(+), 16 deletions(-)

diff --git a/man/journald.conf.xml b/man/journald.conf.xml
index 0797deb..0b9de65 100644
--- a/man/journald.conf.xml
+++ b/man/journald.conf.xml
@@ -322,6 +322,16 @@
 seconds. 
 
 
+
+
+
SyncIntervalSec=
+
+The timeout before syncing 
journal
+data to disk. After syncing journal files have
+OFFLINE state. Default timeout is 5 minutes.
+
+
+
 
 
ForwardToSyslog=
 ForwardToKMsg=
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 13fc8ed..f06bb32 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -68,6 +68,48 @@
 /* How many entries to keep in the entry array chain cache at max */
 #define CHAIN_CACHE_MAX 20
 
+int journal_file_set_online(JournalFile *f) {
+assert(f);
+
+if (!f->writable)
+return -EPERM;
+
+if (!(f->fd >= 0 && f->header))
+return -EINVAL;
+
+switch(f->header->state) {
+case STATE_ONLINE:
+return 0;
+
+case STATE_OFFLINE:
+f->header->state = STATE_ONLINE;
+return 0;
+
+default:
+return -EINVAL;
+}
+}
+
+int journal_file_set_offline(JournalFile *f) {
+assert(f);
+
+if (!(f->header && f->writable && f->fd >= 0))
+return -EINVAL;
+
+if (f->header->state != STATE_ONLINE)
+return 0;
+
+if (fsync(f->fd))
+return -errno;
+
+f->header->state = STATE_OFFLINE;
+
+if(fsync(f->fd))
+return -errno;
+
+return 0;
+}
+
 void journal_file_close(JournalFile *f) {
 assert(f);
 
@@ -81,16 +123,10 @@ void journal_file_close(JournalFile *f) {
 if (f->mmap && f->fd >= 0)
 mmap_cache_close_fd(f->mmap, f->fd);
 
-if (f->writable && f->fd >= 0)
-fdatasync(f->fd);
-
-if (f->header) {
-/* Mark the file offline. Don't override the archived state if 
it already is set */
-if (f->writable && f->header->state == STATE_ONLINE)
-f->header->state = STATE_OFFLINE;
+journal_file_set_offline(f);
 
+if (f->header)
 munmap(f->header, PAGE_ALIGN(sizeof(Header)));
-}
 
 if (f->fd >= 0)
 close_nointr_nofail(f->fd);
@@ -177,7 +213,7 @@ static int journal_file_refresh_header(JournalFile *f) {
 
 f->header->boot_id = boot_id;
 
-f->header->state = STATE_ONLINE;
+journal_file_set_online(f);
 
 /* Sync the online state to disk */
 msync(f->header, PAGE_ALIGN(sizeof(Header)), MS_SYNC);
@@ -457,6 +493,10 @@ int journal_file_append_object(JournalFile *f, int type, 
uint64_t size, Object *
 assert(offset);
 assert(ret);
 
+r = journal_file_set_online(f);
+if (r < 0)
+return r;
+
 p = le64toh(f->header->tail_object_offset);
 if (p == 0)
 p = le64toh(f->header->header_size);
@@ -1267,9 +1307,6 @@ int journal_file_append_entry(JournalFile *f, const 
dual_timestamp *ts, const st
 assert(f);
 assert(iovec || n_iovec == 0);
 
-if (!f->writable)
-return -EPERM;
-
 if (!ts) {
 dual_timestamp_get(&_ts);
 ts = &_ts;
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index cdbc8e4..0eab501 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -106,6 +106,8 @@ int journal_file_open(
 JournalFile *template,
 JournalFile **ret);
 
+int journal_file_set_offline(JournalFile *f);
+int journal_file_set_online(JournalFile *f);
 void journal_file_close(JournalFile *j);
 
 int journal_file_open_reliably(
diff --git a/src/journal/journald-gperf.gperf b/src/journal/journald-gperf.gperf
index 1baef14..57b45f9 100644
--- a/src/journal/journald-gperf.gperf
+++ b/sr

Re: [systemd-devel] [PATCH] [RFCv6] Add sync timer to journal server

2013-03-23 Thread Oleksii Shevchuk
> > Add option to force journal sync with fdatasync. Disabled by default.
> Hi Oleksii,
> why is it off by default?

Hi Zbyszek, 
After discussion i am unsure about defaults for that option. 
Maybe only who cares should enable it?


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


[systemd-devel] [PATCH] [RFCv6] Add sync timer to journal server

2013-03-23 Thread Oleksii Shevchuk
Add option to force journal sync with fdatasync. Disabled by default.
Interval configured via SyncIntervalSec option at journal.conf. Synced
journal files will be marked as OFFLINE.

Manual sync can be performed via sending SIGUSR1.
---
 man/journald.conf.xml|   9 +++
 src/journal/journal-file.c   |  61 
 src/journal/journal-file.h   |   2 +
 src/journal/journald-gperf.gperf |   1 +
 src/journal/journald-server.c| 117 +--
 src/journal/journald-server.h|   6 ++
 src/journal/journald.conf|   1 +
 7 files changed, 181 insertions(+), 16 deletions(-)

diff --git a/man/journald.conf.xml b/man/journald.conf.xml
index 0797deb..f2d2806 100644
--- a/man/journald.conf.xml
+++ b/man/journald.conf.xml
@@ -322,6 +322,15 @@
 seconds. 
 
 
+
+
+
SyncIntervalSec=
+
+The maximum time to
+commit new journal data to disk. Disabled by
+default
+
+
 
 
ForwardToSyslog=
 ForwardToKMsg=
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 13fc8ed..b722eea 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -68,6 +68,48 @@
 /* How many entries to keep in the entry array chain cache at max */
 #define CHAIN_CACHE_MAX 20
 
+int journal_file_set_online(JournalFile *f) {
+assert(f);
+
+if (!f->writable)
+return -EPERM;
+
+if (!(f->fd >= 0 && f->header))
+return -EINVAL;
+
+switch(f->header->state) {
+case STATE_ONLINE:
+return 0;
+
+case STATE_OFFLINE:
+f->header->state = STATE_ONLINE;
+return 0;
+
+default:
+return -EINVAL;
+}
+}
+
+int journal_file_set_offline(JournalFile *f) {
+assert(f);
+
+if (!(f->header && f->writable && f->fd >= 0))
+return -EINVAL;
+
+if (f->header->state != STATE_ONLINE)
+return 0;
+
+if (fdatasync(f->fd))
+return -errno;
+
+f->header->state = STATE_OFFLINE;
+
+if(fdatasync(f->fd))
+return -errno;
+
+return 0;
+}
+
 void journal_file_close(JournalFile *f) {
 assert(f);
 
@@ -81,16 +123,10 @@ void journal_file_close(JournalFile *f) {
 if (f->mmap && f->fd >= 0)
 mmap_cache_close_fd(f->mmap, f->fd);
 
-if (f->writable && f->fd >= 0)
-fdatasync(f->fd);
-
-if (f->header) {
-/* Mark the file offline. Don't override the archived state if 
it already is set */
-if (f->writable && f->header->state == STATE_ONLINE)
-f->header->state = STATE_OFFLINE;
+journal_file_set_offline(f);
 
+if (f->header)
 munmap(f->header, PAGE_ALIGN(sizeof(Header)));
-}
 
 if (f->fd >= 0)
 close_nointr_nofail(f->fd);
@@ -177,7 +213,7 @@ static int journal_file_refresh_header(JournalFile *f) {
 
 f->header->boot_id = boot_id;
 
-f->header->state = STATE_ONLINE;
+journal_file_set_online(f);
 
 /* Sync the online state to disk */
 msync(f->header, PAGE_ALIGN(sizeof(Header)), MS_SYNC);
@@ -457,6 +493,10 @@ int journal_file_append_object(JournalFile *f, int type, 
uint64_t size, Object *
 assert(offset);
 assert(ret);
 
+r = journal_file_set_online(f);
+if (r < 0)
+return r;
+
 p = le64toh(f->header->tail_object_offset);
 if (p == 0)
 p = le64toh(f->header->header_size);
@@ -1267,9 +1307,6 @@ int journal_file_append_entry(JournalFile *f, const 
dual_timestamp *ts, const st
 assert(f);
 assert(iovec || n_iovec == 0);
 
-if (!f->writable)
-return -EPERM;
-
 if (!ts) {
 dual_timestamp_get(&_ts);
 ts = &_ts;
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index cdbc8e4..0eab501 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -106,6 +106,8 @@ int journal_file_open(
 JournalFile *template,
 JournalFile **ret);
 
+int journal_file_set_offline(JournalFile *f);
+int journal_file_set_online(JournalFile *f);
 void journal_file_close(JournalFile *j);
 
 int journal_file_open_reliably(
diff --git a/src/journal/journald-gperf.gperf b/src/journal/journald-gperf.gperf
index 1baef14..57b45f9 100644
--- a/src/journal/journald-gperf.gperf
+++ b/src/journal/journald-gperf.gperf
@@ -18,6 +18,7 @@ struct ConfigPerfItem;
 Journal.Sto

[systemd-devel] [PATCH] [RFCv5] Add sync timer to journal server

2013-03-22 Thread Oleksii Shevchuk
Sync journal with fdatasync after 10s of inactivity (by default), or
or after 10m of last commit (by default). Intervals configured via
SyncIntervalIdleSec and SyncIntervalMaxSec options at journal.conf.
Manual sync can be performed via sending SIGUSR1.
---
 src/journal/journal-file.c   |  29 ++-
 src/journal/journal-file.h   |   1 +
 src/journal/journald-gperf.gperf |   2 +
 src/journal/journald-server.c| 161 ++-
 src/journal/journald-server.h|   7 ++
 src/journal/journald.conf|   2 +
 6 files changed, 196 insertions(+), 6 deletions(-)

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 13fc8ed..8597869 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -68,6 +68,26 @@
 /* How many entries to keep in the entry array chain cache at max */
 #define CHAIN_CACHE_MAX 20
 
+int journal_file_sync(JournalFile *f) {
+assert(f);
+
+if (f->header->state != STATE_ONLINE)
+return 0;
+
+if (! (f->writable && f->fd >= 0))
+return -EINVAL;
+
+if (fdatasync(f->fd))
+return -errno;
+
+f->header->state = STATE_OFFLINE;
+
+if(fdatasync(f->fd))
+return -errno;
+
+return 0;
+}
+
 void journal_file_close(JournalFile *f) {
 assert(f);
 
@@ -81,8 +101,7 @@ void journal_file_close(JournalFile *f) {
 if (f->mmap && f->fd >= 0)
 mmap_cache_close_fd(f->mmap, f->fd);
 
-if (f->writable && f->fd >= 0)
-fdatasync(f->fd);
+journal_file_sync(f);
 
 if (f->header) {
 /* Mark the file offline. Don't override the archived state if 
it already is set */
@@ -457,6 +476,9 @@ int journal_file_append_object(JournalFile *f, int type, 
uint64_t size, Object *
 assert(offset);
 assert(ret);
 
+if (f->header->state == STATE_OFFLINE)
+f->header->state = STATE_ONLINE;
+
 p = le64toh(f->header->tail_object_offset);
 if (p == 0)
 p = le64toh(f->header->header_size);
@@ -1270,6 +1292,9 @@ int journal_file_append_entry(JournalFile *f, const 
dual_timestamp *ts, const st
 if (!f->writable)
 return -EPERM;
 
+if (f->header->state == STATE_OFFLINE)
+f->header->state = STATE_ONLINE;
+
 if (!ts) {
 dual_timestamp_get(&_ts);
 ts = &_ts;
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index cdbc8e4..717d64c 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -106,6 +106,7 @@ int journal_file_open(
 JournalFile *template,
 JournalFile **ret);
 
+int journal_file_sync(JournalFile *f);
 void journal_file_close(JournalFile *j);
 
 int journal_file_open_reliably(
diff --git a/src/journal/journald-gperf.gperf b/src/journal/journald-gperf.gperf
index 1baef14..aac72b1 100644
--- a/src/journal/journald-gperf.gperf
+++ b/src/journal/journald-gperf.gperf
@@ -18,6 +18,8 @@ struct ConfigPerfItem;
 Journal.Storage,config_parse_storage,   0, offsetof(Server, 
storage)
 Journal.Compress,   config_parse_bool,  0, offsetof(Server, 
compress)
 Journal.Seal,   config_parse_bool,  0, offsetof(Server, seal)
+Journal.SyncIntervalIdleSec,config_parse_usec,  0, offsetof(Server, 
sync_interval_idle_usec)
+Journal.SyncIntervalMaxSec, config_parse_usec,  0, offsetof(Server, 
sync_interval_max_usec)
 Journal.RateLimitInterval,  config_parse_usec,  0, offsetof(Server, 
rate_limit_interval)
 Journal.RateLimitBurst, config_parse_unsigned,  0, offsetof(Server, 
rate_limit_burst)
 Journal.SystemMaxUse,   config_parse_bytes_off, 0, offsetof(Server, 
system_metrics.max_use)
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 855430a..0805754 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -67,6 +68,8 @@
 
 #define USER_JOURNALS_MAX 1024
 
+#define DEFAULT_SYNC_INTERVAL_IDLE_USEC (10*USEC_PER_SEC)
+#define DEFAULT_SYNC_INTERVAL_MAX_USEC (10*USEC_PER_MINUTE)
 #define DEFAULT_RATE_LIMIT_INTERVAL (10*USEC_PER_SEC)
 #define DEFAULT_RATE_LIMIT_BURST 200
 
@@ -344,6 +347,46 @@ void server_rotate(Server *s) {
 }
 }
 
+void server_sync(Server *s) {
+JournalFile *f;
+void *k;
+Iterator i;
+int r;
+
+static struct itimerspec sync_timer_disable = {
+.it_value.tv_sec = 0,
+.it_value.tv_nsec = 0,
+.it_interval.tv_sec = 0,
+.it_interval.tv_nsec = 0,
+};
+
+if (s->runtime_journal) {
+r = journal_file_sync(s->runtime_journal);
+if (r < 0)
+log_error("Failed to sync runtime journal: 

Re: [systemd-devel] [PATCH] [RFCv3] Add sync timer to journal server

2013-03-19 Thread Oleksii Shevchuk
On Tue, Mar 19, 2013 at 07:53:45AM +0200, Oleksii Shevchuk wrote:
> > > > +if (! (f->writable && f->fd >= 0))
> > > > +return -1;
> > > -1 means EPERM. Something different is needed.
> > 
> > EINVAL/EBUSY/EFAULT ?
> At least if !f->writable then the return code should be 0.

At last variant of patch header is checked first for STATE_ONLINE.
I think the state ro+ONLINE is incorrect, is it?

> I think that this is the same thing as with fixed times: if you set
> the interval to 10 msgs, you get a random sync every few days,
> which is useless. If you set it low, than you limit the throughput.
> I think that the msg-based limit doesn't make much sense.

I think there should be the way to set syncing with lowest possible
timeouts for debugging random hangs or so. If you think that this
approach useless, I can remove msg counter at all
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] [RFCv4] Add sync timer to journal server

2013-03-18 Thread Oleksii Shevchuk
Sync journal with fdatasync after 10s of inactivity (by default), or
after 10 messages (by default), or after 1h of last commit (by
default). Intervals configured via SyncIntervalIdleSec,
SyncIntervalMaxSec and SyncIntervalMsg options at journal.conf.
Manual sync can be performed via sending SIGUSR1.
---
 src/journal/journal-file.c   |  29 ++-
 src/journal/journal-file.h   |   1 +
 src/journal/journald-gperf.gperf |   3 +
 src/journal/journald-server.c| 171 ++-
 src/journal/journald-server.h|   9 +++
 src/journal/journald.conf|   3 +
 6 files changed, 210 insertions(+), 6 deletions(-)

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 13fc8ed..8597869 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -68,6 +68,26 @@
 /* How many entries to keep in the entry array chain cache at max */
 #define CHAIN_CACHE_MAX 20
 
+int journal_file_sync(JournalFile *f) {
+assert(f);
+
+if (f->header->state != STATE_ONLINE)
+return 0;
+
+if (! (f->writable && f->fd >= 0))
+return -EINVAL;
+
+if (fdatasync(f->fd))
+return -errno;
+
+f->header->state = STATE_OFFLINE;
+
+if(fdatasync(f->fd))
+return -errno;
+
+return 0;
+}
+
 void journal_file_close(JournalFile *f) {
 assert(f);
 
@@ -81,8 +101,7 @@ void journal_file_close(JournalFile *f) {
 if (f->mmap && f->fd >= 0)
 mmap_cache_close_fd(f->mmap, f->fd);
 
-if (f->writable && f->fd >= 0)
-fdatasync(f->fd);
+journal_file_sync(f);
 
 if (f->header) {
 /* Mark the file offline. Don't override the archived state if 
it already is set */
@@ -457,6 +476,9 @@ int journal_file_append_object(JournalFile *f, int type, 
uint64_t size, Object *
 assert(offset);
 assert(ret);
 
+if (f->header->state == STATE_OFFLINE)
+f->header->state = STATE_ONLINE;
+
 p = le64toh(f->header->tail_object_offset);
 if (p == 0)
 p = le64toh(f->header->header_size);
@@ -1270,6 +1292,9 @@ int journal_file_append_entry(JournalFile *f, const 
dual_timestamp *ts, const st
 if (!f->writable)
 return -EPERM;
 
+if (f->header->state == STATE_OFFLINE)
+f->header->state = STATE_ONLINE;
+
 if (!ts) {
 dual_timestamp_get(&_ts);
 ts = &_ts;
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index cdbc8e4..717d64c 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -106,6 +106,7 @@ int journal_file_open(
 JournalFile *template,
 JournalFile **ret);
 
+int journal_file_sync(JournalFile *f);
 void journal_file_close(JournalFile *j);
 
 int journal_file_open_reliably(
diff --git a/src/journal/journald-gperf.gperf b/src/journal/journald-gperf.gperf
index 1baef14..cb323e7 100644
--- a/src/journal/journald-gperf.gperf
+++ b/src/journal/journald-gperf.gperf
@@ -18,6 +18,9 @@ struct ConfigPerfItem;
 Journal.Storage,config_parse_storage,   0, offsetof(Server, 
storage)
 Journal.Compress,   config_parse_bool,  0, offsetof(Server, 
compress)
 Journal.Seal,   config_parse_bool,  0, offsetof(Server, seal)
+Journal.SyncIntervalIdleSec,config_parse_usec,  0, offsetof(Server, 
sync_interval_idle_usec)
+Journal.SyncIntervalMaxSec, config_parse_usec,  0, offsetof(Server, 
sync_interval_max_usec)
+Journal.SyncIntervalMsg,config_parse_unsigned,  0, offsetof(Server, 
sync_interval_msg)
 Journal.RateLimitInterval,  config_parse_usec,  0, offsetof(Server, 
rate_limit_interval)
 Journal.RateLimitBurst, config_parse_unsigned,  0, offsetof(Server, 
rate_limit_burst)
 Journal.SystemMaxUse,   config_parse_bytes_off, 0, offsetof(Server, 
system_metrics.max_use)
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index ac565c7..4f9438b 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -67,6 +68,9 @@
 
 #define USER_JOURNALS_MAX 1024
 
+#define DEFAULT_SYNC_INTERVAL_IDLE_USEC (10*USEC_PER_SEC)
+#define DEFAULT_SYNC_INTERVAL_MAX_USEC (1*USEC_PER_HOUR)
+#define DEFAULT_SYNC_INTERVAL_MSG 10
 #define DEFAULT_RATE_LIMIT_INTERVAL (10*USEC_PER_SEC)
 #define DEFAULT_RATE_LIMIT_BURST 200
 
@@ -344,6 +348,48 @@ void server_rotate(Server *s) {
 }
 }
 
+void server_sync(Server *s) {
+JournalFile *f;
+void *k;
+Iterator i;
+int r;
+
+static struct itimerspec sync_timer_disable = {
+.it_value.tv_sec = 0,
+.it_value.tv_nsec = 0,
+.it_interval.tv_sec = 0,
+.it_interval.tv_nsec = 0,
+};
+
+ 

Re: [systemd-devel] [PATCH] [RFCv3] Add sync timer to journal server

2013-03-18 Thread Oleksii Shevchuk
> > +if (! (f->writable && f->fd >= 0))
> > +return -1;
> -1 means EPERM. Something different is needed.

EINVAL/EBUSY/EFAULT ?

> > +fdatasync(f->fd);
> Apparently the only error code which could happen here is EIO.
> Are you sure that we want to ignore it?

I think we don't care at that point

> What is the effect of fdatasync every 10 msg during high load? Wouldn't
> this decrease the throughput significantly?

In case of high load and idle timer strategy should be the way to have
guaranted maximum count of not saved messages. But I have doubt about
it. I can set this as optional parameter with high defaults, and
introduce additional timer with maximal commit timeout. What do you
think about it?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] [RFCv3] Add sync timer to journal server

2013-03-18 Thread Oleksii Shevchuk
Sync journal with fdatasync after 10s of inactivity (by default), or
after 10 messages (by default). Intervals configured
via SyncIntervalSec and SyncIntervalMsg options at journal.conf.
Manual sync can be performed via sending SIGUSR1.
---
 src/journal/journal-file.c   |  25 +++-
 src/journal/journal-file.h   |   1 +
 src/journal/journald-gperf.gperf |   2 +
 src/journal/journald-server.c| 126 +--
 src/journal/journald-server.h|   7 +++
 src/journal/journald.conf|   2 +
 6 files changed, 157 insertions(+), 6 deletions(-)

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 13fc8ed..2637f88 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -68,6 +68,22 @@
 /* How many entries to keep in the entry array chain cache at max */
 #define CHAIN_CACHE_MAX 20
 
+int journal_file_sync(JournalFile *f) {
+assert(f);
+
+if (! (f->writable && f->fd >= 0))
+return -1;
+
+if (fdatasync(f->fd))
+return -errno;
+
+f->header->state = STATE_OFFLINE;
+
+fdatasync(f->fd);
+
+return 0;
+}
+
 void journal_file_close(JournalFile *f) {
 assert(f);
 
@@ -81,8 +97,7 @@ void journal_file_close(JournalFile *f) {
 if (f->mmap && f->fd >= 0)
 mmap_cache_close_fd(f->mmap, f->fd);
 
-if (f->writable && f->fd >= 0)
-fdatasync(f->fd);
+journal_file_sync(f);
 
 if (f->header) {
 /* Mark the file offline. Don't override the archived state if 
it already is set */
@@ -457,6 +472,9 @@ int journal_file_append_object(JournalFile *f, int type, 
uint64_t size, Object *
 assert(offset);
 assert(ret);
 
+if (f->header->state == STATE_OFFLINE)
+f->header->state = STATE_ONLINE;
+
 p = le64toh(f->header->tail_object_offset);
 if (p == 0)
 p = le64toh(f->header->header_size);
@@ -1270,6 +1288,9 @@ int journal_file_append_entry(JournalFile *f, const 
dual_timestamp *ts, const st
 if (!f->writable)
 return -EPERM;
 
+if (f->header->state == STATE_OFFLINE)
+f->header->state = STATE_ONLINE;
+
 if (!ts) {
 dual_timestamp_get(&_ts);
 ts = &_ts;
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index cdbc8e4..717d64c 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -106,6 +106,7 @@ int journal_file_open(
 JournalFile *template,
 JournalFile **ret);
 
+int journal_file_sync(JournalFile *f);
 void journal_file_close(JournalFile *j);
 
 int journal_file_open_reliably(
diff --git a/src/journal/journald-gperf.gperf b/src/journal/journald-gperf.gperf
index 1baef14..fe4958f 100644
--- a/src/journal/journald-gperf.gperf
+++ b/src/journal/journald-gperf.gperf
@@ -18,6 +18,8 @@ struct ConfigPerfItem;
 Journal.Storage,config_parse_storage,   0, offsetof(Server, 
storage)
 Journal.Compress,   config_parse_bool,  0, offsetof(Server, 
compress)
 Journal.Seal,   config_parse_bool,  0, offsetof(Server, seal)
+Journal.SyncIntervalSec,config_parse_usec,  0, offsetof(Server, 
sync_interval_usec)
+Journal.SyncIntervalMsg,config_parse_unsigned,  0, offsetof(Server, 
sync_interval_msg)
 Journal.RateLimitInterval,  config_parse_usec,  0, offsetof(Server, 
rate_limit_interval)
 Journal.RateLimitBurst, config_parse_unsigned,  0, offsetof(Server, 
rate_limit_burst)
 Journal.SystemMaxUse,   config_parse_bytes_off, 0, offsetof(Server, 
system_metrics.max_use)
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index ac565c7..050cdee 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -67,6 +68,8 @@
 
 #define USER_JOURNALS_MAX 1024
 
+#define DEFAULT_SYNC_INTERVAL_USEC (10*USEC_PER_SEC)
+#define DEFAULT_SYNC_INTERVAL_MSG 10
 #define DEFAULT_RATE_LIMIT_INTERVAL (10*USEC_PER_SEC)
 #define DEFAULT_RATE_LIMIT_BURST 200
 
@@ -344,6 +347,33 @@ void server_rotate(Server *s) {
 }
 }
 
+void server_sync(Server *s) {
+JournalFile *f;
+void *k;
+Iterator i;
+int r;
+
+if (s->runtime_journal) {
+r = journal_file_sync(s->runtime_journal);
+if (r < 0)
+log_error("Failed to sync runtime journal: %s", 
strerror(-r));
+}
+
+if (s->system_journal) {
+r = journal_file_sync(s->system_journal);
+if (r < 0)
+log_error("Failed to sync system journal: %s", 
strerror(-r));
+}
+
+HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) {
+r = journal_file_sync(f);
+if (r < 0)
+   

[systemd-devel] [PATCH] [RFCv2 (typos)] Add sync timer to journal server

2013-03-16 Thread Oleksii Shevchuk
Sync journal with fdatasync after 10s of inactivity (by default), or
after 10 messages (by default). Intervals configured
via SyncIntervalSec and SyncIntervalMsg options at journal.conf.
Manual sync can be performed via sending SIGALRM.
---
 src/journal/journal-file.c   |  13 -
 src/journal/journal-file.h   |   1 +
 src/journal/journald-gperf.gperf |   2 +
 src/journal/journald-server.c| 115 +--
 src/journal/journald-server.h|   7 +++
 src/journal/journald.conf|   2 +
 6 files changed, 134 insertions(+), 6 deletions(-)

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 13fc8ed..42a410a 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -68,6 +68,16 @@
 /* How many entries to keep in the entry array chain cache at max */
 #define CHAIN_CACHE_MAX 20
 
+int journal_file_sync(JournalFile *f) {
+if (! (f->writable && f->fd >= 0))
+return -1;
+
+if (fdatasync(f->fd))
+return -errno;
+
+return 0;
+}
+
 void journal_file_close(JournalFile *f) {
 assert(f);
 
@@ -81,8 +91,7 @@ void journal_file_close(JournalFile *f) {
 if (f->mmap && f->fd >= 0)
 mmap_cache_close_fd(f->mmap, f->fd);
 
-if (f->writable && f->fd >= 0)
-fdatasync(f->fd);
+journal_file_sync(f);
 
 if (f->header) {
 /* Mark the file offline. Don't override the archived state if 
it already is set */
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index cdbc8e4..717d64c 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -106,6 +106,7 @@ int journal_file_open(
 JournalFile *template,
 JournalFile **ret);
 
+int journal_file_sync(JournalFile *f);
 void journal_file_close(JournalFile *j);
 
 int journal_file_open_reliably(
diff --git a/src/journal/journald-gperf.gperf b/src/journal/journald-gperf.gperf
index 1baef14..fe4958f 100644
--- a/src/journal/journald-gperf.gperf
+++ b/src/journal/journald-gperf.gperf
@@ -18,6 +18,8 @@ struct ConfigPerfItem;
 Journal.Storage,config_parse_storage,   0, offsetof(Server, 
storage)
 Journal.Compress,   config_parse_bool,  0, offsetof(Server, 
compress)
 Journal.Seal,   config_parse_bool,  0, offsetof(Server, seal)
+Journal.SyncIntervalSec,config_parse_usec,  0, offsetof(Server, 
sync_interval_usec)
+Journal.SyncIntervalMsg,config_parse_unsigned,  0, offsetof(Server, 
sync_interval_msg)
 Journal.RateLimitInterval,  config_parse_usec,  0, offsetof(Server, 
rate_limit_interval)
 Journal.RateLimitBurst, config_parse_unsigned,  0, offsetof(Server, 
rate_limit_burst)
 Journal.SystemMaxUse,   config_parse_bytes_off, 0, offsetof(Server, 
system_metrics.max_use)
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index ac565c7..d76e61e 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -67,6 +67,8 @@
 
 #define USER_JOURNALS_MAX 1024
 
+#define DEFAULT_SYNC_INTERVAL_USEC (10*USEC_PER_SEC)
+#define DEFAULT_SYNC_INTERVAL_MSG 10
 #define DEFAULT_RATE_LIMIT_INTERVAL (10*USEC_PER_SEC)
 #define DEFAULT_RATE_LIMIT_BURST 200
 
@@ -344,6 +346,23 @@ void server_rotate(Server *s) {
 }
 }
 
+void server_sync(Server *s) {
+JournalFile *f;
+void *k;
+Iterator i;
+int r;
+
+r = journal_file_sync(s->runtime_journal);
+if (r < 0)
+log_error("Failed to sync journal: %s", strerror(-r));
+
+HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) {
+r = journal_file_sync(f);
+if (r < 0)
+log_error("Failed to sync user journal: %s", 
strerror(-r));
+}
+}
+
 void server_vacuum(Server *s) {
 char *p;
 char ids[33];
@@ -475,8 +494,10 @@ static void write_to_journal(Server *s, uid_t uid, struct 
iovec *iovec, unsigned
 }
 
 r = journal_file_append_entry(f, NULL, iovec, n, &s->seqnum, NULL, 
NULL);
-if (r >= 0)
+if (r >= 0) {
+server_schedule_sync(s);
 return;
+}
 
 if (vacuumed || !shall_try_append_again(f, r)) {
 log_error("Failed to write entry, ignoring: %s", strerror(-r));
@@ -991,8 +1012,6 @@ int process_event(Server *s, struct epoll_event *ev) {
 return -errno;
 }
 
-log_info("Received SIG%s", signal_to_string(sfsi.ssi_signo));
-
 if (sfsi.ssi_signo == SIGUSR1) {
 touch("/run/systemd/journal/flushed");
 server_flush_to_var(s);
@@ -1005,6 +1024,13 @@ int process_event(Server *s, struct epoll_event *ev) {
 return 1;
 }
 
+if (sfsi.ssi_signo == SIGALRM) {
+server_sync(

[systemd-devel] [PATCH] [RFC] Add sync timer to journal server

2013-03-16 Thread Oleksii Shevchuk
Sync journal with fdatasync after 10s of inactivity (by default), or
after 10 messages (by default). Intervals configured
via SyncIntervalSec and SyncIntervalMsg options at journal.conf.
Manual sync can be performed via sending SIGALRM.
---
 src/journal/journal-file.c   |  13 -
 src/journal/journal-file.h   |   1 +
 src/journal/journald-gperf.gperf |   2 +
 src/journal/journald-server.c| 116 +--
 src/journal/journald-server.h|   7 +++
 src/journal/journald.conf|   2 +
 6 files changed, 135 insertions(+), 6 deletions(-)

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 13fc8ed..42a410a 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -68,6 +68,16 @@
 /* How many entries to keep in the entry array chain cache at max */
 #define CHAIN_CACHE_MAX 20
 
+int journal_file_sync(JournalFile *f) {
+if (! (f->writable && f->fd >= 0))
+return -1;
+
+if (fdatasync(f->fd))
+return -errno;
+
+return 0;
+}
+
 void journal_file_close(JournalFile *f) {
 assert(f);
 
@@ -81,8 +91,7 @@ void journal_file_close(JournalFile *f) {
 if (f->mmap && f->fd >= 0)
 mmap_cache_close_fd(f->mmap, f->fd);
 
-if (f->writable && f->fd >= 0)
-fdatasync(f->fd);
+journal_file_sync(f);
 
 if (f->header) {
 /* Mark the file offline. Don't override the archived state if 
it already is set */
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index cdbc8e4..717d64c 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -106,6 +106,7 @@ int journal_file_open(
 JournalFile *template,
 JournalFile **ret);
 
+int journal_file_sync(JournalFile *f);
 void journal_file_close(JournalFile *j);
 
 int journal_file_open_reliably(
diff --git a/src/journal/journald-gperf.gperf b/src/journal/journald-gperf.gperf
index 1baef14..fe4958f 100644
--- a/src/journal/journald-gperf.gperf
+++ b/src/journal/journald-gperf.gperf
@@ -18,6 +18,8 @@ struct ConfigPerfItem;
 Journal.Storage,config_parse_storage,   0, offsetof(Server, 
storage)
 Journal.Compress,   config_parse_bool,  0, offsetof(Server, 
compress)
 Journal.Seal,   config_parse_bool,  0, offsetof(Server, seal)
+Journal.SyncIntervalSec,config_parse_usec,  0, offsetof(Server, 
sync_interval_usec)
+Journal.SyncIntervalMsg,config_parse_unsigned,  0, offsetof(Server, 
sync_interval_msg)
 Journal.RateLimitInterval,  config_parse_usec,  0, offsetof(Server, 
rate_limit_interval)
 Journal.RateLimitBurst, config_parse_unsigned,  0, offsetof(Server, 
rate_limit_burst)
 Journal.SystemMaxUse,   config_parse_bytes_off, 0, offsetof(Server, 
system_metrics.max_use)
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index ac565c7..fada229 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -67,6 +67,8 @@
 
 #define USER_JOURNALS_MAX 1024
 
+#define DEFAULT_SYNC_INTERVAL_USEC (10*USEC_PER_SEC)
+#define DEFAULT_SYNC_INTERVAL_MSG 10
 #define DEFAULT_RATE_LIMIT_INTERVAL (10*USEC_PER_SEC)
 #define DEFAULT_RATE_LIMIT_BURST 200
 
@@ -344,6 +346,23 @@ void server_rotate(Server *s) {
 }
 }
 
+void server_sync(Server *s) {
+JournalFile *f;
+void *k;
+Iterator i;
+int r;
+
+r = journal_file_sync(s->runtime_journal);
+if (r < 0)
+log_error("Failed to sync journal: %s", strerror(-r));
+
+HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) {
+r = journal_file_sync(f);
+if (r < 0)
+log_error("Failed to sync user journal: %s", 
strerror(-r));
+}
+}
+
 void server_vacuum(Server *s) {
 char *p;
 char ids[33];
@@ -475,8 +494,10 @@ static void write_to_journal(Server *s, uid_t uid, struct 
iovec *iovec, unsigned
 }
 
 r = journal_file_append_entry(f, NULL, iovec, n, &s->seqnum, NULL, 
NULL);
-if (r >= 0)
+if (r >= 0) {
+server_shedule_sync(s);
 return;
+}
 
 if (vacuumed || !shall_try_append_again(f, r)) {
 log_error("Failed to write entry, ignoring: %s", strerror(-r));
@@ -991,8 +1012,6 @@ int process_event(Server *s, struct epoll_event *ev) {
 return -errno;
 }
 
-log_info("Received SIG%s", signal_to_string(sfsi.ssi_signo));
-
 if (sfsi.ssi_signo == SIGUSR1) {
 touch("/run/systemd/journal/flushed");
 server_flush_to_var(s);
@@ -1005,6 +1024,13 @@ int process_event(Server *s, struct epoll_event *ev) {
 return 1;
 }
 
+if (sfsi.ssi_signo == SIGALRM) {
+server_sync(s

Re: [systemd-devel] [PATCH] [Up: 1h default] Add sync timer to journal server

2013-03-16 Thread Oleksii Shevchuk

I understend your point. Current behavior is sufficient to indicate that 
all stuff is alive and have some guaranted sync points (like --MARK--
message).

So, I can introduce next changes: remove regular syncs, add delayed sync
based on last commit, add periodical syncs.

> For the sync logic, I'm not sure, but I can imagine that we need to
> msync() all mapping too, before we flush the stuff to the filesystem.

Why do you think so?

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


[systemd-devel] [PATCH] [Up: 1h default] Add sync timer to journal server

2013-03-16 Thread Oleksii Shevchuk
Sync journal with fdatasync every 1h (by default). Interval configured
via SyncInterval option at journal.conf. Manual sync can be performed
via sending SIGALRM.
---
 src/journal/journal-file.c   | 13 ++-
 src/journal/journal-file.h   |  1 +
 src/journal/journald-gperf.gperf |  1 +
 src/journal/journald-server.c| 79 +++-
 src/journal/journald-server.h|  4 ++
 src/journal/journald.conf|  1 +
 6 files changed, 96 insertions(+), 3 deletions(-)

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 13fc8ed..42a410a 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -68,6 +68,16 @@
 /* How many entries to keep in the entry array chain cache at max */
 #define CHAIN_CACHE_MAX 20
 
+int journal_file_sync(JournalFile *f) {
+if (! (f->writable && f->fd >= 0))
+return -1;
+
+if (fdatasync(f->fd))
+return -errno;
+
+return 0;
+}
+
 void journal_file_close(JournalFile *f) {
 assert(f);
 
@@ -81,8 +91,7 @@ void journal_file_close(JournalFile *f) {
 if (f->mmap && f->fd >= 0)
 mmap_cache_close_fd(f->mmap, f->fd);
 
-if (f->writable && f->fd >= 0)
-fdatasync(f->fd);
+journal_file_sync(f);
 
 if (f->header) {
 /* Mark the file offline. Don't override the archived state if 
it already is set */
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index cdbc8e4..717d64c 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -106,6 +106,7 @@ int journal_file_open(
 JournalFile *template,
 JournalFile **ret);
 
+int journal_file_sync(JournalFile *f);
 void journal_file_close(JournalFile *j);
 
 int journal_file_open_reliably(
diff --git a/src/journal/journald-gperf.gperf b/src/journal/journald-gperf.gperf
index 1baef14..e3594d6 100644
--- a/src/journal/journald-gperf.gperf
+++ b/src/journal/journald-gperf.gperf
@@ -18,6 +18,7 @@ struct ConfigPerfItem;
 Journal.Storage,config_parse_storage,   0, offsetof(Server, 
storage)
 Journal.Compress,   config_parse_bool,  0, offsetof(Server, 
compress)
 Journal.Seal,   config_parse_bool,  0, offsetof(Server, seal)
+Journal.SyncInterval,   config_parse_usec,  0, offsetof(Server, 
sync_interval)
 Journal.RateLimitInterval,  config_parse_usec,  0, offsetof(Server, 
rate_limit_interval)
 Journal.RateLimitBurst, config_parse_unsigned,  0, offsetof(Server, 
rate_limit_burst)
 Journal.SystemMaxUse,   config_parse_bytes_off, 0, offsetof(Server, 
system_metrics.max_use)
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index ac565c7..82e4f75 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -67,6 +67,7 @@
 
 #define USER_JOURNALS_MAX 1024
 
+#define DEFAULT_SYNC_INTERVAL USEC_PER_HOUR
 #define DEFAULT_RATE_LIMIT_INTERVAL (10*USEC_PER_SEC)
 #define DEFAULT_RATE_LIMIT_BURST 200
 
@@ -344,6 +345,25 @@ void server_rotate(Server *s) {
 }
 }
 
+void server_sync(Server *s) {
+JournalFile *f;
+void *k;
+Iterator i;
+int r;
+
+log_info("Syncing journal...");
+
+r = journal_file_sync(s->runtime_journal);
+if (r < 0)
+log_error("Failed to sync journal: %s", strerror(-r));
+
+HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) {
+r = journal_file_sync(f);
+if (r < 0)
+log_error("Failed to sync user journal: %s", 
strerror(-r));
+}
+}
+
 void server_vacuum(Server *s) {
 char *p;
 char ids[33];
@@ -1005,6 +1025,11 @@ int process_event(Server *s, struct epoll_event *ev) {
 return 1;
 }
 
+if (sfsi.ssi_signo == SIGALRM) {
+server_sync(s);
+return 1;
+}
+
 return 0;
 
 } else if (ev->data.fd == s->dev_kmsg_fd) {
@@ -1194,7 +1219,7 @@ static int open_signalfd(Server *s) {
 assert(s);
 
 assert_se(sigemptyset(&mask) == 0);
-sigset_add_many(&mask, SIGINT, SIGTERM, SIGUSR1, SIGUSR2, -1);
+sigset_add_many(&mask, SIGINT, SIGTERM, SIGUSR1, SIGUSR2, SIGALRM, -1);
 assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
 
 s->signal_fd = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
@@ -1286,6 +1311,48 @@ static int server_parse_config_file(Server *s) {
 return r;
 }
 
+static int server_setup_sync_timer(Server *s) {
+int r;
+
+struct sigevent sync_timer = {
+.sigev_notify = SIGEV_SIGNAL,
+.sigev_signo  = SIGALRM,
+};
+
+struct itimerspec sync_timer_interval = {
+.it_value.tv_sec = s->sync_interval / USEC_PER_SEC,
+.it_value.tv_nsec = s->s

[systemd-devel] [PATCH] Add sync timer to journal server

2013-03-16 Thread Oleksii Shevchuk
Sync journal with fdatasync every 1m (by default). Interval configured
via SyncInterval option at journal.conf. Manual sync can be performed
via sending SIGALRM.
---
 src/journal/journal-file.c   | 13 +--
 src/journal/journal-file.h   |  1 +
 src/journal/journald-gperf.gperf |  1 +
 src/journal/journald-server.c| 77 +++-
 src/journal/journald-server.h|  4 +++
 5 files changed, 93 insertions(+), 3 deletions(-)

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 13fc8ed..42a410a 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -68,6 +68,16 @@
 /* How many entries to keep in the entry array chain cache at max */
 #define CHAIN_CACHE_MAX 20
 
+int journal_file_sync(JournalFile *f) {
+if (! (f->writable && f->fd >= 0))
+return -1;
+
+if (fdatasync(f->fd))
+return -errno;
+
+return 0;
+}
+
 void journal_file_close(JournalFile *f) {
 assert(f);
 
@@ -81,8 +91,7 @@ void journal_file_close(JournalFile *f) {
 if (f->mmap && f->fd >= 0)
 mmap_cache_close_fd(f->mmap, f->fd);
 
-if (f->writable && f->fd >= 0)
-fdatasync(f->fd);
+journal_file_sync(f);
 
 if (f->header) {
 /* Mark the file offline. Don't override the archived state if 
it already is set */
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index cdbc8e4..717d64c 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -106,6 +106,7 @@ int journal_file_open(
 JournalFile *template,
 JournalFile **ret);
 
+int journal_file_sync(JournalFile *f);
 void journal_file_close(JournalFile *j);
 
 int journal_file_open_reliably(
diff --git a/src/journal/journald-gperf.gperf b/src/journal/journald-gperf.gperf
index 1baef14..e3594d6 100644
--- a/src/journal/journald-gperf.gperf
+++ b/src/journal/journald-gperf.gperf
@@ -18,6 +18,7 @@ struct ConfigPerfItem;
 Journal.Storage,config_parse_storage,   0, offsetof(Server, 
storage)
 Journal.Compress,   config_parse_bool,  0, offsetof(Server, 
compress)
 Journal.Seal,   config_parse_bool,  0, offsetof(Server, seal)
+Journal.SyncInterval,   config_parse_usec,  0, offsetof(Server, 
sync_interval)
 Journal.RateLimitInterval,  config_parse_usec,  0, offsetof(Server, 
rate_limit_interval)
 Journal.RateLimitBurst, config_parse_unsigned,  0, offsetof(Server, 
rate_limit_burst)
 Journal.SystemMaxUse,   config_parse_bytes_off, 0, offsetof(Server, 
system_metrics.max_use)
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index ac565c7..ce6045c 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -67,6 +67,7 @@
 
 #define USER_JOURNALS_MAX 1024
 
+#define DEFAULT_SYNC_INTERVAL (60*USEC_PER_SEC)
 #define DEFAULT_RATE_LIMIT_INTERVAL (10*USEC_PER_SEC)
 #define DEFAULT_RATE_LIMIT_BURST 200
 
@@ -344,6 +345,25 @@ void server_rotate(Server *s) {
 }
 }
 
+void server_sync(Server *s) {
+JournalFile *f;
+void *k;
+Iterator i;
+int r;
+
+log_info("Syncing journal...");
+
+r = journal_file_sync(s->runtime_journal);
+if (r < 0)
+log_error("Failed to sync journal: %s", strerror(-r));
+
+HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) {
+r = journal_file_sync(f);
+if (r < 0)
+log_error("Failed to sync user journal: %s", 
strerror(-r));
+}
+}
+
 void server_vacuum(Server *s) {
 char *p;
 char ids[33];
@@ -1005,6 +1025,11 @@ int process_event(Server *s, struct epoll_event *ev) {
 return 1;
 }
 
+if (sfsi.ssi_signo == SIGALRM) {
+server_sync(s);
+return 1;
+}
+
 return 0;
 
 } else if (ev->data.fd == s->dev_kmsg_fd) {
@@ -1194,7 +1219,7 @@ static int open_signalfd(Server *s) {
 assert(s);
 
 assert_se(sigemptyset(&mask) == 0);
-sigset_add_many(&mask, SIGINT, SIGTERM, SIGUSR1, SIGUSR2, -1);
+sigset_add_many(&mask, SIGINT, SIGTERM, SIGUSR1, SIGUSR2, SIGALRM, -1);
 assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
 
 s->signal_fd = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
@@ -1286,6 +1311,48 @@ static int server_parse_config_file(Server *s) {
 return r;
 }
 
+static int server_setup_sync_timer(Server *s) {
+int r;
+
+struct sigevent sync_timer = {
+.sigev_notify = SIGEV_SIGNAL,
+.sigev_signo  = SIGALRM,
+};
+
+struct itimerspec sync_timer_interval = {
+.it_value.tv_sec = s->sync_interval / USEC_PER_SEC,
+.it_value.tv_nsec = s->sync_interval % USEC_PER_SEC,
+  

[systemd-devel] systemctl link and systemctl enable/disable incompatibility

2013-03-15 Thread Oleksii Shevchuk
Hi list. Currently we have next problem. systemctl have link option, and 
manual says:
The effect of this command is that a unit file is available for
start and *other* commands although it isn't installed directly in the
unit search path.

So, I assume at that point, that systemctl enable/disable should work
for linked units. Unfortunately it couldn't, because install/remove
contexts called with allow_symlinks=false, so unit_file_load returns
ELOOP. Looks like this behavior couldn't be changed with simple
allow_symlinks=false->true, because of problems with disable and Alias.

So, either enable/disable logic should be refactored, or additional info
should go to the manual page, or link functionality should be dropped i
think.

What is the right way to solve that problem?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Specifier support for Alias

2013-03-09 Thread Oleksii Shevchuk
> To achieve this:
> "Mount units must be named after the mount point directories they control."

> Our is there a better way?

Hm. Really. Anyway, looks like it's fixed/works in latest release:

systemctl enable iit-bs-cifs@D.mount 
ln -s '/etc/systemd/system/iit-bs-cifs@.mount' 
'/etc/systemd/system/mnt-iit-bs-cifs-D.mount'

But hehe.. There is another bug, with escaping:

> grep Alias iit-bs-cifs@.mount 
Alias=mnt-iit\x2dbs\x2dcifs\x2d%i.mount

So alias created unescaped..

And it doesn't work anyway. Looks like templated .mount units couldn't
be supported with current restrictions. I.e. unit name with @ wont't be
equal to Where=, and templates in Alias= couldn't be resolved, because
of missing @..
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Specifier support for Alias

2013-03-09 Thread Oleksii Shevchuk
> I am using a NAS and want to create .mount and .automount service files for 
> the
> shared.
> The service files differs only by the name of the share and mount target.

It's certainly bug, but why to use Alias for that purpose?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [ANNOUNCE] systemd 198

2013-03-08 Thread Oleksii Shevchuk
Lennart, thanks for answer, but probably I mean something else.

set-cgroup-attr creates drop-in with ControlGroupAttribute= for unit. Why don't
have something like 

systemctl set unit.service ControlGroupAttribute="cpu.shared 2000" 
systemctl set unit.service ConditionPathExists=/run/blah 

and so on?

They can be configured via drop-ins anyway. Or you mean that cgroup
attrs will act immediately, but other things doesn't, and that will make
some confuse?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [ANNOUNCE] systemd 198

2013-03-08 Thread Oleksii Shevchuk
> In fact, the drop-in logic I added primarily to have a nice place
> where "set-cgroup-attr" could be made persistent.

Maybe it's better to have generic interface for setting parameters,
instead of this specific one?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[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 @@
+ 
+http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl";?>
+http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd";>
+
+
+
+
+
+coredump.conf
+systemd
+
+
+
+Developer
+Lennart
+Poettering
+lenn...@poettering.net
+
+
+Developer
+    Oleksii
+Shevchuk
+alx...@gmail.com
+
+
+
+
+
+coredump.conf
+5
+
+
+
+coredump.conf
+Coredump utility configuration file
+
+
+
+/etc/systemd/coredump.conf
+
+
+
+Description
+
+This files configures several parameters of the
+systemd-coredump utility.
+
+
+
+
+Options
+
+All options are configured in the
+[Coredump] section:
+
+
+
+
+User=
+Group=
+
+Enforce UID/GID of
+systemd-coredump while 
loading
+and storing coredump. If not setted, then 
uid/gid of
+crashed process will be used.
+
+
+
+
+SaveToJournal=
+
+Tales a boolean value. If 
enabled
+(the default) core dump will be stored in the
+COREDUMP= field of log message.
+
+
+
+
+
SaveToFilesystem=
+
+  

[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 jo

[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


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

2013-02-20 Thread Oleksii Shevchuk
By default services has infty limit, afaik

If you have 25M truncated cores, that's because of systemd-coredump
limitation. Feel free to try this patch:

http://lists.freedesktop.org/archives/systemd-devel/2013-February/009065.html
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd + ssh-agent

2013-02-18 Thread Oleksii Shevchuk
I use this (with pam_gnome_keyring):

 > cat gnome-keyring-env.service 
[Unit]
Description=Setup gnome keyring environment

[Service]
Type=oneshot
ExecStart=/bin/sh -c "for env in $(gnome-keyring-daemon -s); do systemctl 
--user set-environment $env; done"
ExecStop=/bin/sh -c "for env in GNOME_KEYRING_CONTROL SSH_AUTH_SOCK 
GPG_AGENT_INFO; do systemctl --no-block --user unset-environment $env; done"
RemainAfterExit=yes

[Install]
WantedBy=env.target
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] D-Bus activation for systemd user session

2013-02-16 Thread Oleksii Shevchuk
To use d-bus activation with user session you need dbus from git, or the
patch

https://github.com/sofar/user-session-units/blob/master/patches/dbus-fix-sba-for-dbus-activation.patch

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


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

2013-02-15 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| 142 +++
 src/core/manager.c   |   1 +
 src/journal/coredump-gperf.gperf |  23 ++
 src/journal/coredump.c   | 537 ---
 src/journal/coredump.conf|  16 ++
 src/journal/coredump.h   |  47 
 src/journal/journald-server.h|   2 +-
 9 files changed, 685 insertions(+), 97 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 e4eb26c..5e3360e 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/locale.conf.5 \
man/localtime.5 \
diff --git a/Makefile.am b/Makefile.am
index 10934eb..3d59b14 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2609,7 +2609,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
@@ -2628,10 +2629,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
@@ -2675,10 +2678,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..cac2065
--- /dev/null
+++ b/man/coredump.conf.xml
@@ -0,0 +1,142 @@
+ 
+http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl";?>
+http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd";>
+
+
+
+
+
+coredump.conf
+systemd
+
+
+
+Developer
+Lennart
+Poettering
+lenn...@poettering.net
+
+
+Developer
+    Oleksii
+Shevchuk
+alx...@gmail.com
+
+
+
+
+
+coredump.conf
+5
+
+
+
+coredump.conf
+Coredump utility configuration file
+
+
+
+/etc/systemd/coredump.conf
+
+
+
+Description
+
+This files configures several parameters of the
+systemd-coredump utility.
+
+
+
+
+Options
+
+All options are configured in the
+[Coredump] section:
+
+
+
+
+User=
+Group=
+
+Enforce UID/GID of
+systemd-coredump while 
loading
+and storing coredump. If not setted, then 
uid/gid of
+crashed process will be used.
+
+
+
+
+
StoreIntoJournal=
+
+Tales a boolean value. If 
enabled
+(the default) core dump will be stored in the
+COREDUMP= field of log message.
+
+
+
+
+StoreIntoFile=
+
+Takes a boolean
+value. If enabled, c

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

2013-02-14 Thread Oleksii Shevchuk
Introduce configuration file: /etc/systemd/coredump.conf

[Coredump]
StoreIntoJournal=yes/no
StoreIntoFile=yes/no
MaxCoreSize=size-in-bytes

If StoreIntoFile=yes, then coredump will be saved to
temporary-formated file at /var/log/coredump/MACHINE-ID/COMM-XX

If MaxCoreSize specified, then core will be truncated to that size
---
 Makefile.am  |  10 +-
 src/core/manager.c   |   1 +
 src/journal/coredump-gperf.gperf |  20 ++
 src/journal/coredump.c   | 452 ---
 src/journal/coredump.h   |  35 +++
 src/journal/journald-server.h|   2 +-
 6 files changed, 441 insertions(+), 79 deletions(-)
 create mode 100644 src/journal/coredump-gperf.gperf
 create mode 100644 src/journal/coredump.h

diff --git a/Makefile.am b/Makefile.am
index 10934eb..3725cbe 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2628,10 +2628,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
@@ -2675,10 +2677,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/src/core/manager.c b/src/core/manager.c
index 28f169d..c9f410e 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -51,6 +51,7 @@
 #include "hashmap.h"
 #include "macro.h"
 #include "strv.h"
+#include "env-util.h"
 #include "log.h"
 #include "util.h"
 #include "mkdir.h"
diff --git a/src/journal/coredump-gperf.gperf b/src/journal/coredump-gperf.gperf
new file mode 100644
index 000..d64533c
--- /dev/null
+++ b/src/journal/coredump-gperf.gperf
@@ -0,0 +1,20 @@
+%{
+#include 
+#include 
+#include "coredump.h"
+#include "conf-parser.h"
+%}
+struct ConfigPerfItem;
+%null_strings
+%language=ANSI-C
+%define slot-name section_and_lvalue
+%define hash-function-name coredump_gperf_hash
+%define lookup-function-name coredump_gperf_lookup
+%readonly-tables
+%omit-struct-type
+%struct-type
+%includes
+%%
+Coredump.StoreIntoJournal, config_parse_bool,   0, offsetof(Coredump, 
to_journal)
+Coredump.StoreIntoFile,config_parse_bool,   0, offsetof(Coredump, 
to_file)
+Coredump.MaxCoreSize,  config_parse_bytes_size, 0, offsetof(Coredump, 
max_size)
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index 021b4c6..f848fc6 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -3,7 +3,8 @@
 /***
   This file is part of systemd.
 
-  Copyright 2012 Lennart Poettering
+  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
@@ -22,6 +23,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 
 #include 
@@ -35,9 +39,13 @@
 #include "macro.h"
 #include "mkdir.h"
 #include "special.h"
+#include "sd-id128.h"
+#include "coredump.h"
+#include "conf-parser.h"
 #include "cgroup-util.h"
 
-#define COREDUMP_MAX (24*1024*1024)
+#define COREDUMP_MAX_DEFAULT ( 24 * 1024 * 1024 )
+#define COREDUMP_CONFIG "/etc/systemd/coredump.conf"
 
 enum {
 ARG_PID = 1,
@@ -49,26 +57,51 @@ enum {
 _ARG_MAX
 };
 
-static int divert_coredump(void) {
-_cleanup_fclose_ FILE *f = NULL;
+static int coredump_drop_creds(uid_t uid, uid_t gid)
+{
+if (setresgid(gid, gid, gid) < 0 ||
+setresuid(uid, uid, uid) < 0) {
+log_error("Failed to drop privileges: %m");
+return -errno;
+}
 
-log_info("Detected coredump of the journal daemon itself, diverting 
coredump to /var/lib/systemd/coredump/.");
+umask(0377);
 
-mkdir_p_label("/var/lib/systemd/coredump", 0755);
+return 0;
+}
+
+static int coredump_parse_config_file(Coredump *s) {
+static const char *fn = COREDUMP_CONFIG;
+FILE _cleanup_fclose_ *f = NULL;
+int r;
 
-f = fopen("/var/lib/systemd/coredump/core.systemd-journald", "we");
+assert(s);
+
+   

Re: [systemd-devel] [PATCH 3/6] Optionally save core dumps as plain files

2013-02-14 Thread Oleksii Shevchuk
> Hmm, if we do this, then I'd suggest not to place this in the journal
> directory. This should be independent of it. Note that the journal logic
> currently watches the entire per-machine dir for changes and we thus
> should really drop stuff there that doesn't belong there..

Saving in journal subdirs leave possibility of remote mounting logging
directory and automatic processing. If there is real issue with that, 
dumps can go to /var/log/coredump/MACHINE-ID/ probably

> > +r = sd_id128_randomize(&coreid);
> > +if (r)
> > +goto journal;

> Do we really want a new random ID in this?

Random Id is the simplest case. Probably we can have several cores from several
instances in same time. PID+Time can be used instead, probably, but
random id looks better for me. Any issues with that? 

> Also, message IDs are *not* supposed to be "just counted up". Instead
> generate a new one with "journalctl --new-id128". However, in this case
> we really should just use the same ID for all cases, and just depending
> on the configuration have a different set of keys in it, i.e. either the
> actual coredump, or the coredump path + hash, or even both. Depending on
> the configuration file...

Journals can be copied to external host without configuration
files. I.e. depending on the configuration file is not an option. On the
other hand, software can search either for COREDUMP filed or the
COREDUMP_FILE..
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2013-02-13 Thread Oleksii Shevchuk
---
 src/core/dbus-unit.c  | 18 +++-
 src/core/job.c| 27 +++-
 src/core/job.h|  1 +
 src/core/load-fragment-gperf.gperf.m4 |  2 +-
 src/core/load-fragment.c  |  3 ++
 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, 167 insertions(+), 37 deletions(-)

diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index d1de46a..91b6f4f 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -202,6 +202,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;
@@ -1236,7 +1252,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 2bafbc1..a4fcc76 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -294,11 +294,13 @@ void job_dump(Job *j, FILE*f, const char *prefix) {
 "%s-> Job %u:\n"
 "%s\tAction: %s -> %s\n"
 "%s\tState: %s\n"
-"%s\tForced: %s\n",
+"%s\tForced: %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->override),
+prefix, yes_no(j->root));
 }
 
 /*
@@ -510,6 +512,20 @@ 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(j->unit, UNIT_ACTIVATING, 
UNIT_FAILED, false);
+r = 0;
+break;
+}
+}
+
 r = unit_start(j->unit);
 
 /* If this unit cannot be started, then simply wait */
@@ -946,6 +962,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-sent-dbus-new-signal=%s\n", 
yes_no(j->sent_dbus_new_signal));
 fprintf(f, "job-ignore-order=%s\n", yes_no(j->ignore_order));
@@ -1008,6 +1025,12 @@ int job_deserialize(Job *j, FILE *f, FDSet *fds) {
 log_debug("Failed to parse job state %s", v);
 else
 j->state = s;
+} else if (streq(l, "job-root")) {
+int b = parse_

[systemd-devel] [PATCH] Fix the race in deserialization.

2013-02-13 Thread Oleksii Shevchuk
unit_notify is fired in deserelization code (particulary in
service_set_state). Units passed in random order, and there is possibility,
that unit with StopWhenUnneeded=yes passed before it actual dependecies. In
that case unit will be stopped as unneeded, because deps in UNIT_INACTIVE state
yet.

So, reuse similar logic (unit.c:1421) to avoid this race
---
 src/core/unit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/core/unit.c b/src/core/unit.c
index f7d00b6..360da07 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1497,7 +1497,8 @@ void unit_notify(Unit *u, UnitActiveState os, 
UnitActiveState ns, bool reload_su
 
 /* Maybe we finished startup and are now ready for being
  * stopped because unneeded? */
-unit_check_unneeded(u);
+if (u->manager->n_reloading <= 0)
+unit_check_unneeded(u);
 
 unit_add_to_dbus_queue(u);
 unit_add_to_gc_queue(u);
-- 
1.8.1.2

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


Re: [systemd-devel] [PATCH 1/6] Set StopWhenUnneeded=no, if unit started manually

2013-02-13 Thread Oleksii Shevchuk
Lennart, thanks for reviewing. 

> so the current patch can't really work, or am I missing something?

Patch works, as I use it every day. Anyway idea with override is better,
as it leaves space for additional usecases. 

But I don't get, how root of transactions should be detected? Should I
mark the job as root in transaction_apply?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] dependencies between instances

2013-02-13 Thread Oleksii Shevchuk
> Can you suggest other usecases?

I can. Situation like local client-server, where server requires root
creds, cannot into socket/d-bus activation and requires device or
something about it; client should be running from user and server
requires.

Example: pcscd + nfc-eventd

So, how it supposed to be working:

1. Device inserted
2. System-wide unit started
2.1. Deps of unit started
2.2. System instance makes announce about started unit
2.3  User instances gets announce
3. User instances makes this virtual unit active
4. User instances starts user configured deps of unit

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


Re: [systemd-devel] bootchart: tabs to spaces?

2013-02-12 Thread Oleksii Shevchuk
> (Yeah, like hitting space 8 times instead of using tab in
> most editors without "smart" identation.)

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


[systemd-devel] [PATCH 5/6] Add hexstr function

2013-02-12 Thread Oleksii Shevchuk
Function convers byte array to hex string
---
 src/shared/util.c | 23 +++
 src/shared/util.h |  1 +
 2 files changed, 24 insertions(+)

diff --git a/src/shared/util.c b/src/shared/util.c
index 24f9e7e..2a5cbbb 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1368,6 +1368,29 @@ char hexchar(int x) {
 return table[x & 15];
 }
 
+char * hexstr (const uint8_t *in, size_t count)
+{
+char *r = NULL, *i = NULL;
+
+if (!in || !count)
+goto finish;
+
+r = i = new(char, count * 2 + 1);
+if (! r)
+goto finish;
+
+while (count--) {
+*i++ = hexchar(*in >> 4);
+*i++ = hexchar(*in);
+++in;
+}
+
+*i = '\0';
+
+ finish:
+return r;
+}
+
 int unhexchar(char c) {
 
 if (c >= '0' && c <= '9')
diff --git a/src/shared/util.h b/src/shared/util.h
index cd13457..fe85fa8 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -211,6 +211,7 @@ int get_process_uid(pid_t pid, uid_t *uid);
 int get_process_gid(pid_t pid, gid_t *gid);
 
 char hexchar(int x);
+char * hexstr (const uint8_t *in, size_t count);
 int unhexchar(char c);
 char octchar(int x);
 int unoctchar(char c);
-- 
1.8.1.2

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


[systemd-devel] [PATCH 6/6] Add SHA1 hash sum to coredump report

2013-02-11 Thread Oleksii Shevchuk
If coredump goes to raw file, compute hash sum of it and store to
journal. Feature is optional, if libgrcypt enabled (HAVE_GCRYPT)
---
 Makefile.am   |  9 
 src/journal/coredump.c| 48 +++
 src/journal/journald-server.h |  2 +-
 3 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index af9e903..42cf7c6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2672,6 +2672,15 @@ systemd_coredump_LDADD += \
libsystemd-login-internal.la
 endif
 
+if HAVE_GCRYPT
+systemd_coredump_CFLAGS = \
+   $(GCRYPT_CFLAGS) \
+   -Wno-pointer-arith
+
+systemd_coredump_LDADD += \
+   $(GCRYPT_LIBS)
+endif
+
 rootlibexec_PROGRAMS += \
systemd-coredump
 
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index 680b26c..c9bda68 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -24,6 +24,10 @@
 #include 
 #include 
 
+#if defined(HAVE_GCRYPT)
+#include 
+#endif
+
 #include 
 
 #ifdef HAVE_LOGIND
@@ -50,6 +54,13 @@ enum {
 _ARG_MAX
 };
 
+#if defined(HAVE_GCRYPT)
+static void gcry_md_closep(gcry_md_hd_t *p)
+{
+gcry_md_close(*p);
+}
+#endif
+
 static int submit_process_core(struct iovec iovec[15], int idx,
const char * comm,
const int journal)
@@ -61,6 +72,10 @@ static int submit_process_core(struct iovec iovec[15], int 
idx,
 _cleanup_free_   char * corelink = NULL;
 _cleanup_free_   char * t = NULL;
 
+#if defined(HAVE_GCRYPT)
+_cleanup_free_   char * h = NULL;
+#endif
+
 if (journal) {
 mkdir_p_label("/var/lib/systemd/coredump", 0755);
 corelink = 
strdup("/var/lib/systemd/coredump/core.systemd-journald");
@@ -152,6 +167,17 @@ journal:
 log_debug("chmod %s: %s", corepath, strerror(errno));
 }
 
+#if defined(HAVE_GCRYPT)
+__attribute__((cleanup(gcry_md_closep)))
+gcry_md_hd_t HD;
+gcry_error_t gr = gcry_md_open (&HD, GCRY_MD_SHA1, 0);
+if (gr != GPG_ERR_NO_ERROR) {
+log_error("Failed to initialize gcrypt hash context: 
%s",
+  gpg_strerror(gr));
+goto finish;
+}
+#endif
+
 for (;;) {
 uint8_t buffer[4096];
 size_t l, q;
@@ -171,6 +197,9 @@ journal:
 log_error("Failed to write coredump: %m");
 goto finish;
 }
+#if defined(HAVE_GCRYPT)
+gcry_md_write(HD, buffer, l);
+#endif
 }
 
 fflush(corefile);
@@ -190,6 +219,25 @@ journal:
 t = strjoin("COREDUMP_FILE=coredump/", corelink, NULL);
 if (t)
 IOVEC_SET_STRING(iovec[idx ++], t);
+
+#if defined(HAVE_GCRYPT)
+char * bh = hexstr(gcry_md_read(HD, GCRY_MD_SHA1), 20);
+
+if (! bh) {
+r = log_oom();
+goto finish;
+}
+
+h = strjoin("COREDUMP_FILE_SHA1=", bh, NULL);
+free(bh);
+
+if (! h) {
+r = log_oom();
+goto finish;
+}
+
+IOVEC_SET_STRING(iovec[idx ++], h);
+#endif
 }
 
 r = sd_journal_sendv(iovec, idx);
diff --git a/src/journal/journald-server.h b/src/journal/journald-server.h
index 9f50a29..3d05925 100644
--- a/src/journal/journald-server.h
+++ b/src/journal/journald-server.h
@@ -121,7 +121,7 @@ typedef struct Server {
 struct udev *udev;
 } Server;
 
-#define N_IOVEC_META_FIELDS 17
+#define N_IOVEC_META_FIELDS 18
 #define N_IOVEC_KERNEL_FIELDS 64
 #define N_IOVEC_UDEV_FIELDS 32
 
-- 
1.8.1.2

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


[systemd-devel] [PATCH 5/6] Add hexstr function

2013-02-11 Thread Oleksii Shevchuk
Function that converts byte array to hex string
---
 src/shared/util.c | 23 +++
 src/shared/util.h |  1 +
 2 files changed, 24 insertions(+)

diff --git a/src/shared/util.c b/src/shared/util.c
index 24f9e7e..6dbfe29 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1368,6 +1368,29 @@ char hexchar(int x) {
 return table[x & 15];
 }
 
+char * hexstr (const uint8_t *in, size_t count)
+{
+char *r, *i = NULL;
+
+if (!in || !count)
+goto finish;
+
+r = i = new(char, count * 2 + 1);
+if (! r)
+goto finish;
+
+while (count--) {
+*i++ = hexchar(*in >> 4);
+*i++ = hexchar(*in);
+++in;
+}
+
+*i = '\0';
+
+ finish:
+return r;
+}
+
 int unhexchar(char c) {
 
 if (c >= '0' && c <= '9')
diff --git a/src/shared/util.h b/src/shared/util.h
index cd13457..fe85fa8 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -211,6 +211,7 @@ int get_process_uid(pid_t pid, uid_t *uid);
 int get_process_gid(pid_t pid, gid_t *gid);
 
 char hexchar(int x);
+char * hexstr (const uint8_t *in, size_t count);
 int unhexchar(char c);
 char octchar(int x);
 int unoctchar(char c);
-- 
1.8.1.2

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


[systemd-devel] [PATCH 4/6] Add COREDUMP_FILE= support to systemd-coredumpctl

2013-02-11 Thread Oleksii Shevchuk
---
 src/journal/coredumpctl.c | 258 +-
 1 file changed, 207 insertions(+), 51 deletions(-)

diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c
index b6e5581..9ad8d3b 100644
--- a/src/journal/coredumpctl.c
+++ b/src/journal/coredumpctl.c
@@ -43,7 +43,7 @@ static enum {
 } arg_action = ACTION_LIST;
 
 static Set *matches = NULL;
-static FILE* output = NULL;
+static const char* output_path = NULL;
 static char* field = NULL;
 
 static int arg_no_pager = false;
@@ -75,6 +75,21 @@ static Set *new_matches(void) {
 return NULL;
 }
 
+tmp = strdup("MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b2");
+if (!tmp) {
+log_oom();
+set_free(set);
+return NULL;
+}
+
+r = set_put(set, tmp);
+if (r < 0) {
+log_error("failed to add to set: %s", strerror(-r));
+free(tmp);
+set_free(set);
+return NULL;
+}
+
 return set;
 }
 
@@ -183,17 +198,12 @@ static int parse_argv(int argc, char *argv[]) {
 break;
 
 case 'o':
-if (output) {
+if (output_path) {
 log_error("cannot set output more than once");
 return -EINVAL;
 }
 
-output = fopen(optarg, "we");
-if (!output) {
-log_error("writing to '%s': %m", optarg);
-return -errno;
-}
-
+output_path = optarg;
 break;
 
 case 'F':
@@ -292,15 +302,16 @@ static int print_entry(FILE* file, sd_journal *j, int 
had_legend) {
 
 SD_JOURNAL_FOREACH_DATA(j, d, l) {
 retrieve(d, l, "COREDUMP_PID", &pid);
-retrieve(d, l, "COREDUMP_PID", &pid);
 retrieve(d, l, "COREDUMP_UID", &uid);
 retrieve(d, l, "COREDUMP_GID", &gid);
 retrieve(d, l, "COREDUMP_SIGNAL", &sgnl);
 retrieve(d, l, "COREDUMP_EXE", &exe);
-if (!exe)
+if (!exe) {
 retrieve(d, l, "COREDUMP_COMM", &exe);
-if (!exe)
+}
+if (!exe) {
 retrieve(d, l, "COREDUMP_CMDLINE", &exe);
+}
 }
 
 if (!pid && !uid && !gid && !sgnl && !exe) {
@@ -379,12 +390,23 @@ static int focus(sd_journal *j) {
 }
 
 static int dump_core(sd_journal* j) {
-const void *data;
+const char *data;
 size_t len, ret;
 int r;
 
+_cleanup_fclose_
+FILE* output = NULL;
+
 assert(j);
 
+if (output_path) {
+output = fopen(output_path, "we");
+if (!output) {
+log_error("writing to '%s': %m", optarg);
+return -errno;
+}
+}
+
 /* We want full data, nothing truncated. */
 sd_journal_set_data_threshold(j, 0);
 
@@ -399,20 +421,103 @@ static int dump_core(sd_journal* j) {
 return -ENOTTY;
 }
 
-r = sd_journal_get_data(j, "COREDUMP", (const void**) &data, &len);
+r = sd_journal_get_data(j, "MESSAGE_ID", (const void **) &data, &len);
 if (r < 0) {
-log_error("Failed to retrieve COREDUMP field: %s", 
strerror(-r));
+log_error("Failed to retrieve MESSAGE_ID field: %s", 
strerror(-r));
 return r;
 }
 
-assert(len >= 9);
-data = (const uint8_t*) data + 9;
-len -= 9;
+assert(len >= 11);
+
+if (strcmp(data + 11, "fc2e22bc6ee647b6b90729ab34a250b1") == 0) {
+r = sd_journal_get_data(j, "COREDUMP", (const void**) &data, 
&len);
+if (r < 0) {
+log_error("Failed to retrieve COREDUMP field: %s", 
strerror(-r));
+return r;
+}
+
+assert(len >= 9);
+data += 9;
+len  -= 9;
 
-ret = fwrite(data, len, 1, output ? output : stdout);
-if (ret != 1) {
-log_error("dumping coredump: %m (%zu)", ret);
-return -errno;
+ret = fwrite(data, len, 1, output ? output : stdout);
+if (ret != 1) {
+log_error("dumping coredump: %m (%zu)", ret);
+return -errno;
+}
+}
+else if (strcmp(data + 11, "fc2e22bc6ee647b6b90729ab34a250b2") == 0) {
+_cleanup_free_ char *coredump = NULL;
+_cleanup_fclose_ FILE *fcoredump = NULL;
+_cleanup_fclose_ FILE *fout = NULL;
+const char * corepath

  1   2   >