1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-15 07:24:00 +03:00
Commit Graph

13343 Commits

Author SHA1 Message Date
Lennart Poettering
b408e2a8be man: update sd_bus_request_name() man page 2013-12-13 04:06:43 +01:00
Lennart Poettering
11846aa746 bus: make sure exit-on-idle logic works on kdbus systems that do not generate NameLost 2013-12-13 04:06:43 +01:00
Lennart Poettering
2c8d477a01 bus: fix parsing of matches against empty strings 2013-12-13 04:06:43 +01:00
Thomas Hindoe Paaboel Andersen
5fba7bbfa4 scan-build: silence some warnings
test-fileio/test-strv:
Use the streq_ptr to make build-scan not worry about passing in a null
to a nonnull function.

test-dhcp-option:
Prevent a theoretical null pointer dereference
2013-12-12 23:08:47 +01:00
Lennart Poettering
e4bb80a076 bus: fix rewind logic 2013-12-12 20:49:32 +01:00
Lennart Poettering
c4ef331782 service: process watchdog timeouts with lowest priority 2013-12-12 20:49:32 +01:00
Kay Sievers
5bb658a178 bus: remove explicit activator-specific flags, the kdbus supports it now 2013-12-12 20:27:23 +01:00
Kay Sievers
07442efff8 bus: update kdbus.h 2013-12-12 20:19:12 +01:00
Lennart Poettering
3df7a7e610 bus: always pass valid timeout to kdbus 2013-12-12 20:00:45 +01:00
Lennart Poettering
0f437184b6 bus: enforce endianess and marshalling for messages we send 2013-12-12 20:00:45 +01:00
Shawn Landden
9ff09bcb86 timedatectl: work with old timedated
Which does have TimeUSec. Should we specifically check for this method
instead of assuming time=0 means it doesn't exist?

Before:
shawn@debian-T61:~/git/systemd$ ./timedatectl
      Local time: Wed 1969-12-31 16:00:00 PST
  Universal time: Thu 1970-01-01 00:00:00 UTC
        RTC time: n/a
        Timezone: America/Los_Angeles (PST, -0800)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  Sun 1969-10-26 01:59:59 PDT
                  Sun 1969-10-26 01:00:00 PST
 Next DST change: DST begins (the clock jumps one hour forward) at
                  Sun 1970-04-26 01:59:59 PST
                  Sun 1970-04-26 03:00:00 PDT

After:
shawn@debian-T61:~/git/systemd$ ./timedatectl
      Local time: Wed 2013-12-11 14:03:21 PST
  Universal time: Wed 2013-12-11 22:03:21 UTC
        RTC time: n/a
        Timezone: America/Los_Angeles (PST, -0800)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  Sun 2013-11-03 01:59:59 PDT
                  Sun 2013-11-03 01:00:00 PST
 Next DST change: DST begins (the clock jumps one hour forward) at
                  Sun 2014-03-09 01:59:59 PST
                  Sun 2014-03-09 03:00:00 PDT
2013-12-12 20:00:45 +01:00
Zbigniew Jędrzejewski-Szmek
189b2384d6 build-sys: use internal library for dhcp client tests
Also clean up AM_CFLAGS in a few places.
2013-12-12 11:43:34 -05:00
Patrik Flykt
d2fe46b514 dhcp: Add function to free DHCP client data 2013-12-12 11:43:34 -05:00
Patrik Flykt
751246ee37 dhcp: Add notification callback
Define a notification callback and events for stopping and client
lease expiry. Add functions to fetch IP parameters from a lease.
2013-12-12 11:43:34 -05:00
Patrik Flykt
51debc1e39 dhcp: Compute expire, T1 and T2 timers
Compute the default T1 and T2 timer values if they were not set by
the DHCP server. Verify that the values are reasonable.
2013-12-12 11:43:34 -05:00
Patrik Flykt
3e3d8f7857 dhcp: Process DHCP Ack/Nak message
Process a DHCP Ack/Nak in much the same way as an DHCP Offer. Factor
out header verification and process options sent. Add notification
functionality with discrete values for the outcome of the DHCP Ack/
Nak processing.
2013-12-12 11:43:34 -05:00
Patrik Flykt
564ba3b0ef dhcp: Add maximum message size option
Add maximum message size option to keep some DHCP server implementations
from sending too big messages. See ConnMan commit
0c5c862749c05193cf4c513628328c6db02b5222.
2013-12-12 11:43:34 -05:00
Patrik Flykt
e2dfc79f06 dhcp: Send DHCP Request to acquire an IP address
Create and send a DHCP Request message reusing already existing parts
of the code. This causes factoring out IP and UDP header creation and
moving next timeout calculation to be done every time in the timer
callback function independent of DHCP state. Also add an exponential
part to the timer calculation, bail out if there are errors while
resending the DHCP message for the sixth or more times.
2013-12-12 11:43:34 -05:00
Patrik Flykt
8c00042c93 dhcp: Handle received DHCP Offer message
Create a function for handling the full IP, UDP and DHCP packet
and tie it to the main loop. Verify IP and UDP headers and checksum.
Creat a new lease structure with using the values supplied in the
DHCP message. Free the lease structure when client is stopped.

