Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libxkbcommon for openSUSE:Factory checked in at 2023-01-04 17:51:02 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libxkbcommon (Old) and /work/SRC/openSUSE:Factory/.libxkbcommon.new.1563 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libxkbcommon" Wed Jan 4 17:51:02 2023 rev:40 rq:1046396 version:1.5.0 Changes: -------- --- /work/SRC/openSUSE:Factory/libxkbcommon/libxkbcommon.changes 2022-05-23 15:51:45.738647321 +0200 +++ /work/SRC/openSUSE:Factory/.libxkbcommon.new.1563/libxkbcommon.changes 2023-01-04 17:51:20.793737377 +0100 @@ -1,0 +2,9 @@ +Mon Jan 2 23:38:34 UTC 2023 - Jan Engelhardt <jeng...@inai.de> + +- Update to release 1.5.0 + * Fix crash in `xkbcli interactive-wayland` under a compositor + which supports new versions of the xdg-shell protocol. + * New API: XKB_CONTEXT_NO_SECURE_GETENV, + RXKB_CONTEXT_NO_SECURE_GETENV + +------------------------------------------------------------------- Old: ---- libxkbcommon-1.4.1.tar.xz New: ---- libxkbcommon-1.5.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libxkbcommon.spec ++++++ --- /var/tmp/diff_new_pack.aLIMFK/_old 2023-01-04 17:51:21.985744402 +0100 +++ /var/tmp/diff_new_pack.aLIMFK/_new 2023-01-04 17:51:21.989744425 +0100 @@ -1,7 +1,7 @@ # # spec file for package libxkbcommon # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -23,7 +23,7 @@ %endif Name: libxkbcommon -Version: 1.4.1 +Version: 1.5.0 Release: 0 Summary: Library for handling xkb descriptions License: MIT @@ -35,7 +35,7 @@ Source2: baselibs.conf BuildRequires: bison BuildRequires: flex -BuildRequires: meson >= 0.49 +BuildRequires: meson >= 0.51 BuildRequires: pkg-config BuildRequires: xz BuildRequires: pkgconfig(libxml-2.0) ++++++ libxkbcommon-1.4.1.tar.xz -> libxkbcommon-1.5.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/.github/workflows/github-release.yml new/libxkbcommon-1.5.0/.github/workflows/github-release.yml --- old/libxkbcommon-1.4.1/.github/workflows/github-release.yml 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/.github/workflows/github-release.yml 2023-01-02 20:23:30.000000000 +0100 @@ -15,7 +15,7 @@ permissions: contents: write steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 persist-credentials: false diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/.github/workflows/linux.yml new/libxkbcommon-1.5.0/.github/workflows/linux.yml --- old/libxkbcommon-1.4.1/.github/workflows/linux.yml 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/.github/workflows/linux.yml 2023-01-02 20:23:30.000000000 +0100 @@ -1,6 +1,10 @@ name: linux -on: [push, pull_request] +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] # Set permissions at the job level. permissions: {} @@ -14,10 +18,10 @@ matrix: compiler: [clang, gcc] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: persist-credentials: false - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v4 with: python-version: '3.9' - name: Install dependencies @@ -37,4 +41,14 @@ meson compile -C build - name: Test run: + meson test -C build --print-errorlogs --no-suite python-tests + - name: Test with valgrind + run: meson test -C build --print-errorlogs --setup=valgrind --no-suite python-tests + - name: Upload test logs + uses: actions/upload-artifact@v3 + if: failure() + with: + name: test logs + path: | + build/meson-logs/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/.github/workflows/macos.yml new/libxkbcommon-1.5.0/.github/workflows/macos.yml --- old/libxkbcommon-1.4.1/.github/workflows/macos.yml 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/.github/workflows/macos.yml 2023-01-02 20:23:30.000000000 +0100 @@ -15,10 +15,10 @@ permissions: contents: read steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: persist-credentials: false - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v4 with: python-version: '3.9' - name: Install dependencies diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/.github/workflows/windows.yml new/libxkbcommon-1.5.0/.github/workflows/windows.yml --- old/libxkbcommon-1.4.1/.github/workflows/windows.yml 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/.github/workflows/windows.yml 2023-01-02 20:23:30.000000000 +0100 @@ -15,10 +15,10 @@ permissions: contents: read steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: persist-credentials: false - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v4 with: python-version: '3.9' - name: Install dependencies diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/NEWS new/libxkbcommon-1.5.0/NEWS --- old/libxkbcommon-1.4.1/NEWS 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/NEWS 2023-01-02 20:23:30.000000000 +0100 @@ -1,3 +1,30 @@ +libxkbcommon 1.5.0 - 2023-01-02 +================== + +- Add `xkb_context` flag `XKB_CONTEXT_NO_SECURE_GETENV` and `rxkb_context` flag + `RXKB_CONTEXT_NO_SECURE_GETENV`. + + xkbcommon uses `getenv_secure()` to obtain environment variables. This flag + makes xkbcommon use `getenv()` instead. + + This is useful for some clients that have relatively benign capabilities set, + like CAP_SYS_NICE, that also want to use e.g. the XKB configuration from the + environment and user configs in XDG_CONFIG_HOME. + + Contributed by Ronan Pigott. + +- Fix crash in `xkbcli interactive-wayland` under a compositor which supports + new versions of the xdg-shell protocol. + + Contributed by Jan Alexander Steffens (heftig). + +- Fix some MSVC build issues. + +- Fix some issues when including xkbcommon as a meson subproject. + +- meson>=0.51 is now required. + + libxkbcommon 1.4.1 - 2022-05-21 ================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/include/xkbcommon/xkbcommon.h new/libxkbcommon-1.5.0/include/xkbcommon/xkbcommon.h --- old/libxkbcommon-1.4.1/include/xkbcommon/xkbcommon.h 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/include/xkbcommon/xkbcommon.h 2023-01-02 20:23:30.000000000 +0100 @@ -580,9 +580,17 @@ XKB_CONTEXT_NO_DEFAULT_INCLUDES = (1 << 0), /** * Don't take RMLVO names from the environment. + * * @since 0.3.0 */ - XKB_CONTEXT_NO_ENVIRONMENT_NAMES = (1 << 1) + XKB_CONTEXT_NO_ENVIRONMENT_NAMES = (1 << 1), + /** + * Disable the use of secure_getenv for this context, so that privileged + * processes can use environment variables. Client uses at their own risk. + * + * @since 1.5.0 + */ + XKB_CONTEXT_NO_SECURE_GETENV = (1 << 2) }; /** @@ -1334,6 +1342,33 @@ struct xkb_keymap * xkb_state_get_keymap(struct xkb_state *state); +/** + * @page server-client-state Server State and Client State + * @parblock + * + * The xkb_state API is used by two distinct actors in most window-system + * architectures: + * + * 1. A *server* - for example, a Wayland compositor, an X11 server, an evdev + * listener. + * + * Servers maintain the XKB state for a device according to input events from + * the device, such as key presses and releases, and out-of-band events from + * the user, like UI layout switchers. + * + * 2. A *client* - for example, a Wayland client, an X11 client. + * + * Clients do not listen to input from the device; instead, whenever the + * server state changes, the server serializes the state and notifies the + * clients that the state has changed; the clients then update the state + * from the serialization. + * + * Some entry points in the xkb_state API are only meant for servers and some + * are only meant for clients, and the two should generally not be mixed. + * + * @endparblock + */ + /** Specifies the direction of the key (press / release). */ enum xkb_key_direction { XKB_KEY_UP, /**< The key was released. */ @@ -1380,11 +1415,8 @@ * Update the keyboard state to reflect a given key being pressed or * released. * - * This entry point is intended for programs which track the keyboard state - * explicitly (like an evdev client). If the state is serialized to you by - * a master process (like a Wayland compositor) using functions like - * xkb_state_serialize_mods(), you should use xkb_state_update_mask() instead. - * The two functions should not generally be used together. + * This entry point is intended for *server* applications and should not be used + * by *client* applications; see @ref server-client-state for details. * * A series of calls to this function should be consistent; that is, a call * with XKB_KEY_DOWN for a key should be matched by an XKB_KEY_UP; if a key @@ -1412,21 +1444,16 @@ /** * Update a keyboard state from a set of explicit masks. * - * This entry point is intended for window systems and the like, where a - * master process holds an xkb_state, then serializes it over a wire - * protocol, and clients then use the serialization to feed in to their own - * xkb_state. + * This entry point is intended for *client* applications; see @ref + * server-client-state for details. *Server* applications should use + * xkb_state_update_key() instead. * * All parameters must always be passed, or the resulting state may be * incoherent. * * The serialization is lossy and will not survive round trips; it must only - * be used to feed slave state objects, and must not be used to update the - * master state. - * - * If you do not fit the description above, you should use - * xkb_state_update_key() instead. The two functions should not generally be - * used together. + * be used to feed client state objects, and must not be used to update the + * server state. * * @returns A mask of state components that have changed as a result of * the update. If nothing in the state has changed, returns 0. @@ -1604,6 +1631,10 @@ * The counterpart to xkb_state_update_mask for modifiers, to be used on * the server side of serialization. * + * This entry point is intended for *server* applications; see @ref + * server-client-state for details. *Client* applications should use the + * xkb_state_mod_*_is_active API. + * * @param state The keyboard state. * @param components A mask of the modifier state components to serialize. * State components other than XKB_STATE_MODS_* are ignored. @@ -1613,9 +1644,6 @@ * @returns A xkb_mod_mask_t representing the given components of the * modifier state. * - * This function should not be used in regular clients; please use the - * xkb_state_mod_*_is_active API instead. - * * @memberof xkb_state */ xkb_mod_mask_t @@ -1626,6 +1654,10 @@ * The counterpart to xkb_state_update_mask for layouts, to be used on * the server side of serialization. * + * This entry point is intended for *server* applications; see @ref + * server-client-state for details. *Client* applications should use the + * xkb_state_layout_*_is_active API. + * * @param state The keyboard state. * @param components A mask of the layout state components to serialize. * State components other than XKB_STATE_LAYOUT_* are ignored. @@ -1635,9 +1667,6 @@ * @returns A layout index representing the given components of the * layout state. * - * This function should not be used in regular clients; please use the - * xkb_state_layout_*_is_active API instead. - * * @memberof xkb_state */ xkb_layout_index_t diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/include/xkbcommon/xkbregistry.h new/libxkbcommon-1.5.0/include/xkbcommon/xkbregistry.h --- old/libxkbcommon-1.4.1/include/xkbcommon/xkbregistry.h 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/include/xkbcommon/xkbregistry.h 2023-01-02 20:23:30.000000000 +0100 @@ -163,6 +163,13 @@ * on the lookup behavior. */ RXKB_CONTEXT_LOAD_EXOTIC_RULES = (1 << 1), + /** + * Disable the use of secure_getenv for this context, so that privileged + * processes can use environment variables. Client uses at their own risk. + * + * @since 1.5.0 + */ + RXKB_CONTEXT_NO_SECURE_GETENV = (1 << 2) }; /** diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/meson.build new/libxkbcommon-1.5.0/meson.build --- old/libxkbcommon-1.4.1/meson.build 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/meson.build 2023-01-02 20:23:30.000000000 +0100 @@ -1,13 +1,13 @@ project( 'libxkbcommon', 'c', - version: '1.4.1', + version: '1.5.0', default_options: [ 'c_std=c11', 'warning_level=2', 'b_lundef=true', ], - meson_version : '>= 0.49.0', + meson_version : '>= 0.51.0', ) pkgconfig = import('pkgconfig') cc = meson.get_compiler('c') @@ -17,7 +17,6 @@ # Compiler flags. cflags = [ '-fno-strict-aliasing', - '-fsanitize-undefined-trap-on-error', '-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wpointer-arith', @@ -41,7 +40,7 @@ if XKBCONFIGROOT == '' xkeyboard_config_dep = dependency('xkeyboard-config', required: false) if xkeyboard_config_dep.found() - XKBCONFIGROOT = xkeyboard_config_dep.get_pkgconfig_variable('xkb_base') + XKBCONFIGROOT = xkeyboard_config_dep.get_variable(pkgconfig: 'xkb_base') else XKBCONFIGROOT = get_option('prefix')/get_option('datadir')/'X11'/'xkb' endif @@ -146,7 +145,7 @@ # Supports -Wl,--version-script? have_version_script = cc.links( 'int main(){}', - args: '-Wl,--version-script=' + meson.source_root()/'xkbcommon.map', + args: '-Wl,--version-script=' + meson.current_source_dir()/'xkbcommon.map', name: '-Wl,--version-script', ) @@ -232,7 +231,7 @@ libxkbcommon_link_args = [] libxkbcommon_link_deps = [] if have_version_script - libxkbcommon_link_args += '-Wl,--version-script=' + meson.source_root()/'xkbcommon.map' + libxkbcommon_link_args += '-Wl,--version-script=' + meson.current_source_dir()/'xkbcommon.map' libxkbcommon_link_deps += 'xkbcommon.map' elif cc.get_argument_syntax() == 'msvc' libxkbcommon_def = custom_target('xkbcommon.def', @@ -300,7 +299,7 @@ libxkbcommon_x11_link_args = [] libxkbcommon_x11_link_deps = [] if have_version_script - libxkbcommon_x11_link_args += '-Wl,--version-script=' + meson.source_root()/'xkbcommon-x11.map' + libxkbcommon_x11_link_args += '-Wl,--version-script=' + meson.current_source_dir()/'xkbcommon-x11.map' libxkbcommon_x11_link_deps += 'xkbcommon-x11.map' elif cc.get_argument_syntax() == 'msvc' libxkbcommon_x11_def = custom_target('xkbcommon-x11.def', @@ -360,7 +359,7 @@ libxkbregistry_link_args = [] libxkbregistry_link_deps = [] if have_version_script - libxkbregistry_link_args += '-Wl,--version-script=' + meson.source_root()/'xkbregistry.map' + libxkbregistry_link_args += '-Wl,--version-script=' + meson.current_source_dir()/'xkbregistry.map' libxkbregistry_link_deps += 'xkbregistry.map' elif cc.get_argument_syntax() == 'msvc' libxkbregistry_def = custom_target('xkbregistry.def', @@ -483,18 +482,18 @@ You can disable the Wayland xkbcli programs with -Denable-wayland=false.''') endif - wayland_scanner = find_program(wayland_scanner_dep.get_pkgconfig_variable('wayland_scanner')) + wayland_scanner = find_program(wayland_scanner_dep.get_variable(pkgconfig: 'wayland_scanner')) wayland_scanner_code_gen = generator( wayland_scanner, output: '@BASENAME@-protocol.c', - arguments: ['code', '@INPUT@', '@OUTPUT@'], + arguments: ['private-code', '@INPUT@', '@OUTPUT@'], ) wayland_scanner_client_header_gen = generator( wayland_scanner, output: '@BASENAME@-client-protocol.h', arguments: ['client-header', '@INPUT@', '@OUTPUT@'], ) - wayland_protocols_datadir = wayland_protocols_dep.get_pkgconfig_variable('pkgdatadir') + wayland_protocols_datadir = wayland_protocols_dep.get_variable(pkgconfig: 'pkgdatadir') xdg_shell_xml = wayland_protocols_datadir/'stable/xdg-shell/xdg-shell.xml' xdg_shell_sources = [ wayland_scanner_code_gen.process(xdg_shell_xml), @@ -524,7 +523,7 @@ # xkeyboard-config "verifier" xkct_config = configuration_data() -xkct_config.set('MESON_BUILD_ROOT', meson.build_root()) +xkct_config.set('MESON_BUILD_ROOT', meson.current_build_dir()) xkct_config.set('XKB_CONFIG_ROOT', XKBCONFIGROOT) configure_file(input: 'test/xkeyboard-config-test.py.in', output: 'xkeyboard-config-test', @@ -534,15 +533,15 @@ test_env = environment() test_env.set('XKB_LOG_LEVEL', 'debug') test_env.set('XKB_LOG_VERBOSITY', '10') -test_env.set('top_srcdir', meson.source_root()) -test_env.set('top_builddir', meson.build_root()) +test_env.set('top_srcdir', meson.current_source_dir()) +test_env.set('top_builddir', meson.current_build_dir()) test_env.set('HAVE_XKBCLI_INTERACTIVE_EVDEV', configh_data.get('HAVE_XKBCLI_INTERACTIVE_EVDEV', 0).to_string()) test_env.set('HAVE_XKBCLI_INTERACTIVE_WAYLAND', configh_data.get('HAVE_XKBCLI_INTERACTIVE_WAYLAND', 0).to_string()) test_env.set('HAVE_XKBCLI_INTERACTIVE_X11', configh_data.get('HAVE_XKBCLI_INTERACTIVE_X11', 0).to_string()) test_env.set('HAVE_XKBCLI_LIST', configh_data.get('HAVE_XKBCLI_LIST', 0).to_string()) test_configh_data = configuration_data() -test_configh_data.set_quoted('TEST_XKB_CONFIG_ROOT', meson.source_root()/'test'/'data') +test_configh_data.set_quoted('TEST_XKB_CONFIG_ROOT', meson.current_source_dir()/'test'/'data') configure_file(output: 'test-config.h', configuration: test_configh_data) # Some tests need to use unexported symbols, so we link them against @@ -596,14 +595,11 @@ executable('test-filecomp', 'test/filecomp.c', dependencies: test_dep), env: test_env, ) -# TODO: This test currently uses some functions that don't exist on Windows. -if cc.get_id() != 'msvc' - test( - 'context', - executable('test-context', 'test/context.c', dependencies: test_dep), - env: test_env, - ) -endif +test( + 'context', + executable('test-context', 'test/context.c', dependencies: test_dep), + env: test_env, +) test( 'rules-file', executable('test-rules-file', 'test/rules-file.c', dependencies: test_dep), @@ -685,7 +681,7 @@ 'registry', executable('test-registry', 'test/registry.c', include_directories: include_directories('src'), - dependencies: dep_libxkbregistry), + dependencies: [dep_libxkbregistry, test_dep]), env: test_env, ) endif @@ -702,7 +698,7 @@ ] env = environment() - env.set('XKB_CONFIG_ROOT', meson.source_root()/'test'/'data') + env.set('XKB_CONFIG_ROOT', meson.current_source_dir()/'test'/'data') foreach keysym: keysyms_to_test test('keysym-test-@0@'.format(keysym), find_program('test/test-keysym.py'), @@ -733,7 +729,7 @@ # Benchmarks. bench_env = environment() -bench_env.set('top_srcdir', meson.source_root()) +bench_env.set('top_srcdir', meson.current_source_dir()) benchmark( 'key-proc', executable('bench-key-proc', 'bench/key-proc.c', dependencies: test_dep), @@ -795,7 +791,7 @@ doxygen_data.set('PACKAGE_NAME', meson.project_name()) doxygen_data.set('PACKAGE_VERSION', meson.project_version()) doxygen_data.set('INPUT', ' '.join(doxygen_input)) - doxygen_data.set('OUTPUT_DIRECTORY', meson.build_root()) + doxygen_data.set('OUTPUT_DIRECTORY', meson.current_build_dir()) doxyfile = configure_file( input: 'doc/Doxyfile.in', output: 'Doxyfile', @@ -807,7 +803,7 @@ 'doc', input: [doxyfile] + doxygen_input, output: 'html', - command: [doxygen_wrapper, doxygen.path(), meson.build_root()/'Doxyfile', meson.source_root()], + command: [doxygen_wrapper, doxygen, meson.current_build_dir()/'Doxyfile', meson.current_source_dir()], install: true, install_dir: docdir, build_by_default: true, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/src/compose/parser.c new/libxkbcommon-1.5.0/src/compose/parser.c --- old/libxkbcommon-1.4.1/src/compose/parser.c 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/src/compose/parser.c 2023-01-02 20:23:30.000000000 +0100 @@ -262,7 +262,7 @@ scanner_buf_append(s, '%'); } else if (scanner_chr(s, 'H')) { - const char *home = secure_getenv("HOME"); + const char *home = xkb_context_getenv(table->ctx, "HOME"); if (!home) { scanner_err(s, "%%H was used in an include statement, but the HOME environment variable is not set"); return TOK_ERROR; @@ -273,7 +273,7 @@ } } else if (scanner_chr(s, 'L')) { - char *path = get_locale_compose_file_path(table->locale); + char *path = get_locale_compose_file_path(table->ctx, table->locale); if (!path) { scanner_err(s, "failed to expand %%L to the locale Compose file"); return TOK_ERROR; @@ -286,7 +286,7 @@ free(path); } else if (scanner_chr(s, 'S')) { - const char *xlocaledir = get_xlocaledir_path(); + const char *xlocaledir = get_xlocaledir_path(table->ctx); if (!scanner_buf_appends(s, xlocaledir)) { scanner_err(s, "include path after expanding %%S is too long"); return TOK_ERROR; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/src/compose/paths.c new/libxkbcommon-1.5.0/src/compose/paths.c --- old/libxkbcommon-1.4.1/src/compose/paths.c 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/src/compose/paths.c 2023-01-02 20:23:30.000000000 +0100 @@ -23,9 +23,10 @@ #include "config.h" +#include "xkbcommon/xkbcommon.h" #include "utils.h" +#include "context.h" #include "paths.h" -#include "utils.h" enum resolve_name_direction { LEFT_TO_RIGHT, @@ -33,9 +34,9 @@ }; const char * -get_xlocaledir_path(void) +get_xlocaledir_path(struct xkb_context *ctx) { - const char *dir = secure_getenv("XLOCALEDIR"); + const char *dir = xkb_context_getenv(ctx, "XLOCALEDIR"); if (!dir) dir = XLOCALEDIR; return dir; @@ -47,8 +48,8 @@ * @filename is relative to the xlocaledir. */ static char * -resolve_name(const char *filename, enum resolve_name_direction direction, - const char *name) +resolve_name(struct xkb_context *ctx, const char *filename, + enum resolve_name_direction direction, const char *name) { int ret; bool ok; @@ -62,7 +63,7 @@ char *match; size_t left_len, right_len, name_len; - xlocaledir = get_xlocaledir_path(); + xlocaledir = get_xlocaledir_path(ctx); ret = snprintf(path, sizeof(path), "%s/%s", xlocaledir, filename); if (ret < 0 || (size_t) ret >= sizeof(path)) @@ -137,27 +138,27 @@ } char * -resolve_locale(const char *locale) +resolve_locale(struct xkb_context *ctx, const char *locale) { - char *alias = resolve_name("locale.alias", LEFT_TO_RIGHT, locale); + char *alias = resolve_name(ctx, "locale.alias", LEFT_TO_RIGHT, locale); return alias ? alias : strdup(locale); } char * -get_xcomposefile_path(void) +get_xcomposefile_path(struct xkb_context *ctx) { - return strdup_safe(secure_getenv("XCOMPOSEFILE")); + return strdup_safe(xkb_context_getenv(ctx, "XCOMPOSEFILE")); } char * -get_xdg_xcompose_file_path(void) +get_xdg_xcompose_file_path(struct xkb_context *ctx) { const char *xdg_config_home; const char *home; - xdg_config_home = secure_getenv("XDG_CONFIG_HOME"); + xdg_config_home = xkb_context_getenv(ctx, "XDG_CONFIG_HOME"); if (!xdg_config_home || xdg_config_home[0] != '/') { - home = secure_getenv("HOME"); + home = xkb_context_getenv(ctx, "HOME"); if (!home) return NULL; return asprintf_safe("%s/.config/XCompose", home); @@ -167,11 +168,11 @@ } char * -get_home_xcompose_file_path(void) +get_home_xcompose_file_path(struct xkb_context *ctx) { const char *home; - home = secure_getenv("HOME"); + home = xkb_context_getenv(ctx, "HOME"); if (!home) return NULL; @@ -179,7 +180,7 @@ } char * -get_locale_compose_file_path(const char *locale) +get_locale_compose_file_path(struct xkb_context *ctx, const char *locale) { char *resolved; char *path; @@ -198,7 +199,7 @@ if (streq(locale, "C")) locale = "en_US.UTF-8"; - resolved = resolve_name("compose.dir", RIGHT_TO_LEFT, locale); + resolved = resolve_name(ctx, "compose.dir", RIGHT_TO_LEFT, locale); if (!resolved) return NULL; @@ -206,7 +207,7 @@ path = resolved; } else { - const char *xlocaledir = get_xlocaledir_path(); + const char *xlocaledir = get_xlocaledir_path(ctx); path = asprintf_safe("%s/%s", xlocaledir, resolved); free(resolved); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/src/compose/paths.h new/libxkbcommon-1.5.0/src/compose/paths.h --- old/libxkbcommon-1.4.1/src/compose/paths.h 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/src/compose/paths.h 2023-01-02 20:23:30.000000000 +0100 @@ -25,21 +25,21 @@ #define COMPOSE_RESOLVE_H char * -resolve_locale(const char *locale); +resolve_locale(struct xkb_context *ctx, const char *locale); const char * -get_xlocaledir_path(void); +get_xlocaledir_path(struct xkb_context *ctx); char * -get_xcomposefile_path(void); +get_xcomposefile_path(struct xkb_context *ctx); char * -get_xdg_xcompose_file_path(void); +get_xdg_xcompose_file_path(struct xkb_context *ctx); char * -get_home_xcompose_file_path(void); +get_home_xcompose_file_path(struct xkb_context *ctx); char * -get_locale_compose_file_path(const char *locale); +get_locale_compose_file_path(struct xkb_context *ctx, const char *locale); #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/src/compose/table.c new/libxkbcommon-1.5.0/src/compose/table.c --- old/libxkbcommon-1.4.1/src/compose/table.c 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/src/compose/table.c 2023-01-02 20:23:30.000000000 +0100 @@ -38,7 +38,7 @@ struct xkb_compose_table *table; struct compose_node dummy; - resolved_locale = resolve_locale(locale); + resolved_locale = resolve_locale(ctx, locale); if (!resolved_locale) return NULL; @@ -174,7 +174,7 @@ if (!table) return NULL; - path = get_xcomposefile_path(); + path = get_xcomposefile_path(ctx); if (path) { file = fopen(path, "rb"); if (file) @@ -182,7 +182,7 @@ } free(path); - path = get_xdg_xcompose_file_path(); + path = get_xdg_xcompose_file_path(ctx); if (path) { file = fopen(path, "rb"); if (file) @@ -190,7 +190,7 @@ } free(path); - path = get_home_xcompose_file_path(); + path = get_home_xcompose_file_path(ctx); if (path) { file = fopen(path, "rb"); if (file) @@ -198,7 +198,7 @@ } free(path); - path = get_locale_compose_file_path(table->locale); + path = get_locale_compose_file_path(ctx, table->locale); if (path) { file = fopen(path, "rb"); if (file) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/src/context-priv.c new/libxkbcommon-1.5.0/src/context-priv.c --- old/libxkbcommon-1.4.1/src/context-priv.c 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/src/context-priv.c 2023-01-02 20:23:30.000000000 +0100 @@ -34,6 +34,16 @@ #include "utils.h" #include "context.h" +char * +xkb_context_getenv(struct xkb_context *ctx, const char *name) +{ + if (ctx->use_secure_getenv) { + return secure_getenv(name); + } else { + return getenv(name); + } +} + unsigned int xkb_context_num_failed_include_paths(struct xkb_context *ctx) { @@ -105,7 +115,7 @@ const char *env = NULL; if (ctx->use_environment_names) - env = secure_getenv("XKB_DEFAULT_RULES"); + env = xkb_context_getenv(ctx, "XKB_DEFAULT_RULES"); return env ? env : DEFAULT_XKB_RULES; } @@ -116,7 +126,7 @@ const char *env = NULL; if (ctx->use_environment_names) - env = secure_getenv("XKB_DEFAULT_MODEL"); + env = xkb_context_getenv(ctx, "XKB_DEFAULT_MODEL"); return env ? env : DEFAULT_XKB_MODEL; } @@ -127,7 +137,7 @@ const char *env = NULL; if (ctx->use_environment_names) - env = secure_getenv("XKB_DEFAULT_LAYOUT"); + env = xkb_context_getenv(ctx, "XKB_DEFAULT_LAYOUT"); return env ? env : DEFAULT_XKB_LAYOUT; } @@ -136,12 +146,12 @@ xkb_context_get_default_variant(struct xkb_context *ctx) { const char *env = NULL; - const char *layout = secure_getenv("XKB_DEFAULT_LAYOUT"); + const char *layout = xkb_context_getenv(ctx, "XKB_DEFAULT_LAYOUT"); /* We don't want to inherit the variant if they haven't also set a * layout, since they're so closely paired. */ if (layout && ctx->use_environment_names) - env = secure_getenv("XKB_DEFAULT_VARIANT"); + env = xkb_context_getenv(ctx, "XKB_DEFAULT_VARIANT"); return env ? env : DEFAULT_XKB_VARIANT; } @@ -152,7 +162,7 @@ const char *env = NULL; if (ctx->use_environment_names) - env = secure_getenv("XKB_DEFAULT_OPTIONS"); + env = xkb_context_getenv(ctx, "XKB_DEFAULT_OPTIONS"); return env ? env : DEFAULT_XKB_OPTIONS; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/src/context.c new/libxkbcommon-1.5.0/src/context.c --- old/libxkbcommon-1.4.1/src/context.c 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/src/context.c 2023-01-02 20:23:30.000000000 +0100 @@ -29,20 +29,12 @@ #include <sys/types.h> #include <sys/stat.h> #include <errno.h> -#ifdef _MSC_VER -# include <direct.h> -# include <io.h> -# ifndef S_ISDIR -# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -# endif -#else -# include <unistd.h> -#endif #include "xkbcommon/xkbcommon.h" #include "utils.h" #include "context.h" + /** * Append one directory to the context's include path. */ @@ -86,14 +78,14 @@ const char * xkb_context_include_path_get_extra_path(struct xkb_context *ctx) { - const char *extra = secure_getenv("XKB_CONFIG_EXTRA_PATH"); + const char *extra = xkb_context_getenv(ctx, "XKB_CONFIG_EXTRA_PATH"); return extra ? extra : DFLT_XKB_CONFIG_EXTRA_PATH; } const char * xkb_context_include_path_get_system_path(struct xkb_context *ctx) { - const char *root = secure_getenv("XKB_CONFIG_ROOT"); + const char *root = xkb_context_getenv(ctx, "XKB_CONFIG_ROOT"); return root ? root : DFLT_XKB_CONFIG_ROOT; } @@ -107,9 +99,9 @@ char *user_path; int ret = 0; - home = secure_getenv("HOME"); + home = xkb_context_getenv(ctx, "HOME"); - xdg = secure_getenv("XDG_CONFIG_HOME"); + xdg = xkb_context_getenv(ctx, "XDG_CONFIG_HOME"); if (xdg != NULL) { user_path = asprintf_safe("%s/xkb", xdg); if (user_path) { @@ -298,13 +290,15 @@ ctx->log_fn = default_log_fn; ctx->log_level = XKB_LOG_LEVEL_ERROR; ctx->log_verbosity = 0; + ctx->use_environment_names = !(flags & XKB_CONTEXT_NO_ENVIRONMENT_NAMES); + ctx->use_secure_getenv = !(flags & XKB_CONTEXT_NO_SECURE_GETENV); /* Environment overwrites defaults. */ - env = secure_getenv("XKB_LOG_LEVEL"); + env = xkb_context_getenv(ctx, "XKB_LOG_LEVEL"); if (env) xkb_context_set_log_level(ctx, log_level(env)); - env = secure_getenv("XKB_LOG_VERBOSITY"); + env = xkb_context_getenv(ctx, "XKB_LOG_VERBOSITY"); if (env) xkb_context_set_log_verbosity(ctx, log_verbosity(env)); @@ -316,8 +310,6 @@ return NULL; } - ctx->use_environment_names = !(flags & XKB_CONTEXT_NO_ENVIRONMENT_NAMES); - ctx->atom_table = atom_table_new(); if (!ctx->atom_table) { xkb_context_unref(ctx); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/src/context.h new/libxkbcommon-1.5.0/src/context.h --- old/libxkbcommon-1.4.1/src/context.h 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/src/context.h 2023-01-02 20:23:30.000000000 +0100 @@ -53,8 +53,12 @@ size_t text_next; unsigned int use_environment_names : 1; + unsigned int use_secure_getenv : 1; }; +char * +xkb_context_getenv(struct xkb_context *ctx, const char *name); + unsigned int xkb_context_num_failed_include_paths(struct xkb_context *ctx); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/src/registry.c new/libxkbcommon-1.5.0/src/registry.c --- old/libxkbcommon-1.4.1/src/registry.c 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/src/registry.c 2023-01-02 20:23:30.000000000 +0100 @@ -72,6 +72,7 @@ enum context_state context_state; bool load_extra_rules_files; + bool use_secure_getenv; struct list models; /* list of struct rxkb_models */ struct list layouts; /* list of struct rxkb_layouts */ @@ -437,6 +438,17 @@ DECLARE_CREATE_FOR_TYPE(rxkb_context); DECLARE_TYPED_GETTER_FOR_TYPE(rxkb_context, log_level, enum rxkb_log_level); +static char * +rxkb_context_getenv(struct rxkb_context *ctx, const char *name) +{ + if (ctx->use_secure_getenv) { + return secure_getenv(name); + } else { + return getenv(name); + } +} + + XKB_EXPORT void rxkb_context_set_log_level(struct rxkb_context *ctx, enum rxkb_log_level level) @@ -508,11 +520,12 @@ ctx->context_state = CONTEXT_NEW; ctx->load_extra_rules_files = flags & RXKB_CONTEXT_LOAD_EXOTIC_RULES; + ctx->use_secure_getenv = !(flags & RXKB_CONTEXT_NO_SECURE_GETENV); ctx->log_fn = default_log_fn; ctx->log_level = RXKB_LOG_LEVEL_ERROR; /* Environment overwrites defaults. */ - env = secure_getenv("RXKB_LOG_LEVEL"); + env = rxkb_context_getenv(ctx, "RXKB_LOG_LEVEL"); if (env) rxkb_context_set_log_level(ctx, log_level(env)); @@ -593,9 +606,9 @@ return false; } - home = secure_getenv("HOME"); + home = rxkb_context_getenv(ctx, "HOME"); - xdg = secure_getenv("XDG_CONFIG_HOME"); + xdg = rxkb_context_getenv(ctx, "XDG_CONFIG_HOME"); if (xdg != NULL) { user_path = asprintf_safe("%s/xkb", xdg); if (user_path) { @@ -619,13 +632,13 @@ } } - extra = secure_getenv("XKB_CONFIG_EXTRA_PATH"); + extra = rxkb_context_getenv(ctx, "XKB_CONFIG_EXTRA_PATH"); if (extra != NULL) ret |= rxkb_context_include_path_append(ctx, extra); else ret |= rxkb_context_include_path_append(ctx, DFLT_XKB_CONFIG_EXTRA_PATH); - root = secure_getenv("XKB_CONFIG_ROOT"); + root = rxkb_context_getenv(ctx, "XKB_CONFIG_ROOT"); if (root != NULL) ret |= rxkb_context_include_path_append(ctx, root); else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/src/utils.h new/libxkbcommon-1.5.0/src/utils.h --- old/libxkbcommon-1.4.1/src/utils.h 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/src/utils.h 2023-01-02 20:23:30.000000000 +0100 @@ -31,13 +31,21 @@ #include <stdio.h> #include <string.h> #if HAVE_UNISTD_H -#include <unistd.h> +# include <unistd.h> #else /* Required on Windows where unistd.h doesn't exist */ -#define R_OK 4 /* Test for read permission. */ -#define W_OK 2 /* Test for write permission. */ -#define X_OK 1 /* Test for execute permission. */ -#define F_OK 0 /* Test for existence. */ +# define R_OK 4 /* Test for read permission. */ +# define W_OK 2 /* Test for write permission. */ +# define X_OK 1 /* Test for execute permission. */ +# define F_OK 0 /* Test for existence. */ +#endif + +#ifdef _MSC_VER +# include <direct.h> +# include <io.h> +# ifndef S_ISDIR +# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +# endif #endif #include "darray.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/src/xkbcomp/rules.c new/libxkbcommon-1.5.0/src/xkbcomp/rules.c --- old/libxkbcommon-1.4.1/src/xkbcomp/rules.c 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/src/xkbcomp/rules.c 2023-01-02 20:23:30.000000000 +0100 @@ -382,7 +382,7 @@ scanner_buf_append(&s, '%'); } else if (scanner_chr(&s, 'H')) { - const char *home = secure_getenv("HOME"); + const char *home = xkb_context_getenv(m->ctx, "HOME"); if (!home) { scanner_err(&s, "%%H was used in an include statement, but the HOME environment variable is not set"); return; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/test/common.c new/libxkbcommon-1.5.0/test/common.c --- old/libxkbcommon-1.4.1/test/common.c 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/test/common.c 2023-01-02 20:23:30.000000000 +0100 @@ -34,6 +34,7 @@ #include <limits.h> #include <fcntl.h> +#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #ifdef _MSC_VER @@ -163,6 +164,52 @@ } char * +test_makedir(const char *parent, const char *path) +{ + char *dirname; + int err; + + dirname = asprintf_safe("%s/%s", parent, path); + assert(dirname); +#ifdef _MSC_VER + err = _mkdir(dirname); +#else + err = mkdir(dirname, 0777); +#endif + assert(err == 0); + + return dirname; +} + +char * +test_maketempdir(const char *template) +{ +#ifdef _MSC_VER + const char *basetmp = getenv("TMP"); + if (basetmp == NULL) { + basetmp = getenv("TEMP"); + } + if (basetmp == NULL) { + basetmp = getenv("top_builddir"); + } + assert(basetmp != NULL); + char *tmpdir = asprintf_safe("%s/%s", basetmp, template); + assert(tmpdir != NULL); + char *tmp = _mktemp(tmpdir); + assert(tmp == tmpdir); + int ret = _mkdir(tmp); + assert(ret == 0); + return tmpdir; +#else + char *tmpdir = asprintf_safe("/tmp/%s", template); + assert(tmpdir != NULL); + char *tmp = mkdtemp(tmpdir); + assert(tmp == tmpdir); + return tmpdir; +#endif +} + +char * test_get_path(const char *path_rel) { char *path; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/test/context.c new/libxkbcommon-1.5.0/test/context.c --- old/libxkbcommon-1.4.1/test/context.c 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/test/context.c 2023-01-02 20:23:30.000000000 +0100 @@ -30,15 +30,6 @@ #include <sys/stat.h> #include <sys/types.h> -#ifdef _MSC_VER -# include <io.h> -# include <direct.h> -# ifndef S_ISDIR -# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -# endif -#else -# include <unistd.h> -#endif /* keeps a cache of all makedir/maketmpdir directories so we can free and * rmdir them in one go, see unmakedirs() */ @@ -82,29 +73,15 @@ static const char *makedir(const char *parent, const char *path) { - char *dirname; - int err; - - dirname = asprintf_safe("%s/%s", parent, path); - assert(dirname); - err = mkdir(dirname, 0777); - assert(err == 0); - + char *dirname = test_makedir(parent, path); dirnames[ndirs++] = dirname; - return dirname; } static const char *maketmpdir(void) { - const char *template = "/tmp/xkbcommon-test.XXXXXX"; - char *tmpdir = strdup(template); - - tmpdir = mkdtemp(tmpdir); - assert(tmpdir != NULL); - + char *tmpdir = test_maketempdir("xkbcommon-test.XXXXXX"); dirnames[ndirs++] = tmpdir; - return tmpdir; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/test/registry.c new/libxkbcommon-1.5.0/test/registry.c --- old/libxkbcommon-1.4.1/test/registry.c 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/test/registry.c 2023-01-02 20:23:30.000000000 +0100 @@ -35,6 +35,7 @@ #include "xkbcommon/xkbregistry.h" #include "utils.h" +#include "test.h" #define NO_VARIANT NULL @@ -132,14 +133,13 @@ int rc; FILE *fp; - tmpdir = asprintf_safe("/tmp/%s.%d.XXXXXX", ruleset, iteration++); - assert(tmpdir); - assert(mkdtemp(tmpdir) == tmpdir); + char *template = asprintf_safe("%s.%d.XXXXXX", ruleset, iteration++); + assert(template != NULL); + tmpdir = test_maketempdir(template); + free(template); + + free(test_makedir(tmpdir, "rules")); - rc = snprintf_safe(buf, sizeof(buf), "%s/rules", tmpdir); - assert(rc); - rc = mkdir(buf, 0777); - assert(rc == 0); rc = snprintf_safe(buf, sizeof(buf), "%s/rules/%s.xml", tmpdir, ruleset); assert(rc); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/test/test.h new/libxkbcommon-1.5.0/test/test.h --- old/libxkbcommon-1.4.1/test/test.h 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/test/test.h 2023-01-02 20:23:30.000000000 +0100 @@ -54,6 +54,12 @@ test_key_seq_va(struct xkb_keymap *keymap, va_list args); char * +test_makedir(const char *parent, const char *path); + +char * +test_maketempdir(const char *template); + +char * test_get_path(const char *path_rel); char * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libxkbcommon-1.4.1/tools/interactive-wayland.c new/libxkbcommon-1.5.0/tools/interactive-wayland.c --- old/libxkbcommon-1.4.1/tools/interactive-wayland.c 2022-05-21 21:55:22.000000000 +0200 +++ new/libxkbcommon-1.5.0/tools/interactive-wayland.c 2023-01-02 20:23:30.000000000 +0100 @@ -42,7 +42,7 @@ #include "xdg-shell-client-protocol.h" #include <wayland-util.h> -#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) struct interactive_dpy { struct wl_display *dpy; @@ -557,7 +557,7 @@ seat->global_name = name; seat->inter = inter; seat->wl_seat = wl_registry_bind(registry, name, &wl_seat_interface, - MAX(version, 5)); + MIN(version, 5)); wl_seat_add_listener(seat->wl_seat, &seat_listener, seat); ret = asprintf(&seat->name_str, "seat:%d", wl_proxy_get_id((struct wl_proxy *) seat->wl_seat)); @@ -607,17 +607,17 @@ else if (strcmp(interface, "xdg_wm_base") == 0) { inter->shell = wl_registry_bind(registry, name, &xdg_wm_base_interface, - MAX(version, 2)); + MIN(version, 2)); xdg_wm_base_add_listener(inter->shell, &shell_listener, inter); } else if (strcmp(interface, "wl_compositor") == 0) { inter->compositor = wl_registry_bind(registry, name, &wl_compositor_interface, - MAX(version, 1)); + MIN(version, 1)); } else if (strcmp(interface, "wl_shm") == 0) { inter->shm = wl_registry_bind(registry, name, &wl_shm_interface, - MAX(version, 1)); + MIN(version, 1)); } }