[systemd-devel] serialization bug, swap bug, etc.
~ I'm getting this on every reload: systemd[1]: Unknown serialization item 'subscribed=:1.1' Doesn't seem to break anything though. ~ I'm also getting this on every reload: systemd[1]: [/usr/lib/systemd/system/systemd-journald.service:24] Failed to parse capability in bounding set, ignoring: CAP_AUDIT_READ I suppose I can ignore the message. I see that cap_audit_read was added to kernel 3.16, but unfortunately it doesn't exist in the current libcap release (libcap 2.24). ~ If there are two .swap units for the same partition (one made by fstab-generator, another by gpt-generator), systemd tries to swapon it twice, resulting in "swapon failed: Device or resource busy". This was broken first when systemd-gpt-generator appeared, then systemd was taught to recognize duplicates, but now it seems to be broken again. (I *think* it broke around commit 3018d31238caabc2e.) -- Mantas Mikulėnas ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] VLAN's not coming up "systemd-networkd.service loaded failed" + systemd-networkd seg fault
No one has any clue? Or do I need to provide more information? (if so what?) Thanks once again, Brendan - Original Message - From: "Brendan Horan" To: "systemd-devel" Sent: Thursday, 13 November, 2014 11:59:49 AM Subject: [systemd-devel] VLAN's not coming up "systemd-networkd.service loaded failed" + systemd-networkd seg fault Hi, I am trying configure VLAN sub interfaces with networkd. When the machine boots the physical interface never seems to come UP. Thus all the sub interface VLAN's also do not get activated. I also notice systemd-networkd seg faults during boot, example message : "[7.036581] systemd-network[677]: segfault at 255 ip 7f88955634c9 sp 7fffb34fd8b0 error 4 in systemd-networkd[7f8895559000+86000] [7.093289] systemd-network[682]: segfault at 255 ip 7f3cd632e4c9 sp 7fff25936ed0 error 4 in systemd-networkd[7f3cd6324000+86000] If I then manually bring up my physical interface the VLAN sub interfaces get created. I am not sure what I am doing wrong and what is causing systemd-networkd to seg fault. My configs are as follows : :: :: 20-physical-int1.network :: [Match] MACAddress=XX:XX:XX:XX:XX:XX [Network] VLAN=PI-vlan.8 VLAN=PI-vlan.76 VLAN=PI-vlan.86 VLAN=PI-vlan.243 :: 30-PI-vlan-8.netdev :: [NetDev] Name=PI-vlan.8 Kind=vlan [VLAN] Id=8 :: 31-PI-vlan-76.netdev :: [NetDev] Name=PI-vlan.76 Kind=vlan [VLAN] Id=76 :: 32-PI-vlan-86.netdev :: [NetDev] Name=PI-vlan.86 Kind=vlan [VLAN] Id=86 :: 33-PI-vlan-243.netdev :: [NetDev] Name=PI-vlan.243 Kind=vlan [VLAN] Id=243 :: 40-PI-vlan-8.network :: [Match] Name=PI-vlan.8 [Network] Address=xxx.xxx.xxx.xxx/24 [Route] Gateway=xxx.xxx.xxx.xxx :: 41-PI-vlan-76.network :: [Match] Name=PI-vlan.76 [Network] Address=xxx.xxx.xxx.xxx/24 [Route] Gateway=xxx.xxx.xxx.xxx :: 42-PI-vlan-86.network :: [Match] Name=PI-vlan.86 [Network] Address=xxx.xxx.xxx.xxx/24 [Route] Gateway=xxx.xxx.xxx.xxx :: 43-PI-vlan-.243.network :: [Match] Name=PI-vlan.243 [Network] Address=xxx.xxx.xxx.xxx/24 [Route] Gateway=xxx.xxx.xxx.xxx :: :: If you need more info I am happy to try provide it. Thank you, (and thanks for systemd!) ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [BUG] too many rfkill services
В Tue, 18 Nov 2014 18:37:03 +0100 Łukasz Stelmach пишет: > > After several suspend/resumes systemctl shows more than three dozens of > rfkill devices even though I've got only one BT and one WLAN. > > --8<---cut here---start->8--- > systemd-rfkill@rfkill0.service loaded active exitedLoad/Save RF Kill > Switch Status of rfkill0 > systemd-rfkill@rfkill1.service loaded active exitedLoad/Save RF Kill > Switch Status of rfkill1 > systemd-rfkill@rfkill2.service loaded active exitedLoad/Save RF Kill > Switch Status of rfkill4 > systemd-rfkill@rfkill3.service loaded active exitedLoad/Save RF Kill > Switch Status of rfkill4 > I confirm it. [...] > > The actual issue as I see it is that systemd does not stop and remove > rfkill services that refer to nonexistent devices. > The problem is, there no easy way to build device name from rfkillN for BindsTo. May be additional format specifier that would query udev database. Alternatively systemd-rfkill can be changed to accept sysfs path directly. signature.asc Description: PGP signature ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH 1/2] test: empty environment variables in unit files
--- src/test/test-unit-file.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c index 03b3e25..f31a1bb 100644 --- a/src/test/test-unit-file.c +++ b/src/test/test-unit-file.c @@ -222,6 +222,9 @@ static void test_config_parse_exec(void) { "MODULE_0=coretemp\n" \ "MODULE_1=f71882fg" +#define env_file_5 \ +"a=\n" \ +"b=" static void test_load_env_file_1(void) { _cleanup_strv_free_ char **data = NULL; @@ -300,6 +303,24 @@ static void test_load_env_file_4(void) { unlink(name); } +static void test_load_env_file_5(void) { +_cleanup_strv_free_ char **data = NULL; +int r; + +char name[] = "/tmp/test-load-env-file.XX"; +_cleanup_close_ int fd; + +fd = mkostemp_safe(name, O_RDWR|O_CLOEXEC); +assert_se(fd >= 0); +assert_se(write(fd, env_file_5, sizeof(env_file_5)) == sizeof(env_file_5)); + +r = load_env_file(NULL, name, NULL, &data); +assert_se(r == 0); +assert_se(streq(data[0], "a=")); +assert_se(streq(data[1], "b=")); +assert_se(data[2] == NULL); +unlink(name); +} static void test_install_printf(void) { charname[] = "name.service", @@ -387,6 +408,7 @@ int main(int argc, char *argv[]) { test_load_env_file_2(); test_load_env_file_3(); test_load_env_file_4(); +test_load_env_file_5(); TEST_REQ_RUNNING_SYSTEMD(test_install_printf()); return r; -- 2.1.3 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH 2/2] update TODO
Empty environment variables in Environment= and EnvironmentFile= options work. --- TODO | 2 -- 1 file changed, 2 deletions(-) diff --git a/TODO b/TODO index d4138fe..3e8d04c 100644 --- a/TODO +++ b/TODO @@ -191,8 +191,6 @@ Features: * generator that automatically discovers btrfs subvolumes, identifies their purpose based on some xattr on them. -* support setting empty environment variables with Environment= and EnvironmentFile= - * timer units: actually add extra delays to timer units with high AccuracySec values, don't start them already when we are awake... * a way for container managers to turn off getty starting via $container_headless= or so... -- 2.1.3 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH 0/2] Empty environment variables in unit files work
with this file: [Unit] Description=Test empty variables [Service] Environment=TEST= TEST2= ExecStart=/bin/bash -c "env" [Install] WantedBy=default.target I get this output: Nov 19 16:59:07 arch-tree systemd[1]: Starting Test empty variables... Nov 19 16:59:07 arch-tree systemd[1]: Started Test empty variables. Nov 19 16:59:07 arch-tree bash[131]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin Nov 19 16:59:07 arch-tree bash[131]: PWD=/ Nov 19 16:59:07 arch-tree bash[131]: TEST= Nov 19 16:59:07 arch-tree bash[131]: SHLVL=1 Nov 19 16:59:07 arch-tree bash[131]: TEST2= Nov 19 16:59:07 arch-tree bash[131]: _=/usr/sbin/env Iago López Galeiras (2): test: empty environment variables in unit files update TODO TODO | 2 -- src/test/test-unit-file.c | 22 ++ 2 files changed, 22 insertions(+), 2 deletions(-) -- 2.1.3 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] /usr vs /etc for default distro units enablement
В Tue, 18 Nov 2014 16:22:18 + Colin Guthrie пишет: > Michael Biebl wrote on 18/11/14 15:55: > > 2014-11-18 16:30 GMT+01:00 Colin Guthrie : > >> Michael Biebl wrote on 18/11/14 15:09: > >>> 2014-11-18 15:59 GMT+01:00 Colin Guthrie : > Didier Roche wrote on 18/11/14 13:58: > > This would be maybe a nice way for the admin to know what's coming from > > a distribution default or not. However, let's say I want to ensure that > > ssh will always be available on my server, I would (even if it's in my > > server preset) then systemctl enable openssh, no matter whatever future > > preset updates does (like disable it in the next batch upgrade). > > For the avoidance of doubt, I believe that running systemctl preset > should only ever happen on *first* install, never on upgrade or such > like. > > >>> > >>> And what are you going to do, if the unit file changes? > >>> Say v1 had > >>> > >>> [Install] > >>> WantedBy=multi-user.target > >>> > >>> and version B has > >>> [Install] > >>> WantedBy=foo.target > >> > >> > >> Well this is an edge case I'm sure you'll agree. > > > > Actually, in the short period of time (and with the currently still > > low number of packages shipping native units) in Debian, this happened > > more often then I'd have expected. > > > > So I think we should have a better answer then just saying this is an edge > > case. > > I still thing we should still call it an edge case tho' :) > > Having a way around it is fine tho'. > > >> Ultimately, with this case, doing the preset is wrong anyway. You don't > >> want the distro choice, you want the "what the user had" choice. > > > > You only want to preservce the user choice, if it deviated from the > > distro choice. > > Well, depending on implementation that's one and the same thing. With > the current implementation of preset, they *are* the same thing, Not really. There is no way to distinguish between unit enabled by presets and unit enabled by admin. > so I > think my statement is valid. > > > Otherwise the package state should be updated to > > reflect the latest distro choice. > > Assuming currently implementation, my script did this :) > > But I can see why you'd like to encapsulate this better in a more > automated fashion and I don't have a direct answer for this (but then I > don't think the proposed scheme here covered the opposite case either - > i.e. user deviating from distro choice - so IMO it's just as bad!) > > Col > ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] make systemd service takes cpu exclusively
В Tue, 18 Nov 2014 06:25:43 + "Cao, XinX" пишет: > Hi, Umut & David, > > My project needs the Graphical desktop to display on monitor as fast as > possible, but I found lots of unrelated services( such as sound, network, ... > ) are competing CPU even they are explicitly After graphical service. And > this competion delays the startup of graphical desktop process. So, my > opinion is to make graphical related programs runs first and the other > unrelated services only starts after graphical program finished startup. Let me guess. Your Graphical desktop is defined of simple or forking, right? So from systemd point of view service is started as soon as process is forked and it proceeds with starting further service defined After this one. The problem with After is that it is effective only if systemd can know when service startup is completed. And in general it is possible only with types dbus or notify (and cooperating server). In case of GUI you do not even have single process representing service, depending on definition of "Graphical desktop". ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] Starting configurable set of services first
On 10/28/2014 01:06 AM, Umut Tezduyar Lindskog wrote: > On Wed, Oct 22, 2014 at 7:44 PM, Lennart Poettering > wrote: >> On Tue, 02.09.14 10:06, Umut Tezduyar Lindskog (u...@tezduyar.com) wrote: >> >>> Hi, >>> >>> I would like to start a configurable set of services first and the >>> services are wanted by multi-user.target. I am using a service to jump >>> to multi-user.target and I was wondering if we can support this use >>> case natively by systemd. >>> >>> multi-user.target.wants >>> A.service >>> B.service >>> C.service >>> D.service >>> >>> default.target > stage.target >>> stage.target.wants (These are set by generator) >>> A.service >>> C.service >>> switcher.service >>> >>> switcher.service (This is generated by generator) >>> [Unit] >>> Description=Switch to multi-user.targe >>> After=A.service C.service >>> [Service] >>> Type=oneshot >>> RemainAfterExit=yes >>> ExecStart=/usr/bin/systemctl --no-block start multi-user.target >>> >>> This way I am jumping from one target to another target during runtime. >>> >>> - What stage.target wants is dynamic. If it was static, my job would >>> have been very simple. >>> - I am aware of StartupCPUShares but it is not the ultimate solution >>> A) there is a configurable minimum quota in CFS which still gives CPU >>> to other processes. B) We still fork other processes and this causes >>> changes in timeout values of other processes. >>> - Adding dynamically After= to B and D service files is not the >>> ultimate solution either because B and D might be socket/dbus >>> activated by A or C. >>> >>> Should this be something we should support natively by systemd? >> >> As discussed at th systemd hackfest: I am a bit conservative about >> this as it introduces plenty chance for deadlocks, where services >> might trigger/request some other unit but we'd delay it until the >> later stage... >> >> I think the implementation you chose is actually pretty good. I am not >> sure though that we should do this upstream. I mean, I really would >> prefer if we'd dump as much work as possible on the IO elevator and >> CPU scheduler, and then adjust the priorities of it to give hints what >> matters more. Trying to second-guess the elevator and scheduler in >> userspace feels a bit like chickening out to me, even though I am sure >> that it might be something that one has to do for now, in the real >> world... > > I am not agreeing on this. Once you fork the process, it will always > get some CPU even though you play with cpu.shares, sched_latency_ns, > sched_min_granularity_ns. My goal is not forking it at all until high > priority services are activated. Just like Before=, After=. > I have similar problem with this. And I'd introduced extra dependencies. But Lennard said same like. :) http://lists.freedesktop.org/archives/systemd-devel/2014-February/017457.html http://lists.freedesktop.org/archives/systemd-devel/2014-March/017524.html So I just keep that as our downstream patch. (Some was enhanced. Using hash to avoid compare line by line. just trivial. basic concept is same.) The summary is.. I add an option and named that default extra dependency. (I couldn't imagine any abbreviation.) And make if service was not listed on ignore extra dependency and has no DefaultDependencies=no option then that service is started after all of default extra dependency units. But we also still have many After=/Before= options in many unit files. :) I agree about Lennard's thought. I can easily break a ordering cycle or make circular dependencies. But we don't have other option. In our system, cpu usage go up to 100% almost just after systemd start dispatching from job queue. Until default.target is activated. If new unit come up to the race round then that will make more and more slower. I hope we can find some of general way to resolve. WaLyong >> >> There's one change I'd really like to see done though in systemd, that >> might make things nicer for you. Currently, it's undefined in systemd >> which job is dispatched first, if multiple jobs can be executed. That >> means when we are about to fork off a number of processes there's no >> way to control which one gets forked off first. I'd be willing to >> merge a patch that turns this into a prioq, so that some priority >> value can be configured (or automatically derived) for each unit, and >> the one with the highest priority would win, and be processed >> first. This would not provide you with everything what you want, but >> would make things a bit nicer when we dump all possible work on the >> scheduler/elevator, because after all we cannot really dump all work >> at the same time, and hence should at least give you control in which >> order to dump it, if you follow what I mean. > > I have understood your propose with the exception of one thing. When > do we start dispatching low priority jobs? When the high priority jobs > are dispatched/forked or when the high priority jobs are > dispatched/acti
Re: [systemd-devel] [PATCH] sd-dhcp-client: fix REBOOT state handling
On Tue, 2014-11-18 at 18:41 +0100, Tom Gundersen wrote: > (but cc'ing Patrik just to make sure) > > RFC 2131: > > > > secs 2 Filled in by client, seconds elapsed since client > >began address acquisition or renewal process. > > @@ -422,7 +423,15 @@ static int client_message_init(sd_dhcp_client *client, > > DHCPPacket **ret, > > > > /* Although 'secs' field is a SHOULD in RFC 2131, certain DHCP > > servers > > refuse to issue an DHCP lease if 'secs' is set to zero */ > > -packet->dhcp.secs = htobe16(client->secs); > > +r = sd_event_now(client->event, clock_boottime_or_monotonic(), > > &time_now); > > +if (r < 0) > > +return r; > > +assert(time_now >= client->start_time); > > + > > +/* seconds between sending first and last DISCOVER > > + * must always be strictly positive to deal with broken servers */ > > +secs = ((time_now - client->start_time) / USEC_PER_SEC) ? : 1; > > +packet->dhcp.secs = htobe16(secs); The previous code assumed that resending a message mean really sending an identical one in place of the lost one. This change actually nags on the other end that time has really passed, be it a clue to a DHCP relay that it should do something else than before. Looking at the RFC snippet and the patch, I think this is what the RFC actually tried to say. Cheers, Patrik ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] StartupCPUShares
Hi XinX, On Wed, Nov 19, 2014 at 8:30 AM, Cao, XinX wrote: > Hi, Umut, > > > > Days ago you told me “StartupCPUShares”, and I had a test of > this option in my system. But it seems systemd on my system doesn’t know > this item. And I got this message “Unknow lvalue StartupCPUShares in section > Service”. That’s very strange. So can you give me some suggestions about > this ? Thank you. http://www.freedesktop.org/software/systemd/man/systemd.resource-control.html talks about StartupCPUShares=. StartupCPUShares= is available on systemd 213. > > > > My system is Tizen, and the systemd version is 212 now. ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] systemd-nspawn /dev/pts/multi/user missing with centos7
Hi, i try to a centos7 (bootstrapped with yum) system with systemd-nspawn (systemd-nspawn -D centos7 -b) on opensuse 13.2 This works basically, but there are some problems: 1. remove pam_loginuid from /etc/pam.d/login 2. add https://github.com/systemd/systemd/blob/master/units/container-ge...@.service.m4.in to the centos system to get machinectl login workinh 3. remove /etc/securetty to get *working* ssh access (without after some seconds, a login screen was displayed) now i only have this[1] error message which spams the journal, any ideas how to solve? egards Flo [1] Nov 19 13:17:47 centos7 systemd[1]: Started Container Getty on /dev/pts/multi/user. Nov 19 13:17:47 centos7 agetty[763]: /dev/pts/multi/user: No such file or directory Nov 19 13:17:57 centos7 systemd[1]: container-getty@multi-user.service holdoff time over, scheduling restart. Nov 19 13:17:57 centos7 systemd[1]: Stopping Container Getty on /dev/pts/multi/user... Nov 19 13:17:57 centos7 systemd[1]: Starting Container Getty on /dev/pts/multi/user... Nov 19 13:17:57 centos7 systemd[1]: Started Container Getty on /dev/pts/multi/user. Nov 19 13:17:57 centos7 agetty[764]: /dev/pts/multi/user: No such file or directory Nov 19 13:18:07 centos7 systemd[1]: container-getty@multi-user.service holdoff time over, scheduling restart. Nov 19 13:18:07 centos7 systemd[1]: Stopping Container Getty on /dev/pts/multi/user... Nov 19 13:18:07 centos7 systemd[1]: Starting Container Getty on /dev/pts/multi/user... Nov 19 13:18:07 centos7 systemd[1]: Started Container Getty on /dev/pts/multi/user. Nov 19 13:18:07 centos7 agetty[765]: /dev/pts/multi/user: No such file or directory Nov 19 13:18:17 centos7 systemd[1]: container-getty@multi-user.service holdoff time over, scheduling restart. Nov 19 13:18:17 centos7 systemd[1]: Stopping Container Getty on /dev/pts/multi/user... Nov 19 13:18:17 centos7 systemd[1]: Starting Container Getty on /dev/pts/multi/user... Nov 19 13:18:17 centos7 systemd[1]: Started Container Getty on /dev/pts/multi/user. Nov 19 13:18:17 centos7 agetty[766]: /dev/pts/multi/user: No such file or directory Nov 19 13:18:27 centos7 systemd[1]: container-getty@multi-user.service holdoff time over, scheduling restart. Nov 19 13:18:27 centos7 systemd[1]: Stopping Container Getty on /dev/pts/multi/user... Nov 19 13:18:27 centos7 systemd[1]: Starting Container Getty on /dev/pts/multi/user... Nov 19 13:18:27 centos7 systemd[1]: Started Container Getty on /dev/pts/multi/user. Nov 19 13:18:27 centos7 agetty[767]: /dev/pts/multi/user: No such file or directory Nov 19 13:18:33 centos7 login[31]: pam_unix(login:session): session closed for user root ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] This patch solves the bug 52630 described here: https://bugs.freedesktop.org/show_bug.cgi?id=52630 .
Hi, Is there any chance that someone can validate this fix? I tested the patch against systemd-215 present in Debian testing, but can't test it with the current version. However, the patch is very simple and should work with the latest version. Also, the bug involved is pretty important for cryptsetup / dm-crypt users, so it would be nice to validate the patch. Sorry to insist. Best regards, Quentin Le 18/11/2014 15:54, qlefebvre_...@yahoo.com a écrit : From: Quentin Lefebvre For plain dm-crypt devices, the behavior of cryptsetup package is to ignore the hash algorithm when a key file is provided. With this patch, systemd-cryptsetup now behaves as cryptsetup, so that old plain dm-crypt devices created with cryptsetup can be mounted at boot time by systemd, with no modification of /etc/crypttab. --- src/cryptsetup/cryptsetup.c | 5 + 1 file changed, 5 insertions(+) diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index 94570eb..88626da 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -403,6 +403,11 @@ static int attach_luks_or_plain(struct crypt_device *cd, } else params.hash = "ripemd160"; +/* for CRYPT_PLAIN, the behavior of cryptsetup package + * is to ignore the hash algorithm when a key file is provided */ +if (key_file) +params.hash = NULL; + if (arg_cipher) { size_t l; ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/1] sd-dhcp-lease: fix copy-paste error asserting wrong function argument
Applied. Thanks! On Wed, Nov 19, 2014 at 1:57 PM, Thomas Haller wrote: > --- > src/libsystemd-network/sd-dhcp-lease.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/libsystemd-network/sd-dhcp-lease.c > b/src/libsystemd-network/sd-dhcp-lease.c > index f046ac5..3da71a2 100644 > --- a/src/libsystemd-network/sd-dhcp-lease.c > +++ b/src/libsystemd-network/sd-dhcp-lease.c > @@ -51,7 +51,7 @@ int sd_dhcp_lease_get_address(sd_dhcp_lease *lease, struct > in_addr *addr) { > > int sd_dhcp_lease_get_lifetime(sd_dhcp_lease *lease, uint32_t *lifetime) { > assert_return(lease, -EINVAL); > -assert_return(lease, -EINVAL); > +assert_return(lifetime, -EINVAL); > > *lifetime = lease->lifetime; > > -- > 1.9.3 > > ___ > 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] Type=simple and BusName=
Hi, Quote from man service: BusName= Takes a D-Bus bus name that this service is reachable as. This option is mandatory for services where Type= is set to dbus, but its use is otherwise recommended if the process takes a name on the D-Bus bus. Why it is recommended? If you have Type=simple and BusName= then you are getting a warning: systemd[1]: umut.service has a D-Bus service name specified, but is not of type dbus. Ignoring. Should we fix the man page or fix the warning? Umut ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH 1/1] sd-dhcp-lease: fix copy-paste error asserting wrong function argument
--- src/libsystemd-network/sd-dhcp-lease.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index f046ac5..3da71a2 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -51,7 +51,7 @@ int sd_dhcp_lease_get_address(sd_dhcp_lease *lease, struct in_addr *addr) { int sd_dhcp_lease_get_lifetime(sd_dhcp_lease *lease, uint32_t *lifetime) { assert_return(lease, -EINVAL); -assert_return(lease, -EINVAL); +assert_return(lifetime, -EINVAL); *lifetime = lease->lifetime; -- 1.9.3 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] plans/roadmap for mdns support in resolved
2014-11-19 1:32 GMT+03:00 Lennart Poettering : > Yeah, that should just work already. LLMNR uses single-label names, > hence resolving the unqualified hostname of local link-local peers > should "just work" if resolved and nss-resolve are used. > Thats fine. > Note that link-local ipv6 addresses for the name resolution stuff > aren't fun to use in Linux right now, as the glibc NSS eats up the > scopeid, when a client wants to resolve a hostname and specifies an > address family. THis has the effect that resolving to link-local IPv6 > addresses via "ssh" will just work (since ssh makes no restrictions on > the address family when resolving the hostname), but via "ping6" will > actually fail (since ping6 specifies AF_INET6 as address family...). Hm I need very specific use-case. I have eth0, eth1, dummy0 with ipv6 addresses in different nets and i need to assign hostname to dummy0 address, that can be reacheable via eth0 or eth1 =). Does this possible? -- Vasiliy Tolstov, e-mail: v.tols...@selfip.ru jabber: v...@selfip.ru ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH v2 1/2] utf8: intruduce utf8_escape_non_printable
Hi On Wed, Nov 12, 2014 at 11:49 AM, WaLyong Cho wrote: > --- > src/shared/utf8.c| 39 +++ > src/shared/utf8.h| 1 + > src/test/test-utf8.c | 25 + > 3 files changed, 65 insertions(+) > > diff --git a/src/shared/utf8.c b/src/shared/utf8.c > index 8702ceb..0b6c38e 100644 > --- a/src/shared/utf8.c > +++ b/src/shared/utf8.c > @@ -212,6 +212,45 @@ char *utf8_escape_invalid(const char *str) { > return p; > } > > +char *utf8_escape_non_printable(const char *str) { > +char *p, *s; > + > +assert(str); > + > +p = s = malloc(strlen(str) * 4 + 1); > +if (!p) > +return NULL; > + > +while (*str) { > +int len; > + > +len = utf8_encoded_valid_unichar(str); > +if (len > 0) { > +if (utf8_is_printable(str, len)) { > +s = mempcpy(s, str, len); > +str += len; > +} else { > +if ((*str < ' ') || (*str >= 127)) { > +*(s++) = '\\'; > +*(s++) = 'x'; > +*(s++) = hexchar((int) *str >> 4); > +*(s++) = hexchar((int) *str); > +} else > +*(s++) = *str; > + > +str += 1; This part is wrong. You cannot rely on ``*str'' to be the correct Unicode value for the character. utf8_is_printable() returns false also for multi-byte UTF8 characters. By taking it unmodified, it will include the UTF8 management bits, which we really don't want here. If you really want this, I'd prefer if you decode each UTF8 character, and if it is non-printable you print "\uABCD" or "\UABCDWXYZ" (like C++ does) as a 6-byte or 10-byte sequence. Other characters are just printed normally. Thanks David > +} > +} else { > +s = mempcpy(s, UTF8_REPLACEMENT_CHARACTER, > strlen(UTF8_REPLACEMENT_CHARACTER)); > +str += 1; > +} > +} > + > +*s = '\0'; > + > +return p; > +} > + > char *ascii_is_valid(const char *str) { > const char *p; > > diff --git a/src/shared/utf8.h b/src/shared/utf8.h > index c087995..1fe1a35 100644 > --- a/src/shared/utf8.h > +++ b/src/shared/utf8.h > @@ -30,6 +30,7 @@ > const char *utf8_is_valid(const char *s) _pure_; > char *ascii_is_valid(const char *s) _pure_; > char *utf8_escape_invalid(const char *s); > +char *utf8_escape_non_printable(const char *str); > > bool utf8_is_printable_newline(const char* str, size_t length, bool newline) > _pure_; > _pure_ static inline bool utf8_is_printable(const char* str, size_t length) { > diff --git a/src/test/test-utf8.c b/src/test/test-utf8.c > index b7d988f..6dde63c 100644 > --- a/src/test/test-utf8.c > +++ b/src/test/test-utf8.c > @@ -66,12 +66,37 @@ static void test_utf8_escaping(void) { > assert_se(utf8_is_valid(p3)); > } > > +static void test_utf8_escaping_printable(void) { > +_cleanup_free_ char *p1, *p2, *p3, *p4, *p5; > + > +p1 = utf8_escape_non_printable("goo goo goo"); > +puts(p1); > +assert_se(utf8_is_valid(p1)); > + > +p2 = utf8_escape_non_printable("\341\204\341\204"); > +puts(p2); > +assert_se(utf8_is_valid(p2)); > + > +p3 = utf8_escape_non_printable("\341\204"); > +puts(p3); > +assert_se(utf8_is_valid(p3)); > + > +p4 = > utf8_escape_non_printable("ąę\n가너도루\n1234\n\341\204\341\204\n\001 \019\20\a"); > +puts(p4); > +assert_se(utf8_is_valid(p4)); > + > +p5 = utf8_escape_non_printable("\001 \019\20\a"); > +puts(p5); > +assert_se(utf8_is_valid(p5)); > +} > + > int main(int argc, char *argv[]) { > test_utf8_is_valid(); > test_utf8_is_printable(); > test_ascii_is_valid(); > test_utf8_encoded_valid_unichar(); > test_utf8_escaping(); > +test_utf8_escaping_printable(); > > return 0; > } > -- > 1.9.3 > > ___ > 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] [PATCH] systemd: Fix wrong timestamps in rtc-in-local time mode.
systemd generates some timestamps before the very first call of settimeofday(). When we are in rtc-in-local time mode, these timestamps are wrong. Affected timestamps are: Kernel, InitRD, Userspace, SecurityStart, SecurityFinish In this patch, adjustments are applied after the very first call. Before applying this patch: $ last hch tty1 Wed Nov 19 15:39 still logged in reboot system boot 3.16.0-4-amd64 Wed Nov 19 23:39 - 15:40 (-7:-59) ... $ systemctl show ... FirmwareTimestampMonotonic=0 LoaderTimestampMonotonic=0 KernelTimestamp=Wed 2014-11-19 23:39:10 CST KernelTimestampMonotonic=0 InitRDTimestampMonotonic=0 UserspaceTimestamp=Wed 2014-11-19 23:39:13 CST UserspaceTimestampMonotonic=2707714 FinishTimestamp=Wed 2014-11-19 15:39:25 CST FinishTimestampMonotonic=14463839 SecurityStartTimestamp=Wed 2014-11-19 23:39:13 CST SecurityStartTimestampMonotonic=2710030 SecurityFinishTimestamp=Wed 2014-11-19 23:39:13 CST SecurityFinishTimestampMonotonic=2721209 ... After applying this patch: $ last hch tty1 Wed Nov 19 15:43 still logged in reboot system boot 3.16.0-4-amd64 Wed Nov 19 15:43 - 15:43 (00:00) ... $ systemctl show ... FirmwareTimestampMonotonic=0 LoaderTimestampMonotonic=0 KernelTimestamp=Wed 2014-11-19 15:42:57 CST KernelTimestampMonotonic=0 InitRDTimestampMonotonic=0 UserspaceTimestamp=Wed 2014-11-19 15:43:00 CST UserspaceTimestampMonotonic=2862393 FinishTimestamp=Wed 2014-11-19 15:43:13 CST FinishTimestampMonotonic=15647941 SecurityStartTimestamp=Wed 2014-11-19 15:43:00 CST SecurityStartTimestampMonotonic=2864772 SecurityFinishTimestamp=Wed 2014-11-19 15:43:00 CST SecurityFinishTimestampMonotonic=2875854 ... --- src/core/main.c| 11 ++- src/shared/time-util.c | 14 ++ src/shared/time-util.h | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/core/main.c b/src/core/main.c index 64acdf7..86af1e5 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1318,8 +1318,17 @@ int main(int argc, char *argv[]) { r = clock_set_timezone(&min); if (r < 0) log_error("Failed to apply local time delta, ignoring: %s", strerror(-r)); -else +else { log_info("RTC configured in localtime, applying delta of %i minutes to system time.", min); + +/* Fix timestamps generated before the very first call. */ +dual_timestamp_warp(&kernel_timestamp, min); + dual_timestamp_warp(&userspace_timestamp, min); +if(in_initrd()) + dual_timestamp_warp(&initrd_timestamp, min); + dual_timestamp_warp(&security_start_timestamp, min); + dual_timestamp_warp(&security_finish_timestamp, min); +} } else if (!in_initrd()) { /* * Do a dummy very first call to seal the kernel's time warp magic. diff --git a/src/shared/time-util.c b/src/shared/time-util.c index d3404af..f323835 100644 --- a/src/shared/time-util.c +++ b/src/shared/time-util.c @@ -88,6 +88,20 @@ dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u) { return ts; } +dual_timestamp* dual_timestamp_warp(dual_timestamp *ts, int min) { +usec_t d; +if (min >= 0) { +d = min * USEC_PER_MINUTE; +ts->realtime = +ts->realtime > d ? +ts->realtime - d : 0; +} else { +d = (-min) * USEC_PER_MINUTE; +ts->realtime = ts->realtime + d; +} +return ts; +} + usec_t timespec_load(const struct timespec *ts) { assert(ts); diff --git a/src/shared/time-util.h b/src/shared/time-util.h index b55a660..8c09963 100644 --- a/src/shared/time-util.h +++ b/src/shared/time-util.h @@ -74,6 +74,7 @@ usec_t now(clockid_t clock); dual_timestamp* dual_timestamp_get(dual_timestamp *ts); dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u); dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u); +dual_timestamp* dual_timestamp_warp(dual_timestamp *ts, int min); static inline bool dual_timestamp_is_set(dual_timestamp *ts) { return ((ts->realtime > 0 && ts->realtime != USEC_INFINITY) || -- 2.1.3 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [RFC 4/4] add remote-fs dependencies if needed after change
On Thu, Nov 06, 2014 at 09:11:03PM -0800, Chris Leech wrote: > It it not working for -o remount,_netdev. But that looks like a > libmount issue in that the ROOT field is not being set in utab on a > remount, so if the initial mount did not require a utab entry then > remount options never get merge in properly in mnt_table_parse_mtab Fixed in util-linux git tree. Thanks. Karel -- Karel Zak http://karelzak.blogspot.com ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH 2/4] util: add functions getting proc status, maps, limits, cgroup
--- src/shared/util.c| 13 + src/shared/util.h| 4 src/test/test-util.c | 17 + 3 files changed, 34 insertions(+) diff --git a/src/shared/util.c b/src/shared/util.c index 0166052..d62d90c 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -892,6 +892,19 @@ int get_process_root(pid_t pid, char **root) { return get_process_link_contents(p, root); } +#define DEFINE_FN_GET_PROCESS_FULL_FILE(name) \ +int get_process_##name(pid_t pid, char **name) { \ +const char *p; \ +assert(pid >= 0); \ +p = procfs_file_alloca(pid, #name); \ +return read_full_file(p, name, /*size*/NULL); \ +} + +DEFINE_FN_GET_PROCESS_FULL_FILE(status) +DEFINE_FN_GET_PROCESS_FULL_FILE(maps) +DEFINE_FN_GET_PROCESS_FULL_FILE(limits) +DEFINE_FN_GET_PROCESS_FULL_FILE(cgroup) + char *strnappend(const char *s, const char *suffix, size_t b) { size_t a; char *r; diff --git a/src/shared/util.h b/src/shared/util.h index fc59481..2c9e4fe 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -297,6 +297,10 @@ int get_process_gid(pid_t pid, gid_t *gid); int get_process_capeff(pid_t pid, char **capeff); int get_process_cwd(pid_t pid, char **cwd); int get_process_root(pid_t pid, char **root); +int get_process_status(pid_t pid, char **status); +int get_process_maps(pid_t pid, char **maps); +int get_process_limits(pid_t pid, char **limits); +int get_process_cgroup(pid_t pid, char **cgroup); char hexchar(int x) _const_; int unhexchar(char c) _const_; diff --git a/src/test/test-util.c b/src/test/test-util.c index 7bf8ff6..f7c0210 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -491,6 +491,7 @@ static void test_u64log2(void) { static void test_get_process_comm(void) { struct stat st; _cleanup_free_ char *a = NULL, *c = NULL, *d = NULL, *f = NULL, *i = NULL, *cwd = NULL, *root = NULL; +_cleanup_free_ char *s = NULL, *l = NULL, *m = NULL, *cg = NULL; unsigned long long b; pid_t e; uid_t u; @@ -543,6 +544,22 @@ static void test_get_process_comm(void) { assert_se(r >= 0 || r == -EACCES); log_info("pid1 root: '%s'", root); +r = get_process_status(me, &s); +assert_se(r >= 0 || r == -EACCES); +log_info("pid1 strlen(status): '%zd'", strlen(s)); + +r = get_process_maps(me, &m); +assert_se(r >= 0 || r == -EACCES); +log_info("pid1 strlen(maps): '%zd'", strlen(m)); + +r = get_process_limits(me, &l); +assert_se(r >= 0 || r == -EACCES); +log_info("pid1 strlen(limits): '%zd'", strlen(l)); + +r = get_process_cgroup(me, &cg); +assert_se(r >= 0 || r == -EACCES); +log_info("pid1 strlen(cgroup): '%zd'", strlen(cg)); + assert_se(get_ctty_devnr(1, &h) == -ENOENT); getenv_for_pid(1, "PATH", &i); -- 1.8.3.1 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH 1/4] util: add functions getting proc cwd and root
/proc/[pid]/cwd and /proc/[pid]/root are symliks to corresponding directories The added functions returns values of that symlinks. --- src/shared/util.c| 39 +++ src/shared/util.h| 2 ++ src/test/test-util.c | 13 - 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/shared/util.c b/src/shared/util.c index eeced47..0166052 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -797,19 +797,30 @@ int get_process_capeff(pid_t pid, char **capeff) { return get_status_field(p, "\nCapEff:", capeff); } +static int get_process_link_contents(const char *proc_file, char **name) { +int r; + +assert(proc_file); +assert(name); + +r = readlink_malloc(proc_file, name); +if (r < 0) +return r == -ENOENT ? -ESRCH : r; + +return 0; +} + int get_process_exe(pid_t pid, char **name) { const char *p; char *d; int r; assert(pid >= 0); -assert(name); p = procfs_file_alloca(pid, "exe"); - -r = readlink_malloc(p, name); +r = get_process_link_contents(p, name); if (r < 0) -return r == -ENOENT ? -ESRCH : r; +return r; d = endswith(*name, " (deleted)"); if (d) @@ -861,6 +872,26 @@ int get_process_gid(pid_t pid, gid_t *gid) { return get_process_id(pid, "Gid:", gid); } +int get_process_cwd(pid_t pid, char **cwd) { +const char *p; + +assert(pid >= 0); + +p = procfs_file_alloca(pid, "cwd"); + +return get_process_link_contents(p, cwd); +} + +int get_process_root(pid_t pid, char **root) { +const char *p; + +assert(pid >= 0); + +p = procfs_file_alloca(pid, "root"); + +return get_process_link_contents(p, root); +} + char *strnappend(const char *s, const char *suffix, size_t b) { size_t a; char *r; diff --git a/src/shared/util.h b/src/shared/util.h index 835fee4..fc59481 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -295,6 +295,8 @@ int get_process_exe(pid_t pid, char **name); int get_process_uid(pid_t pid, uid_t *uid); int get_process_gid(pid_t pid, gid_t *gid); int get_process_capeff(pid_t pid, char **capeff); +int get_process_cwd(pid_t pid, char **cwd); +int get_process_root(pid_t pid, char **root); char hexchar(int x) _const_; int unhexchar(char c) _const_; diff --git a/src/test/test-util.c b/src/test/test-util.c index 01b0192..7bf8ff6 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -490,13 +490,14 @@ static void test_u64log2(void) { static void test_get_process_comm(void) { struct stat st; -_cleanup_free_ char *a = NULL, *c = NULL, *d = NULL, *f = NULL, *i = NULL; +_cleanup_free_ char *a = NULL, *c = NULL, *d = NULL, *f = NULL, *i = NULL, *cwd = NULL, *root = NULL; unsigned long long b; pid_t e; uid_t u; gid_t g; dev_t h; int r; +pid_t me; if (stat("/proc/1/comm", &st) == 0) { assert_se(get_process_comm(1, &a) >= 0); @@ -532,6 +533,16 @@ static void test_get_process_comm(void) { log_info("pid1 gid: "GID_FMT, g); assert_se(g == 0); +me = getpid(); + +r = get_process_cwd(me, &cwd); +assert_se(r >= 0 || r == -EACCES); +log_info("pid1 cwd: '%s'", cwd); + +r = get_process_root(me, &root); +assert_se(r >= 0 || r == -EACCES); +log_info("pid1 root: '%s'", root); + assert_se(get_ctty_devnr(1, &h) == -ENOENT); getenv_for_pid(1, "PATH", &i); -- 1.8.3.1 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH 4/4] coredump: collect all /proc data useful for bug reporting
/proc/[pid]: - status - maps - limits - cgroup - cwd - root - environ - fd/ & fdinfo/ joined in open_fds --- src/journal/coredump.c | 137 - 1 file changed, 135 insertions(+), 2 deletions(-) diff --git a/src/journal/coredump.c b/src/journal/coredump.c index 26a2010..1b04105 100644 --- a/src/journal/coredump.c +++ b/src/journal/coredump.c @@ -461,18 +461,87 @@ static int allocate_journal_field(int fd, size_t size, char **ret, size_t *ret_s return 0; } +/* Joins /proc/[pid]/fd/ and /proc/[pid]/fdinfo/ into the following lines: + * + * 0:/dev/pts/23 + * pos:0 + * flags: 012 + * 1:/dev/pts/23 + * pos:0 + * flags: 012 + * 2:/dev/pts/23 + * + */ +static int compose_open_fds(pid_t pid, char **open_fds) { +const char *fd_name = NULL, *fdinfo_name = NULL; +char *outcome = NULL; +size_t len = 0, allocated = 0; +char line[LINE_MAX]; +unsigned fd = 0; +int r = 0; + +assert(pid >= 0); + +fd_name = alloca(strlen("/proc//fd/") + DECIMAL_STR_MAX(pid_t) + DECIMAL_STR_MAX(unsigned) + 1); +fdinfo_name = alloca(strlen("/proc//fdinfo/") + DECIMAL_STR_MAX(pid_t) + DECIMAL_STR_MAX(unsigned) + 1); + +while (fd <= 9) { +_cleanup_free_ char *name = NULL; +_cleanup_fclose_ FILE *fdinfo = NULL; + +sprintf((char *)fd_name, "/proc/"PID_FMT"/fd/%u", pid, fd); +r = readlink_malloc(fd_name, &name); +if (r < 0) { +if (r == -ENOENT) { +*open_fds = outcome; +r = 0; +} +else +free(outcome); + +break; +} + +if (!GREEDY_REALLOC(outcome, allocated, len + strlen(name) + DECIMAL_STR_MAX(unsigned) + 3)) +return -ENOMEM; + +len += sprintf(outcome + len, "%u:%s\n", fd, name); +++fd; + +sprintf((char *)fdinfo_name, "/proc/"PID_FMT"/fdinfo/%u", pid, fd); +fdinfo = fopen(fdinfo_name, "r"); +if (fdinfo == NULL) +continue; + +while(fgets(line, sizeof(line), fdinfo) != NULL) { +if (!GREEDY_REALLOC(outcome, allocated, len + strlen(line) + 2)) +return -ENOMEM; + +len += sprintf(outcome + len, "%s", line); +if (strchr(line, '\n') == NULL) { +outcome[len++] = '\n'; +outcome[len] = '\0'; +} +} +} + +return r; +} + int main(int argc, char* argv[]) { _cleanup_free_ char *core_pid = NULL, *core_uid = NULL, *core_gid = NULL, *core_signal = NULL, *core_timestamp = NULL, *core_comm = NULL, *core_exe = NULL, *core_unit = NULL, *core_session = NULL, *core_message = NULL, *core_cmdline = NULL, *coredump_data = NULL, -*core_slice = NULL, *core_cgroup = NULL, *core_owner_uid = NULL, +*core_slice = NULL, *core_cgroup = NULL, *core_owner_uid = NULL, *core_open_fds = NULL, +*core_proc_status = NULL, *core_proc_maps = NULL, *core_proc_limits = NULL, *core_proc_cgroup = NULL, +*core_cwd = NULL, *core_root = NULL, *core_environ = NULL, *exe = NULL, *comm = NULL, *filename = NULL; const char *info[_INFO_LEN]; _cleanup_close_ int coredump_fd = -1; -struct iovec iovec[18]; +struct iovec iovec[26]; off_t coredump_size; int r, j = 0; uid_t uid, owner_uid; @@ -638,6 +707,70 @@ int main(int argc, char* argv[]) { IOVEC_SET_STRING(iovec[j++], core_cgroup); } +if (compose_open_fds(pid, &t) >= 0) { +core_open_fds = strappend("COREDUMP_OPEN_FDS=", t); +free(t); + +if (core_open_fds) +IOVEC_SET_STRING(iovec[j++], core_open_fds); +} + +if (get_process_status(pid, &t) >= 0) { +core_proc_status = strappend("COREDUMP_PROC_STATUS=", t); +free(t); + +if (core_proc_status) +IOVEC_SET_STRING(iovec[j++], core_proc_status); +} + +if (get_process_maps(pid, &t) >= 0) { +core_proc_maps = strappend("COREDUMP_PROC_MAPS=", t); +free(t); + +if (core_proc_maps) +IOVEC_SET_STRING(iovec[j++], core_proc_maps); +} + +if (get_process_limits(pid, &t) >= 0) { +core_proc_limits = strappend("COREDUMP_PROC_LIMITS=", t); +free(t); + +if (core_proc_limits) +
[systemd-devel] [PATCH 0/4] coredump: add journal fields useful for bug reporting
Hello, these patches add several new fields to systemd-coredump journal messages. The added fields should enable ABRT to report core files from systemd-journald to various bug tracking systems. The added fields: - COREDUMP_PROC_STATUS : a copy of /proc/[pid]/status - COREDUMP_PROC_MAPS : a copy of /proc/[pid]/maps - COREDUMP_PROC_LIMITS : a copy of /proc/[pid]/limits - COREDUMP_PROC_CGROUP : a copy of /proc/[pid]/cgroup - COREDUMP_ENVIRON : an escaped copy of /proc/[pid]/environ - COREDUMP_CWD : readlink /proc/[pid]/cwd - COREDUMP_ROOT: readlink /proc/[pid]/root - COREDUMP_OPEN_FDS: readlink /proc/[pid]/fd/* + /proc/[pid]/fdinfo/* Except COREDUMP_OPEN_FDS, the functions getting contents of the fields are added to util.c, because I think these functions can be reused. COREDUMP_OPEN_FDS filed is something special, hence I added it to journal/coredump.c I split the patch set into four patches to better comprehend my intentions. There was a short discussion about this topic in September: http://lists.freedesktop.org/archives/systemd-devel/2014-September/022864.html Jakub Filak (4): util: add functions getting proc cwd and root util: add functions getting proc status, maps, limits, cgroup util: add function getting proc environ coredump: collect all /proc data useful for bug reporting src/journal/coredump.c | 137 +++- src/shared/util.c | 212 +++-- src/shared/util.h | 7 ++ src/test/test-util.c | 34 +++- 4 files changed, 326 insertions(+), 64 deletions(-) -- 1.8.3.1 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH 3/4] util: add function getting proc environ
On the contrary of env, the added function returns all characters cescaped, because it improves reproducibility. --- src/shared/util.c| 160 +-- src/shared/util.h| 1 + src/test/test-util.c | 6 +- 3 files changed, 109 insertions(+), 58 deletions(-) diff --git a/src/shared/util.c b/src/shared/util.c index d62d90c..448efa5 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -174,6 +174,69 @@ char* first_word(const char *s, const char *word) { return (char*) p; } +static size_t cescape_char(char c, char *buf) { +char * buf_old = buf; + +switch (c) { + +case '\a': +*(buf++) = '\\'; +*(buf++) = 'a'; +break; +case '\b': +*(buf++) = '\\'; +*(buf++) = 'b'; +break; +case '\f': +*(buf++) = '\\'; +*(buf++) = 'f'; +break; +case '\n': +*(buf++) = '\\'; +*(buf++) = 'n'; +break; +case '\r': +*(buf++) = '\\'; +*(buf++) = 'r'; +break; +case '\t': +*(buf++) = '\\'; +*(buf++) = 't'; +break; +case '\v': +*(buf++) = '\\'; +*(buf++) = 'v'; +break; +case '\\': +*(buf++) = '\\'; +*(buf++) = '\\'; +break; +case '"': +*(buf++) = '\\'; +*(buf++) = '"'; +break; +case '\'': +*(buf++) = '\\'; +*(buf++) = '\''; +break; + +default: +/* For special chars we prefer octal over + * hexadecimal encoding, simply because glib's + * g_strescape() does the same */ +if ((c < ' ') || (c >= 127)) { +*(buf++) = '\\'; +*(buf++) = octchar((unsigned char) c >> 6); +*(buf++) = octchar((unsigned char) c >> 3); +*(buf++) = octchar((unsigned char) c); +} else +*(buf++) = c; +break; +} + +return buf - buf_old; +} + int close_nointr(int fd) { assert(fd >= 0); @@ -905,6 +968,45 @@ DEFINE_FN_GET_PROCESS_FULL_FILE(maps) DEFINE_FN_GET_PROCESS_FULL_FILE(limits) DEFINE_FN_GET_PROCESS_FULL_FILE(cgroup) +int get_process_environ(pid_t pid, char **environ) { +_cleanup_fclose_ FILE *f = NULL; +_cleanup_free_ char *outcome = NULL; +int c; +const char *p; +char escaped[4]; +size_t allocated = 0, sz = 0, escaped_len = 0; + +assert(pid >= 0); +assert(environ); + +p = procfs_file_alloca(pid, "environ"); + +f = fopen(p, "re"); +if (!f) +return -errno; + +while ((c = fgetc(f)) != EOF) { +if (c == '\0') { +escaped[0] = '\n'; +escaped_len = 1; +} +else +escaped_len = cescape_char(c, escaped); + +if (!GREEDY_REALLOC(outcome, allocated, sz + escaped_len + 1)) +return -ENOMEM; + +memcpy(outcome + sz, escaped, escaped_len); +sz += escaped_len; +} + +outcome[sz] = '\0'; +*environ = outcome; +outcome = NULL; + +return 0; +} + char *strnappend(const char *s, const char *suffix, size_t b) { size_t a; char *r; @@ -1284,63 +1386,7 @@ char *cescape(const char *s) { return NULL; for (f = s, t = r; *f; f++) - -switch (*f) { - -case '\a': -*(t++) = '\\'; -*(t++) = 'a'; -break; -case '\b': -*(t++) = '\\'; -*(t++) = 'b'; -break; -case '\f': -*(t++) = '\\'; -*(t++) = 'f'; -break; -case '\n': -*(t++) = '\\'; -*(t++) = 'n'; -break; -case '\r': -*(t++) = '\\'; -*(t++) = 'r'; -
[systemd-devel] Hosts without /etc/machine-id on boot
Hey, Some other topic related to "empty /etc" discussions: when preparing some generic distro images, we are have the desire to ensure that all new instances will get a different /etc/machine-id file. As part of the empty /etc at boot, we first thought that removing /etc/machine-id would be sufficient, however, the instance then doesn't generate a new machine-id file and complain heavily. The new debug message of systemd 216+ helped shading some lights on it: http://cgit.freedesktop.org/systemd/systemd-stable/diff/src/core/machine-id-setup.c?h=v216-stable&id=896050eeb3acbf4106d71204a5173b4984cf1675, and adding debug statement in machine_id_setup() from src/core/machine-id-setup.c just before "open(etc_machine_id, O_RDWR|O_CREAT|O_CLOEXEC|O_NOCTTY, 0444)" explains what happens with /proc/mounts: [2.119041] systemd[1]: rootfs / rootfs rw [2.126775] systemd[1]: /dev/disk/by-uuid/ec8166e5-d5ed-45ec-b350-6cf5773904ac / ext4 ro,relatime,data=ordered It's clear then that at this stage of the boot process / is readonly. The error message (and code) will say that in this case, what is supported is an empty /etc/machine-id. After reboot, the consequence is that /etc/machine-id is mounted as a tmpfs: tmpfs on /etc/machine-id type tmpfs (ro,relatime,size=204948k,mode=755) However, this means is that each boot of this instance will result in a different machine-id, which isn't what is desired in the empty /etc case after a factory reset. I know that there is the utility systemd-machine-id-setup that we are running on systemd postinst in debian/ubuntu, but that doesn't cover the factory reset one. Is there anything obvious that I'm missing to cover that case or anything in the pipe? Cheers, Didier ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH v2] localed: validate set-x11-keymap input
David Herrmann writes: > Hi > > On Fri, Nov 14, 2014 at 12:42 PM, Jan Synacek wrote: >> Try to validate the input similarly to how setxkbmap does it. Multiple >> layouts and variants can be specified, separated by a comma. Variants >> can also be left out, meaning that the user doesn't want any particular >> variant for the respective layout. >> >> Variants are validated respectively to their layouts. First variant >> validates against first layout, second variant to second layout, etc. If >> there are more entries of either layouts or variants, only their >> respective counterparts are validated, the rest is ignored. >> >> Examples: >> $ set-x11-keymap us,cz pc105 ,qwerty >> "us" is not validated, because no respective variant was specified. "cz" >> is checked for an existing "qwerty" variant, the check succeeds. >> >> $ set-x11-keymap us pc105 ,qwerty >> "us" is not validated as in the above example. The rest of the variants >> is ignored, because there are no respective layouts. >> >> $ set-x11-keymap us,cz pc105 qwerty >> "us" is validated against the "qwerty" variant, check fails, because >> there is no "qwerty" variant for the "us" layout. >> >> $ set-x11-keymap us,cz pc105 euro,qwerty >> Validation succeeds, there is the "euro" variant for the "us" layout, >> and "qwerty" variant for the "cz" layout. >> >> http://lists.freedesktop.org/archives/systemd-devel/2014-October/024411.html > > I didn't follow the discussion on v1, but why don't we use > libxkbcommon to compile the keymap? If it doesn't compile, print an > error (or warning and maybe optionally still proceed?). > > Sure, this would add a dependency to libxkbcommon for localed, but we > could make it optional. And libxkbcommon has no dependencies by > itself. Furthermore, set-x11-keymap is pretty useless without > libxkbcommon installed, anyway. > > It'd be a ~10 line patch to use > xkb_context_new()+xkb_keymap_from_rmlvo(). And it would be guaranteed > to have the same semantics as the real keymap compilation. > > Thanks > David For some reason, I was under the impression that depending on libxkbcommon would mean depending on plenty of X libraries... Using the library and making the dependency on it optional sounds like the best solution to me. Waiting for more opinions. Cheers, -- Jan Synacek Software Engineer, Red Hat signature.asc Description: PGP signature ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel