Re: [systemd-devel] Moving systemd-bootchart to a standalone repository

2016-02-24 Thread Simon Peeters
2016-02-18 19:16 GMT+01:00 Lennart Poettering :
> On Thu, 18.02.16 11:32, Daniel Mack (dan...@zonque.org) wrote:
>
>> On 02/17/2016 08:02 PM, Umut Tezduyar Lindskog wrote:
>> > Hi,
>> >
>> > src/shared & src/basic have very useful code that upstream have been
>> > static linking to most binaries. My understanding is that we haven’t
>> > been feeling comfortable about the API to make these paths a
>> > standalone library (or include them in libsystemd).
>>
>> That's correct.
>>
>> > Now that we started duplicating the code outside of systemd main
>> > repo, wouldn’t it be wise to make it a library even if it was
>> > something like libsystemd_onlyandonlyinternal.so.
>> >
>> > For people who can follow upstream’s speed and catch up with API
>> > changes we would gain:
>>
>> I see your point, and that's one reason why we are not splitting out
>> more packages. Downstream deviation would be cumbersome to handle, and
>> providing API/ABI stability for a library is considered outside of the
>> scope of the systemd project. And without this guarantee, things will
>> break all the time, so that's not a win.
>>
>> In the case of bootchart, however, I believe amount of code this small
>> tool shares with the rest of systemd (from src/shared and src/basic) is
>> small enough to justify an exception. And things like lists, hashmaps
>> and trivial file parses could eventually even be solved differently,
>> with other libraries or whatever, if the maintainer decides so.
>>
>> Auke, did you have a look at the current code base of the standalone
>> repo? Does it look feasible to you?
>
> I'd be willing to explore the idea where we make src/basic a somewhat
> self-contained dir that could be imported as git submodule like gnulib
> (as suggested by Armin) by other packages. Key would be that they
> pinpoint a specific revision though, as we'd not provide API compat
> for this.
>
> Of course, we should do so only if there are actually projects IRL
> that are interested in this.

definitely, even though most of the C code I write nowadays is are toy
projects,I almost always start of by copying the shared stuff from
systemd.

I also think having these tools easily available will in general make
it more easy to write quality C code. (and reduce NIH)

> I am fine with making the code in src/basic more reusable, I am not
> very keen on establishing a fixed API for it though.
>
> Lennart
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Query regarding "EnvironmentFile"

2015-12-16 Thread Simon Peeters
2015-12-16 9:47 GMT+00:00 Reindl Harald <h.rei...@thelounge.net>:
>
>
> Am 15.12.2015 um 18:59 schrieb Simon Peeters:
>>
>> 2015-12-10 15:20 GMT+00:00 Reindl Harald <h.rei...@thelounge.net>:
>>>
>>>
>>> Am 10.12.2015 um 15:46 schrieb Jóhann B. Guðmundsson:
>>>>
>>>>
>>>> If you are unaware of any other use case for it
>>>
>>>
>>> EnvironmentFile=-/etc/sysconfig/httpd
>>> ExecStart=/usr/sbin/httpd $OPTIONS -D FOREGROUND
>>>
>>> [root@testserver:~]$ cat /etc/sysconfig/httpd
>>> OPTIONS="-D testserver"
>>>
>>> Apache:
>>> 
>>> Include "conf/local/testserver.conf"
>>> 
>>>
>>> and now you can use the same systemd-unit on a dozens of machines and
>>> include specific config snippets WITOUT touch the systemd-unit or
>>> *anything*
>>> else in the apache configuration
>>>
>>>> perhaps it's time to
>>>> start looking into obsoleting it
>>>
>>>
>>> don't get me wrong but you sound once again like seek for changes to
>>> break
>>> users configuration to later blame users why they did not fix which ain't
>>> broken
>>
>>
>> Why not do like normal people
>
>
> "normal people" - what's wrong with you?

Nothing really, all systems both at my direct employer and those at
our customers run perfectly fine, and everything is automated, so in
our relatively small team we have more than enough time left to de
some R on future and upcoming tech.

>> and use configmanagement to put the
>> right apache config on the right host?
>
>
> because i know how to configure servers and don't need handholding tools
> since i develop my own admin backends for many years and services helping on
> repeatly needed taks but don't chain me to a limited subset of the supported
> options

If you want to use your home grown configmanagement tool, then learn
it to decently manage your apache config.

>> This whole "-D testserver" and ""  looks like an
>> ugly workaround for a lacking configmanagment system.
>
>
> config managements fpr webservers are ugly workaround for lacking knowledge
> and only fine for 08/15 setups but a no-go where you need flexibility

I think a lot of people disagree with you on that, including most of
the devops world.

>> More preciesly conf/local/testserver.conf probably shouldn't even
>> exist on non testing mahines
>
>
> guess why it's in the subfolder "local"
>
>> '/etc/…/testserver.conf': ensure => absent }" in puppet
>
>
> go away with that crap - only over my dead body besides Perl, PHP and Python
> now Ruby and it's dependencies would make it to any server here

Then use something else, like ansible, which is python, or cfengine,
or juju, or any other one in this list
https://en.wikipedia.org/wiki/Comparison_of_open-source_configuration_management_software

My point being if you want to manage your apache config, manage your
apache config, intead of doing wierd workarounds with environment
variables and changing the ExecStart of your service.

In your case this is even flawed:
If the /etc/sysconfig/httpd file changes, then a systemctl reload
httpd wouldn't propagate the changes, while if you instead managed the
config directly it would.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Query regarding "EnvironmentFile"

2015-12-15 Thread Simon Peeters
2015-12-10 15:20 GMT+00:00 Reindl Harald :
>
> Am 10.12.2015 um 15:46 schrieb Jóhann B. Guðmundsson:
>>
>> If you are unaware of any other use case for it
>
>
> EnvironmentFile=-/etc/sysconfig/httpd
> ExecStart=/usr/sbin/httpd $OPTIONS -D FOREGROUND
>
> [root@testserver:~]$ cat /etc/sysconfig/httpd
> OPTIONS="-D testserver"
>
> Apache:
> 
> Include "conf/local/testserver.conf"
> 
>
> and now you can use the same systemd-unit on a dozens of machines and
> include specific config snippets WITOUT touch the systemd-unit or *anything*
> else in the apache configuration
>
>> perhaps it's time to
>> start looking into obsoleting it
>
>
> don't get me wrong but you sound once again like seek for changes to break
> users configuration to later blame users why they did not fix which ain't
> broken

Why not do like normal people and use configmanagement to put the
right apache config on the right host?
This whole "-D testserver" and ""  looks like an
ugly workaround for a lacking configmanagment system.

More preciesly conf/local/testserver.conf probably shouldn't even
exist on non testing mahines. (a simple "file {
'/etc/…/testserver.conf': ensure => absent }" in puppet or "file:
path='/etc/…/testserver.conf' state=absent" in ansable)
If you have that you could probably even hardcode an
"IncludeOptional", though i still would advice against it, and just
conditionalize the line in your configmanagement (usinge lineinfile or
so.)

Greetings

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


[systemd-devel] socket-activated containers with domain sockets

2015-05-16 Thread Simon Peeters
hej all.

I have a kind off weird setup using socket-activated containers:

nginx on the host listens on port 80 and has a 'proxy_pass
http://unix:/run/http/$host;' directive.

then I have webserver@.socket listening on 'ListenStream=/run/http/%I'
which in turn activates a container.

this works fine with the following 'nginx-container@.service'
[Service]
ExecStart=/usr/bin/systemd-nspawn --private-network
--bind=/srv/%i:/srv/http -D /var/lib/machines/nginx_base -x -M
nginx_%i /usr/bin/nginx -g 'daemon off;'

[Install]
Also=webserver@%i.socket
Alias=webserver@%i.service

witch runs a (patched) nginx as only binary in that container.

now I want to run systemd in such a container to run both nginx and nodejs.
the problem is, what should be in my 'nginx.socket' in order to pass
on that first socket systemd gets, which is a UDS outside of the
container?


greetings


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


Re: [systemd-devel] is there a plan for NIC teaming support ?

2015-03-09 Thread Simon Peeters
2015-03-05 5:41 GMT+01:00 Branko bran...@s5tehnika.net:
 I have a need to put my NICs in RAID0 so to speak, but according to
 materials I have found on net I can't use NIC bonding driver because I would
 need LACP (IEEE whatever) aware L2 switch, so I was refered to teaming
 driver, which should be ( if those folks is to be believed) replacing bond
 driver in future.

 Since systemd doesn't support teaming ( teaming module + libeteam), I had to
 scotchstape it together under systemd and it was major PITA.

 libteam doesn't seem to complicated to be included as a module in systemd,
 which should take away most of the headaches...

AFAIK (and according to wikipedia) you can also use the bonding driver
without LACP.
https://en.wikipedia.org/wiki/Link_aggregation#Driver_modes
and I don't think the teaming driver can do more without LACP than the
bonding driver can.


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


Re: [systemd-devel] Jenkins Failing and Not Updating Github Mirror

2015-01-17 Thread Simon Peeters
2015-01-18 1:28 GMT+01:00 Chris Atkinson c...@pipeline.com:
 It looks like Jenkins has been failing to build for the last three days
 and hasn't updated the Github mirror for a similar period (since commit
 435fc3176520a58f1c20ccb983c9fb40b30a1471).

 https://github.com/systemd/systemd
 http://systemd.getpantheon.com:8080/jenkins/

 Regards,

so a quick analysis:

The build initially broke on 30535c16924a3da7b47ea87190d929d617d95c5a
(nspawn: add file system locks for controlling access to container
images), due to missing kernel #defines probably triggered by an older
kernel on the jenkins machine. This was fixed in
f4a53250acb3aea2eb5ebed059887b9417afbd9e (missing: add macros for OFD
locks), but unfortunately a missing zlib dependency introduced by
edce2aed3aa93b84f7b4c70412bdb665da2977b0 (import: support importing
qcow2 images) had already broken the build again.

So the solution would be to make zlib available on the jenkins machine
(David?), or make zlib an optional dep (Lennart?).

about the github mirror not being updated: that is how David set up
the jenkins, so the github mirror is always at the latest successfully
building commit.

Greetings


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


Re: [systemd-devel] [PATCH] Fix install location of systemd.pc

2014-12-31 Thread Simon Peeters
2014-12-31 11:12 GMT+00:00 Martin Pitt martin.p...@ubuntu.com:
 Simon Peeters [2014-12-29 15:01 +]:
 I have no preference between the 2, but moving the pc file to
 $libdir/pkgconfig just does not make sense.

 Why not? pkg-config looks in both /usr/share and /usr/lib, so it
 doesn't care. And you can't install systemd for multiple architectures
 in parallel anyway, so you'd only ever have one version installed.

Let me rephrase what I wrote above that quote:

