1
0
mirror of https://github.com/systemd/systemd synced 2026-03-15 09:34:47 +01:00

Compare commits

..

17 Commits

Author SHA1 Message Date
dependabot[bot]
4afd7808fe build(deps): bump the actions group across 1 directory with 9 updates
Bumps the actions group with 9 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [actions/checkout](https://github.com/actions/checkout) | `4.2.2` | `6.0.2` |
| [actions/setup-python](https://github.com/actions/setup-python) | `5.6.0` | `6.2.0` |
| [actions/upload-artifact](https://github.com/actions/upload-artifact) | `4` | `6` |
| [github/codeql-action](https://github.com/github/codeql-action) | `3.29.7` | `4.32.0` |
| [redhat-plumbers-in-action/differential-shellcheck](https://github.com/redhat-plumbers-in-action/differential-shellcheck) | `5.5.3` | `5.5.6` |
| [redhat-plumbers-in-action/gather-pull-request-metadata](https://github.com/redhat-plumbers-in-action/gather-pull-request-metadata) | `1.8.1` | `1.9.0` |
| [redhat-plumbers-in-action/advanced-issue-labeler](https://github.com/redhat-plumbers-in-action/advanced-issue-labeler) | `3.2.3` | `3.2.4` |
| [actions/github-script](https://github.com/actions/github-script) | `7.0.1` | `8.0.0` |
| [super-linter/super-linter](https://github.com/super-linter/super-linter) | `8.3.0` | `8.3.2` |



Updates `actions/checkout` from 4.2.2 to 6.0.2
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](11bd71901b...de0fac2e45)

Updates `actions/setup-python` from 5.6.0 to 6.2.0
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](a26af69be9...a309ff8b42)

Updates `actions/upload-artifact` from 4 to 6
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v6)

Updates `github/codeql-action` from 3.29.7 to 4.32.0
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](51f77329af...b20883b0cd)

Updates `redhat-plumbers-in-action/differential-shellcheck` from 5.5.3 to 5.5.6
- [Release notes](https://github.com/redhat-plumbers-in-action/differential-shellcheck/releases)
- [Changelog](https://github.com/redhat-plumbers-in-action/differential-shellcheck/blob/main/docs/CHANGELOG.md)
- [Commits](dd551ce780...d965e66ec0)

Updates `redhat-plumbers-in-action/gather-pull-request-metadata` from 1.8.1 to 1.9.0
- [Release notes](https://github.com/redhat-plumbers-in-action/gather-pull-request-metadata/releases)
- [Commits](b3dbc3f843...b86d1eaf70)

Updates `redhat-plumbers-in-action/advanced-issue-labeler` from 3.2.3 to 3.2.4
- [Release notes](https://github.com/redhat-plumbers-in-action/advanced-issue-labeler/releases)
- [Commits](e38e6809c5...b80ae64e3e)

Updates `actions/github-script` from 7.0.1 to 8.0.0
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](60a0d83039...ed597411d8)

Updates `super-linter/super-linter` from 8.3.0 to 8.3.2
- [Release notes](https://github.com/super-linter/super-linter/releases)
- [Changelog](https://github.com/super-linter/super-linter/blob/main/CHANGELOG.md)
- [Commits](502f4fe48a...d5b0a2ab11)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.2
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: actions/setup-python
  dependency-version: 6.2.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: actions/upload-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: github/codeql-action
  dependency-version: 4.32.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: redhat-plumbers-in-action/differential-shellcheck
  dependency-version: 5.5.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: redhat-plumbers-in-action/gather-pull-request-metadata
  dependency-version: 1.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: redhat-plumbers-in-action/advanced-issue-labeler
  dependency-version: 3.2.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: actions/github-script
  dependency-version: 8.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: super-linter/super-linter
  dependency-version: 8.3.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-28 16:27:11 +09:00
Yu Watanabe
701cf5b698
ansi-color: follow-ups for $SYSTEMD_COLOR=auto-* (#40442)
Follow-ups for #40303
2026-01-28 16:00:38 +09:00
dependabot[bot]
5169b07226 build(deps): bump meson from 1.10.0 to 1.10.1 in /.github/workflows
Bumps [meson](https://github.com/mesonbuild/meson) from 1.10.0 to 1.10.1.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/1.10.0...1.10.1)

---
updated-dependencies:
- dependency-name: meson
  dependency-version: 1.10.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-28 15:25:50 +09:00
Yu Watanabe
49beafb40a github/dependabot: fix mkosi -> systemd/mkosi 2026-01-28 14:59:58 +09:00
Yu Watanabe
586ae3f29a github: make dependabot not update mkosi reference
The refernce to mkosi is manually updated by using tools/fetch-mkosi.py,
and should not be done automatically, as it may have a bigger impact.

Follow-up for c69c5dd58abae56fd47240a06b60c4c9050154a2.
2026-01-28 14:53:02 +09:00
sd416
c69c5dd58a
github: add group configuration for dependabot actions update (#40490)
Add group configuration for dependabot github actions update. This will
ensure that depandabot only creates 1 PR for updating all the new github
actions rather than 1 PR / action update.
2026-01-28 14:23:21 +09:00
Yu Watanabe
5a30581d67 format-table: fix typo
Follow-up for f42dc5ea18e920c70a8571309bfd66757f5e01cb.
2026-01-28 14:10:42 +09:00
Yu Watanabe
bf6452b62e dissect: fix typo
Follow-up for 688ebd3313c481b72f6106f615814fde0ece3827.
2026-01-28 14:09:23 +09:00
Yu Watanabe
0340f60ed2
sd-bus: several follow-ups for MSG_CTRUNC handling (#40488)
Follow-ups for #40089.
2026-01-28 14:01:25 +09:00
Mike Yuan
c49c8331b9
sd-bus/bus-message: more prudently verify it's SCM_RIGHTS that got truncated
Follow-up for 6c8de404c98fb9b965cba68360c2db1e3f55b776

As discussed in
https://github.com/systemd/systemd/pull/40089#issuecomment-3672063388,
if any other control msg got truncated it's a genuine error, and
we should reject the message as a whole.
2026-01-28 03:34:25 +01:00
Mike Yuan
f452c324e7
sd-bus/bus-socket: reinstate MSG_TRUNC handling in bus_socket_read_message()
We switched away from recvmsg_safe() in order to gracefully
handle MSG_CTRUNC. But MSG_TRUNC really shouldn't happen.

While at it, do not use RET_NERRNO with ssize_t.
2026-01-28 03:34:25 +01:00
Mike Yuan
43e08aea6e
sd-bus/bus-socket: restore recvmsg_safe() during auth
At auth stage we reject any fds, hence either way the connection
would fail. Let's play it safe and check for MSG_(C)TRUNC still.
2026-01-28 03:07:01 +01:00
Yu Watanabe
149a8e6306 Bump required minimum version of glibc to 2.34
Major distributions already have glibc >= 2.34.
Let's bump the required minimum version.

Note, glibc-2.34 was released on 2021-08-01.
2026-01-28 10:56:53 +09:00
Mike Yuan
28fb7e869c storagetm: ensure device lock fd is opened for writing
Follow-up for e582484789a6d889d11b97d9c2afa74c3c985130

_cleanup_close_ is dropped, as the fd would be immediately
consumed by the nvme_subsystem_add() call below anyways.
2026-01-28 10:56:22 +09:00
Mike Yuan
480003c560 reread-partition-table: fix typo 2026-01-28 10:56:22 +09:00
Mike Yuan
cc7fe807c1
ansi-color: $SYSTEMD_COLORS=true should mean generic "auto", not 24bit
Follow-up for af718e05350884c0b6a9fa7248e5d2f2564c93f0

The commit changed the documentation, but the actual impl
was apparently not updated. And the documented behavior
feels a bit off. I think generally "auto"/true should
override $NO_COLOR.

Plus, the test for auto-24bit is at odds with the logic
we merged. I guess it was overlooked after applying
https://github.com/systemd/systemd/pull/40303#discussion_r2720450393
2026-01-27 19:20:30 +01:00
Mike Yuan
97be547c6f
ansi-color: assert on final result of get_color_mode() being settled 2026-01-27 19:17:42 +01:00
42 changed files with 152 additions and 408 deletions

View File

@ -6,6 +6,12 @@ updates:
directory: "/"
schedule:
interval: "monthly"
groups:
actions:
patterns:
- "*"
exclude-patterns:
- "systemd/mkosi"
open-pull-requests-limit: 2
- package-ecosystem: "pip"
directory: "/.github/workflows"

View File

@ -51,9 +51,9 @@ jobs:
env: ${{ matrix.env }}
steps:
- name: Repository checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Setup python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
with:
python-version: ${{ matrix.python-version }}
- name: Build check

View File

@ -60,14 +60,14 @@ jobs:
sanitizer: ${{ matrix.sanitizer }}
output-sarif: true
- name: Upload Crash
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
if: failure() && steps.build.outcome == 'success'
with:
name: ${{ matrix.sanitizer }}-${{ matrix.architecture }}-artifacts
path: ./out/artifacts
- name: Upload Sarif
if: always() && steps.build.outcome == 'success'
uses: github/codeql-action/upload-sarif@51f77329afa6477de8c49fc9c7046c15b9a4e79d
uses: github/codeql-action/upload-sarif@b20883b0cd1f46c72ae0ba6d1090936928f9fa30
with:
# Path to SARIF file relative to the root of the repository
sarif_file: cifuzz-sarif/results.sarif

View File

@ -42,10 +42,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Initialize CodeQL
uses: github/codeql-action/init@51f77329afa6477de8c49fc9c7046c15b9a4e79d
uses: github/codeql-action/init@b20883b0cd1f46c72ae0ba6d1090936928f9fa30
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql-config.yml
@ -60,7 +60,7 @@ jobs:
fi
- name: Autobuild
uses: github/codeql-action/autobuild@51f77329afa6477de8c49fc9c7046c15b9a4e79d
uses: github/codeql-action/autobuild@b20883b0cd1f46c72ae0ba6d1090936928f9fa30
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@51f77329afa6477de8c49fc9c7046c15b9a4e79d
uses: github/codeql-action/analyze@b20883b0cd1f46c72ae0ba6d1090936928f9fa30

View File

@ -24,7 +24,7 @@ jobs:
if: github.repository == 'systemd/systemd' || github.repository == 'systemd/systemd-stable'
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- uses: systemd/mkosi@e3642f81d3a7f8f9310c0c734b2ba9dd41e50e14
# Freeing up disk space with rm -rf can take multiple minutes. Since we don't need the extra free space
@ -128,7 +128,7 @@ jobs:
--quiet
- name: Archive failed test journals
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
if: failure() && (github.repository == 'systemd/systemd' || github.repository == 'systemd/systemd-stable')
with:
name: ci-coverage-${{ github.run_id }}-${{ github.run_attempt }}-arch-rolling-failed-test-journals

View File

@ -22,7 +22,7 @@ jobs:
COVERITY_SCAN_NOTIFICATION_EMAIL: "${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}"
steps:
- name: Repository checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
# Reuse the setup phase of the unit test script to avoid code duplication
- name: Install build dependencies
run: |

View File

@ -30,7 +30,7 @@ jobs:
name: Pull Request Metadata
- name: Repository checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
fetch-depth: 0

View File

@ -23,12 +23,12 @@ jobs:
steps:
- name: Repository checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
fetch-depth: 0
- name: Differential ShellCheck
uses: redhat-plumbers-in-action/differential-shellcheck@dd551ce780d8af741f8cd8bab6982667b906b457
uses: redhat-plumbers-in-action/differential-shellcheck@d965e66ec0b3b2f821f75c8eff9b12442d9a7d1e
with:
# exclude all `.in` files because they may contain unsupported syntax, and they have to be preprocessed first
# TEMPORARY: exclude bash completion files, they would generate too many defects in Code scanning dashboard (600+)

View File

@ -16,14 +16,14 @@ jobs:
steps:
- name: Repository checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- id: metadata
name: Gather Pull Request Metadata
uses: redhat-plumbers-in-action/gather-pull-request-metadata@b3dbc3f843e8343dbcb2af5bffba72c974d3a07a
uses: redhat-plumbers-in-action/gather-pull-request-metadata@b86d1eaf7038cf88a56b26ba3e504f10e07b0ce5
- name: Upload Pull Request Metadata artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
with:
name: Pull Request Metadata
path: ${{ steps.metadata.outputs.metadata-file }}

View File

@ -20,7 +20,7 @@ jobs:
template: [ bug_report.yml, feature_request.yml ]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Parse issue form
uses: stefanbuck/github-issue-parser@1e5bdee70d4b3e066a33aa0669ab782943825f94
@ -29,7 +29,7 @@ jobs:
template-path: .github/ISSUE_TEMPLATE/${{ matrix.template }}
- name: Set labels based on component field
uses: redhat-plumbers-in-action/advanced-issue-labeler@e38e6809c5420d038eed380d49ee9a6ca7c92dbf
uses: redhat-plumbers-in-action/advanced-issue-labeler@b80ae64e3e156e9c111b075bfa04b295d54e8e2e
with:
issue-form: ${{ steps.issue-parser.outputs.jsonString }}
template: ${{ matrix.template }}

View File

@ -30,7 +30,7 @@ jobs:
steps:
- name: Repository checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
if: github.event_name == 'pull_request'
- name: Label PR based on policy in labeler.yml
@ -42,7 +42,7 @@ jobs:
sync-labels: false
- name: Set or remove labels based on systemd development workflow
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd
if: startsWith(github.event_name, 'pull_request') && github.event.action != 'closed' && !github.event.pull_request.draft
with:
script: |
@ -83,7 +83,7 @@ jobs:
}
- name: Add please-review label on command in issue comment
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/please-review')
with:
script: |
@ -95,7 +95,7 @@ jobs:
})
- name: Remove specific labels when PR is closed or merged
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd
if: startsWith(github.event_name, 'pull_request') && github.event.action == 'closed'
with:
script: |

View File

@ -23,13 +23,13 @@ jobs:
steps:
- name: Repo checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
# We need a full repo clone
fetch-depth: 0
- name: Lint Code Base
uses: super-linter/super-linter/slim@502f4fe48a81a392756e173e39a861f8c8efe056
uses: super-linter/super-linter/slim@d5b0a2ab116623730dd094f15ddc1b6b25bf7b99
env:
DEFAULT_BRANCH: main
MULTI_STATUS: false

View File

@ -166,7 +166,7 @@ jobs:
shim: 0
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- uses: systemd/mkosi@e3642f81d3a7f8f9310c0c734b2ba9dd41e50e14
# Freeing up disk space with rm -rf can take multiple minutes. Since we don't need the extra free space
@ -311,7 +311,7 @@ jobs:
"${MAX_LINES[@]}"
- name: Archive failed test journals
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
if: failure() && (github.repository == 'systemd/systemd' || github.repository == 'systemd/systemd-stable')
with:
name: ci-mkosi-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.distro }}-${{ matrix.release }}-${{ matrix.runner }}-failed-test-journals

View File

@ -1,6 +1,6 @@
meson==1.10.0 \
--hash=sha256:4b27aafce281e652dcb437b28007457411245d975c48b5db3a797d3e93ae1585 \
--hash=sha256:8071860c1f46a75ea34801490fd1c445c9d75147a65508cd3a10366a7006cc1c
meson==1.10.1 \
--hash=sha256:c42296f12db316a4515b9375a5df330f2e751ccdd4f608430d41d7d6210e4317 \
--hash=sha256:fe43d1cc2e6de146fbea78f3a062194bcc0e779efc8a0f0d7c35544dfb86731f
ninja==1.11.1.4 \
--hash=sha256:055f386fb550c2c9d6157e45e20a84d29c47968876b9c5794ae2aec46f952306 \
--hash=sha256:096487995473320de7f65d622c3f1d16c3ad174797602218ca8c967f51ec38a0 \

View File

@ -29,7 +29,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

View File

@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Repository checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Install build dependencies
uses: jirutka/setup-alpine@v1

View File

@ -40,7 +40,7 @@ jobs:
runner: ubuntu-24.04-s390x
steps:
- name: Repository checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Install build dependencies
run: |
# Drop XDG_* stuff from /etc/environment, so we don't get the user

2
README
View File

@ -201,7 +201,7 @@ REQUIREMENTS:
CONFIG_PSI
CONFIG_MEMCG
glibc >= 2.31
glibc >= 2.34
libxcrypt >= 4.4.0 (optional)
libmount >= 2.30 (from util-linux)
(util-linux *must* be built without --enable-libmount-support-mtab)

View File

@ -225,15 +225,16 @@
<term><varname>$SYSTEMD_COLORS</varname></term>
<listitem>
<para>Takes a boolean argument, or a special value.</para>
<para>Takes a boolean argument, or a special value. By default (unset), <command>systemd</command>
and related utilities will use colors in their output if possible. If <varname>$COLORTERM</varname>
is set to <literal>truecolor</literal> or <literal>24bit</literal>, 24-bit colors will be enabled,
256 colors otherwise, unless <varname>$NO_COLOR</varname> or <varname>$TERM</varname> indicates
colors are disabled.</para>
<variablelist>
<varlistentry>
<term><option>true</option></term>
<listitem><para>The default. <command>systemd</command> and related utilities will use colors in
their output if possible. Same as <literal>auto-24bit</literal> if <varname>$COLORTERM</varname>
is set to <literal>truecolor</literal> or <literal>24bit</literal>; same as
<literal>auto-256</literal> otherwise.</para></listitem>
<listitem><para>Same as unset, except that <varname>$NO_COLOR</varname> is ignored.</para></listitem>
</varlistentry>
<varlistentry>

View File

@ -565,10 +565,6 @@ foreach ident : [
['renameat2', '''#include <stdio.h>'''], # since musl-1.2.6
['set_mempolicy', '''#include <sys/syscall.h>'''], # declared at numaif.h provided by libnuma, which we do not use
['get_mempolicy', '''#include <sys/syscall.h>'''], # declared at numaif.h provided by libnuma, which we do not use
['strerrorname_np', '''#include <string.h>'''], # since glibc-2.32
['mallinfo2', '''#include <malloc.h>'''], # since glibc-2.33
['execveat', '''#include <unistd.h>'''], # since glibc-2.34
['close_range', '''#include <unistd.h>'''], # since glibc-2.34
['epoll_pwait2', '''#include <sys/epoll.h>'''], # since glibc-2.35
['fsconfig', '''#include <sys/mount.h>'''], # since glibc-2.36
['fsmount', '''#include <sys/mount.h>'''], # since glibc-2.36

View File

@ -55,11 +55,11 @@ static ColorMode get_color_mode_impl(void) {
/* First, we check $SYSTEMD_COLORS, which is the explicit way to change the mode. */
ColorMode m = parse_systemd_colors();
if (IN_SET(m, COLOR_OFF, COLOR_16, COLOR_256, COLOR_24BIT))
if (m >= 0 && m < _COLOR_MODE_FIXED_MAX)
return m;
/* Next, check for the presence of $NO_COLOR; value is ignored. */
if (getenv("NO_COLOR"))
if (m != COLOR_TRUE && getenv("NO_COLOR"))
return COLOR_OFF;
/* If the above didn't work, we turn colors off unless we are on a TTY. And if we are on a TTY we
@ -92,13 +92,14 @@ static ColorMode get_color_mode_impl(void) {
}
ColorMode get_color_mode(void) {
if (cached_color_mode < 0)
if (cached_color_mode < 0) {
cached_color_mode = get_color_mode_impl();
assert(cached_color_mode >= 0 && cached_color_mode < _COLOR_MODE_FIXED_MAX);
}
return cached_color_mode;
}
static const char* const color_mode_table[_COLOR_MODE_MAX] = {
[COLOR_OFF] = "off",
[COLOR_16] = "16",
@ -107,9 +108,10 @@ static const char* const color_mode_table[_COLOR_MODE_MAX] = {
[COLOR_AUTO_16] = "auto-16",
[COLOR_AUTO_256] = "auto-256",
[COLOR_AUTO_24BIT] = "auto-24bit",
[COLOR_TRUE] = "true",
};
DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(color_mode, ColorMode, COLOR_24BIT);
DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(color_mode, ColorMode, COLOR_TRUE);
/*
* Check that the string is formatted like an ANSI color code, i.e. that it consists of one or more

View File

@ -9,9 +9,17 @@ typedef enum ColorMode {
COLOR_16, /* Only the base 16 colors. */
COLOR_256, /* Only 256 colors. */
COLOR_24BIT, /* For truecolor or 24bit color support, no restriction. */
COLOR_AUTO_16, /* The "AUTO" modes are as the above, but subject to suitable settings for */
COLOR_AUTO_256, /* the environment variables TERM and NO_COLOR. */
_COLOR_MODE_FIXED_MAX,
/* The "AUTO" modes are as the above, but subject to suitable settings for the environment variables
* TERM and NO_COLOR. */
COLOR_AUTO_16 = _COLOR_MODE_FIXED_MAX,
COLOR_AUTO_256,
COLOR_AUTO_24BIT,
/* Same as default (unset), except that $NO_COLOR is ignored/overridden */
COLOR_TRUE,
_COLOR_MODE_MAX,
_COLOR_MODE_INVALID = -EINVAL,
} ColorMode;

View File

@ -24,7 +24,7 @@ int errno_from_name(const char *name) {
return sc->id;
}
#if HAVE_STRERRORNAME_NP
#ifdef __GLIBC__
const char* errno_name_no_fallback(int id) {
if (id == 0) /* To stay in line with our implementation below. */
return NULL;

View File

@ -1,27 +1,26 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include_next <malloc.h>
#include <errno.h>
#include <stdio.h>
/* struct mallinfo2 will be defined and struct mallinfo is converted to struct mallinfo2 in
* override/malloc.h. Hence, here we define struct mallinfo. */
struct mallinfo {
int arena; /* non-mmapped space allocated from system */
int ordblks; /* number of free chunks */
int smblks; /* number of fastbin blocks */
int hblks; /* number of mmapped regions */
int hblkhd; /* space in mmapped regions */
int usmblks; /* always 0, preserved for backwards compatibility */
int fsmblks; /* space available in freed fastbin blocks */
int uordblks; /* total allocated space */
int fordblks; /* total free space */
int keepcost; /* top-most, releasable (via malloc_trim) space */
struct mallinfo2 {
size_t arena; /* non-mmapped space allocated from system */
size_t ordblks; /* number of free chunks */
size_t smblks; /* number of fastbin blocks */
size_t hblks; /* number of mmapped regions */
size_t hblkhd; /* space in mmapped regions */
size_t usmblks; /* always 0, preserved for backwards compatibility */
size_t fsmblks; /* space available in freed fastbin blocks */
size_t uordblks; /* total allocated space */
size_t fordblks; /* total free space */
size_t keepcost; /* top-most, releasable (via malloc_trim) space */
};
static inline struct mallinfo mallinfo(void) {
return (struct mallinfo) {};
static inline struct mallinfo2 mallinfo2(void) {
return (struct mallinfo2) {};
}
static inline int malloc_info(int options, FILE *stream) {
@ -35,5 +34,3 @@ static inline int malloc_info(int options, FILE *stream) {
static inline int malloc_trim(size_t pad) {
return 0;
}
#include_next <malloc.h>

View File

@ -10,3 +10,9 @@
* found. Let's always use getopt_long(). */
int getopt_fix(int argc, char * const *argv, const char *optstring);
#define getopt(argc, argv, optstring) getopt_fix(argc, argv, optstring)
int missing_close_range(unsigned first_fd, unsigned end_fd, unsigned flags);
#define close_range missing_close_range
int missing_execveat(int dirfd, const char *pathname, char * const argv[], char * const envp[], int flags);
#define execveat missing_execveat

View File

@ -1,39 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include_next <malloc.h> /* IWYU pragma: export */
#if !HAVE_MALLINFO2
struct mallinfo2 {
size_t arena; /* non-mmapped space allocated from system */
size_t ordblks; /* number of free chunks */
size_t smblks; /* number of fastbin blocks */
size_t hblks; /* number of mmapped regions */
size_t hblkhd; /* space in mmapped regions */
size_t usmblks; /* always 0, preserved for backwards compatibility */
size_t fsmblks; /* space available in freed fastbin blocks */
size_t uordblks; /* total allocated space */
size_t fordblks; /* total free space */
size_t keepcost; /* top-most, releasable (via malloc_trim) space */
};
static inline struct mallinfo2 mallinfo2(void) {
_Pragma("GCC diagnostic push");
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"");
struct mallinfo m = mallinfo();
_Pragma("GCC diagnostic pop");
return (struct mallinfo2) {
.arena = m.arena,
.ordblks = m.ordblks,
.smblks = m.smblks,
.hblks = m.hblks,
.hblkhd = m.hblkhd,
.usmblks = 0,
.fsmblks = m.fsmblks,
.uordblks = m.uordblks,
.fordblks = m.fordblks,
.keepcost = m.keepcost,
};
}
#endif

View File

@ -6,11 +6,8 @@ import functools
# We only generate numbers for a dozen or so syscalls
SYSCALLS = [
'close_range', # defined in glibc header since glibc-2.33
'fchmodat2', # defined in glibc header since glibc-2.39
'mount_setattr', # defined in glibc header since glibc-2.34
'open_tree_attr',
'openat2', # defined in glibc header since glibc-2.32
'quotactl_fd', # defined in glibc header since glibc-2.35
'removexattrat',
'setxattrat',

View File

@ -1,13 +0,0 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include_next <sys/random.h> /* IWYU pragma: export */
#include <assert.h>
/* Defined since glibc-2.32. */
#ifndef GRND_INSECURE
# define GRND_INSECURE 0x0004
#else
static_assert(GRND_INSECURE == 0x0004, "");
#endif

View File

@ -54,76 +54,6 @@
# define missing_arch_template 1
# endif
#ifndef __IGNORE_close_range
# if defined(__aarch64__)
# define systemd_NR_close_range 436
# elif defined(__alpha__)
# define systemd_NR_close_range 546
# elif defined(__arc__) || defined(__tilegx__)
# define systemd_NR_close_range 436
# elif defined(__arm__)
# define systemd_NR_close_range 436
# elif defined(__i386__)
# define systemd_NR_close_range 436
# elif defined(__ia64__)
# define systemd_NR_close_range 1460
# elif defined(__loongarch_lp64)
# define systemd_NR_close_range 436
# elif defined(__m68k__)
# define systemd_NR_close_range 436
# elif defined(_MIPS_SIM)
# if _MIPS_SIM == _MIPS_SIM_ABI32
# define systemd_NR_close_range 4436
# elif _MIPS_SIM == _MIPS_SIM_NABI32
# define systemd_NR_close_range 6436
# elif _MIPS_SIM == _MIPS_SIM_ABI64
# define systemd_NR_close_range 5436
# else
# error "Unknown MIPS ABI"
# endif
# elif defined(__hppa__)
# define systemd_NR_close_range 436
# elif defined(__powerpc__)
# define systemd_NR_close_range 436
# elif defined(__riscv)
# if __riscv_xlen == 32
# define systemd_NR_close_range 436
# elif __riscv_xlen == 64
# define systemd_NR_close_range 436
# else
# error "Unknown RISC-V ABI"
# endif
# elif defined(__s390__)
# define systemd_NR_close_range 436
# elif defined(__sh__)
# define systemd_NR_close_range 436
# elif defined(__sparc__)
# define systemd_NR_close_range 436
# elif defined(__x86_64__)
# if defined(__ILP32__)
# define systemd_NR_close_range (436 | /* __X32_SYSCALL_BIT */ 0x40000000)
# else
# define systemd_NR_close_range 436
# endif
# elif !defined(missing_arch_template)
# warning "close_range() syscall number is unknown for your architecture"
# endif
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_close_range && __NR_close_range >= 0
# if defined systemd_NR_close_range
static_assert(__NR_close_range == systemd_NR_close_range, "");
# endif
# else
# if defined __NR_close_range
# undef __NR_close_range
# endif
# if defined systemd_NR_close_range && systemd_NR_close_range >= 0
# define __NR_close_range systemd_NR_close_range
# endif
# endif
#endif
#ifndef __IGNORE_fchmodat2
# if defined(__aarch64__)
# define systemd_NR_fchmodat2 452
@ -194,76 +124,6 @@ static_assert(__NR_fchmodat2 == systemd_NR_fchmodat2, "");
# endif
#endif
#ifndef __IGNORE_mount_setattr
# if defined(__aarch64__)
# define systemd_NR_mount_setattr 442
# elif defined(__alpha__)
# define systemd_NR_mount_setattr 552
# elif defined(__arc__) || defined(__tilegx__)
# define systemd_NR_mount_setattr 442
# elif defined(__arm__)
# define systemd_NR_mount_setattr 442
# elif defined(__i386__)
# define systemd_NR_mount_setattr 442
# elif defined(__ia64__)
# define systemd_NR_mount_setattr 1466
# elif defined(__loongarch_lp64)
# define systemd_NR_mount_setattr 442
# elif defined(__m68k__)
# define systemd_NR_mount_setattr 442
# elif defined(_MIPS_SIM)
# if _MIPS_SIM == _MIPS_SIM_ABI32
# define systemd_NR_mount_setattr 4442
# elif _MIPS_SIM == _MIPS_SIM_NABI32
# define systemd_NR_mount_setattr 6442
# elif _MIPS_SIM == _MIPS_SIM_ABI64
# define systemd_NR_mount_setattr 5442
# else
# error "Unknown MIPS ABI"
# endif
# elif defined(__hppa__)
# define systemd_NR_mount_setattr 442
# elif defined(__powerpc__)
# define systemd_NR_mount_setattr 442
# elif defined(__riscv)
# if __riscv_xlen == 32
# define systemd_NR_mount_setattr 442
# elif __riscv_xlen == 64
# define systemd_NR_mount_setattr 442
# else
# error "Unknown RISC-V ABI"
# endif
# elif defined(__s390__)
# define systemd_NR_mount_setattr 442
# elif defined(__sh__)
# define systemd_NR_mount_setattr 442
# elif defined(__sparc__)
# define systemd_NR_mount_setattr 442
# elif defined(__x86_64__)
# if defined(__ILP32__)
# define systemd_NR_mount_setattr (442 | /* __X32_SYSCALL_BIT */ 0x40000000)
# else
# define systemd_NR_mount_setattr 442
# endif
# elif !defined(missing_arch_template)
# warning "mount_setattr() syscall number is unknown for your architecture"
# endif
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_mount_setattr && __NR_mount_setattr >= 0
# if defined systemd_NR_mount_setattr
static_assert(__NR_mount_setattr == systemd_NR_mount_setattr, "");
# endif
# else
# if defined __NR_mount_setattr
# undef __NR_mount_setattr
# endif
# if defined systemd_NR_mount_setattr && systemd_NR_mount_setattr >= 0
# define __NR_mount_setattr systemd_NR_mount_setattr
# endif
# endif
#endif
#ifndef __IGNORE_open_tree_attr
# if defined(__aarch64__)
# define systemd_NR_open_tree_attr 467
@ -334,76 +194,6 @@ static_assert(__NR_open_tree_attr == systemd_NR_open_tree_attr, "");
# endif
#endif
#ifndef __IGNORE_openat2
# if defined(__aarch64__)
# define systemd_NR_openat2 437
# elif defined(__alpha__)
# define systemd_NR_openat2 547
# elif defined(__arc__) || defined(__tilegx__)
# define systemd_NR_openat2 437
# elif defined(__arm__)
# define systemd_NR_openat2 437
# elif defined(__i386__)
# define systemd_NR_openat2 437
# elif defined(__ia64__)
# define systemd_NR_openat2 1461
# elif defined(__loongarch_lp64)
# define systemd_NR_openat2 437
# elif defined(__m68k__)
# define systemd_NR_openat2 437
# elif defined(_MIPS_SIM)
# if _MIPS_SIM == _MIPS_SIM_ABI32
# define systemd_NR_openat2 4437
# elif _MIPS_SIM == _MIPS_SIM_NABI32
# define systemd_NR_openat2 6437
# elif _MIPS_SIM == _MIPS_SIM_ABI64
# define systemd_NR_openat2 5437
# else
# error "Unknown MIPS ABI"
# endif
# elif defined(__hppa__)
# define systemd_NR_openat2 437
# elif defined(__powerpc__)
# define systemd_NR_openat2 437
# elif defined(__riscv)
# if __riscv_xlen == 32
# define systemd_NR_openat2 437
# elif __riscv_xlen == 64
# define systemd_NR_openat2 437
# else
# error "Unknown RISC-V ABI"
# endif
# elif defined(__s390__)
# define systemd_NR_openat2 437
# elif defined(__sh__)
# define systemd_NR_openat2 437
# elif defined(__sparc__)
# define systemd_NR_openat2 437
# elif defined(__x86_64__)
# if defined(__ILP32__)
# define systemd_NR_openat2 (437 | /* __X32_SYSCALL_BIT */ 0x40000000)
# else
# define systemd_NR_openat2 437
# endif
# elif !defined(missing_arch_template)
# warning "openat2() syscall number is unknown for your architecture"
# endif
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_openat2 && __NR_openat2 >= 0
# if defined systemd_NR_openat2
static_assert(__NR_openat2 == systemd_NR_openat2, "");
# endif
# else
# if defined __NR_openat2
# undef __NR_openat2
# endif
# if defined systemd_NR_openat2 && systemd_NR_openat2 >= 0
# define __NR_openat2 systemd_NR_openat2
# endif
# endif
#endif
#ifndef __IGNORE_quotactl_fd
# if defined(__aarch64__)
# define systemd_NR_quotactl_fd 443

View File

@ -3,20 +3,6 @@
#include_next <unistd.h> /* IWYU pragma: export */
/* Defined since glibc-2.34.
* Supported since kernel v5.9 (9b4feb630e8e9801603f3cab3a36369e3c1cf88d). */
#if !HAVE_CLOSE_RANGE
int missing_close_range(unsigned first_fd, unsigned end_fd, unsigned flags);
# define close_range missing_close_range
#endif
/* Defined since glibc-2.34.
* Supported since kernel v3.19 (51f39a1f0cea1cacf8c787f652f26dfee9611874). */
#if !HAVE_EXECVEAT
int missing_execveat(int dirfd, const char *pathname, char * const argv[], char * const envp[], int flags);
# define execveat missing_execveat
#endif
#if !HAVE_PIVOT_ROOT
int missing_pivot_root(const char *new_root, const char *put_old);
# define pivot_root missing_pivot_root

View File

@ -11,4 +11,5 @@ libc_wrapper_sources += files(
'stdio.c',
'stdlib.c',
'string.c',
'unistd.c',
)

15
src/libc/musl/unistd.c Normal file
View File

@ -0,0 +1,15 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <sys/syscall.h>
#include <unistd.h>
int missing_close_range(unsigned first_fd, unsigned end_fd, unsigned flags) {
/* Kernel-side the syscall expects fds as unsigned integers (just like close() actually), while
* userspace exclusively uses signed integers for fds. glibc chose to expose it 1:1 however, hence we
* do so here too, even if we end up passing signed fds to it most of the time. */
return syscall(__NR_close_range, first_fd, end_fd, flags);
}
int missing_execveat(int dirfd, const char *pathname, char * const argv[], char * const envp[], int flags) {
return syscall(__NR_execveat, dirfd, pathname, argv, envp, flags);
}

View File

@ -3,21 +3,6 @@
#include <sys/syscall.h>
#include <unistd.h>
#if !HAVE_CLOSE_RANGE
int missing_close_range(unsigned first_fd, unsigned end_fd, unsigned flags) {
/* Kernel-side the syscall expects fds as unsigned integers (just like close() actually), while
* userspace exclusively uses signed integers for fds. glibc chose to expose it 1:1 however, hence we
* do so here too, even if we end up passing signed fds to it most of the time. */
return syscall(__NR_close_range, first_fd, end_fd, flags);
}
#endif
#if !HAVE_EXECVEAT
int missing_execveat(int dirfd, const char *pathname, char * const argv[], char * const envp[], int flags) {
return syscall(__NR_execveat, dirfd, pathname, argv, envp, flags);
}
#endif
#if !HAVE_PIVOT_ROOT
int missing_pivot_root(const char *new_root, const char *put_old) {
return syscall(__NR_pivot_root, new_root, put_old);

View File

@ -4210,15 +4210,19 @@ static int message_parse_fields(sd_bus_message *m, bool got_ctrunc) {
"Received a bus message with too many fds: %" PRIu32 " received vs. %" PRIu32 " declared",
m->n_fds, n_unix_fds_declared);
if (m->n_fds < n_unix_fds_declared && !got_ctrunc)
return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
"Received a bus message with too few fds: %" PRIu32 " received vs. %" PRIu32 " declared",
m->n_fds, n_unix_fds_declared);
if (m->n_fds < n_unix_fds_declared) {
if (!got_ctrunc)
return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
"Received a bus message with too few fds: %" PRIu32 " received vs. %" PRIu32 " declared",
m->n_fds, n_unix_fds_declared);
if (got_ctrunc)
log_error("Received a bus message with MSG_CTRUNC set with %" PRIu32 " fds received vs %" PRIu32 " declared",
m->n_fds, n_unix_fds_declared);
} else if (got_ctrunc)
return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
"Received a bus message with truncated control data, refusing.");
switch (m->header->type) {
case SD_BUS_MESSAGE_SIGNAL:

View File

@ -657,7 +657,7 @@ static int bus_socket_read_auth(sd_bus *b) {
.msg_controllen = sizeof(control),
};
k = RET_NERRNO(recvmsg(b->input_fd, &mh, MSG_DONTWAIT|MSG_CMSG_CLOEXEC));
k = recvmsg_safe(b->input_fd, &mh, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
if (k == -ENOTSOCK) {
b->prefer_readv = true;
k = readv(b->input_fd, &iov, 1);
@ -1397,14 +1397,8 @@ static int bus_socket_make_message(sd_bus *bus, size_t size) {
}
int bus_socket_read_message(sd_bus *bus) {
struct msghdr mh;
struct iovec iov = {};
ssize_t k;
size_t need;
int r;
void *b;
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int) * BUS_FDS_MAX)) control;
bool handle_cmsg = false;
assert(bus);
assert(IN_SET(bus->state, BUS_RUNNING, BUS_HELLO));
@ -1416,19 +1410,18 @@ int bus_socket_read_message(sd_bus *bus) {
if (bus->rbuffer_size >= need)
return bus_socket_make_message(bus, need);
b = realloc(bus->rbuffer, need);
void *b = realloc(bus->rbuffer, need);
if (!b)
return -ENOMEM;
bus->rbuffer = b;
iov = IOVEC_MAKE((uint8_t *)bus->rbuffer + bus->rbuffer_size, need - bus->rbuffer_size);
struct iovec iov = IOVEC_MAKE((uint8_t*) bus->rbuffer + bus->rbuffer_size, need - bus->rbuffer_size);
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int) * BUS_FDS_MAX)) control;
struct msghdr mh;
bool handle_cmsg = false;
ssize_t k;
if (bus->prefer_readv) {
k = readv(bus->input_fd, &iov, 1);
if (k < 0)
k = -errno;
} else {
if (!bus->prefer_readv) {
mh = (struct msghdr) {
.msg_iov = &iov,
.msg_iovlen = 1,
@ -1436,24 +1429,29 @@ int bus_socket_read_message(sd_bus *bus) {
.msg_controllen = sizeof(control),
};
k = RET_NERRNO(recvmsg(bus->input_fd, &mh, MSG_DONTWAIT|MSG_CMSG_CLOEXEC));
if (k == -ENOTSOCK) {
k = recvmsg(bus->input_fd, &mh, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
if (k < 0 && errno == ENOTSOCK)
bus->prefer_readv = true;
k = readv(bus->input_fd, &iov, 1);
if (k < 0)
k = -errno;
} else
else
handle_cmsg = true;
}
if (ERRNO_IS_NEG_TRANSIENT(k))
return 0;
if (k < 0)
return (int) k;
if (bus->prefer_readv)
k = readv(bus->input_fd, &iov, 1);
if (k < 0) {
if (ERRNO_IS_TRANSIENT(errno))
return 0;
return -errno;
}
if (k == 0) {
if (handle_cmsg)
cmsg_close_all(&mh); /* On EOF we shouldn't have gotten an fd, but let's make sure */
return -ECONNRESET;
}
if (handle_cmsg && FLAGS_SET(mh.msg_flags, MSG_TRUNC)) {
cmsg_close_all(&mh);
return -EXFULL;
}
bus->rbuffer_size += k;

View File

@ -2743,7 +2743,7 @@ int dissected_image_mount(
if (r < 0)
return log_debug_errno(r, "Failed to check is '%s' is an OS tree: %m", where);
if (r > 0) {
log_debug("Succesfully identified '%s' as an OS tree", where);
log_debug("Successfully identified '%s' as an OS tree", where);
ok = true;
}
}

View File

@ -10,7 +10,7 @@
typedef enum TableDataType {
TABLE_EMPTY,
TABLE_STRING,
TABLE_STRING_WITH_ANSI, /* like the above, but contains ANSI sequences/TABs. They will be stripped when outputing to JSON */
TABLE_STRING_WITH_ANSI, /* like the above, but contains ANSI sequences/TABs. They will be stripped when outputting to JSON */
TABLE_HEADER, /* in regular mode: the cells in the first row, that carry the column names */
TABLE_FIELD, /* in vertical mode: the cells in the first column, that carry the field names */
TABLE_STRV,

View File

@ -256,7 +256,7 @@ static int reread_partition_table_full(sd_device *dev, int fd, RereadPartitionTa
if (FLAGS_SET(flags, REREADPT_BSD_LOCK)) {
lock_fd = fd_reopen(fd, O_RDONLY|O_CLOEXEC|O_NOCTTY);
if (lock_fd < 0)
return log_device_debug_errno(dev, lock_fd, "Failed top open lock fd for block device '%s': %m", p);
return log_device_debug_errno(dev, lock_fd, "Failed to open lock fd for block device '%s': %m", p);
if (flock(lock_fd, LOCK_EX|LOCK_NB) < 0) {
r = log_device_debug_errno(dev, errno, "Failed to take BSD lock on block device '%s': %m", p);

View File

@ -923,7 +923,6 @@ static bool device_is_allowed(sd_device *d) {
}
static int device_added(Context *c, sd_device *device) {
_cleanup_close_ int fd = -EBADF;
int r;
assert(c);
@ -967,7 +966,7 @@ static int device_added(Context *c, sd_device *device) {
return 0;
}
fd = sd_device_open(device, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
int fd = sd_device_open(device, O_RDWR|O_CLOEXEC|O_NONBLOCK);
if (fd < 0) {
log_device_warning_errno(device, fd, "Failed to open newly acquired device '%s', ignoring device: %m", devname);
return 0;

View File

@ -849,14 +849,18 @@ TEST(table_ansi) {
TABLE_STRING_WITH_ANSI, ANSI_GREY "thisisgrey"));
unsigned saved_columns = columns();
bool saved_color = colors_enabled();
_cleanup_free_ char *saved_term = NULL;
const char *e = getenv("TERM");
_cleanup_free_ char *saved_term = NULL, *saved_color = NULL;
const char *e;
e = getenv("TERM");
if (e)
ASSERT_NOT_NULL((saved_term = strdup(e)));
e = getenv("SYSTEMD_COLORS");
if (e)
ASSERT_NOT_NULL((saved_color = strdup(e)));
ASSERT_OK_ERRNO(setenv("COLUMNS", "200", /* overwrite= */ true));
ASSERT_OK_ERRNO(setenv("SYSTEMD_COLORS", "1", /* overwrite= */ true));
ASSERT_OK_ERRNO(setenv("SYSTEMD_COLORS", "24bit", /* overwrite= */ true));
ASSERT_OK_ERRNO(setenv("TERM", FALLBACK_TERM, /* overwrite= */ true));
reset_terminal_feature_caches();
@ -904,7 +908,7 @@ TEST(table_ansi) {
ASSERT_OK(sd_json_variant_dump(j, SD_JSON_FORMAT_COLOR_AUTO|SD_JSON_FORMAT_PRETTY_AUTO, /* f= */ NULL, /* prefix= */ NULL));
ASSERT_OK(setenvf("COLUMNS", /* overwrite= */ true, "%u", saved_columns));
ASSERT_OK(setenvf("SYSTEMD_COLORS", /* overwrite= */ true, "%i", saved_color));
ASSERT_OK(set_unset_env("SYSTEMD_COLORS", saved_color, /* overwrite= */ true));
ASSERT_OK(set_unset_env("TERM", saved_term, /* overwrite= */ true));
}

View File

@ -11,7 +11,7 @@ static int run(int argc, char **argv) {
test_setup_logging(LOG_DEBUG);
assert_se(setenv("SYSTEMD_COLORS", "1", 1) == 0); /* Force the qrcode to be printed */
assert_se(setenv("SYSTEMD_COLORS", "24bit", 1) == 0); /* Force the qrcode to be printed */
r = print_qrcode(stdout, "This should say \"TEST\"", "TEST");
if (r == -EOPNOTSUPP)

View File

@ -332,18 +332,19 @@ TEST(get_color_mode) {
test_get_color_mode_with_env("SYSTEMD_COLORS", "no", COLOR_OFF);
test_get_color_mode_with_env("SYSTEMD_COLORS", "16", COLOR_16);
test_get_color_mode_with_env("SYSTEMD_COLORS", "256", COLOR_256);
test_get_color_mode_with_env("SYSTEMD_COLORS", "1", COLOR_24BIT);
test_get_color_mode_with_env("SYSTEMD_COLORS", "yes", COLOR_24BIT);
test_get_color_mode_with_env("SYSTEMD_COLORS", "24bit", COLOR_24BIT);
test_get_color_mode_with_env("SYSTEMD_COLORS", "auto-16", terminal_is_dumb() ? COLOR_OFF : COLOR_16);
test_get_color_mode_with_env("SYSTEMD_COLORS", "auto-256", terminal_is_dumb() ? COLOR_OFF : COLOR_256);
ASSERT_OK_ERRNO(setenv("COLORTERM", "truecolor", true));
test_get_color_mode_with_env("SYSTEMD_COLORS", "auto-24bit", terminal_is_dumb() ? COLOR_OFF : COLOR_24BIT);
ASSERT_OK_ERRNO(setenv("COLORTERM", "truecolor", true));
test_get_color_mode_with_env("SYSTEMD_COLORS", "1", terminal_is_dumb() ? COLOR_OFF : COLOR_24BIT);
test_get_color_mode_with_env("SYSTEMD_COLORS", "yes", terminal_is_dumb() ? COLOR_OFF : COLOR_24BIT);
ASSERT_OK_ERRNO(unsetenv("COLORTERM"));
test_get_color_mode_with_env("SYSTEMD_COLORS", "auto-24bit", terminal_is_dumb() ? COLOR_OFF : COLOR_256);
test_get_color_mode_with_env("SYSTEMD_COLORS", "true", terminal_is_dumb() ? COLOR_OFF : COLOR_256);
ASSERT_OK_ERRNO(setenv("NO_COLOR", "1", true));
test_get_color_mode_with_env("SYSTEMD_COLORS", "true", terminal_is_dumb() ? COLOR_OFF : COLOR_256);
test_get_color_mode_with_env("SYSTEMD_COLORS", "auto-16", COLOR_OFF);
test_get_color_mode_with_env("SYSTEMD_COLORS", "auto-256", COLOR_OFF);
test_get_color_mode_with_env("SYSTEMD_COLORS", "auto-24bit", COLOR_OFF);