Split out socket handling into a creation and a sending part. As a
result modify the test code.
2013-12-12 11:43:34 -05:00
Patrik Flykt
d3d8ac2f2b dhcp: Add timeout and main loop support
Require a main loop to be set when creating a DHCP client. Set up
a timer to resend DHCP Discover messages and add a 0-2 second
delay to the timeout value. Move to state Selecting after successful
sending of a Discover message.
2013-12-12 11:43:34 -05:00
Patrik Flykt
117539f8b7 build: Add dependency on libsystemd-bus needed for main loop 2013-12-12 11:43:34 -05:00
Patrik Flykt
bbdf06d9f2 dhcp: Add function to stop the DHCP client
The client is stopped and brought back to its initial state.
2013-12-12 11:43:34 -05:00
Patrik Flykt
f5a70de7a9 dhcp: Support seconds elapsed since start of DHCP negotiation
It was noticed by Grant Erickson in ConnMan commit
95e15c09350acf58d4707056ae2614570883ef66 that:

   "Certain DHCP servers, such as that implemented in Mac OS X
    (< 10.7) for its "Internet Sharing" feature, refuse to issue
    a DHCP lease to clients that have not set a non-zero value
    in their DISCOVER or REQUEST packets."
2013-12-12 11:43:34 -05:00
Patrik Flykt
290c7324ca dhcp: Add test for discover DHCP packet creation
Set a fake MAC address and emulate raw packet sending. When the buffer
containing the Discover message is received, check selected IP and
UDP headers and compute IP header and UDP message checksums. Also
send the DHCP message for option parsing and expect a successful
outcome.
2013-12-12 11:43:34 -05:00
Patrik Flykt
e1c244dea0 build: Add libsystemd-dhcp 2013-12-12 11:43:34 -05:00
Patrik Flykt
46a66b794a dhcp: Add DHCP discover sending
On starting the client, use the supplied interface mac address and create
a transaction id. Puzzle together an IP/UDP/DHCP Discover message, compute
checksums and send it out as a raw packet.

Create an additional function that constructs default options common to
all DHCP messages.

Set the DHCP Client ID option as noticed by Grant Erickson in ConnMan
commit b18d9798b3a0ae46ed87d6d2be8d5a474bf3ab1e:

   "Some Internet gateways and Wi-Fi access points are unhappy when the
    DHCPv4 client-id option (61) is missing and will refuse to issue a
    DHCP lease."
2013-12-12 11:43:34 -05:00
Patrik Flykt
8b4a96932d dhcp: Add function for sending a raw packet
Open a packet socket, create a link level header, send packet and
close socket. Adding it to a separate file makes testing of the
DHCP sending much easier, as the test program can supply any socket
to the DHCP client code.
2013-12-12 11:43:34 -05:00
Patrik Flykt
e88bc7958c shared: Add struct sockaddr_ll to sockaddr_union 2013-12-12 11:43:34 -05:00
Patrik Flykt
39b7f59600 dhcp: Add test function for computing checksum 2013-12-12 11:43:34 -05:00
Patrik Flykt
d8b61a1dc9 dhcp: Add option append tests
Add checks for invalid lengths and parameters when using the option
appending function. Add also checks for adding options, see to it
that the resulting array is identical to the array of options added.
2013-12-12 11:43:34 -05:00
Patrik Flykt
a10c375e02 dhcp: Add tests for DHCP options, file and sname fields
Add a structure describing the DHCP file, sname and trailing options
fields. Create a messge holding these fields and call the internal
option parsing function.