If I understand lennarts commit message, the only reason for libdir to
be in the pc file is to find the libdir for the primary arch.
moving this pc file into $libdir/pkgconfig would require you to know
the libdir for the primary arch (or at least the one systemd was
compiled for) in order to read it, so the libdir variable in the pc
file is redundant because the information it contains needs to be
known in order to read it.
So if you would move the pc file to $libdir then the libdir variable
in the pc file no longer has any purpose, so you can drop it.
Now you have a pc file in libdir without any architecture specific
data, so you could as well move it back to /usr/share

But anyway, that is only if I understand the purpose of the libdir var
in the pc file correctly.


Greetings. (and enjoy the end of 2014!)

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


Re: [systemd-devel] [PATCH] Fix install location of systemd.pc

2014-12-29 Thread Simon Peeters
2014-12-29 13:02 GMT+00:00 Martin Pitt martin.p...@ubuntu.com:
 Mike Gilbert [2014-12-28 12:41 -0500]:
 From Lennart's commit message, it seems like this was done intentionally.

 The addition of libdir was certainly intentional, that's why I didn't
 propose to just remove libdir. But it looks like this was just missing
 to adjust the install location accordingly?

just my 2c:

well, the addition of libdir was to be able to find the libdir for the
primary arch (however you might define that), moving the pc file
with this info to $libdir/pkgconfig makes that argument moot since you
need to know libdir in order to know libdir.

So if I can follow lennart correctly there are 2 possible ways:
- have libdir in the pc file in /usr/share and make it to denote the
primary arch (which is the current situation)
- not have libdir in the pc file at all and still have the pc file in
/usr/share (since libdir does not make sense if the file is in
$libdir/pkgconfig, and it is the only reason why it might not belong
in /usr/share)

I have no preference between the 2, but moving the pc file to
$libdir/pkgconfig just does not make sense.


Greetings.

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


[systemd-devel] dynamic uid allocation (was: [PATCH] loopback setup in unprivileged containers)

2014-12-29 Thread Simon Peeters
2014-12-29 14:14 GMT+00:00 Tom Gundersen t...@jklm.no:
 On Mon, Dec 29, 2014 at 2:34 PM, Lennart Poettering
 lenn...@poettering.net wrote:
snip
 I am open to adding support for this, but I think the allocation of
 the UID ranges should really happen automatically, and not be
 something the admin has to manually assign.

 Which means we'd enter dynamic UID allocation terroritory, and that
 opens a huge can of worms...

 Would we not also need to support explicit assignment, in case someone
 has a preexisting image they want to match in a specific way? In that
 case we could start off without the dynamic allocation and add that
 later. It certainly would make testing a lot simpler if we had userns
 support sooner rather than later (at least in the case of netlink it
 appears to be quite a mess).

Inspired by this topic I wrote a quick'n'dirty uid allocator[1]
this allocator manages the upper 2G uid's, which using Matthias Urlichs example
of 2048 uid's per container, still allows for 1M containers.

It curently can't persist these allocations, but that is on my 0.0.1 todolist.

You can request a uid range (or single uid) via dbus or using the command line:
# uidalloc alloc 2048
allocates a chunk of 2048 uid's

# uidalloc release ${id returned by above command}
releases the chunk again.

An allocated chunk can be accessed 2 ways:
 - using the id generated by uidallocd
 - using an alias passed by the client application
The idea is that for example systemd-nspawn could use
sd_nspawn_${machine_id_of_container} as an alias, so that when it starts
the container it checks fot the existance of that alias, and if it doesn't exist
it leases a new chunk.

Also I have written this to be generic, so that (If anybod ever uses this) it
could also be used for f.ex guest sessions, ldap users,...

if anybody wants to help out: feel free to do so.
if you are interested and have questions: shoot!

Greetings

Simon Peeters

[1] https://github.com/SimonPe/uidallocd

ps: I know the code is ugly, my terminology is wierd, and all other stuff.
If that bothers you: fix it.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] dynamic uid allocation (was: [PATCH] loopback setup in unprivileged containers)

2014-12-29 Thread Simon Peeters
2014-12-30 6:49 GMT+00:00 Simon Peeters peeters.si...@gmail.com:
 2014-12-29 14:14 GMT+00:00 Tom Gundersen t...@jklm.no:
 On Mon, Dec 29, 2014 at 2:34 PM, Lennart Poettering
 lenn...@poettering.net wrote:
 snip
 I am open to adding support for this, but I think the allocation of
 the UID ranges should really happen automatically, and not be
 something the admin has to manually assign.

 Which means we'd enter dynamic UID allocation terroritory, and that
 opens a huge can of worms...

 Would we not also need to support explicit assignment, in case someone
 has a preexisting image they want to match in a specific way? In that
 case we could start off without the dynamic allocation and add that
 later. It certainly would make testing a lot simpler if we had userns
 support sooner rather than later (at least in the case of netlink it
 appears to be quite a mess).

 Inspired by this topic I wrote a quick'n'dirty uid allocator[1]
 this allocator manages the upper 2G uid's, which using Matthias Urlichs 
 example
 of 2048 uid's per container, still allows for 1M containers.

 It curently can't persist these allocations, but that is on my 0.0.1 
 todolist.

 You can request a uid range (or single uid) via dbus or using the command 
 line:
 # uidalloc alloc 2048
 allocates a chunk of 2048 uid's

 # uidalloc release ${id returned by above command}
 releases the chunk again.

 An allocated chunk can be accessed 2 ways:
  - using the id generated by uidallocd
  - using an alias passed by the client application
 The idea is that for example systemd-nspawn could use
 sd_nspawn_${machine_id_of_container} as an alias, so that when it starts
 the container it checks fot the existance of that alias, and if it doesn't 
 exist
 it leases a new chunk.

 Also I have written this to be generic, so that (If anybod ever uses this) it
 could also be used for f.ex guest sessions, ldap users,...

 if anybody wants to help out: feel free to do so.
 if you are interested and have questions: shoot!

 Greetings

 Simon Peeters

 [1] https://github.com/SimonPe/uidallocd

 ps: I know the code is ugly, my terminology is wierd, and all other stuff.
 If that bothers you: fix it.
pps: half of the code is copied from systemd's src/shared
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Hackfest at FOSDEM 2015?

2014-11-20 Thread Simon Peeters
 Brussels. I am all for it, but we'd really need somebody to organize
 it, i.e. find a room for us.

 Anyone volunteering for this?
If nobody else steps up, I might do it, but I do have a very tight
schedule currently, so I would rather have someone else do it.
If somebody else does this and for some practical reasons a Belgian is
needed (they ask for a Belgian ID, keys have to be picked up in
advance,...) I am willing to help.

 I was wondering if we could try to find a room at the uni instead.
I think this could be possible, but I'm not sure about network
connectivity outside of FOSDEM (the network gets set up on Friday, and
torn down Sunday evening, so we wouldn't be able to rely on that).
Belgian universities (well at least the one in Ghent) tend to be very
careful about that since their provider (belnet) requires that it is
only used for researcheducation.
I also don't know whether we should do this via the FOSDEM organisers,
or contact ULB[1] directly. (In case of the later, the person doing
this might want to brush up his/her French)

 And when shall we do the hackfest? We could:

 a) do it one day before FOSDEM, i.e. Fri 27th Jan 2015
 b) do it one day after FOSDEM, i.e. Mon 2nd Feb 2015
 c) during FOSDEM?

I am in favour of a because I want to attend configmanagementcamp[2] on Monday.
(but b would allow me to volunteer for the set-up on Friday, so both
have advantages)

Greetings/Hilsen/Groeten

Simon


[1] just as a sidenote: there are 2 universities in Brussels: a Dutch
speaking, the VUB (NOT the one where FOSDEM takes place) and a French
speaking, the ULB (the one where FOSDEM takes place). Both mean Free
University of Brussels, but are completely unrelated.
[2] http://cfgmgmtcamp.eu/ which takes place at my school.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Shell expressions in EnvironmentFile

2014-10-07 Thread Simon Peeters
2014-10-07 19:12 GMT+02:00 Jon Stanley jonstan...@gmail.com:
 Since EnvironmentFile in a service isn't sourced by any shell, shell
 expressions in it will obviously not work the way that they did in a
 SysV style script.

 Nor does it seems that the environment gets preserved between
 ExecStartPre (where one could run a script that sets environment
 variables to be later used in the starting of the service) and
 ExecStart, so something like the following won't work:

Which is logical since no system exists to modify the environment of
the parent proces.

 [Service]
 ExecStartPre=/something/that/sets/var
 ExecStart=/some/file $var

ExecStart=/bin/sh -c . /something/that/sets/var; /some/file $var

in other words: If you want shell behaviour, use a shell.

 Is there some way to get dynamically determined data into the
 environment such that it can be passed to the daemon at start?


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


[systemd-devel] nss-mymachines and virtual machines

2014-09-26 Thread Simon Peeters
hej,

In the light of my linux classes i was looking into hooking up vagrant
with machined in order to be able to use nss-mymachines to resolve the
ip address on the host-only adaptor. Unfortunatly the network side of
machined seems to only work with containers (since afaik it looks for
a veth pair).

It would be nice to enable this also for virtual machines (in this
case virtualbox).

we could:
 * allow the ip and optionally interface to be specified on machine creation.
   + ensures nobody can change it once the machine is running
   - would require yet another create dbus call
 * add the ip and interface as writable properties.
   + less code, easy to use.
   - allows any system process (not only the supervisor of the
machine) to modify this information at runtime.

Any ideas on this?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] timedated: add configure option to set name of controlled NTP service

2014-08-26 Thread Simon Peeters
2014-08-26 14:37 GMT+02:00 Lennart Poettering lenn...@poettering.net:
 On Tue, 26.08.14 16:34, Andrei Borzenkov (arvidj...@gmail.com) wrote:

  I don't really think that timedated should manage an NTP server like
  ntpd/chrony. timedated's primary job is to be a service to GNOME and
  other DEs. But if an admin wants to upgrade to a full NTP server, then
  he should really enable/disable that with systemctl or a similar
  command.

 What's wrong with having standard API for querying whether NTP is
 enabled on a system? Is it better if every DE has to use home-grown
 checks multiplied by number of NTP implementations?

 We are simply not in that business. I mean, we don't provide the same
 for HTTP implementations, FTP implementations, webdav implementations,
 and so on either...

But we do for display managers, so maybe we can go the same way here:
- have al (s)ntp clients include Alias=timesync.service
- timedated uses timesync.service for:
  - checking wether ntp is enabled.
  - disabling ntp if requested.
- timedated still uses systemd-timesyncd.service to enable ntp.

I think this achieves what both sides want here:
 - it allows the admin to systemctl enable somentpd.service
 - it is quiet minimal in changes with what we have now (except the
Alias part in all other ntp service files)
 - it allows timedated to check and controll ntp even if an other ntp
