Commit graph

245 commits

Author SHA1 Message Date
Lennart Poettering 84f6181c2a clients: various simplifications 2013-11-06 17:32:51 +01:00
Kay Sievers 6c8ea34fd9 Revert "hostnamed: prevent it from crashing if the chassis is unknown"
This reverts commit 95b015de38.

"bus: handle serialization of NULL strings" (cd6f997f71)
should fix this issue.
2013-11-06 13:38:28 +01:00
Thomas Hindoe Paaboel Andersen 95b015de38 hostnamed: prevent it from crashing if the chassis is unknown
When fallback_chassis would return null it led to a crash and an
empty result in hostnamectl. Only seen after the sd-port.
2013-11-06 00:30:29 +01:00
Kay Sievers 9f6eb1cd58 bus: update bus_map_all_properties() 2013-11-05 02:57:49 +01:00
Thomas Hindoe Paaboel Andersen fc7689bc9c hostnamectl: H requires an argument, P is no longer used 2013-11-04 17:32:50 +01:00
Simon Peeters b028f3e410 hostnamectl: port to sd-bus
Kay:
 - rebase to new transport logic
 - replaced iteration macro with property map
2013-11-02 02:15:54 +01:00
Kay Sievers 9bcbce4201 bus: avoid 'bool' storage when retrieving 'b' from the message
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.
2013-10-22 03:35:45 +02:00
Lennart Poettering abc5fe7250 bus: automatically flush bus queue when we exit the event loop
This way, we do not have to call it manually
2013-10-18 01:43:55 +02:00
Lennart Poettering 66a4c743c0 hostnamed: port over from libdbus to libsystemd-bus 2013-10-18 00:49:01 +02:00
Zbigniew Jędrzejewski-Szmek 872c8faaf2 Fix write-only use of a few variables
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.
2013-10-13 17:56:54 -04:00
Zbigniew Jędrzejewski-Szmek ac4c8d6da8 Allow tabs in environment files
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
2013-09-11 21:58:22 -04:00
Zbigniew Jędrzejewski-Szmek 960787ae27 hostnamectl: show only specific hostname when requested
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.
2013-08-14 19:06:54 -04:00
Daniel Wallace 7085053a43 Allow for the use of @ in remote host calls
Without this you have to use %40 with the -H flag because dbus doesn't
like the @ sign being unescaped.
2013-06-09 18:26:41 -04:00
Jan Janssen 546158bc6f Fix --no-ask-password
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.
2013-05-23 00:28:04 -04:00
Jan Janssen 2927b326cc man: Document missing options 2013-05-21 09:23:51 -04:00
Lennart Poettering c0b21b9669 hostnamectl: suppress outputting of pretty hostname field in status if empty 2013-05-07 20:56:41 +02:00
Lennart Poettering e724b0639c hostname: only suppress setting of pretty hostname if it is non-equal to the static hostname and if the static hostname is set, too
https://bugzilla.redhat.com/show_bug.cgi?id=957814
2013-05-07 20:56:41 +02:00
Zbigniew Jędrzejewski-Szmek b92bea5d2a Use initalization instead of explicit zeroing
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.
2013-04-05 19:50:57 -04:00
Lennart Poettering fda2c5d28b hostnamectl: if somebody invokes 'hostnamectl set-hostname' with a valid 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.
2013-04-03 22:06:16 +02:00
Lennart Poettering f73141d765 shared: rework env file reader
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.
2013-04-03 20:12:57 +02:00
Lennart Poettering 574d5f2dfc util: rename write_one_line_file() to write_string_file()
You can write much more than just one line with this call (and we
frequently do), so let's correct the naming.
2013-04-03 20:12:56 +02:00
Lennart Poettering 737732a41e hostnamed: pretty_string_is_safe() already exists in string_has_cc(), so use that 2013-03-22 18:01:26 +01:00
Colin Walters c6a818c820 Use bus_maybe_send_reply() where applicable
This is a followup to: commit 1a37b9b904

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.
2013-03-18 19:59:32 -04:00
Nathaniel Chen ebe5d6d0d0 hostnamed: allow more special characters in pretty hostname
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.
2013-03-05 20:54:05 +01:00
Harald Hoyer a5c32cff1f honor SELinux labels, when creating and writing config files
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
2013-02-14 16:19:38 +01:00
Lennart Poettering 4d1a690438 env: considerably beef up environment cleaning logic
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])
2013-02-11 03:54:50 +01:00
Lennart Poettering bc2708414b build-sys: drop all distribution specfic checks
Yay, we now have a completely generic systemd. No distribution specific checks anymore!
2013-01-04 23:26:21 +01:00
Lennart Poettering 3960015566 polkit: add "imply" rules to a number of polkit actions 2012-12-31 21:24:26 +01:00
Lennart Poettering 7871c8e932 hostnamed: make chassis type configurable via /etc/machine-info
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.
2012-12-24 19:03:59 +01:00
Lennart Poettering 59f432ea6d hostnamectl: fix parsing of --no-ask-password 2012-11-15 23:07:25 +01:00
Dave Reisner a9cdc94f7f enable localization for common *ctl commands 2012-11-12 14:16:07 -05:00
Kay Sievers f36d7992ef hostnamectl: do not choke on set-hostname with no argument
https://bugzilla.redhat.com/show_bug.cgi?id=871172
2012-10-29 20:56:02 +01:00
Lennart Poettering fe29f9d25b hostnamectl: add more really basic system info to the status output 2012-10-21 03:35:54 +02:00
Lennart Poettering 7591abd480 timedatectl,hostnamectl: rework --help text 2012-10-19 04:51:53 +02:00
Lennart Poettering dbc4fbae58 hostname: add new hostnamectl tool as text client for hostnamed 2012-10-17 21:25:42 +02:00
Lennart Poettering 0b507b17a7 dbus: add some more safety checks before accepting data from bus clients 2012-10-03 13:29:20 -04:00
Shawn Landden 0d0f0c50d3 log.h: new log_oom() -> int -ENOMEM, use it
also a number of minor fixups and bug fixes: spelling, oom errors
that didn't print errors, not properly forwarding error codes,
few more consistency issues, et cetera
2012-07-26 11:48:26 +02:00
Shawn Landden 669241a076 use "Out of memory." consistantly (or with "\n")
glibc/glib both use "out of memory" consistantly so maybe we should
consider that instead of this.

