libweston contains weston_config and weston_shell_utils utilities
functions so include these in the sphinx documentation as well.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This doesn't really belong into shell-utils, so better move it out to
shared/config-parser. Renamed to weston_config_get_binding_modifier
to maintain the same namespace.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This was the only file in Weston using WL_EXPORT on its own line. Fix
the style to follow everything else.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
While the code looks fine, clang 7 memory sanitizer complains about
things like:
==26052==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x7f4f4d003327 in weston_config_get_section /home/pq/build/weston-clang/../../git/weston/shared/config-parser.c:141:2
#1 0x7f4f4cfce11a in wet_main /home/pq/build/weston-clang/../../git/weston/compositor/main.c:3266:12
==26683==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x7f09ebd638e2 in config_section_get_entry /home/pq/build/weston-clang/../../git/weston/shared/config-parser.c:125:2
#1 0x7f09ebd661c4 in weston_config_section_get_bool /home/pq/build/weston-clang/../../git/weston/shared/config-parser.c:310:10
#2 0x7f09ebd2e1e5 in wet_main /home/pq/build/weston-clang/../../git/weston/compositor/main.c:3269:3
In all cases, the errors point to wl_list_for_each().
Making these allocations use zalloc() avoids these errors. Since using
zalloc() is a good habit in any case, I didn't dig deeper.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Wayland innovated a lot of cool things, but non-binary boolean values is
the great advances of our time.
Make config_parser_get_bool() work on boolean values, and switch all its
users.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Make sure we export the get_full_path() accessor (declared in the
header, used by Weston itself) and the parser's destroy function.
Signed-off-by: Daniel Stone <daniels@collabora.com>
It is a public installed header used by libweston.h.
See "Rename compositor.h to libweston/libweston.h" for rationale.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
The in-tree clients can access the functions via libshared, but they are
currently not available for external clients, such as custom shell helper
applications similar to weston-desktop-shell or
weston-ivi-shell-user-interface.
The functions to read the content of the config are already exported.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
It's a bit surprising that Weston looks different when launched from the root
of the git repo vs from elsewhere.
But it's also technically a security vulnerability: if I launch it from
a directory like /tmp, it might pick up a weston.ini created by another user,
which could then load modules with arbitrary code. Basically, it's the same
problem as including "." in $PATH.
Signed-off-by: Dima Ryazanov <dima@gmail.com>
Now that WESTON_MODULE_MAP supersedes WESTON_BUILD_DIR for libexec
binaries, we don't need to check in WESTON_BUILD_DIR anymore.
There was only one user of weston_config_get_libexec_dir(), so remove
the whole function. There is no reason to export it.
Due to libshared.la being pulled into libweston, this probably was
libweston ABI unintended. Regardless, libweston major has already been
bumped.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
This symbol wasn’t exported from the weston binary, most likely due to
an oversight in 6e2c12496b, and because
internal modules can link against libshared.la directly it hasn’t been
found ever since.
This commit makes it possible for external modules to iterate over the
configuration file.
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Bryce Harrington <bryce@osg.samsung.com>
[With hexadecimal color values now handled via their own routine,
re-introduce the negative unsigned numbers fix.]
strtoul() has a side effect that when given a string representing a
negative number, it treats it as a high value hexadecimal. IOW,
strtoul("-42", &val) sets val to 0xffffffd6. This could potentially
result in unintended surprise behaviors.
Catch this by using strtol() and then manually check for the negative
value. This logic is modelled after Wayland's strtouint().
Note that this change unfortunately reduces the range of parseable
numbers from [0,UINT_MAX] to [0,INT_MAX]. The current users of
weston_config_section_get_uint() are anticipating numbers far smaller
than either of these limits, so the change is believed to have no impact
in practice.
Also add a test case for negative numbers that catches this error
condition.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Previously weston_config_section_get_uint was serving dual purpose for
parsing both unsigned decimal integer values (ids, counts, seconds,
etc.) and hexadecimal values (colors), by relying on strtoul's
auto-detection mechanism.
However, this usage is unable to catch certain kinds of error
conditions, such as specifying a negative number where an unsigned
should be used. And for colors in particular, it would misparse hex
values if the leading 0x was omitted. E.g. "background-color=99999999"
would render a near-black background (effectively 0x05f5e0ff) instead of
medium grey, and "background-color=ffffffff" would be treated as an
error rather than white. "background-color=0x01234567",
"background-color=01234567", and "background-color=1234567" each
resulted in the value being parsed as hexadecimal, octal, and decimal
respectively, resulting in colors 0x01234567, 0x00053977, and 0x0012d687
being displayed.
This new routine forces hexadecimal to be used in all cases when parsing
color values, so "0x01234567" and "01234567" result in the same color
value, "99999999" is grey, and "ffffffff" is white. It also requires
exactly 8 or 10 digits (other lengths likely indicate typos), or the
value "0" (black).
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
The reduction in range limits does have an effect for color values,
which are expressed as hexadecimal values from 0x00000000 to
0xFFFFFFFF. By limiting the range to INT_MAX, color values of
0x80000000 and up are in fact lost.
This reverts commit 6351fb08c2.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
Tested-by: Yong Bakos <ybakos@humanoriented.com>
The third arg to strtol() specifies the base to assume for the number.
When 0 is passed, as is currently done in option-parser.c, hexadecimal
and octal numbers are permitted and automatically detected and
converted.
This change is an expansion of f6051cbab8
to cover the remaining strtol() calls in Weston, where the routine is
being used to read fds and pids - which are always expressed in base-10.
It also changes the calls in config-parser, used by
weston_config_section_get_int(), which in turn is being used to read
scales, sizes, times, rates, and delays; these are all expressed in
base-10 numbers only.
The benefit of limiting this to base-10 is to eliminate surprises when
parsing numbers from the command line. Also, by making the code
consistent with other usages of strtol, it may make it possible to
factor out the common code in the future.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
strtoul() has a side effect that when given a string representing a
negative number, it returns a negated version as the value, and does not
flag an error. IOW, strtoul("-42", &val) sets val to 42. This could
potentially result in unintended surprise behaviors, such as if one were
to inadvertantly set a config param to -1 expecting that to disable it,
but with the result of setting the param to 1 instead.
Catch this by using strtol() and then manually check for the negative
value. This logic is modelled after Wayland's strtouint().
Note that this change unfortunately reduces the range of parseable
numbers from [0,UINT_MAX] to [0,INT_MAX]. The current users of
weston_config_section_get_uint() are anticipating numbers far smaller
than either of these limits, so the change is believed to have no impact
in practice.
Also add a test case for negative numbers that catches this error
condition.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Check errno, which is set of over/underflow, out of range, etc. Also
check for empty strings (the usages covered in this patch already also
cover the case where there are non-digits present). Set errno to 0
before making the strto*l call in case of pre-existing errors
(i.e. ENOTTY when running under the testsuite).
This follows the error checking style used in Wayland
(c.f. wayland-client.c and scanner.c).
In tests, also check errno, and add testcases for parsing '0'.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Removed duplicate definitions of the container_of() macro and
refactored sources to use the single implementation.
Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
We have the Weston command line option '--no-config' which is meant to
prevent loading weston.ini at all. It works for Weston itself, but it
does not work for any clients that also want to read weston.ini.
To fix that, introduce a new environment variable WESTON_CONFIG_FILE.
Weston will set it to the absolute path of the config file it loads.
Clients will load the config file pointed to by WESTON_CONFIG_FILE. If
the environment variable is set but empty, no config file will be
loaded. If the variable is unset, things fall back to the default
"weston.ini".
Note, that Weston will only set WESTON_CONFIG_FILE, it never reads it.
The ability to specify a custom config file to load will be another patch.
All programs that loaded "weston.ini" are modified to honour
WESTON_CONFIG_FILE.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Reviewed-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
open() will happily open directories and other non-normal files.
Attempting to parse them as config files makes no sense, so check that
the opened file is indeed a regular file.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Reviewed-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
desktop shell and weston keyboard both refer to themselves prefixed by
LIBEXECDIR, however this is only valid once installed. make check will
currently either fail or run pre-existing versions.
This patch adds a way to override that location by setting the env var
WESTON_BUILD_DIR - which is then set by the test env script so make check
will test the versions in the build directory regardless of whether they're
installed or not.
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Adding a check in weston_config_full_path so that
we don't crash if we started without a config file.
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
This patch adds 3 new options to weston.ini to allow
the user to change default constant_accel_factor,
min_accel_factor and max_accel_factor. If no options
are set, it falls back using defaults as it did before.
v2: create weston_config_section_get_double and use it
instead of manualy converting string to double.
v3: add default values in weston_config_get_double
instead of using conditionals.
v4: don't pass diagonal as pointer.
AC_USE_SYSTEM_EXTENSIONS enables _XOPEN_SOURCE, _GNU_SOURCE and similar
macros to expose the largest extent of functionality supported by the
underlying system. This is required since these macros are often
limiting rather than merely additive, e.g. _XOPEN_SOURCE will actually
on some systems hide declarations which are not part of the X/Open spec.
Since this goes into config.h rather than the command line, ensure all
source is consistently including config.h before anything else,
including system libraries. This doesn't need to be guarded by a
HAVE_CONFIG_H ifdef, which was only ever a hangover from the X.Org
modular transition.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
[pq: rebased and converted more files]
backtrace:
(gdb) bt
#0 0xb7704424 in __kernel_vsyscall ()
#1 0xb757ddde in raise (sig=5) at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:42
#2 <signal handler called>
#3 weston_config_destroy (config=0x0) at config-parser.c:508
#4 0xb75cbc0e in x11_destroy (ec=0x93506b0) at compositor-x11.c:1473
#5 0x0804e0e9 in main (argc=1, argv=0xbffe5354) at compositor.c:3337
The current config parser, parses the ini file and pulls out the values
specified by the struct config_section passed to parse_config_file() and
then throw the rest away. This means that every place we want to get
info out of the ini file, we have to parse the whole thing again. It's not
a big overhead, but it's also not a convenient API.
This patch adds a parser that parses the ini file to a data structure and
puts that in weston_compositor->config along with API to query comfig
keys from the data structure. The old parser is still available, but
we'll transition to the new approach over the next few commits.
This set of changes adds support for searching for a given config file
in the directories listed in $XDG_CONFIG_DIRS if it wasn't found in
$XDG_CONFIG_HOME or ~/.config. This allows packages to install custom
config files in /etc/xdg/weston, for example, thus allowing them to
avoid dealing with home directories.
To avoid a TOCTOU race the config file is actually open()ed during the
search. Its file descriptor is returned and stored in the compositor
for later use when performing subsequent config file parses.
Signed-off-by: Ossama Othman <ossama.othman@intel.com>
Fixes
config-parser.c: In function 'handle_key':
config-parser.c:81: error: control reaches end of non-void function
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Eventually we will want more functionality in the shared library and we
will rename it at that point. Perhaps we'll name it libnih, but for now
let's stick with libconfig-parser.