server is used
(with the caveat that disable and then enable will result in
switching to systemd-timesyncd)

just my 2c, if you think it is a good way to go, i'll be happy to write a patch.


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


Re: [systemd-devel] Match section of .link file not working

2014-08-25 Thread Simon Peeters
2014-08-25 20:16 GMT+02:00 Andrei Borzenkov arvidj...@gmail.com:
 В Sun, 24 Aug 2014 21:28:51 +0200
 Simon Peeters peeters.si...@gmail.com пишет:
snip
 No, and yes. The wireless adaptor actually only exprts phy0. The
 kernel then by default creates wlan0.
 Then i use :
 # iw phy phy0 interface add wlv1 type __ap
 # iw phy phy0 interface add wlv2 type station
 To create the 2 virtual interfaces that I use. The only real
 difference is the name I give them. (and the type in this case)

 Hmm ... if you use explicit command to create them, you can also assign
 whatever MAC is required as part of interface creation, right? Or do I
 miss something here?

Well, the problem is that that is racy, because networkd tries to up
the device probably even before iw returns.
And iw doesn't support doing this in one step, I have no idea wether
the kernel does.
And this will fail, because there already exists a device with the
same mac address. So my device ends up failed from a networkd pov
and I have to restart networkd to get it configured.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Match section of .link file not working

2014-08-25 Thread Simon Peeters
2014-08-25 19:46 GMT+02:00 Kay Sievers k...@vrfy.org:
 On Mon, Aug 25, 2014 at 7:25 PM, Lennart Poettering
 lenn...@poettering.net wrote:
 On Sun, 24.08.14 06:49, Simon Peeters (peeters.si...@gmail.com) wrote:

  This should be the value of ID_PATH property, not sysfs path. Check with
 
  udevadm info --query
  property 
  /sys/devices/ocp.3/4740.usb/musb-hdrc.1.auto/usb1/1-1/1-1:1.0/net/wlv3
 
  oops, I confused ID_PATH with DEVPATH, now i feel like an idiot.

 ID_PATH is basically the reduced + stable part of the full sysfs path.

 Ok, so there is only one problem now:
 ID_PATH is the same for all my vif interfaces, and i need to select
 only one of them.

 ID_PATH usually describes the parent hardware, and the same hardware
 can have multiple independent devices. Unique names for several
 devices need to be composed by appending something to the parent
 hardware.

 I don't have a good idea what a working model for your case would be,
 where multiple devices share the same parent. This is not a common
 model.

 This is some embedded device with your hw connected to some platform
 bus?

 Currently the ID_PATH logic doesn't understand platform busses (since it
 is not clear how stable they are). This has come up before, and could
 probably be fixed. Maybe we should assume that platform busses are
 always enuemrated in a stable way, dunno.

 Kay probably has something useful to say here. Kay?

 Special buses need explicit support in the code if ID_PATH is not
 generated, but that does not look like the problem here.

 Seems the USB interface exports 3 different network devices. Do they
 have any unique property? Like dev_id, dev_port in /sys? Or are the
 types of the netifs unique?

Well, as posted earlier , these are virtual interfaces, kind of the
vlans for wifi (allows to connect ot multiple networks on a same phy).
(sory for not precise enough in the original post)
So they do not realy have something unique and stable appart from the name.

I think there are 3 posible ways to go forward:
 - fix iw (and maybe the kernel to) to support a mac address parameter
at interface creation time (so the mac is set even before udev sees
it)
 - Add vif netdev support to networkd similar to how vlans are
handled, also alowing to set the mac address.
 - Support [Match] Name= in .link files, even if it is with a large
warning, or even as an unsupported ymmv option (because names are
normaly not stable)

1. could be hard if the kernel does not support this, which i havn't
checked yet.
2. would be ideal and could also work in most cases if the kernel does
not support this in an atomic operation (since networkd can not race
with itself)
3. this would be the easy, almost lazy, way, but would also work with
wathever wierd exotic virtual device the kernel developrs come up
with.

I noted this boils down to almost the same discution there was a while
ago under the title: [systemd-devel] systemd-networkd: setting the
MAC address for a .netdev unit?[0] with the only difference that
.netdev support for vif's not yet exists. (so I do this in a separate
unit)

 If anything like that is available, that could be appended to the
 parent ID_PATH string and identify the device uniquely, if you get
 what I mean.

nah, I don't think so, I can check but the only thing i can imagine is
the name passed during creation, or maybe some sequence id, but I am
not sure wether that would be usable.

 Kay

[0] http://lists.freedesktop.org/archives/systemd-devel/2014-April/018712.html
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Match section of .link file not working

2014-08-24 Thread Simon Peeters
 Ok, so there is only one problem now:
 ID_PATH is the same for all my vif interfaces, and i need to select
 only one of them.


 Please show udevadm info -q all for each interface.

P: 
/devices/ocp/4740.usb/47401c00.usb/musb-hdrc.1.auto/usb2/2-1/2-1:1.0/net/wlan0
E: 
DEVPATH=/devices/ocp/4740.usb/47401c00.usb/musb-hdrc.1.auto/usb2/2-1/2-1:1.0/net/wlan0
E: DEVTYPE=wlan
E: ID_BUS=usb
E: ID_MODEL=USB2.0_WLAN
E: ID_MODEL_ENC=USB2.0\x20WLAN
E: ID_MODEL_FROM_DATABASE=TP-Link TL-WN821N v2 / TL-WN822N v1 802.11n
[Atheros AR9170]
E: ID_MODEL_ID=1002
E: ID_NET_DRIVER=carl9170
E: ID_NET_NAME_MAC=wlx6cfdb907b167
E: ID_OUI_FROM_DATABASE=Proware Technologies Co Ltd.
E: ID_PATH=platform-musb-hdrc.1.auto-usb-0:1:1.0
E: ID_PATH_TAG=platform-musb-hdrc_1_auto-usb-0_1_1_0
E: ID_REVISION=0106
E: ID_SERIAL=ATHER_USB2.0_WLAN_12345
E: ID_SERIAL_SHORT=12345
E: ID_TYPE=generic
E: ID_USB_CLASS_FROM_DATABASE=Vendor Specific Class
E: ID_USB_DRIVER=carl9170
E: ID_USB_INTERFACES=:ff:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_PROTOCOL_FROM_DATABASE=Vendor Specific Protocol
E: ID_USB_SUBCLASS_FROM_DATABASE=Vendor Specific Subclass
E: ID_VENDOR=ATHER
E: ID_VENDOR_ENC=ATHER
E: ID_VENDOR_FROM_DATABASE=Atheros Communications, Inc.
E: ID_VENDOR_ID=0cf3
E: IFINDEX=10
E: INTERFACE=wlan0
E: SUBSYSTEM=net
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/wlan0
E: TAGS=:systemd:
E: USEC_INITIALIZED=805171

P: 
/devices/ocp/4740.usb/47401c00.usb/musb-hdrc.1.auto/usb2/2-1/2-1:1.0/net/wlv1
E: 
DEVPATH=/devices/ocp/4740.usb/47401c00.usb/musb-hdrc.1.auto/usb2/2-1/2-1:1.0/net/wlv1
E: DEVTYPE=wlan
E: ID_BUS=usb
E: ID_MODEL=USB2.0_WLAN
E: ID_MODEL_ENC=USB2.0\x20WLAN
E: ID_MODEL_FROM_DATABASE=TP-Link TL-WN821N v2 / TL-WN822N v1 802.11n
[Atheros AR9170]
E: ID_MODEL_ID=1002
E: ID_NET_DRIVER=carl9170
E: ID_NET_NAME_MAC=wlx6cfdb907b167
E: ID_OUI_FROM_DATABASE=Proware Technologies Co Ltd.
E: ID_PATH=platform-musb-hdrc.1.auto-usb-0:1:1.0
E: ID_PATH_TAG=platform-musb-hdrc_1_auto-usb-0_1_1_0
E: ID_REVISION=0106
E: ID_SERIAL=ATHER_USB2.0_WLAN_12345
E: ID_SERIAL_SHORT=12345
E: ID_TYPE=generic
E: ID_USB_CLASS_FROM_DATABASE=Vendor Specific Class
E: ID_USB_DRIVER=carl9170
E: ID_USB_INTERFACES=:ff:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_PROTOCOL_FROM_DATABASE=Vendor Specific Protocol
E: ID_USB_SUBCLASS_FROM_DATABASE=Vendor Specific Subclass
E: ID_VENDOR=ATHER
E: ID_VENDOR_ENC=ATHER
E: ID_VENDOR_FROM_DATABASE=Atheros Communications, Inc.
E: ID_VENDOR_ID=0cf3
E: IFINDEX=11
E: INTERFACE=wlv1
E: SUBSYSTEM=net
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/wlv1
E: TAGS=:systemd:
E: USEC_INITIALIZED=113969784

P: 
/devices/ocp/4740.usb/47401c00.usb/musb-hdrc.1.auto/usb2/2-1/2-1:1.0/net/wlv2
E: 
DEVPATH=/devices/ocp/4740.usb/47401c00.usb/musb-hdrc.1.auto/usb2/2-1/2-1:1.0/net/wlv2
E: DEVTYPE=wlan
E: ID_BUS=usb
E: ID_MODEL=USB2.0_WLAN
E: ID_MODEL_ENC=USB2.0\x20WLAN
E: ID_MODEL_FROM_DATABASE=TP-Link TL-WN821N v2 / TL-WN822N v1 802.11n
[Atheros AR9170]
E: ID_MODEL_ID=1002
E: ID_NET_DRIVER=carl9170
E: ID_NET_NAME_MAC=wlx6cfdb907b167
E: ID_OUI_FROM_DATABASE=Proware Technologies Co Ltd.
E: ID_PATH=platform-musb-hdrc.1.auto-usb-0:1:1.0
E: ID_PATH_TAG=platform-musb-hdrc_1_auto-usb-0_1_1_0
E: ID_REVISION=0106
E: ID_SERIAL=ATHER_USB2.0_WLAN_12345
E: ID_SERIAL_SHORT=12345
E: ID_TYPE=generic
E: ID_USB_CLASS_FROM_DATABASE=Vendor Specific Class
E: ID_USB_DRIVER=carl9170
E: ID_USB_INTERFACES=:ff:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_PROTOCOL_FROM_DATABASE=Vendor Specific Protocol
E: ID_USB_SUBCLASS_FROM_DATABASE=Vendor Specific Subclass
E: ID_VENDOR=ATHER
E: ID_VENDOR_ENC=ATHER
E: ID_VENDOR_FROM_DATABASE=Atheros Communications, Inc.
E: ID_VENDOR_ID=0cf3
E: IFINDEX=12
E: INTERFACE=wlv2
E: SUBSYSTEM=net
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/wlv2
E: TAGS=:systemd:
E: USEC_INITIALIZED=114033988