Eliminates one string out of a number of binaries. Also fixes extra newline
in udev/scsi_id
2012-07-25 11:23:57 +02:00
Lennart Poettering 5430f7f2bc relicense to LGPLv2.1 (with exceptions)
We finally got the OK from all contributors with non-trivial commits to
relicense systemd from GPL2+ to LGPL2.1+.

Some udev bits continue to be GPL2+ for now, but we are looking into
relicensing them too, to allow free copy/paste of all code within
systemd.

The bits that used to be MIT continue to be MIT.

The big benefit of the relicensing is that closed source code may now
link against libsystemd-login.so and friends.
2012-04-12 00:24:39 +02:00
Lennart Poettering 89f134406a logind: introduce CanReboot/CanPowerOff bus calls 2012-02-11 00:13:10 +01:00
Kay Sievers 131a4dcfd4 login: move seat udev rules to login subdir 2012-01-22 18:32:13 +01:00
Michal Schmidt d200735e13 dbus: more efficient implementation of properties
The way the various properties[] arrays are initialized is inefficient:
 - only the .data members change at runtime, yet the whole arrays of
   properties with all the fields are constructed on the stack one by
   one by the code.
 - there's duplication, eg. the properties of "org.freedesktop.systemd1.Unit"
   are repeated in several unit types.

Fix it by moving the information about properties into static const
sections. Instead of storing the .data directly in the property, store
a constant offset from a run-time base.
The small arrays of struct BusBoundProperties bind together the constant
information with the right runtime information (the base pointer).

On my system the code shrinks by 60 KB, data increases by 10 KB.
2012-01-16 13:34:42 +01:00
Lennart Poettering 2f9dec073b build-sys: add stub makefiles to subdirs 2012-01-05 16:29:21 +01:00
Kay Sievers 681cfc6c40 hostnamed, localed: move config files to subdir 2011-12-31 07:23:57 +01:00
Kay Sievers 00c36f274b hostnamed: move sources to subdirectory 2011-12-31 07:03:33 +01:00