From 99f1bc955a26eef8c9f4f5fee3247571618351b8 Mon Sep 17 00:00:00 2001 From: illiliti Date: Mon, 10 Jul 2023 14:13:58 +0300 Subject: [PATCH 1/7] udev_device.c: stub udev_device_get_current_tags_list_entry impl --- udev.h | 1 + udev_device.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/udev.h b/udev.h index 057d4af2..3aaa3272 100644 --- a/udev.h +++ b/udev.h @@ -70,6 +70,7 @@ int udev_device_has_tag(struct udev_device *udev_device, const char *tag); struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device *udev_device); struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device *udev_device); struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_device *udev_device); +struct udev_list_entry *udev_device_get_current_tags_list_entry(struct udev_device *udev_device); struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device *udev_device); const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key); const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr); diff --git a/udev_device.c b/udev_device.c index 7bf35d5a..84f8c073 100644 --- a/udev_device.c +++ b/udev_device.c @@ -228,6 +228,11 @@ struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device return NULL; } +/* XXX NOT IMPLEMENTED */ struct udev_list_entry *udev_device_get_current_tags_list_entry(struct udev_device *udev_device) +{ + return NULL; +} + struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device *udev_device) { return udev_device ? udev_list_entry_get_next(&udev_device->sysattrs) : NULL; From ee32ac5f6494047b9ece26e7a5920650cdf46655 Mon Sep 17 00:00:00 2001 From: illiliti Date: Mon, 10 Jul 2023 14:15:04 +0300 Subject: [PATCH 2/7] Makefile: bump libudev version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 58f70e4e..4e970b82 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ libudev.pc: libudev.pc.in -e 's|@exec_prefix@|${PREFIX}|g' \ -e "s|@libdir@|$$libdir|g" \ -e "s|@includedir@|$$includedir|g" \ - -e 's|@VERSION@|243|g' \ + -e 's|@VERSION@|251|g' \ libudev.pc.in > libudev.pc install-headers: udev.h From 90480bf525cf8e5ca85f4efab6a8bfd18140d70c Mon Sep 17 00:00:00 2001 From: Brian <89487381+b4yuan@users.noreply.github.com> Date: Tue, 5 Dec 2023 03:40:23 -0500 Subject: [PATCH 3/7] Add CodeQL Workflow for Code Security Analysis (#61) * Add CodeQL Workflow for Code Security Analysis Add CodeQL Workflow for Code Security Analysis This pull request introduces a CodeQL workflow to enhance the security analysis of our repository. CodeQL is a powerful static analysis tool that helps identify and mitigate security vulnerabilities in our codebase. By integrating this workflow into our GitHub Actions, we can proactively identify and address potential issues before they become security threats. We added a new CodeQL workflow file (.github/workflows/codeql.yml) that - Runs on every push and pull request to the main branch. - Excludes queries with a high false positive rate or low-severity findings. - Does not display results for third-party code, focusing only on our own codebase. Testing: To validate the functionality of this workflow, we have run several test scans on the codebase and reviewed the results. The workflow successfully compiles the project, identifies issues, and provides actionable insights while reducing noise by excluding certain queries and third-party code. Deployment: Once this pull request is merged, the CodeQL workflow will be active and automatically run on every push and pull request to the main branch. To view the results of these code scans, please follow these steps: 1. Under the repository name, click on the Security tab. 2. In the left sidebar, click Code scanning alerts. Additional Information: - You can further customize the workflow to adapt to your specific needs by modifying the workflow file. - For more information on CodeQL and how to interpret its results, refer to the GitHub documentation and the CodeQL documentation. Signed-off-by: Brian * Add CodeQL Workflow for Code Security Analysis Add CodeQL Workflow for Code Security Analysis This pull request introduces a CodeQL workflow to enhance the security analysis of our repository. CodeQL is a powerful static analysis tool that helps identify and mitigate security vulnerabilities in our codebase. By integrating this workflow into our GitHub Actions, we can proactively identify and address potential issues before they become security threats. We added a new CodeQL workflow file (.github/workflows/codeql.yml) that - Runs on every pull request (functionality to run on every push to main branches is included as a comment for convenience). - Runs daily. - Excludes queries with a high false positive rate or low-severity findings. - Does not display results for git submodules, focusing only on our own codebase. Testing: To validate the functionality of this workflow, we have run several test scans on the codebase and reviewed the results. The workflow successfully compiles the project, identifies issues, and provides actionable insights while reducing noise by excluding certain queries and third-party code. Deployment: Once this pull request is merged, the CodeQL workflow will be active and automatically run on every push and pull request to the main branch. To view the results of these code scans, please follow these steps: 1. Under the repository name, click on the Security tab. 2. In the left sidebar, click Code scanning alerts. Additional Information: - You can further customize the workflow to adapt to your specific needs by modifying the workflow file. - For more information on CodeQL and how to interpret its results, refer to the GitHub documentation and the CodeQL documentation (https://codeql.github.com/ and https://codeql.github.com/docs/). Signed-off-by: Brian * Add CodeQL Workflow for Code Security Analysis Add CodeQL Workflow for Code Security Analysis This pull request introduces a CodeQL workflow to enhance the security analysis of our repository. CodeQL is a powerful static analysis tool that helps identify and mitigate security vulnerabilities in our codebase. By integrating this workflow into our GitHub Actions, we can proactively identify and address potential issues before they become security threats. We added a new CodeQL workflow file (.github/workflows/codeql.yml) that - Runs on every pull request (functionality to run on every push to main branches is included as a comment for convenience). - Runs daily. - Excludes queries with a high false positive rate or low-severity findings. - Does not display results for git submodules, focusing only on our own codebase. Testing: To validate the functionality of this workflow, we have run several test scans on the codebase and reviewed the results. The workflow successfully compiles the project, identifies issues, and provides actionable insights while reducing noise by excluding certain queries and third-party code. Deployment: Once this pull request is merged, the CodeQL workflow will be active and automatically run on every push and pull request to the main branch. To view the results of these code scans, please follow these steps: 1. Under the repository name, click on the Security tab. 2. In the left sidebar, click Code scanning alerts. Additional Information: - You can further customize the workflow to adapt to your specific needs by modifying the workflow file. - For more information on CodeQL and how to interpret its results, refer to the GitHub documentation and the CodeQL documentation (https://codeql.github.com/ and https://codeql.github.com/docs/). Signed-off-by: Brian * Add CodeQL Workflow for Code Security Analysis Add CodeQL Workflow for Code Security Analysis This pull request introduces a CodeQL workflow to enhance the security analysis of our repository. CodeQL is a powerful static analysis tool that helps identify and mitigate security vulnerabilities in our codebase. By integrating this workflow into our GitHub Actions, we can proactively identify and address potential issues before they become security threats. We added a new CodeQL workflow file (.github/workflows/codeql.yml) that - Runs on every pull request (functionality to run on every push to main branches is included as a comment for convenience). - Runs daily. - Excludes queries with a high false positive rate or low-severity findings. - Does not display results for git submodules, focusing only on our own codebase. Testing: To validate the functionality of this workflow, we have run several test scans on the codebase and reviewed the results. The workflow successfully compiles the project, identifies issues, and provides actionable insights while reducing noise by excluding certain queries and third-party code. Deployment: Once this pull request is merged, the CodeQL workflow will be active and automatically run on every push and pull request to the main branch. To view the results of these code scans, please follow these steps: 1. Under the repository name, click on the Security tab. 2. In the left sidebar, click Code scanning alerts. Additional Information: - You can further customize the workflow to adapt to your specific needs by modifying the workflow file. - For more information on CodeQL and how to interpret its results, refer to the GitHub documentation and the CodeQL documentation (https://codeql.github.com/ and https://codeql.github.com/docs/). Signed-off-by: Brian --------- Signed-off-by: Brian --- .github/workflows/codeql-buildscript.sh | 3 + .github/workflows/codeql.yml | 126 ++++++++++++++++++++++++ .github/workflows/fail_on_error.py | 34 +++++++ 3 files changed, 163 insertions(+) create mode 100644 .github/workflows/codeql-buildscript.sh create mode 100644 .github/workflows/codeql.yml create mode 100755 .github/workflows/fail_on_error.py diff --git a/.github/workflows/codeql-buildscript.sh b/.github/workflows/codeql-buildscript.sh new file mode 100644 index 00000000..d9eae582 --- /dev/null +++ b/.github/workflows/codeql-buildscript.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +make diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..81649227 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,126 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + # push: + # branches: [ "main", "master" ] + schedule: + - cron: '0 0 * * *' + pull_request: + branches: '*' + +jobs: + analyze: + name: Analyze + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners + # Consider using larger runners for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-20.04' }} + timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'cpp' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: recursive + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + queries: security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + #- name: Autobuild + # uses: github/codeql-action/autobuild@v2 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + - run: | + ./.github/workflows/codeql-buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" + upload: false + id: step1 + + # Filter out rules with low severity or high false positve rate + # Also filter out warnings in third-party code + - name: Filter out unwanted errors and warnings + uses: advanced-security/filter-sarif@v1 + with: + patterns: | + -**:cpp/path-injection + -**:cpp/world-writable-file-creation + -**:cpp/poorly-documented-function + -**:cpp/potentially-dangerous-function + -**:cpp/use-of-goto + -**:cpp/integer-multiplication-cast-to-long + -**:cpp/comparison-with-wider-type + -**:cpp/leap-year/* + -**:cpp/ambiguously-signed-bit-field + -**:cpp/suspicious-pointer-scaling + -**:cpp/suspicious-pointer-scaling-void + -**:cpp/unsigned-comparison-zero + -**/cmake*/Modules/** + input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif + output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif + + - name: Upload CodeQL results to code scanning + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: ${{ steps.step1.outputs.sarif-output }} + category: "/language:${{matrix.language}}" + + - name: Upload CodeQL results as an artifact + if: success() || failure() + uses: actions/upload-artifact@v3 + with: + name: codeql-results + path: ${{ steps.step1.outputs.sarif-output }} + retention-days: 5 + + - name: Fail if an error is found + run: | + ./.github/workflows/fail_on_error.py \ + ${{ steps.step1.outputs.sarif-output }}/cpp.sarif diff --git a/.github/workflows/fail_on_error.py b/.github/workflows/fail_on_error.py new file mode 100755 index 00000000..29791742 --- /dev/null +++ b/.github/workflows/fail_on_error.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +import json +import sys + +# Return whether SARIF file contains error-level results +def codeql_sarif_contain_error(filename): + with open(filename, 'r') as f: + s = json.load(f) + + for run in s.get('runs', []): + rules_metadata = run['tool']['driver']['rules'] + if not rules_metadata: + rules_metadata = run['tool']['extensions'][0]['rules'] + + for res in run.get('results', []): + if 'ruleIndex' in res: + rule_index = res['ruleIndex'] + elif 'rule' in res and 'index' in res['rule']: + rule_index = res['rule']['index'] + else: + continue + try: + rule_level = rules_metadata[rule_index]['defaultConfiguration']['level'] + except IndexError as e: + print(e, rule_index, len(rules_metadata)) + else: + if rule_level == 'error': + return True + return False + +if __name__ == "__main__": + if codeql_sarif_contain_error(sys.argv[1]): + sys.exit(1) From a2cc51bb142c16eac5598237d2edb46f095607be Mon Sep 17 00:00:00 2001 From: Mingjie Shen Date: Tue, 5 Dec 2023 03:41:24 -0500 Subject: [PATCH 4/7] udev_device.c: fix TOCTOU race condition (#57) Separately checking the state of a file before operating on it may allow an attacker to modify the file between the two operations. Reference: CWE-367. --- udev_device.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/udev_device.c b/udev_device.c index 84f8c073..c0895cee 100644 --- a/udev_device.c +++ b/udev_device.c @@ -267,16 +267,17 @@ const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const snprintf(path, sizeof(path), "%s/%s", udev_device_get_syspath(udev_device), sysattr); - if (lstat(path, &st) != 0 || !S_ISREG(st.st_mode)) { - return NULL; - } - file = fopen(path, "r"); if (!file) { return NULL; } + if (fstat(fileno(file), &st) != 0 || !S_ISREG(st.st_mode)) { + fclose(file); + return NULL; + } + // TODO dynamic allocation of data len = fread(data, 1, sizeof(data) - 1, file); @@ -309,16 +310,17 @@ int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *s snprintf(path, sizeof(path), "%s/%s", udev_device_get_syspath(udev_device), sysattr); - if (lstat(path, &st) != 0 || !S_ISREG(st.st_mode)) { - return -1; - } - file = fopen(path, "w"); if (!file) { return -1; } + if (fstat(fileno(file), &st) != 0 || !S_ISREG(st.st_mode)) { + fclose(file); + return -1; + } + len = strlen(value); if (fwrite(value, 1, len, file) != len) { From 5eca08d71d51074bfe7b14fcf7d89318f4f6ff47 Mon Sep 17 00:00:00 2001 From: liamHowatt <30486941+liamHowatt@users.noreply.github.com> Date: Tue, 5 Dec 2023 04:15:26 -0500 Subject: [PATCH 5/7] Avoidable OOM on small systems (#62) * bandaid fix OOM * refactor fix OOM * Makefile: remove no longer needed -pthread option * libudev.pc.in: remove threads requirement --------- Co-authored-by: illiliti --- Makefile | 2 +- libudev.pc.in | 1 - udev_enumerate.c | 65 +++++++++++------------------------------------- 3 files changed, 15 insertions(+), 53 deletions(-) diff --git a/Makefile b/Makefile index 4e970b82..1fc5a1f4 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ PREFIX = /usr/local LIBDIR = ${PREFIX}/lib INCLUDEDIR = ${PREFIX}/include PKGCONFIGDIR = ${LIBDIR}/pkgconfig -XCFLAGS = ${CPPFLAGS} ${CFLAGS} -std=c99 -fPIC -pthread -D_XOPEN_SOURCE=700 \ +XCFLAGS = ${CPPFLAGS} ${CFLAGS} -std=c99 -fPIC -D_XOPEN_SOURCE=700 \ -Wall -Wextra -Wpedantic -Wmissing-prototypes -Wstrict-prototypes \ -Wno-unused-parameter XLDFLAGS = ${LDFLAGS} -shared -Wl,-soname,libudev.so.1 diff --git a/libudev.pc.in b/libudev.pc.in index 7e29d8ca..2d3f0b03 100644 --- a/libudev.pc.in +++ b/libudev.pc.in @@ -9,5 +9,4 @@ Description: Daemonless replacement for libudev Version: @VERSION@ URL: https://github.com/illiliti/libudev-zero Libs: -L${libdir} -ludev -Libs.private: -pthread Cflags: -I${includedir} diff --git a/udev_enumerate.c b/udev_enumerate.c index c553269e..6fd49c09 100644 --- a/udev_enumerate.c +++ b/udev_enumerate.c @@ -21,7 +21,6 @@ #include #include #include -#include #include "udev.h" #include "udev_list.h" @@ -38,13 +37,6 @@ struct udev_enumerate { int refcount; }; -struct udev_enumerate_thread { - struct udev_enumerate *udev_enumerate; - pthread_mutex_t *mutex; - char path[PATH_MAX]; - pthread_t thread; -}; - int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem) { return udev_enumerate ? !!udev_list_entry_add(&udev_enumerate->subsystem_match, subsystem, NULL, 0) - 1 : -1; @@ -231,31 +223,27 @@ static int filter_sysattr(struct udev_enumerate *udev_enumerate, struct udev_dev return 1; } -static void *add_device(void *ptr) +static void add_device(struct udev_enumerate *udev_enumerate, const char *path) { - struct udev_enumerate_thread *thread = ptr; struct udev_device *udev_device; - udev_device = udev_device_new_from_syspath(thread->udev_enumerate->udev, thread->path); + udev_device = udev_device_new_from_syspath(udev_enumerate->udev, path); if (!udev_device) { - return NULL; + return; } - if (!filter_subsystem(thread->udev_enumerate, udev_device) || - !filter_sysname(thread->udev_enumerate, udev_device) || - !filter_property(thread->udev_enumerate, udev_device) || - !filter_sysattr(thread->udev_enumerate, udev_device)) { + if (!filter_subsystem(udev_enumerate, udev_device) || + !filter_sysname(udev_enumerate, udev_device) || + !filter_property(udev_enumerate, udev_device) || + !filter_sysattr(udev_enumerate, udev_device)) { udev_device_unref(udev_device); - return NULL; + return; } - pthread_mutex_lock(thread->mutex); - udev_list_entry_add(&thread->udev_enumerate->devices, udev_device_get_syspath(udev_device), NULL, 0); - pthread_mutex_unlock(thread->mutex); + udev_list_entry_add(&udev_enumerate->devices, udev_device_get_syspath(udev_device), NULL, 0); udev_device_unref(udev_device); - return NULL; } static int filter_dot(const struct dirent *de) @@ -265,9 +253,7 @@ static int filter_dot(const struct dirent *de) static int scan_devices(struct udev_enumerate *udev_enumerate, const char *path) { - struct udev_enumerate_thread *thread; - pthread_mutex_t mutex; - int i, cnt, ret = 1; + int i, cnt; struct dirent **de; cnt = scandir(path, &de, filter_dot, NULL); @@ -276,41 +262,18 @@ static int scan_devices(struct udev_enumerate *udev_enumerate, const char *path) return 0; } - thread = calloc(cnt, sizeof(*thread)); - - if (!thread) { - ret = 0; - goto free_de; - } - - pthread_mutex_init(&mutex, NULL); - for (i = 0; i < cnt; i++) { - thread[i].mutex = &mutex; - thread[i].udev_enumerate = udev_enumerate; - - snprintf(thread[i].path, sizeof(thread[i].path), "%s/%s", path, de[i]->d_name); - - if (pthread_create(&thread[i].thread, NULL, add_device, &thread[i]) != 0) { - ret = 0; - break; - } + char device_path[PATH_MAX]; + snprintf(device_path, sizeof(device_path), "%s/%s", path, de[i]->d_name); + add_device(udev_enumerate, device_path); } - for (i = 0; i < cnt; i++) { - pthread_join(thread[i].thread, NULL); - } - - free(thread); - pthread_mutex_destroy(&mutex); - -free_de: for (i = 0; i < cnt; i++) { free(de[i]); } free(de); - return ret; + return 1; } int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate) From c027f870c8a57b62ab501d693d5b390f80de3bc0 Mon Sep 17 00:00:00 2001 From: Sertonix Date: Tue, 13 Feb 2024 11:19:20 +0000 Subject: [PATCH 6/7] README: update link to PipeWire patch (#64) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 21f8f19f..6cd52025 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Keep in mind that libudev-zero isn't ideal. Here are some pros/cons: * android-tools - requires udev rules for non-root usage * NetworkManager - needs investigation * libgudev - needs investigation -* PipeWire - depends on udev internal properties. [patch](https://github.com/illiliti/libudev-zero/issues/26#issuecomment-846858706) +* PipeWire - depends on udev internal properties. [patch](https://github.com/illiliti/libudev-zero/issues/26#issuecomment-1848802791) * ldm - depends on udev internal properties * lvm2 - uses deprecated `udev_queue` API * cups - needs investigation From bbeb7ad51c1edb7ab3cf63f30a21e9bb383b7994 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 13 Feb 2024 11:20:52 +0000 Subject: [PATCH 7/7] Fixes incorrect detection of touchpads (#66) Some touchpad drivers (such as applespi) claim to have both EV_ABS and EV_REL capabilities. These touchpads are then reported as mice by libudev-zero. --- udev_device.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/udev_device.c b/udev_device.c index c0895cee..b0577964 100644 --- a/udev_device.c +++ b/udev_device.c @@ -458,13 +458,7 @@ static void set_properties_from_evdev(struct udev_device *udev_device) udev_list_entry_add(&udev_device->properties, "ID_INPUT_SWITCH", "1", 0); } - if (test_bit(ev_bits, EV_REL)) { - if (test_bit(rel_bits, REL_Y) && test_bit(rel_bits, REL_X) && - test_bit(key_bits, BTN_MOUSE)) { - udev_list_entry_add(&udev_device->properties, "ID_INPUT_MOUSE", "1", 0); - } - } - else if (test_bit(ev_bits, EV_ABS)) { + if (test_bit(ev_bits, EV_ABS)) { if (test_bit(key_bits, BTN_SELECT) || test_bit(key_bits, BTN_TR) || test_bit(key_bits, BTN_START) || test_bit(key_bits, BTN_TL)) { if (test_bit(key_bits, BTN_TOUCH)) { @@ -494,6 +488,12 @@ static void set_properties_from_evdev(struct udev_device *udev_device) } } } + else if (test_bit(ev_bits, EV_REL)) { + if (test_bit(rel_bits, REL_Y) && test_bit(rel_bits, REL_X) && + test_bit(key_bits, BTN_MOUSE)) { + udev_list_entry_add(&udev_device->properties, "ID_INPUT_MOUSE", "1", 0); + } + } if (!test_bit(ev_bits, EV_KEY)) { return;