summaryrefslogtreecommitdiff
path: root/src/hostname
Commit message (Collapse)AuthorAgeFilesLines
* event: rework sd-event exit logicLennart Poettering2013-12-131-2/+0
| | | | | | | | | | | | | With this change a failing event source handler will not cause the entire event loop to fail. Instead, we just disable the specific event source, log a message at debug level and go on. This also introduces a new concept of "exit code" which can be stored in the event loop and is returned by sd_event_loop(). We also rename "quit" to "exit" everywhere else. Altogether this should make things more robus and keep errors local while still providing a way to return event loop errors in a clear way.
* bus: remove explicit activator-specific flags, the kdbus supports it nowKay Sievers2013-12-121-1/+1
|
* bus: add SD_BUS_NAME_REPLACE_EXISTING to all activatable services, fix one ↵Kay Sievers2013-12-121-1/+1
| | | | flags conversion
* bus: instead of exposing the dbus1 flags when acquiring a name use our own ↵Lennart Poettering2013-12-121-1/+1
| | | | | | | 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.)
* event: hook up sd-event with the service watchdog logicLennart Poettering2013-12-111-0/+2
| | | | | | | | | | | | | Adds a new call sd_event_set_watchdog() that can be used to hook up the event loop with the watchdog supervision logic of systemd. If enabled and $WATCHDOG_USEC is set the event loop will ping the invoking systemd daemon right after coming back from epoll_wait() but not more often than $WATCHDOG_USEC/4. The epoll_wait() will sleep no longer than $WATCHDOG_USEC/4*3, to make sure the service manager is called in time. This means that setting WatchdogSec= in a .service file and calling sd_event_set_watchdog() in your daemon is enough to hook it up with the watchdog logic.
* bus: introduce "trusted" bus concept and encode access control in object vtablesLennart Poettering2013-12-101-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduces a new concept of "trusted" vs. "untrusted" busses. For the latter libsystemd-bus will automatically do per-method access control, for the former all access is automatically granted. Per-method access control is encoded in the vtables: by default all methods are only accessible to privileged clients. If the SD_BUS_VTABLE_UNPRIVILEGED flag is set for a method it is accessible to unprivileged clients too. By default whether a client is privileged is determined via checking for its CAP_SYS_ADMIN capability, but this can be altered via the SD_BUS_VTABLE_CAPABILITY() macro that can be ORed into the flags field of the method. Writable properties are also subject to SD_BUS_VTABLE_UNPRIVILEGED and SD_BUS_VTABLE_CAPABILITY() for controlling write access to them. Note however that read access is unrestricted, as PropertiesChanged messages might send out the values anyway as an unrestricted broadcast. By default the system bus is set to "untrusted" and the user bus is "trusted" since per-method access control on the latter is unnecessary. On dbus1 busses we check the UID of the caller rather than the configured capability since the capability cannot be determined without race. On kdbus the capability is checked if possible from the attached meta-data of a message and otherwise queried from the sending peer. This also decorates the vtables of the various daemons we ship with these flags.
* Fix typo: SetChasis -> SetChassisDavid Coppa2013-12-041-1/+1
|
* bus: make sd_bus_request_name() and sd_bus_release_name() behave more like ↵Lennart Poettering2013-12-031-6/+1
| | | | | | | | | | | | other calls Instead of returning an enum of return codes, make them return error codes like kdbus does internally. Also, document this behaviour so that clients can stick to it. (Also rework bus-control.c to always have to functions for dbus1 vs. kernel implementation of the various calls.)
* bus: rework message handlers to always take an error argumentLennart Poettering2013-11-211-48/+35
| | | | | | | | | | | | | | | | | | | | Message handler callbacks can be simplified drastically if the dispatcher automatically replies to method calls if errors are returned. Thus: add an sd_bus_error argument to all message handlers. When we dispatch a message handler and it returns negative or a set sd_bus_error we send this as message error back to the client. This means errors returned by handlers by default are given back to clients instead of rippling all the way up to the event loop, which is desirable to make things robust. As a side-effect we can now easily turn the SELinux checks into normal function calls, since the method call dispatcher will generate the right error replies automatically now. Also, make sure we always pass the error structure to all property and method handlers as last argument to follow the usual style of passing variables for return values as last argument.
* hostnamed: modernizationsLennart Poettering2013-11-211-9/+5
|
* bus: let's simplify things by getting rid of unnecessary bus parametersLennart Poettering2013-11-211-20/+20
|
* bus: introduce concept of a default bus for each thread and make use of it ↵Lennart Poettering2013-11-121-1/+1
| | | | | | | | everywhere We want to emphasize bus connections as per-thread communication primitives, hence introduce a concept of a per-thread default bus, and make use of it everywhere.
* bus: introduce concept of a "default" event loop per-thread and make use of ↵Lennart Poettering2013-11-121-1/+1
| | | | | | | | | it everywhere Try to emphasize a bit that there should be a mapping between event loops and threads, hence introduce a logic that there's one "default" event loop for each thread, that can be queried via "sd_event_default()".
* clients: try to follow roughly the same order in --help texts for common optionsLennart Poettering2013-11-071-4/+4
|
* bus: log message parsing errors everywhere with a generalized ↵Lennart Poettering2013-11-071-1/+1
| | | | bus_log_parse_error()
* polkit: don't spawn local client if we access a remote systemLennart Poettering2013-11-071-4/+13
|
* consistently use "int" when retrieving "bool" from bus messagesKay Sievers2013-11-071-3/+3
|
* clients: unify how we invoke getopt_long()Lennart Poettering2013-11-061-8/+6
| | | | | Among other things this makes sure we always expose a --version command and show it in the help texts.
* clients: various simplificationsLennart Poettering2013-11-061-1/+1
|
* Revert "hostnamed: prevent it from crashing if the chassis is unknown"Kay Sievers2013-11-061-3/+0
| | | | | | | This reverts commit 95b015de3849d8d8d03d9441ae1682a04c38833b. "bus: handle serialization of NULL strings" (cd6f997f71c3aba16aa08226d423d14cbc787f82) should fix this issue.
* hostnamed: prevent it from crashing if the chassis is unknownThomas Hindoe Paaboel Andersen2013-11-061-0/+3
| | | | | When fallback_chassis would return null it led to a crash and an empty result in hostnamectl. Only seen after the sd-port.
* bus: update bus_map_all_properties()Kay Sievers2013-11-051-7/+8
|
* hostnamectl: H requires an argument, P is no longer usedThomas Hindoe Paaboel Andersen2013-11-041-1/+1
|
* hostnamectl: port to sd-busSimon Peeters2013-11-021-259/+97
| | | | | | Kay: - rebase to new transport logic - replaced iteration macro with property map
* bus: avoid 'bool' storage when retrieving 'b' from the messageKay Sievers2013-10-221-3/+3
| | | | | | Just use an unsigned int as a bool type to avoid issues in the public message reading API; sizeof(bool) == 1, but the code copies 4 bytes at the pointers destination.
* bus: automatically flush bus queue when we exit the event loopLennart Poettering2013-10-181-1/+0
| | | | This way, we do not have to call it manually
* hostnamed: port over from libdbus to libsystemd-busLennart Poettering2013-10-181-374/+308
|
* Fix write-only use of a few variablesZbigniew Jędrzejewski-Szmek2013-10-131-0/+2
| | | | | | Since the invention of read-only memory, write-only memory has been considered deprecated. Where appropriate, either make use of the value, or avoid writing it, to make it clear that it is not used.
* Allow tabs in environment filesZbigniew Jędrzejewski-Szmek2013-09-111-1/+2
| | | | | | | | | | | | bash allows them, and so should we. string_has_cc is changed to allow tabs, and if they are not wanted, they must be now checked for explicitly. There are two other callers, apart from the env file loaders, and one already checked anyway, and the other is changed to check. https://bugs.freedesktop.org/show_bug.cgi?id=68592 https://bugs.gentoo.org/show_bug.cgi?id=481554
* hostnamectl: show only specific hostname when requestedZbigniew Jędrzejewski-Szmek2013-08-141-25/+81
| | | | | | | Existing --pretty, --transient, --static options, used previously for 'set-hostname' verb, are reused for the 'status' verb. If one of them is given, only the specified hostname is printed. This way there's no need to employ awk to get the hostname in a script.
* Allow for the use of @ in remote host callsDaniel Wallace2013-06-091-2/+3
| | | | | Without this you have to use %40 with the -H flag because dbus doesn't like the @ sign being unescaped.
* Fix --no-ask-passwordJan Janssen2013-05-231-3/+3
| | | | | | POSIX_ME_HARDER mode is disabled for localectl. It doesn't make much sense in case of localectl, and there's little reason for localectl to behave specially.
* man: Document missing optionsJan Janssen2013-05-211-0/+1
|
* hostnamectl: suppress outputting of pretty hostname field in status if emptyLennart Poettering2013-05-071-4/+8
|
* hostname: only suppress setting of pretty hostname if it is non-equal to the ↵Lennart Poettering2013-05-071-27/+8
| | | | | | static hostname and if the static hostname is set, too https://bugzilla.redhat.com/show_bug.cgi?id=957814
* Use initalization instead of explicit zeroingZbigniew Jędrzejewski-Szmek2013-04-051-2/+1
| | | | | | | | | | | | | | | | | | | | | | | Before, we would initialize many fields twice: first by filling the structure with zeros, and then a second time with the real values. We can let the compiler do the job for us, avoiding one copy. A downside of this patch is that text gets slightly bigger. This is because all zero() calls are effectively inlined: $ size build/.libs/systemd text data bss dec hex filename before 897737 107300 2560 1007597 f5fed build/.libs/systemd after 897873 107300 2560 1007733 f6075 build/.libs/systemd … actually less than 1‰. A few asserts that the parameter is not null had to be removed. I don't think this changes much, because first, it is quite unlikely for the assert to fail, and second, an immediate SEGV is almost as good as an assert.
* hostnamectl: if somebody invokes 'hostnamectl set-hostname' with a valid ↵Lennart Poettering2013-04-032-9/+29
| | | | | | | | | | | | internet hostname unset the pretty name If people are unaware or uninterested in the concept of pretty host names, and simply invoke "hostnamectl set-hostname" for a valid internet host name, then use this as indication to unset the pretty host name and only set the static/dynamic one. This also allows fqdn, hence "hostnamectl set-hostname www.foobar.com" will just work if people really insist on using fqdns as hostnames.
* shared: rework env file readerLennart Poettering2013-04-031-1/+1
| | | | | | Implement this with a proper state machine, so that newlines and escaped chars can appear in string assignments. This should bring the parser much closer to shell.
* util: rename write_one_line_file() to write_string_file()Lennart Poettering2013-04-031-1/+1
| | | | | You can write much more than just one line with this call (and we frequently do), so let's correct the naming.
* hostnamed: pretty_string_is_safe() already exists in string_has_cc(), so use ↵Lennart Poettering2013-03-221-14/+1
| | | | that
* Use bus_maybe_send_reply() where applicableColin Walters2013-03-181-1/+1
| | | | | | | | | This is a followup to: commit 1a37b9b9043ef83e9900e460a9a1fccced3acf89 It will fix denial messages from dbus-daemon between gdm and systemd-logind on logging into GNOME due to this. See the previous commit for more details.
* hostnamed: allow more special characters in pretty hostnameNathaniel Chen2013-03-051-1/+14
| | | | | | | | | | | | | | | this addresses the bug at: https://bugs.freedesktop.org/show_bug.cgi?id=59311 https://bugzilla.redhat.com/show_bug.cgi?id=895299 hostnamectl is supposed to allow a range of special characters for the 'pretty' hostname: $ hostnamectl set-hostname --pretty "Nathaniels Desktop !@#$%" ..however, it rejects apostrophes, double quotes, and backslashes. The manual for hostnamectl suggests that this should be allowed. It makes sense to reject \0, \n, etc. pretty_string_is_safe() is the same as string_is_safe(), but allows more special characters.
* honor SELinux labels, when creating and writing config filesHarald Hoyer2013-02-142-3/+6
| | | | | | | Also split out some fileio functions to fileio.c and provide a SELinux aware pendant in fileio-label.c see https://bugzilla.redhat.com/show_bug.cgi?id=881577
* env: considerably beef up environment cleaning logicLennart Poettering2013-02-111-0/+1
| | | | | | | | | | | | | Now, actually check if the environment variable names and values used are valid, before accepting them. With this in place are at some places more rigid than POSIX, and less rigid at others. For example, this code allows lower-case environment variables (which POSIX suggests not to use), but it will not allow non-UTF8 variable values. All in all this should be a good middle ground of what to allow and what not to allow as environment variables. (This also splits out all environment related calls into env-util.[ch])
* build-sys: drop all distribution specfic checksLennart Poettering2013-01-041-1/+0
| | | | Yay, we now have a completely generic systemd. No distribution specific checks anymore!
* polkit: add "imply" rules to a number of polkit actionsLennart Poettering2012-12-311-0/+1
|
* hostnamed: make chassis type configurable via /etc/machine-infoLennart Poettering2012-12-242-26/+156
| | | | | | | | | | | | | | | | | | | | | | For many usecases it is useful to store the chassis type somewhere, and /etc/machine-info sounds like a good place. Ideally we could always detect the chassis type from firmware, but frequently that's not available and in many embedded devices probably entirely unrealistic. This patch adds a configurable setting CHASSIS= to /etc/machine-info and exposes this via hostnamectl/hostnamed. hostnamed will guess the chassis type from DMI if nothing is set explicitly. I also added support for detecting it from ACPI, which should be more useful as ACPI 5.0 actually knows a "tablet" chassis type, which neither DMI nor previous ACPI versions knew. This also enables DMI-based and ACPI-based detection for non-x86 systems as ACPI is apparently coming to ARM platforms soon. I tried to minimize the vocabulary of chassis types understood and added: desktop, laptop, server, tablet, handset. This is much less than either APCI or DMI know. If we need more types later on we can easily add them.
* hostnamectl: fix parsing of --no-ask-passwordLennart Poettering2012-11-151-0/+4
|
* enable localization for common *ctl commandsDave Reisner2012-11-121-0/+2
|
* hostnamectl: do not choke on set-hostname with no argumentKay Sievers2012-10-291-1/+1
| | | | https://bugzilla.redhat.com/show_bug.cgi?id=871172