wlv2 is a client and needs a stable mac, otherwise the dhcp f*cs up.
wlv1 is an acesspoint, and needs a mac different from wlv2. (This
should probably also be stable, but i can live with random for this
one.)
(yes, the wlv3 was just for testing, wlv1 and wlv2 are the real ones)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Match section of .link file not working

2014-08-24 Thread Simon Peeters
2014-08-24 20:29 GMT+02:00 Andrei Borzenkov arvidj...@gmail.com:
 В Sun, 24 Aug 2014 09:19:13 +0200
 Simon Peeters peeters.si...@gmail.com пишет:

  Ok, so there is only one problem now:
  ID_PATH is the same for all my vif interfaces, and i need to select
  only one of them.
 
 
  Please show udevadm info -q all for each interface.

 P: 
 /devices/ocp/4740.usb/47401c00.usb/musb-hdrc.1.auto/usb2/2-1/2-1:1.0/net/wlan0
 P: 
 /devices/ocp/4740.usb/47401c00.usb/musb-hdrc.1.auto/usb2/2-1/2-1:1.0/net/wlv1
 P: 
 /devices/ocp/4740.usb/47401c00.usb/musb-hdrc.1.auto/usb2/2-1/2-1:1.0/net/wlv2

 wlv2 is a client and needs a stable mac, otherwise the dhcp f*cs up.
 wlv1 is an acesspoint, and needs a mac different from wlv2. (This
 should probably also be stable, but i can live with random for this
 one.)

 So you have single device that exports multiple interfaces.
No, and yes. The wireless adaptor actually only exprts phy0. The
kernel then by default creates wlan0.
Then i use :
# iw phy phy0 interface add wlv1 type __ap
# iw phy phy0 interface add wlv2 type station
To create the 2 virtual interfaces that I use. The only real
difference is the name I give them. (and the type in this case)

 To
 distinguish between them driver would need to provide some persistent
 information about each interface. I understand that dev_id (or
 dev_port) is supposed to be it, but as of now almost no driver actually
 bothers to set them.
I think dev_id and dev_port are already used, but not really applicable here.

 I wonder how is it possible to match such devices at all ...
Me to.

 (yes, the wlv3 was just for testing, wlv1 and wlv2 are the real ones)

 You mean wlan0?
no, wlan0 is the original device, I use wlv3 as an example in the
first mail, but was ommited in this reply because I already deleted
it)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] About systemd in initrd support

2014-08-23 Thread Simon Peeters
Hej,

2014-08-23 13:46 GMT+02:00 Luca Bruno lethalma...@gmail.com:
 I'm going to do an experiment with NixOS: replace the whole current initrd
 process made of scripts and hooks with systemd.

 Before doing any work however I'd like to hear whether systemd in initrd is
 still wanted in the future, or there's any possible idea about dropping this
 support.

I think this is definitly still wanted.

 Also, apart arch linux, is there any other OS that you know using systemd
 for the whole initrd process?

Every distribution that uses dracut as an initramfs, including mageia,
fedora and RHEL.

 Thanks for you work.

 Best regards,




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


[systemd-devel] Match section of .link file not working

2014-08-23 Thread Simon Peeters
Hej all,

I have a system on wich i wish to randomise the mac address of one
specific interface. This is important because it is a wireless vif,
and having multiple vif's with the same mac doesn't work.

I currently have the following config in 50-wl-mac.link:
[Match]
Path=/devices/ocp.3/4740.usb/musb-hdrc.1.auto/usb1/1-1/1-1:1.0/net/wlv3
Type=wlan

[Link]
MACAddressPolicy=random
---
But when I run
# udevadm test-builtin net_setup_link
/devices/ocp.3/4740.usb/musb-hdrc.1.auto/usb1/1-1/1-1:1.0/net/wlv3
I get:
...
Config file /usr/lib/systemd/network/99-default.link applies to device wlv3
...
And the mac address is not randomised.

This feels like a bug to me, any toughts what could cause this?
This is on 215 (archlinux arm does not yet have 216).


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


Re: [systemd-devel] Match section of .link file not working

2014-08-23 Thread Simon Peeters
2014-08-24 6:23 GMT+02:00 Andrei Borzenkov arvidj...@gmail.com:
 В Sun, 24 Aug 2014 03:04:03 +0200
 Simon Peeters peeters.si...@gmail.com пишет:

 Hej all,

 I have a system on wich i wish to randomise the mac address of one
 specific interface. This is important because it is a wireless vif,
 and having multiple vif's with the same mac doesn't work.

 I currently have the following config in 50-wl-mac.link:
 [Match]
 Path=/devices/ocp.3/4740.usb/musb-hdrc.1.auto/usb1/1-1/1-1:1.0/net/wlv3

 This should be the value of ID_PATH property, not sysfs path. Check with

 udevadm info --query
 property 
 /sys/devices/ocp.3/4740.usb/musb-hdrc.1.auto/usb1/1-1/1-1:1.0/net/wlv3

oops, I confused ID_PATH with DEVPATH, now i feel like an idiot.

thanks.


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


Re: [systemd-devel] Match section of .link file not working

2014-08-23 Thread Simon Peeters
2014-08-24 6:45 GMT+02:00 Simon Peeters peeters.si...@gmail.com:
 2014-08-24 6:23 GMT+02:00 Andrei Borzenkov arvidj...@gmail.com:
 В Sun, 24 Aug 2014 03:04:03 +0200
 Simon Peeters peeters.si...@gmail.com пишет:

 Hej all,

 I have a system on wich i wish to randomise the mac address of one
 specific interface. This is important because it is a wireless vif,
 and having multiple vif's with the same mac doesn't work.

 I currently have the following config in 50-wl-mac.link:
 [Match]
 Path=/devices/ocp.3/4740.usb/musb-hdrc.1.auto/usb1/1-1/1-1:1.0/net/wlv3

 This should be the value of ID_PATH property, not sysfs path. Check with

 udevadm info --query
 property 
 /sys/devices/ocp.3/4740.usb/musb-hdrc.1.auto/usb1/1-1/1-1:1.0/net/wlv3

 oops, I confused ID_PATH with DEVPATH, now i feel like an idiot.

Ok, so there is only one problem now:
ID_PATH is the same for all my vif interfaces, and i need to select
only one of them.

sigh, and manually setting the mac address gives anoying races :(

Any idea how I could match a single vif interface?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] timer: name the stamp file consistently

2014-06-27 Thread Simon Peeters
2014-06-27 19:49 GMT+02:00 Lennart Poettering lenn...@poettering.net:

 Hmm, are you saying the current logic is no stamp file, trigger
 immediately? And you say it should be no stamp file, pretend there was
 one with the current time?

no, afaik what he is saying that the current logic is indeed, no
stamp file, trigger immediately, and that by this logic changing the
naming for the stamp files makes systemd unable to find the stamp file
a previous version created, thus considering it nonexistant, hence
triggering the timer prematurely.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] ease installation on non-running kernels

2014-06-17 Thread Simon Peeters
2014-06-17 22:16 GMT+02:00 Greg KH g...@kroah.com:
 On Tue, Jun 17, 2014 at 03:53:15PM -0400, Dave Reisner wrote:
 On Tue, Jun 17, 2014 at 12:28:27PM -0700, Greg KH wrote:
  On Tue, Jun 17, 2014 at 02:52:43PM -0400, Dave Reisner wrote:
   This lets KERNELDIR apply to the install target as well so that you can
   do something such as the following will Just Work™:
  
 make KERNELDIR=/lib/modules/3.15.0-foo install
   ---
Makefile | 14 +++---
1 file changed, 7 insertions(+), 7 deletions(-)
  
   diff --git a/Makefile b/Makefile
   index c593b51..fe4dd58 100644
   --- a/Makefile
   +++ b/Makefile
   @@ -17,7 +17,7 @@ kdbus$(EXT)-y := \
  
obj-m += kdbus$(EXT).o
  
   -KERNELDIR?= /lib/modules/$(shell uname -r)/build
   +KERNELDIR?= /lib/modules/$(shell uname -r)
PWD  := $(shell pwd)
  
all: module test
   @@ -26,7 +26,7 @@ test::
 $(MAKE) -C test KBUILD_MODNAME=kdbus$(EXT)
  
module:
   - $(MAKE) -C $(KERNELDIR) M=$(PWD)
   + $(MAKE) -C $(KERNELDIR)/build M=$(PWD)
 
  Nope, you just broke the build on my machine when I wanted to build
  against the kernel source tree in /home/gregkh/linux/ that does not have
  a build/ subdirectory in it.

 Fair enough. I figured this would be the response I get [0].

 Um, that should be the workflow of _any_ kernel developer, we all build
 against local kernel directories, not one that is installed in /lib/.
 Some of us don't ever boot kernels installed in /lib :)


Hej all,

I have (locally) a patch that acomplishesh almost the same, but in a
way that does not break gregs setup.

What I did was:
 - Add a KERNELVER variable defaulting to $(shell uname -r)
 - replace all occurences of $(shell uname -r) with $(KERNELVER)

maybe this is a viable solution?