In the test callback function verify that only regular options are
passed and figure out which part of the DHCP message is the one that
is being processed. As the test program knows the full contents of
the test options in the test structure, skip all non-regular fields
and verify that the option provided to the callback indeed is the
one expected. Check also if non-regular option fields are to be
ignored in the end of the option field as the callback is not called
again and the final check when the whole message has been processed
needs to be successful.

Add a boolean flag for pretty-printing, anticipate there will be a
nice option to toggle it in the future.
2013-12-12 11:43:33 -05:00
Patrik Flykt
78628cd273 build: Add DHCP option test 2013-12-12 11:43:33 -05:00
Patrik Flykt
a0ae95c9be dhcp: Add buffer length and invalid cookie tests for DHCP options
Create an initial simple test program for these two cases.
2013-12-12 11:43:33 -05:00
Patrik Flykt
524cf45894 dhcp: Add option appending and parsing
Add functions to append and parse DHCP options. Not all options
are passed to the callback function, the ones not exposed are
pad, end, message type and overload. If indicated by the overload
option, file and sname fields will be examined for more options.

The option functions are internal to DHCP, add a new header files
for interal function prototypes.
2013-12-12 11:43:33 -05:00
Patrik Flykt
b5d01d174c build: Add initial build support
The client test program is the only one to be built so far.
2013-12-12 11:43:33 -05:00
Patrik Flykt
be391925d5 dhcp: Add test for DHCP client initialization and parameter setting 2013-12-12 11:43:33 -05:00
Patrik Flykt
011feef852 dhcp: Add DHCP client initialization
Provide functionality for initializing a DHCP client struct, setting
interface index, last used address and additional options to request.
On initialization the most useful options are added by default.
2013-12-12 11:43:33 -05:00
Patrik Flykt
5f404b1e68 dhcp: Add DHCP protocol structures and initial defines
Create a new directory to host DHCP components.
2013-12-12 11:43:33 -05:00
Lennart Poettering
e5ca092c27 log: protect errno when we use assert_return() 2013-12-12 15:59:13 +01:00
Lennart Poettering
ad5b215d1b core: suppress gcc warnings on selinux-less systems 2013-12-12 15:59:13 +01:00
Lennart Poettering
01390ca8a2 update TODO 2013-12-12 15:59:13 +01:00
Marc-Antoine Perennou
2a410422ec shared: add missing include
Needed for socketpair, recv
2013-12-12 08:49:25 -05:00
Kay Sievers
d90bb66996 bus: add SD_BUS_NAME_REPLACE_EXISTING to all activatable services, fix one flags conversion 2013-12-12 06:41:23 +01:00
Lennart Poettering
29a07cdb4a bus: instead of exposing the dbus1 flags when acquiring a name use our own that are closer to kdbus
This turns around DO_NOT_QUEUE into QUEUE which implies a more useful
default. (And negative options are awful anyway.)
2013-12-12 05:55:58 +01:00
Lennart Poettering
f8e11cda53 bus: properly return an error when we detect a method call timeout 2013-12-12 05:40:05 +01:00
Lennart Poettering
6d99330e26 core: fix bus registration on daemon reexec 2013-12-12 05:40:04 +01:00
Zbigniew Jędrzejewski-Szmek
4d680aeea1 nspawn: complain and continue if machine has same id
If --link-journal=host or --link-journal=guest is used, this totally
cannot work and we exit with an error. If however --link-journal=auto
or --link-journal=no is used, just display a warning.

Having the same machine id can happen if booting from the same
filesystem as the host. Since other things mostly function correctly,
let's allow that.

https://bugs.freedesktop.org/show_bug.cgi?id=68369
2013-12-11 22:39:41 -05:00
Zbigniew Jędrzejewski-Szmek
50f72bca65 Do not log all assert_return failures
% build/journalctl help
Assertion 'match_is_valid(data, size)' failed at ../src/journal/sd-journal.c:227, function sd_journal_add_match(). Ignoring.

Callers cannot be expect to check all arguments always.
2013-12-11 22:26:55 -05:00
Djalal Harouni
faf5077f89 journal: pipe journalctl help output into a pager
journalctl help output might run off the screen, so be consistent
as other systemd tools do and pipe it into a pager.
2013-12-11 22:26:55 -05:00
Zbigniew Jędrzejewski-Szmek
05b92756f7 man: mention SYSTEMD_USER_WANTS
Also split into paragraphs for easier reading and make a few minor
corrections.
2013-12-11 22:26:18 -05:00