mirror of
https://github.com/systemd/systemd
synced 2026-03-15 09:34:47 +01:00
Compare commits
No commits in common. "4afd7808feba81af8b9ba2b24d0dbb1c27d13e0d" and "cab4b9defdef1f9f9d3c31b262aed408a6616490" have entirely different histories.
4afd7808fe
...
cab4b9defd
6
.github/dependabot.yml
vendored
6
.github/dependabot.yml
vendored
@ -6,12 +6,6 @@ updates:
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
groups:
|
||||
actions:
|
||||
patterns:
|
||||
- "*"
|
||||
exclude-patterns:
|
||||
- "systemd/mkosi"
|
||||
open-pull-requests-limit: 2
|
||||
- package-ecosystem: "pip"
|
||||
directory: "/.github/workflows"
|
||||
|
||||
4
.github/workflows/build-test.yml
vendored
4
.github/workflows/build-test.yml
vendored
@ -51,9 +51,9 @@ jobs:
|
||||
env: ${{ matrix.env }}
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
- name: Setup python
|
||||
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
|
||||
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Build check
|
||||
|
||||
4
.github/workflows/cifuzz.yml
vendored
4
.github/workflows/cifuzz.yml
vendored
@ -60,14 +60,14 @@ jobs:
|
||||
sanitizer: ${{ matrix.sanitizer }}
|
||||
output-sarif: true
|
||||
- name: Upload Crash
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
|
||||
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
|
||||
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@b20883b0cd1f46c72ae0ba6d1090936928f9fa30
|
||||
uses: github/codeql-action/upload-sarif@51f77329afa6477de8c49fc9c7046c15b9a4e79d
|
||||
with:
|
||||
# Path to SARIF file relative to the root of the repository
|
||||
sarif_file: cifuzz-sarif/results.sarif
|
||||
|
||||
8
.github/workflows/codeql.yml
vendored
8
.github/workflows/codeql.yml
vendored
@ -42,10 +42,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@b20883b0cd1f46c72ae0ba6d1090936928f9fa30
|
||||
uses: github/codeql-action/init@51f77329afa6477de8c49fc9c7046c15b9a4e79d
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
config-file: ./.github/codeql-config.yml
|
||||
@ -60,7 +60,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@b20883b0cd1f46c72ae0ba6d1090936928f9fa30
|
||||
uses: github/codeql-action/autobuild@51f77329afa6477de8c49fc9c7046c15b9a4e79d
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@b20883b0cd1f46c72ae0ba6d1090936928f9fa30
|
||||
uses: github/codeql-action/analyze@51f77329afa6477de8c49fc9c7046c15b9a4e79d
|
||||
|
||||
4
.github/workflows/coverage.yml
vendored
4
.github/workflows/coverage.yml
vendored
@ -24,7 +24,7 @@ jobs:
|
||||
if: github.repository == 'systemd/systemd' || github.repository == 'systemd/systemd-stable'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
- 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@v6
|
||||
uses: actions/upload-artifact@v4
|
||||
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
|
||||
|
||||
2
.github/workflows/coverity.yml
vendored
2
.github/workflows/coverity.yml
vendored
@ -22,7 +22,7 @@ jobs:
|
||||
COVERITY_SCAN_NOTIFICATION_EMAIL: "${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}"
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
# Reuse the setup phase of the unit test script to avoid code duplication
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
|
||||
2
.github/workflows/development-freeze.yml
vendored
2
.github/workflows/development-freeze.yml
vendored
@ -30,7 +30,7 @@ jobs:
|
||||
name: Pull Request Metadata
|
||||
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
||||
@ -23,12 +23,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Differential ShellCheck
|
||||
uses: redhat-plumbers-in-action/differential-shellcheck@d965e66ec0b3b2f821f75c8eff9b12442d9a7d1e
|
||||
uses: redhat-plumbers-in-action/differential-shellcheck@dd551ce780d8af741f8cd8bab6982667b906b457
|
||||
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+)
|
||||
|
||||
6
.github/workflows/gather-pr-metadata.yml
vendored
6
.github/workflows/gather-pr-metadata.yml
vendored
@ -16,14 +16,14 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
|
||||
- id: metadata
|
||||
name: Gather Pull Request Metadata
|
||||
uses: redhat-plumbers-in-action/gather-pull-request-metadata@b86d1eaf7038cf88a56b26ba3e504f10e07b0ce5
|
||||
uses: redhat-plumbers-in-action/gather-pull-request-metadata@b3dbc3f843e8343dbcb2af5bffba72c974d3a07a
|
||||
|
||||
- name: Upload Pull Request Metadata artifact
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
|
||||
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
|
||||
with:
|
||||
name: Pull Request Metadata
|
||||
path: ${{ steps.metadata.outputs.metadata-file }}
|
||||
|
||||
4
.github/workflows/issue-labeler.yml
vendored
4
.github/workflows/issue-labeler.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
||||
template: [ bug_report.yml, feature_request.yml ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
|
||||
- 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@b80ae64e3e156e9c111b075bfa04b295d54e8e2e
|
||||
uses: redhat-plumbers-in-action/advanced-issue-labeler@e38e6809c5420d038eed380d49ee9a6ca7c92dbf
|
||||
with:
|
||||
issue-form: ${{ steps.issue-parser.outputs.jsonString }}
|
||||
template: ${{ matrix.template }}
|
||||
|
||||
8
.github/workflows/labeler.yml
vendored
8
.github/workflows/labeler.yml
vendored
@ -30,7 +30,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
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@ed597411d8f924073f98dfc5c65a23a2325f34cd
|
||||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
|
||||
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@ed597411d8f924073f98dfc5c65a23a2325f34cd
|
||||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
|
||||
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@ed597411d8f924073f98dfc5c65a23a2325f34cd
|
||||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
|
||||
if: startsWith(github.event_name, 'pull_request') && github.event.action == 'closed'
|
||||
with:
|
||||
script: |
|
||||
|
||||
4
.github/workflows/linter.yml
vendored
4
.github/workflows/linter.yml
vendored
@ -23,13 +23,13 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Repo checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
# We need a full repo clone
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Lint Code Base
|
||||
uses: super-linter/super-linter/slim@d5b0a2ab116623730dd094f15ddc1b6b25bf7b99
|
||||
uses: super-linter/super-linter/slim@502f4fe48a81a392756e173e39a861f8c8efe056
|
||||
env:
|
||||
DEFAULT_BRANCH: main
|
||||
MULTI_STATUS: false
|
||||
|
||||
4
.github/workflows/mkosi.yml
vendored
4
.github/workflows/mkosi.yml
vendored
@ -166,7 +166,7 @@ jobs:
|
||||
shim: 0
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
- 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@v6
|
||||
uses: actions/upload-artifact@v4
|
||||
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
|
||||
|
||||
6
.github/workflows/requirements.txt
vendored
6
.github/workflows/requirements.txt
vendored
@ -1,6 +1,6 @@
|
||||
meson==1.10.1 \
|
||||
--hash=sha256:c42296f12db316a4515b9375a5df330f2e751ccdd4f608430d41d7d6210e4317 \
|
||||
--hash=sha256:fe43d1cc2e6de146fbea78f3a062194bcc0e779efc8a0f0d7c35544dfb86731f
|
||||
meson==1.10.0 \
|
||||
--hash=sha256:4b27aafce281e652dcb437b28007457411245d975c48b5db3a797d3e93ae1585 \
|
||||
--hash=sha256:8071860c1f46a75ea34801490fd1c445c9d75147a65508cd3a10366a7006cc1c
|
||||
ninja==1.11.1.4 \
|
||||
--hash=sha256:055f386fb550c2c9d6157e45e20a84d29c47968876b9c5794ae2aec46f952306 \
|
||||
--hash=sha256:096487995473320de7f65d622c3f1d16c3ad174797602218ca8c967f51ec38a0 \
|
||||
|
||||
2
.github/workflows/scorecards.yml
vendored
2
.github/workflows/scorecards.yml
vendored
@ -29,7 +29,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
||||
2
.github/workflows/unit-tests-musl.yml
vendored
2
.github/workflows/unit-tests-musl.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
|
||||
- name: Install build dependencies
|
||||
uses: jirutka/setup-alpine@v1
|
||||
|
||||
2
.github/workflows/unit-tests.yml
vendored
2
.github/workflows/unit-tests.yml
vendored
@ -40,7 +40,7 @@ jobs:
|
||||
runner: ubuntu-24.04-s390x
|
||||
steps:
|
||||
- name: Repository checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
# Drop XDG_* stuff from /etc/environment, so we don't get the user
|
||||
|
||||
2
README
2
README
@ -201,7 +201,7 @@ REQUIREMENTS:
|
||||
CONFIG_PSI
|
||||
CONFIG_MEMCG
|
||||
|
||||
glibc >= 2.34
|
||||
glibc >= 2.31
|
||||
libxcrypt >= 4.4.0 (optional)
|
||||
libmount >= 2.30 (from util-linux)
|
||||
(util-linux *must* be built without --enable-libmount-support-mtab)
|
||||
|
||||
@ -225,16 +225,15 @@
|
||||
<term><varname>$SYSTEMD_COLORS</varname></term>
|
||||
|
||||
<listitem>
|
||||
<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>
|
||||
<para>Takes a boolean argument, or a special value.</para>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><option>true</option></term>
|
||||
<listitem><para>Same as unset, except that <varname>$NO_COLOR</varname> is ignored.</para></listitem>
|
||||
<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>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
|
||||
@ -565,6 +565,10 @@ 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
|
||||
|
||||
@ -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 (m >= 0 && m < _COLOR_MODE_FIXED_MAX)
|
||||
if (IN_SET(m, COLOR_OFF, COLOR_16, COLOR_256, COLOR_24BIT))
|
||||
return m;
|
||||
|
||||
/* Next, check for the presence of $NO_COLOR; value is ignored. */
|
||||
if (m != COLOR_TRUE && getenv("NO_COLOR"))
|
||||
if (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,14 +92,13 @@ 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",
|
||||
@ -108,10 +107,9 @@ 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_TRUE);
|
||||
DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(color_mode, ColorMode, COLOR_24BIT);
|
||||
|
||||
/*
|
||||
* Check that the string is formatted like an ANSI color code, i.e. that it consists of one or more
|
||||
|
||||
@ -9,17 +9,9 @@ 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_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_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_AUTO_24BIT,
|
||||
|
||||
/* Same as default (unset), except that $NO_COLOR is ignored/overridden */
|
||||
COLOR_TRUE,
|
||||
|
||||
_COLOR_MODE_MAX,
|
||||
_COLOR_MODE_INVALID = -EINVAL,
|
||||
} ColorMode;
|
||||
|
||||
@ -24,7 +24,7 @@ int errno_from_name(const char *name) {
|
||||
return sc->id;
|
||||
}
|
||||
|
||||
#ifdef __GLIBC__
|
||||
#if HAVE_STRERRORNAME_NP
|
||||
const char* errno_name_no_fallback(int id) {
|
||||
if (id == 0) /* To stay in line with our implementation below. */
|
||||
return NULL;
|
||||
|
||||
@ -1,26 +1,27 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include_next <malloc.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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 */
|
||||
/* 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 */
|
||||
};
|
||||
|
||||
static inline struct mallinfo2 mallinfo2(void) {
|
||||
return (struct mallinfo2) {};
|
||||
static inline struct mallinfo mallinfo(void) {
|
||||
return (struct mallinfo) {};
|
||||
}
|
||||
|
||||
static inline int malloc_info(int options, FILE *stream) {
|
||||
@ -34,3 +35,5 @@ static inline int malloc_info(int options, FILE *stream) {
|
||||
static inline int malloc_trim(size_t pad) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include_next <malloc.h>
|
||||
|
||||
@ -10,9 +10,3 @@
|
||||
* 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
|
||||
|
||||
39
src/include/override/malloc.h
Normal file
39
src/include/override/malloc.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* 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
|
||||
@ -6,8 +6,11 @@ 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',
|
||||
|
||||
13
src/include/override/sys/random.h
Normal file
13
src/include/override/sys/random.h
Normal file
@ -0,0 +1,13 @@
|
||||
/* 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
|
||||
@ -54,6 +54,76 @@
|
||||
# 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
|
||||
@ -124,6 +194,76 @@ 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
|
||||
@ -194,6 +334,76 @@ 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
|
||||
|
||||
@ -3,6 +3,20 @@
|
||||
|
||||
#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
|
||||
|
||||
@ -11,5 +11,4 @@ libc_wrapper_sources += files(
|
||||
'stdio.c',
|
||||
'stdlib.c',
|
||||
'string.c',
|
||||
'unistd.c',
|
||||
)
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
/* 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);
|
||||
}
|
||||
@ -3,6 +3,21 @@
|
||||
#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);
|
||||
|
||||
@ -4210,19 +4210,15 @@ 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) {
|
||||
if (!got_ctrunc)
|
||||
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 (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:
|
||||
|
||||
@ -657,7 +657,7 @@ static int bus_socket_read_auth(sd_bus *b) {
|
||||
.msg_controllen = sizeof(control),
|
||||
};
|
||||
|
||||
k = recvmsg_safe(b->input_fd, &mh, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
|
||||
k = RET_NERRNO(recvmsg(b->input_fd, &mh, MSG_DONTWAIT|MSG_CMSG_CLOEXEC));
|
||||
if (k == -ENOTSOCK) {
|
||||
b->prefer_readv = true;
|
||||
k = readv(b->input_fd, &iov, 1);
|
||||
@ -1397,8 +1397,14 @@ 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));
|
||||
@ -1410,18 +1416,19 @@ int bus_socket_read_message(sd_bus *bus) {
|
||||
if (bus->rbuffer_size >= need)
|
||||
return bus_socket_make_message(bus, need);
|
||||
|
||||
void *b = realloc(bus->rbuffer, need);
|
||||
b = realloc(bus->rbuffer, need);
|
||||
if (!b)
|
||||
return -ENOMEM;
|
||||
|
||||
bus->rbuffer = b;
|
||||
|
||||
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;
|
||||
iov = IOVEC_MAKE((uint8_t *)bus->rbuffer + bus->rbuffer_size, need - bus->rbuffer_size);
|
||||
|
||||
if (!bus->prefer_readv) {
|
||||
if (bus->prefer_readv) {
|
||||
k = readv(bus->input_fd, &iov, 1);
|
||||
if (k < 0)
|
||||
k = -errno;
|
||||
} else {
|
||||
mh = (struct msghdr) {
|
||||
.msg_iov = &iov,
|
||||
.msg_iovlen = 1,
|
||||
@ -1429,29 +1436,24 @@ int bus_socket_read_message(sd_bus *bus) {
|
||||
.msg_controllen = sizeof(control),
|
||||
};
|
||||
|
||||
k = recvmsg(bus->input_fd, &mh, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
|
||||
if (k < 0 && errno == ENOTSOCK)
|
||||
k = RET_NERRNO(recvmsg(bus->input_fd, &mh, MSG_DONTWAIT|MSG_CMSG_CLOEXEC));
|
||||
if (k == -ENOTSOCK) {
|
||||
bus->prefer_readv = true;
|
||||
else
|
||||
k = readv(bus->input_fd, &iov, 1);
|
||||
if (k < 0)
|
||||
k = -errno;
|
||||
} else
|
||||
handle_cmsg = true;
|
||||
}
|
||||
if (bus->prefer_readv)
|
||||
k = readv(bus->input_fd, &iov, 1);
|
||||
if (k < 0) {
|
||||
if (ERRNO_IS_TRANSIENT(errno))
|
||||
if (ERRNO_IS_NEG_TRANSIENT(k))
|
||||
return 0;
|
||||
|
||||
return -errno;
|
||||
}
|
||||
if (k < 0)
|
||||
return (int) k;
|
||||
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;
|
||||
|
||||
|
||||
@ -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("Successfully identified '%s' as an OS tree", where);
|
||||
log_debug("Succesfully identified '%s' as an OS tree", where);
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 outputting to JSON */
|
||||
TABLE_STRING_WITH_ANSI, /* like the above, but contains ANSI sequences/TABs. They will be stripped when outputing 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,
|
||||
|
||||
@ -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 to open lock fd for block device '%s': %m", p);
|
||||
return log_device_debug_errno(dev, lock_fd, "Failed top 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);
|
||||
|
||||
@ -923,6 +923,7 @@ 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);
|
||||
@ -966,7 +967,7 @@ static int device_added(Context *c, sd_device *device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fd = sd_device_open(device, O_RDWR|O_CLOEXEC|O_NONBLOCK);
|
||||
fd = sd_device_open(device, O_RDONLY|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;
|
||||
|
||||
@ -849,18 +849,14 @@ TEST(table_ansi) {
|
||||
TABLE_STRING_WITH_ANSI, ANSI_GREY "thisisgrey"));
|
||||
|
||||
unsigned saved_columns = columns();
|
||||
_cleanup_free_ char *saved_term = NULL, *saved_color = NULL;
|
||||
const char *e;
|
||||
|
||||
e = getenv("TERM");
|
||||
bool saved_color = colors_enabled();
|
||||
_cleanup_free_ char *saved_term = NULL;
|
||||
const char *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", "24bit", /* overwrite= */ true));
|
||||
ASSERT_OK_ERRNO(setenv("SYSTEMD_COLORS", "1", /* overwrite= */ true));
|
||||
ASSERT_OK_ERRNO(setenv("TERM", FALLBACK_TERM, /* overwrite= */ true));
|
||||
reset_terminal_feature_caches();
|
||||
|
||||
@ -908,7 +904,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(set_unset_env("SYSTEMD_COLORS", saved_color, /* overwrite= */ true));
|
||||
ASSERT_OK(setenvf("SYSTEMD_COLORS", /* overwrite= */ true, "%i", saved_color));
|
||||
ASSERT_OK(set_unset_env("TERM", saved_term, /* overwrite= */ true));
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ static int run(int argc, char **argv) {
|
||||
|
||||
test_setup_logging(LOG_DEBUG);
|
||||
|
||||
assert_se(setenv("SYSTEMD_COLORS", "24bit", 1) == 0); /* Force the qrcode to be printed */
|
||||
assert_se(setenv("SYSTEMD_COLORS", "1", 1) == 0); /* Force the qrcode to be printed */
|
||||
|
||||
r = print_qrcode(stdout, "This should say \"TEST\"", "TEST");
|
||||
if (r == -EOPNOTSUPP)
|
||||
|
||||
@ -332,19 +332,18 @@ 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);
|
||||
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);
|
||||
test_get_color_mode_with_env("SYSTEMD_COLORS", "auto-24bit", terminal_is_dumb() ? COLOR_OFF : COLOR_24BIT);
|
||||
ASSERT_OK_ERRNO(unsetenv("COLORTERM"));
|
||||
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-24bit", 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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user