It allows people to use the default paths (/lib/modules/*/build) but
for a different kernel version, while still allowing users to set
KERNELDIR to whatever they want.

I hope this is usefull


Simon Peeters

PS: if you want me to sent this as a decent patch, let me know and I
do it once I am on my dev machine.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] ease installation on non-running kernels

2014-06-17 Thread Simon Peeters
---
 Makefile | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index c593b51..178257b 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,8 @@ kdbus$(EXT)-y := \
 
 obj-m += kdbus$(EXT).o
 
-KERNELDIR  ?= /lib/modules/$(shell uname -r)/build
+KERNELVER  ?= $(shell uname -r)
+KERNELDIR  ?= /lib/modules/$(KERNELVER)/build
 PWD:= $(shell pwd)
 
 all: module test
@@ -38,12 +39,12 @@ check:
test/test-kdbus
 
 install: module
-   mkdir -p /lib/modules/$(shell uname -r)/kernel/drivers/kdbus$(EXT)/
-   cp -f kdbus$(EXT).ko /lib/modules/$(shell uname 
-r)/kernel/drivers/kdbus$(EXT)/
-   depmod $(shell uname -r)
+   mkdir -p /lib/modules/$(KERNELVER)/kernel/drivers/kdbus$(EXT)/
+   cp -f kdbus$(EXT).ko 
/lib/modules/$(KERNELVER)/kernel/drivers/kdbus$(EXT)/
+   depmod $(KERNELVER)
 
 uninstall:
-   rm -f /lib/modules/$(shell uname -r)/kernel/drivers/kdbus/kdbus$(EXT).ko
+   rm -f /lib/modules/$(KERNELVER)/kernel/drivers/kdbus/kdbus$(EXT).ko
 
 coccicheck:
$(MAKE) -C $(KERNELDIR) M=$(PWD) coccicheck
-- 
2.0.0

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


Re: [systemd-devel] recipe for target 'dbus1-generator-install-hook' failed

2014-02-13 Thread Simon Peeters



On 02/13/14 21:29, Peeters Simon wrote:

hello all,

I usually run systemd from git using the arch aur package systemd-git
and yaourt to compile and install this, but this currently fails with

   LN   dbus1-generator-install-hook
what=  wants=runlevel3.target  dir=/usr/lib/systemd/system 
  [ -z $what ] || (
dir=/tmp/yaourt-tmp-simon/aur-systemd-git/pkg/systemd-git$dir/$wants.wants
 /usr/bin/mkdir -p -m 0755 $dir  cd $dir  rm -f $what  for i
in $what; do ln -s ../$i . || exit $? ; done )
ln: failed to create symbolic link
'/tmp/yaourt-tmp-simon/aur-systemd-git/pkg/systemd-git/usr/lib/systemd/user-generators/systemd-dbus1-generator':
No such file or directory
Makefile:15631: recipe for target 'dbus1-generator-install-hook' failed
make[4]: *** [dbus1-generator-install-hook] Error 1
make[4]: *** Waiting for unfinished jobs

Which appears to be because nothing in the build system creates
/usr/lib/systemd/user-generators.
Unfortunately I am really bad with build systems, so could somebody
check and fix this?

Thanks.


Simon


this appears to be simpler then I tought.

diff --git a/Makefile.am b/Makefile.am
index 181b346..41171fa 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1749,6 +1749,7 @@ systemd_dbus1_generator_LDADD = \
libsystemd-internal.la

 dbus1-generator-install-hook:
+   $(MKDIR_P) $(DESTDIR)$(usergeneratordir)
$(AM_V_LN)$(LN_S) -f 
$(systemgeneratordir)/systemd-dbus1-generator 
$(DESTDIR)$(usergeneratordir)/systemd-dbus1-generator


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


[systemd-devel] various cleanups

2014-01-03 Thread Simon Peeters
Hello,

I have tried to do some cleanups in src/shared 

The CACHED_METHOD one might be going a bit to far,
so feel free to drop it if you don't like it.

[PATCH 1/5] shared: procfs_file_alloca: handle pid==0
[PATCH 2/5] util: CACHED_METHOD macro
[PATCH 3/5] shared: util.c: unify split and split_quoted
[PATCH 4/5] util.c: use read_one_line_file where possible
[PATCH 5/5] strv: multiple cleanups

 src/core/main.c |  20 ++--
 src/modules-load/modules-load.c |   6 +-
 src/shared/apparmor-util.c  |  16 +--
 src/shared/audit.c  |  10 +-
 src/shared/cgroup-util.c|   5 +-
 src/shared/ima-util.c   |  11 +-
 src/shared/macro.h  |  16 +++
 src/shared/path-lookup.c|  83 ---
 src/shared/smack-util.c |  15 ++-
 src/shared/strv.c   | 158 +--
 src/shared/strv.h   |   6 +-
 src/shared/util.c   | 229 +++-
 src/shared/util.h   |  23 ++--
 src/sysctl/sysctl.c |   6 +-
 src/systemctl/systemctl.c   |  17 ++-
 src/test/test-strv.c|  77 +-
 16 files changed, 208 insertions(+), 490 deletions(-)

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


[systemd-devel] [PATCH 5/5] strv: multiple cleanups

2014-01-03 Thread Simon Peeters
- turn strv_merge into strv_extend_strv.
   appending strv b to the end of strv a instead of creating a new strv
- strv_append: remove in favor of strv_extend and strv_push.
- strv_remove: write slightly more elegant
- strv_remove_prefix: remove unused function
- strv_overlap: use strv_contains
- strv_printf: STRV_FOREACH handles NULL correctly
---
 src/core/main.c |  20 ++---
 src/modules-load/modules-load.c |   6 +-
 src/shared/path-lookup.c|  83 ++---
 src/shared/strv.c   | 158 
 src/shared/strv.h   |   6 +-
 src/sysctl/sysctl.c |   6 +-
 src/systemctl/systemctl.c   |  17 ++---
 src/test/test-strv.c|  77 +++-
 8 files changed, 96 insertions(+), 277 deletions(-)

diff --git a/src/core/main.c b/src/core/main.c
index 064445d..ec68549 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -601,15 +601,12 @@ static int config_parse_join_controllers(const char *unit,
 if (strv_overlap(*a, l)) {
 char **c;
 
-c = strv_merge(*a, l);
-if (!c) {
+if (strv_extend_strv(l, *a)  0) {
 strv_free(l);
 strv_free_free(t);
 return log_oom();
 }
 
-strv_free(l);
-l = c;
 } else {
 char **c;
 
@@ -1853,10 +1850,11 @@ finish:
 shutdown_verb,
 NULL
 };
-char **env_block;
+_cleanup_strv_free_ char **env_block = NULL;
+env_block = strv_copy(environ);
 
 if (arm_reboot_watchdog  arg_shutdown_watchdog  0) {
-char e[32];
+char *e;
 
 /* If we reboot let's set the shutdown
  * watchdog and tell the shutdown binary to
@@ -1865,14 +1863,11 @@ finish:
 watchdog_close(false);
 
 /* Tell the binary how often to ping */
-snprintf(e, sizeof(e), WATCHDOG_USEC=%llu, (unsigned 
long long) arg_shutdown_watchdog);
-char_array_0(e);
+asprintf(e, WATCHDOG_USEC=%llu, (unsigned long 
long) arg_shutdown_watchdog);
 
-env_block = strv_append(environ, e);
-} else {
-env_block = strv_copy(environ);
+strv_push(env_block, e);
+} else
 watchdog_close(true);
-}
 
 /* Avoid the creation of new processes forked by the
  * kernel; at this point, we will not listen to the
@@ -1881,7 +1876,6 @@ finish:
 cg_uninstall_release_agent(SYSTEMD_CGROUP_CONTROLLER);
 
 execve(SYSTEMD_SHUTDOWN_BINARY_PATH, (char **) command_line, 
env_block);
-free(env_block);
 log_error(Failed to execute shutdown binary, freezing: %m);
 }
 
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
index 5d141a8..01987f2 100644
--- a/src/modules-load/modules-load.c
+++ b/src/modules-load/modules-load.c
@@ -64,13 +64,9 @@ static int add_modules(const char *p) {
 if (!k)
 return log_oom();
 
-t = strv_merge(arg_proc_cmdline_modules, k);
-if (!t)
+if (strv_extend_strv(arg_proc_cmdline_modules, k)  0)
 return log_oom();
 
-strv_free(arg_proc_cmdline_modules);
-arg_proc_cmdline_modules = t;
-
 return 0;
 }
 
diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c
index 1a47ea9..e2ca942 100644
--- a/src/shared/path-lookup.c
+++ b/src/shared/path-lookup.c
@@ -90,9 +90,9 @@ static char** user_dirs(
 };
 
 const char *home, *e;
-char *config_home = NULL, *data_home = NULL;
-char **config_dirs = NULL, **data_dirs = NULL;
-char **r = NULL, **t;
+_cleanup_free_ char *config_home = NULL, *data_home = NULL;
+_cleanup_strv_free_ char **config_dirs = NULL, **data_dirs = NULL;
+char **r = NULL;
 
 /* Implement the mechanisms defined in
  *
@@ -150,89 +150,48 @@ static char** user_dirs(
 goto fail;
 
 /* Now merge everything we found. */
-if (generator_early) {
-t = strv_append(r, generator_early);
-if (!t)
+if (generator_early)
+if (strv_extend(r, generator_early)  0)

[systemd-devel] [PATCH 1/5] shared: procfs_file_alloca: handle pid==0

2014-01-03 Thread Simon Peeters
when pid is set to 0 use /proc/self
---
 src/shared/audit.c   | 10 ++
 src/shared/cgroup-util.c |  5 +
 src/shared/util.c| 35 +++
 src/shared/util.h|  8 ++--
 4 files changed, 16 insertions(+), 42 deletions(-)

diff --git a/src/shared/audit.c b/src/shared/audit.c
index 9ab4640..8038ac3 100644
--- a/src/shared/audit.c
+++ b/src/shared/audit.c
@@ -46,10 +46,7 @@ int audit_session_from_pid(pid_t pid, uint32_t *id) {
 if (detect_container(NULL)  0)
 return -ENOTSUP;
 
-if (pid == 0)
-p = /proc/self/sessionid;
-else
-p = procfs_file_alloca(pid, sessionid);
+p = procfs_file_alloca(pid, sessionid);
 
 r = read_one_line_file(p, s);
 if (r  0)
@@ -78,10 +75,7 @@ int audit_loginuid_from_pid(pid_t pid, uid_t *uid) {
 if (detect_container(NULL)  0)
 return -ENOTSUP;
 
-if (pid == 0)
-p = /proc/self/loginuid;
-else
-p = procfs_file_alloca(pid, loginuid);
+p = procfs_file_alloca(pid, loginuid);
 
 r = read_one_line_file(p, s);
 if (r  0)
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
index f2af8dc..855c9cd 100644
--- a/src/shared/cgroup-util.c
+++ b/src/shared/cgroup-util.c
@@ -746,10 +746,7 @@ int cg_pid_get_path(const char *controller, pid_t pid, 
char **path) {
 } else
 controller = SYSTEMD_CGROUP_CONTROLLER;
 
-if (pid == 0)
-fs = /proc/self/cgroup;
-else
-fs = procfs_file_alloca(pid, cgroup);
+fs = procfs_file_alloca(pid, cgroup);
 
 f = fopen(fs, re);
 if (!f)
diff --git a/src/shared/util.c b/src/shared/util.c
index f491708..50dac70 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -495,10 +495,7 @@ int get_starttime_of_pid(pid_t pid, unsigned long long 
*st) {
 assert(pid = 0);
 assert(st);
 
-if (pid == 0)
-p = /proc/self/stat;
-else
-p = procfs_file_alloca(pid, stat);
+p = procfs_file_alloca(pid, stat);
 
 f = fopen(p, re);
 if (!f)
@@ -573,10 +570,7 @@ int get_process_comm(pid_t pid, char **name) {
 assert(name);
 assert(pid = 0);
 
-if (pid == 0)
-p = /proc/self/comm;
-else
-p = procfs_file_alloca(pid, comm);
+p = procfs_file_alloca(pid, comm);
 
 r = read_one_line_file(p, name);
 if (r == -ENOENT)
@@ -594,10 +588,7 @@ int get_process_cmdline(pid_t pid, size_t max_length, bool 
comm_fallback, char *
 assert(line);
 assert(pid = 0);
 
-if (pid == 0)
-p = /proc/self/cmdline;
-else
-p = procfs_file_alloca(pid, cmdline);
+p = procfs_file_alloca(pid, cmdline);
 
 f = fopen(p, re);
 if (!f)
@@ -716,10 +707,7 @@ int get_process_capeff(pid_t pid, char **capeff) {
 assert(capeff);
 assert(pid = 0);
 
-if (pid == 0)
-p = /proc/self/status;
-else
-p = procfs_file_alloca(pid, status);
+p = procfs_file_alloca(pid, status);
 
 return get_status_field(p, \nCapEff:, capeff);
 }
@@ -732,10 +720,7 @@ int get_process_exe(pid_t pid, char **name) {
 assert(pid = 0);
 assert(name);
 
-if (pid == 0)
-p = /proc/self/exe;
-else
-p = procfs_file_alloca(pid, exe);
+p = procfs_file_alloca(pid, exe);
 
 r = readlink_malloc(p, name);
 if (r  0)
@@ -2549,10 +2534,7 @@ int get_ctty_devnr(pid_t pid, dev_t *d) {
 
 assert(pid = 0);
 
-if (pid == 0)
-fn = /proc/self/stat;
-else
-fn = procfs_file_alloca(pid, stat);
+fn = procfs_file_alloca(pid, stat);
 
 f = fopen(fn, re);
 if (!f)
@@ -5095,10 +5077,7 @@ int getenv_for_pid(pid_t pid, const char *field, char 
**_value) {
 assert(field);
 assert(_value);
 
-if (pid == 0)
-path = /proc/self/environ;
-else
-path = procfs_file_alloca(pid, environ);
+path = procfs_file_alloca(pid, environ);
 
 f = fopen(path, re);
 if (!f)
diff --git a/src/shared/util.h b/src/shared/util.h
index f6d2ced..311315d 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -762,8 +762,12 @@ int unlink_noerrno(const char *path);
 ({  \
 pid_t _pid_ = (pid);\
 char *_r_;  \
-_r_ = alloca(sizeof(/proc/) -1 + DECIMAL_STR_MAX(pid_t) + 1 
+ sizeof(field)); \
-sprintf(_r_, /proc/%lu/ field, (unsigned long) _pid_); \
+if (_pid_ == 0) {   

[systemd-devel] [PATCH 4/5] util.c: use read_one_line_file where possible

2014-01-03 Thread Simon Peeters
---
 src/shared/util.c | 48 +++-
 1 file changed, 15 insertions(+), 33 deletions(-)

diff --git a/src/shared/util.c b/src/shared/util.c
index db3051d..354d7eb 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -404,8 +404,7 @@ char *split(const char *c, size_t *l, const char 
*separator, bool quoted, char *
 
 int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
 int r;
-_cleanup_fclose_ FILE *f = NULL;
-char line[LINE_MAX];
+_cleanup_free_ char *line = NULL;
 long unsigned ppid;
 const char *p;
 
@@ -418,14 +417,9 @@ int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
 }
 
 p = procfs_file_alloca(pid, stat);
-f = fopen(p, re);
-if (!f)
-return -errno;
-
-if (!fgets(line, sizeof(line), f)) {
-r = feof(f) ? -EIO : -errno;
+r = read_one_line_file(p, line);
+if (r  0)
 return r;
-}
 
 /* Let's skip the pid and comm fields. The latter is enclosed
  * in () but does not escape any () in its value, so let's
@@ -452,25 +446,17 @@ int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
 }
 
 int get_starttime_of_pid(pid_t pid, unsigned long long *st) {
-_cleanup_fclose_ FILE *f = NULL;
-char line[LINE_MAX];
+int r;
+_cleanup_free_ char *line = NULL;
 const char *p;
 
 assert(pid = 0);
 assert(st);
 
 p = procfs_file_alloca(pid, stat);
-
-f = fopen(p, re);
-if (!f)
-return errno == ENOENT ? -ESRCH : -errno;
-
-if (!fgets(line, sizeof(line), f)) {
-if (ferror(f))
-return -errno;
-
-return -EIO;
-}
+r = read_one_line_file(p, line);
+if (r  0)
+return r;
 
 /* Let's skip the pid and comm fields. The latter is enclosed
  * in () but does not escape any () in its value, so let's
@@ -2491,21 +2477,17 @@ int getttyname_harder(int fd, char **r) {
 }
 
 int get_ctty_devnr(pid_t pid, dev_t *d) {
-_cleanup_fclose_ FILE *f = NULL;
-char line[LINE_MAX], *p;
+int r;
+_cleanup_free_ char *line = NULL;
+const char *p;
 unsigned long ttynr;
-const char *fn;
 
 assert(pid = 0);
 
-fn = procfs_file_alloca(pid, stat);
-
-f = fopen(fn, re);
-if (!f)
-return -errno;
-
-if (!fgets(line, sizeof(line), f))
-return feof(f) ? -EIO : -errno;
+p = procfs_file_alloca(pid, stat);
+r = read_one_line_file(p, line);
+if (r  0)
+return r;
 
 p = strrchr(line, ')');
 if (!p)
-- 
1.8.5.2

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


[systemd-devel] [PATCH 3/5] shared: util.c: unify split and split_quoted

2014-01-03 Thread Simon Peeters
---
 src/shared/util.c | 88 ---
 src/shared/util.h | 15 ++
 2 files changed, 36 insertions(+), 67 deletions(-)

diff --git a/src/shared/util.c b/src/shared/util.c
index 2350204..db3051d 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -359,8 +359,23 @@ int safe_atod(const char *s, double *ret_d) {
 return 0;
 }
 
+static size_t strcspn_escaped(const char *s, const char *reject) {
+bool escaped = false;
+size_t n;
+
+for (n=0; s[n]; n++) {
+if (escaped)
+escaped = false;
+else if (s[n] == '\\')
+escaped = true;
+else if (strchr(reject, s[n]))
+return n;
+}
+return n;
+}
+
 /* Split a string into words. */
-char *split(const char *c, size_t *l, const char *separator, char **state) {
+char *split(const char *c, size_t *l, const char *separator, bool quoted, char 
**state) {
 char *current;
 
 current = *state ? *state : (char*) c;
@@ -369,70 +384,19 @@ char *split(const char *c, size_t *l, const char 
*separator, char **state) {
 return NULL;
 
 current += strspn(current, separator);
-*l = strcspn(current, separator);
-*state = current+*l;
-
-return (char*) current;
-}
-
-/* Split a string into words, but consider strings enclosed in '' and
- *  as words even if they include spaces. */
-char *split_quoted(const char *c, size_t *l, char **state) {
-const char *current, *e;
-bool escaped = false;
-
-assert(c);
-assert(l);
-assert(state);
-
-current = *state ? *state : c;
-
-current += strspn(current, WHITESPACE);
-
-if (*current == 0)
+if (!*current)
 return NULL;
 
-else if (*current == '\'') {
-current ++;
-
-for (e = current; *e; e++) {
-if (escaped)
-escaped = false;
-else if (*e == '\\')
-escaped = true;
-else if (*e == '\'')
-break;
-}
-
-*l = e-current;
-*state = (char*) (*e == 0 ? e : e+1);
-
-} else if (*current == '\') {
-current ++;
-
-for (e = current; *e; e++) {
-if (escaped)
-escaped = false;
-else if (*e == '\\')
-escaped = true;
-else if (*e == '\')
-break;
-}
-
-*l = e-current;
-*state = (char*) (*e == 0 ? e : e+1);
-
+if (quoted  strchr(\'\, *current)) {
+char quotechar = *(current++);
+*l = strcspn_escaped(current, (char[]){quotechar, '\0'});
+*state = current+*l+1;
+} else if (quoted) {
+*l = strcspn_escaped(current, separator);
+*state = current+*l;
 } else {
-for (e = current; *e; e++) {
-if (escaped)
-escaped = false;
-else if (*e == '\\')
-escaped = true;
-else if (strchr(WHITESPACE, *e))
-break;
-}
-*l = e-current;
-*state = (char*) e;
+*l = strcspn(current, separator);
+*state = current+*l;
 }
 
 return (char*) current;
diff --git a/src/shared/util.h b/src/shared/util.h
index 311315d..92a8a31 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -182,17 +182,22 @@ static inline int safe_atoi64(const char *s, int64_t 
*ret_i) {
 return safe_atolli(s, (long long int*) ret_i);
 }
 
-char *split(const char *c, size_t *l, const char *separator, char **state);
-char *split_quoted(const char *c, size_t *l, char **state);
+char *split(const char *c, size_t *l, const char *separator, bool quoted, char 
**state);
 
 #define FOREACH_WORD(word, length, s, state)\
-for ((state) = NULL, (word) = split((s), (length), WHITESPACE, 
(state)); (word); (word) = split((s), (length), WHITESPACE, (state)))
+_FOREACH_WORD(word, length, s, WHITESPACE, false, state)
 
 #define FOREACH_WORD_SEPARATOR(word, length, s, separator, state)   \
-for ((state) = NULL, (word) = split((s), (length), (separator), 
(state)); (word); (word) = split((s), (length), (separator), (state)))
+_FOREACH_WORD(word, length, s, separator, false, state)
 
 #define FOREACH_WORD_QUOTED(word, length, s, state) \
-for ((state) = NULL, (word) = split_quoted((s), (length), 

[systemd-devel] [PATCH 1/2] bus: make bus_print_all_properties work for non machinectl cases

2013-11-06 Thread Simon Peeters
add a destination parameter and skip properties we can't read
---
 src/libsystemd-bus/bus-util.c | 16 +++-
 src/libsystemd-bus/bus-util.h |  2 +-
 src/machine/machinectl.c  |  2 +-
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/libsystemd-bus/bus-util.c b/src/libsystemd-bus/bus-util.c
index 3bb1fb7..25738af 100644
--- a/src/libsystemd-bus/bus-util.c
+++ b/src/libsystemd-bus/bus-util.c
@@ -628,7 +628,7 @@ int bus_print_property(const char *name, sd_bus_message 
*property, bool all) {
 return 0;
 }
 
-int bus_print_all_properties(sd_bus *bus, const char *path, char **filter, 
bool all) {
+int bus_print_all_properties(sd_bus *bus, const char *dest, const char *path, 
char **filter, bool all) {
 _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
 int r;
@@ -637,7 +637,7 @@ int bus_print_all_properties(sd_bus *bus, const char *path, 
char **filter, bool
 assert(path);
 
 r = sd_bus_call_method(bus,
-org.freedesktop.machine1,
+dest,
 path,
 org.freedesktop.DBus.Properties,
 GetAll,
@@ -671,8 +671,14 @@ int bus_print_all_properties(sd_bus *bus, const char 
*path, char **filter, bool
 r = bus_print_property(name, reply, all);
 if (r  0)
 return r;
-if (r == 0  all)
-printf(%s=[unprintable]\n, name);
+if (r == 0) {
+if (all)
+printf(%s=[unprintable]\n, name);
+/* skip what we didn't read */
+r = sd_bus_message_skip(reply, contents);
+if (r  0)
+return r;
+}
 
 r = sd_bus_message_exit_container(reply);
 if (r  0)
@@ -866,7 +872,7 @@ int bus_map_all_properties(sd_bus *bus,
 return r;
 
 v = (uint8_t *)userdata + prop-offset;
-if (map[i].set)
+if (map[i].set)
 r = prop-set(bus, member, m, error, v);
 else
 r = map_basic(bus, member, m, error, v);
diff --git a/src/libsystemd-bus/bus-util.h b/src/libsystemd-bus/bus-util.h
index 101a2ec..f982e08 100644
--- a/src/libsystemd-bus/bus-util.h
+++ b/src/libsystemd-bus/bus-util.h
@@ -67,7 +67,7 @@ int bus_open_system_systemd(sd_bus **_bus);
 int bus_open_transport(BusTransport transport, const char *host, bool user, 
sd_bus **bus);
 
 int bus_print_property(const char *name, sd_bus_message *property, bool all);
-int bus_print_all_properties(sd_bus *bus, const char *path, char **filter, 
bool all);
+int bus_print_all_properties(sd_bus *bus, const char *dest, const char *path, 
char **filter, bool all);
 
 int bus_property_get_bool(sd_bus *bus, const char *path, const char 
*interface, const char *property, sd_bus_message *reply, sd_bus_error *error, 
void *userdata);
 int bus_property_get_uid(sd_bus *bus, const char *path, const char *interface, 
const char *property, sd_bus_message *reply, sd_bus_error *error, void 
*userdata);
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 8468436..45dfa00 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -284,7 +284,7 @@ static int show_properties(sd_bus *bus, const char *path, 
bool *new_line) {
 
 *new_line = true;
 
-r = bus_print_all_properties(bus, path, arg_property, arg_all);
+r = bus_print_all_properties(bus, org.freedesktop.machine1, path, 
arg_property, arg_all);
 if (r  0)
 log_error(Could not get properties: %s, strerror(-r));
 
-- 
1.8.4

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


[systemd-devel] [PATCH 1/2] bus-util: add ssh and polkit connection methods

2013-10-29 Thread Simon Peeters
bus_connect_system_ssh is shamelessly copied from Tom Gundersen's wip
patches
---
 src/libsystemd-bus/bus-util.c | 61 +++
 src/libsystemd-bus/bus-util.h |  2 ++
 2 files changed, 63 insertions(+)

diff --git a/src/libsystemd-bus/bus-util.c b/src/libsystemd-bus/bus-util.c
index 42374fe..464e5fb 100644
--- a/src/libsystemd-bus/bus-util.c
+++ b/src/libsystemd-bus/bus-util.c
@@ -450,3 +450,64 @@ int bus_connect_system(sd_bus **_bus) {
 *_bus = bus;
 return 0;
 }
+
+int bus_connect_system_ssh(const char *host, sd_bus **_bus) {
+sd_bus *bus;
+char *p = NULL;
+int r;
+
+assert(_bus);
+assert(host);
+
+asprintf(p, 
unixexec:path=ssh,argv1=-xT,argv2=%s,argv3=systemd-stdio-bridge, host);
+if (!p)
+return -ENOMEM;
+
+r = sd_bus_new(bus);
+if (r  0)
+return r;
+
+r = sd_bus_set_address(bus, p);
+if (r  0)
+return r;
+
+r = sd_bus_set_bus_client(bus, true);
+if (r  0)
+return r;
+
+r = sd_bus_start(bus);
+if (r  0)
+return r;
+
+*_bus = bus;
+return 0;
+}
+
+int bus_connect_system_polkit(sd_bus **_bus) {
+sd_bus *bus;
+int r;
+
+assert(_bus);
+
+if (geteuid() == 0)
+return sd_bus_open_system(_bus);
+
+r = sd_bus_new(bus);
+if (r  0)
+return r;
+
+r = sd_bus_set_address(bus, unixexec:path=pkexec,argv1= 
SYSTEMD_STDIO_BRIDGE_BINARY_PATH);
+if (r  0)
+return r;
+
+r = sd_bus_set_bus_client(bus, true);
+if (r  0)
+return r;
+
+r = sd_bus_start(bus);
+if (r  0)
+return r;
+
+*_bus = bus;
+return 0;
+}
diff --git a/src/libsystemd-bus/bus-util.h b/src/libsystemd-bus/bus-util.h
index cf00436..92df3c2 100644
--- a/src/libsystemd-bus/bus-util.h
+++ b/src/libsystemd-bus/bus-util.h
@@ -38,6 +38,8 @@ int bus_verify_polkit_async(sd_bus *bus, Hashmap **registry, 
sd_bus_message *m,
 void bus_verify_polkit_async_registry_free(sd_bus *bus, Hashmap *registry);
 
 int bus_connect_system(sd_bus **_bus);
+int bus_connect_system_ssh(const char *host, sd_bus **_bus);
+int bus_connect_system_polkit(sd_bus **_bus);
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus*, sd_bus_unref);
 DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_message*, sd_bus_message_unref);
-- 
1.8.4.2

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


[systemd-devel] [PATCH] Move bus_error to dbus-common and remove bus_error_message_or_strerror

2013-04-10 Thread Simon Peeters
bus_error and bus_error_message_or_strerror dit almost exactly the same,
so use only one of them and place it in dbus-common.
---
 src/core/bus-errors.h| 13 -
 src/core/load-fragment.c |  2 +-
 src/core/main.c  |  2 +-
 src/core/path.c  |  2 +-
 src/core/service.c   |  2 +-
 src/core/socket.c|  2 +-
 src/core/timer.c |  2 +-
 src/core/transaction.c   |  1 +
 src/login/inhibit.c  |  4 ++--
 src/login/logind-dbus.c  |  2 +-
 src/shared/dbus-common.c |  6 --
 src/shared/dbus-common.h |  2 +-
 12 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/src/core/bus-errors.h b/src/core/bus-errors.h
index 04c1b28..7a4084e 100644
--- a/src/core/bus-errors.h
+++ b/src/core/bus-errors.h
@@ -21,9 +21,6 @@
   along with systemd; If not, see http://www.gnu.org/licenses/.
 ***/
 
-#include string.h
-#include dbus/dbus.h
-
 #define BUS_ERROR_NO_SUCH_UNIT org.freedesktop.systemd1.NoSuchUnit
 #define BUS_ERROR_NO_SUCH_JOB org.freedesktop.systemd1.NoSuchJob
 #define BUS_ERROR_NOT_SUBSCRIBED org.freedesktop.systemd1.NotSubscribed
@@ -43,13 +40,3 @@
 #define BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC 
org.freedesktop.systemd1.TransactionOrderIsCyclic
 #define BUS_ERROR_SHUTTING_DOWN org.freedesktop.systemd1.ShuttingDown
 #define BUS_ERROR_NO_SUCH_PROCESS org.freedesktop.systemd1.NoSuchProcess
-
-static inline const char *bus_error(const DBusError *e, int r) {
-if (e  e-message)
-return e-message;
-
-if (r = 0)
-return strerror(r);
-
-return strerror(-r);
-}
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 42c181d..0f16fd9 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -44,7 +44,7 @@
 #include missing.h
 #include unit-name.h
 #include unit-printf.h
-#include bus-errors.h
+#include dbus-common.h
 #include utf8.h
 #include path-util.h
 #include syscall-list.h
diff --git a/src/core/main.c b/src/core/main.c
index 7899761..fe9932b 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -40,7 +40,7 @@
 #include fdset.h
 #include special.h
 #include conf-parser.h
-#include bus-errors.h
+#include dbus-common.h
 #include missing.h
 #include label.h
 #include build.h
diff --git a/src/core/path.c b/src/core/path.c
index ff49c06..b8ba057 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -31,7 +31,7 @@
 #include mkdir.h
 #include dbus-path.h
 #include special.h
-#include bus-errors.h
+#include dbus-common.h
 #include path-util.h
 #include macro.h
 
diff --git a/src/core/service.c b/src/core/service.c
index a104b30..cf19ccb 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -36,7 +36,7 @@
 #include unit-printf.h
 #include dbus-service.h
 #include special.h
-#include bus-errors.h
+#include dbus-common.h
 #include exit-status.h
 #include def.h
 #include path-util.h
diff --git a/src/core/socket.c b/src/core/socket.c
index f3cbe08..9f1af1e 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -46,7 +46,7 @@
 #include dbus-socket.h
 #include missing.h
 #include special.h
-#include bus-errors.h
+#include dbus-common.h
 #include label.h
 #include exit-status.h
 #include def.h
diff --git a/src/core/timer.c b/src/core/timer.c
index 16ca573..107dbb3 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -26,7 +26,7 @@
 #include timer.h
 #include dbus-timer.h
 #include special.h
-#include bus-errors.h
+#include dbus-common.h
 
 static const UnitActiveState state_translation_table[_TIMER_STATE_MAX] = {
 [TIMER_DEAD] = UNIT_INACTIVE,
diff --git a/src/core/transaction.c b/src/core/transaction.c
index 4a8d90e..610344e 100644
--- a/src/core/transaction.c
+++ b/src/core/transaction.c
@@ -24,6 +24,7 @@
 
 #include transaction.h
 #include bus-errors.h
+#include dbus-common.h
 
 static void transaction_unlink_job(Transaction *tr, Job *j, bool 
delete_dependencies);
 
diff --git a/src/login/inhibit.c b/src/login/inhibit.c
index 9cb321f..fbab42a 100644
--- a/src/login/inhibit.c
+++ b/src/login/inhibit.c
@@ -251,7 +251,7 @@ int main(int argc, char *argv[]) {
 
 r = print_inhibitors(bus, error);
 if (r  0) {
-log_error(Failed to list inhibitors: %s, 
bus_error_message_or_strerror(error, -r));
+log_error(Failed to list inhibitors: %s, 
bus_error(error, r));
 goto finish;
 }
 
@@ -266,7 +266,7 @@ int main(int argc, char *argv[]) {
 free(w);
 
 if (fd  0) {
-log_error(Failed to inhibit: %s, 
bus_error_message_or_strerror(error, -r));
+log_error(Failed to inhibit: %s, bus_error(error, 
r));
 r = fd;
 goto finish;
 }
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 230dd2b..bc46de7 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -2459,7 +2459,7 @@ int 

[systemd-devel] [PATCH] systemd-analyze: rewrite in C.

2013-02-04 Thread Simon Peeters
Written by Peeters Simon peeters.si...@gmail.com. Makefile stuff
and cleaned up a bit by Auke Kok auke-jan.h@intel.com.
---
 Makefile.am|  21 +-
 src/analyze/systemd-analyze.c  | 575 +
 src/analyze/systemd-analyze.in | 328 ---
 3 files changed, 585 insertions(+), 339 deletions(-)
 create mode 100644 src/analyze/systemd-analyze.c
 delete mode 100755 src/analyze/systemd-analyze.in

diff --git a/Makefile.am b/Makefile.am
index 2631748..e31cbb2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -186,7 +186,8 @@ rootbin_PROGRAMS = \
systemd-ask-password \
systemd-tty-ask-password-agent \
systemd-tmpfiles \
-   systemd-machine-id-setup
+   systemd-machine-id-setup \
+   systemd-analyze
 
 bin_PROGRAMS = \
systemd-cgls \
@@ -221,14 +222,16 @@ systemgenerator_PROGRAMS = \
systemd-fstab-generator \
systemd-system-update-generator
 
-dist_bin_SCRIPTS = \
-   src/analyze/systemd-analyze
+systemd_analyze_SOURCES = \
+   src/analyze/systemd-analyze.c
 
-EXTRA_DIST += \
-   src/analyze/systemd-analyze.in
+systemd_analyze_CFLAGS = \
+   $(AM_CFLAGS) \
+   $(DBUS_CFLAGS)
 
-CLEANFILES += \
-   src/analyze/systemd-analyze
+systemd_analyze_LDADD = \
+   libsystemd-shared.la \
+   libsystemd-dbus.la
 
 dist_bashcompletion_DATA = \
shell-completion/systemd-bash-completion.sh
@@ -3837,10 +3840,6 @@ src/%.policy.in: src/%.policy.in.in Makefile
$(SED_PROCESS)
$(AM_V_GEN)chmod +x $@
 
-src/analyze/systemd-analyze: %: %.in Makefile
-   $(SED_PROCESS)
-   $(AM_V_GEN)chmod +x $@
-
 src/%.c: src/%.gperf
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(GPERF)  $  $@
diff --git a/src/analyze/systemd-analyze.c b/src/analyze/systemd-analyze.c
new file mode 100644
index 000..8aaf238
--- /dev/null
+++ b/src/analyze/systemd-analyze.c
@@ -0,0 +1,575 @@
+#include stdio.h
+#include stdlib.h
+#include getopt.h
+#include locale.h
+
+#include install.h
+#include log.h
+#include dbus-common.h
+#include build.h
+#include util.h
+
+#define svg(...) printf(__VA_ARGS__)
+#define svg_bar(class, begin, end) \
+svg(  rect class=\%s\ x=\%.03f\ y=\%.03f\ width=\%.03f\ 
height=\%.03f\ /\n, \
+(class), \
+scale_x * (begin) * 0.01, scale_y * barcount, \
+scale_x * ((end) - (begin)) * 0.01, scale_y - 1.0)
+#define svg_text_nl(begin, format, ...) \
+svg(  text x=\%.03f\ y=\%.03f\format/text\n, \
+scale_x * (begin) * 0.01 + 5.0, \
+(scale_y * barcount++) + 14.0, ## __VA_ARGS__)
+#define svg_bar_text_nl(class, begin, end, text_format, ...) do { \
+svg_bar(class, begin, end); \
+svg_text_nl(begin, text_format, ## __VA_ARGS__); \
+}while (false)
+
+static UnitFileScope arg_scope = UNIT_FILE_SYSTEM;
+
+double scale_x = 100.0;
+double scale_y = 20.0;
+
+static int barcount = 0;
+
+struct boot_times {
+uint64_t firmware_time;
+uint64_t loader_time;
+uint64_t kernel_time;
+uint64_t kernel_done_time;
+uint64_t initrd_time;
+uint64_t userspace_time;
+uint64_t finish_time;
+};
+struct unit_times {
+char *name;
+uint64_t ixt;
+uint64_t iet;
+uint64_t axt;
+uint64_t aet;
+uint64_t time;
+};
+
+static uint64_t property_getu64(
+DBusConnection *bus,
+const char *dest,
+const char *path,
+const char *interface,
+const char *property)
+{
+int err = errno; //back up errno to prevent accidentally setting it.
+_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
+DBusMessageIter iter, sub;
+uint64_t result = 0;
+
+errno = -bus_method_call_with_reply (bus, dest, path,
+org.freedesktop.DBus.Properties, Get,
+reply, NULL,
+DBUS_TYPE_STRING, interface,
+DBUS_TYPE_STRING, property,
+DBUS_TYPE_INVALID);
+if (errno)
+return 0;
+
+if (!dbus_message_iter_init(reply, iter) ||
+dbus_message_iter_get_arg_type(iter) != 
DBUS_TYPE_VARIANT)
+goto fail;
+
+dbus_message_iter_recurse(iter, sub);
+
+if (dbus_message_iter_get_arg_type(sub) != DBUS_TYPE_UINT64)
+goto fail;
+
+dbus_message_iter_get_basic(sub, result);
+
+errno = err;
+return result;
+fail:
+log_error(Failed to parse reply.);
+errno = EIO;
+return 0;
+}
+
+static int compare_unit_time(const void *a, const void *b)
+{
+const struct unit_times *u = a, *v = b;
+
+if (u-time  v-time)
+return -1;
+if (u-time  

[systemd-devel] [PATCH][V3] systemd-analyze: rewrite in C.

2013-02-04 Thread Simon Peeters
Written by Peeters Simon peeters.si...@gmail.com. Makefile stuff
and cleaned up a bit by Auke Kok auke-jan.h@intel.com.
---

Fixed some stuff and dit some more cleanup.

This should just cover the same usage as the old systemd-analyze, but we can
add more functionality afterwards (systemctl dot, other output formats,...)

This is the rebased version as asked by William.


 Makefile.am|  21 +-
 src/analyze/systemd-analyze.c  | 575 +
 src/analyze/systemd-analyze.in | 328 ---
 3 files changed, 585 insertions(+), 339 deletions(-)
 create mode 100644 src/analyze/systemd-analyze.c
 delete mode 100755 src/analyze/systemd-analyze.in

diff --git a/Makefile.am b/Makefile.am
index 88662c0..f3ab908 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -268,7 +268,8 @@ rootbin_PROGRAMS = \
systemd-ask-password \
systemd-tty-ask-password-agent \
systemd-tmpfiles \
-   systemd-machine-id-setup
+   systemd-machine-id-setup \
+   systemd-analyze
 
 bin_PROGRAMS = \
systemd-cgls \
@@ -299,14 +300,16 @@ systemgenerator_PROGRAMS = \
systemd-system-update-generator \
systemd-efi-boot-generator
 
-dist_bin_SCRIPTS = \
-   src/analyze/systemd-analyze
+systemd_analyze_SOURCES = \
+   src/analyze/systemd-analyze.c
 
-EXTRA_DIST += \
-   src/analyze/systemd-analyze.in
+systemd_analyze_CFLAGS = \
+   $(AM_CFLAGS) \
+   $(DBUS_CFLAGS)
 
-CLEANFILES += \
-   src/analyze/systemd-analyze
+systemd_analyze_LDADD = \
+   libsystemd-shared.la \
+   libsystemd-dbus.la
 
 dist_bashcompletion_DATA = \
shell-completion/systemd-bash-completion.sh
@@ -3855,10 +3858,6 @@ src/%.policy.in: src/%.policy.in.in Makefile
$(SED_PROCESS)
$(AM_V_GEN)chmod +x $@
 
-src/analyze/systemd-analyze: %: %.in Makefile
-   $(SED_PROCESS)
-   $(AM_V_GEN)chmod +x $@
-
 src/%.c: src/%.gperf
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GPERF)$(GPERF)  $  $@
diff --git a/src/analyze/systemd-analyze.c b/src/analyze/systemd-analyze.c
new file mode 100644
index 000..8aaf238
--- /dev/null
+++ b/src/analyze/systemd-analyze.c
@@ -0,0 +1,575 @@
+#include stdio.h
+#include stdlib.h
+#include getopt.h
+#include locale.h
+
+#include install.h
+#include log.h
+#include dbus-common.h
+#include build.h
+#include util.h
+
+#define svg(...) printf(__VA_ARGS__)
+#define svg_bar(class, begin, end) \
+svg(  rect class=\%s\ x=\%.03f\ y=\%.03f\ width=\%.03f\ 
height=\%.03f\ /\n, \
+(class), \
+scale_x * (begin) * 0.01, scale_y * barcount, \
+scale_x * ((end) - (begin)) * 0.01, scale_y - 1.0)
+#define svg_text_nl(begin, format, ...) \
+svg(  text x=\%.03f\ y=\%.03f\format/text\n, \
+scale_x * (begin) * 0.01 + 5.0, \
+(scale_y * barcount++) + 14.0, ## __VA_ARGS__)
+#define svg_bar_text_nl(class, begin, end, text_format, ...) do { \
+svg_bar(class, begin, end); \
+svg_text_nl(begin, text_format, ## __VA_ARGS__); \
+}while (false)
+
+static UnitFileScope arg_scope = UNIT_FILE_SYSTEM;
+
+double scale_x = 100.0;
+double scale_y = 20.0;
+
+static int barcount = 0;
+
+struct boot_times {
+uint64_t firmware_time;
+uint64_t loader_time;
+uint64_t kernel_time;
+uint64_t kernel_done_time;
+uint64_t initrd_time;
+uint64_t userspace_time;
+uint64_t finish_time;
+};
+struct unit_times {
+char *name;
+uint64_t ixt;
+uint64_t iet;
+uint64_t axt;
+uint64_t aet;
+uint64_t time;
+};
+
+static uint64_t property_getu64(
+DBusConnection *bus,
+const char *dest,
+const char *path,
+const char *interface,
+const char *property)
+{
+int err = errno; //back up errno to prevent accidentally setting it.
+_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
+DBusMessageIter iter, sub;
+uint64_t result = 0;
+
+errno = -bus_method_call_with_reply (bus, dest, path,
+org.freedesktop.DBus.Properties, Get,
+reply, NULL,
+DBUS_TYPE_STRING, interface,
+DBUS_TYPE_STRING, property,
+DBUS_TYPE_INVALID);
+if (errno)
+return 0;
+
+if (!dbus_message_iter_init(reply, iter) ||
+dbus_message_iter_get_arg_type(iter) != 
DBUS_TYPE_VARIANT)
+goto fail;
+
+dbus_message_iter_recurse(iter, sub);
+
+if (dbus_message_iter_get_arg_type(sub) != DBUS_TYPE_UINT64)
+goto fail;
+
+dbus_message_iter_get_basic(sub, result);
+
+errno = err;
+return result;
+fail:
+log_error(Failed to