Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/gather-metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: redhat-plumbers-in-action/gather-pull-request-metadata@v1

- name: Upload artifact with gathered metadata
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pr-metadata
path: ${{ steps.Metadata.outputs.metadata-file }}
3 changes: 3 additions & 0 deletions .github/workflows/unit_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ for phase in "${PHASES[@]}"; do

# Beautiful workaround for Fedora's version of Docker
sleep 1
# FIXME?: Point C8S repos to the Vault, since C8S is EOL
$DOCKER_EXEC bash -xec "sed -i 's/^mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*"
$DOCKER_EXEC bash -xec "sed -i 's|#baseurl=http://mirror.centos.org|baseurl=https://vault.centos.org|g' /etc/yum.repos.d/CentOS-*"
$DOCKER_EXEC dnf makecache
# Install and enable EPEL
$DOCKER_EXEC dnf -q -y install epel-release dnf-utils "${ADDITIONAL_DEPS[@]}"
Expand Down
68 changes: 45 additions & 23 deletions hwdb/parse_hwdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
LineStart, LineEnd,
OneOrMore, Combine, Or, Optional, Suppress, Group,
nums, alphanums, printables,
stringEnd, pythonStyleComment, QuotedString,
stringEnd, pythonStyleComment,
ParseBaseException)
except ImportError:
print('pyparsing is not available')
Expand All @@ -56,29 +56,45 @@
EMPTYLINE = LineEnd()
COMMENTLINE = pythonStyleComment + EOL
INTEGER = Word(nums)
STRING = QuotedString('"')
REAL = Combine((INTEGER + Optional('.' + Optional(INTEGER))) ^ ('.' + INTEGER))
SIGNED_REAL = Combine(Optional(Word('-+')) + REAL)
UDEV_TAG = Word(string.ascii_uppercase, alphanums + '_')

TYPES = {'mouse': ('usb', 'bluetooth', 'ps2', '*'),
'evdev': ('name', 'atkbd', 'input'),
'fb': ('pci'),
'id-input': ('modalias'),
'touchpad': ('i8042', 'rmi', 'bluetooth', 'usb'),
'joystick': ('i8042', 'rmi', 'bluetooth', 'usb'),
'keyboard': ('name', ),
'sensor': ('modalias', ),
}

# Patterns that are used to set general properties on a device
GENERAL_MATCHES = {'acpi',
'bluetooth',
'usb',
'pci',
'sdio',
'vmbus',
'OUI',
}


@lru_cache()
def hwdb_grammar():
ParserElement.setDefaultWhitespaceChars('')

prefix = Or(category + ':' + Or(conn) + ':'
for category, conn in TYPES.items())
matchline = Combine(prefix + Word(printables + ' ' + '®')) + EOL

matchline_typed = Combine(prefix + Word(printables + ' ' + '®'))
matchline_general = Combine(Or(GENERAL_MATCHES) + ':' + Word(printables + ' ' + '®'))
matchline = (matchline_typed | matchline_general) + EOL

propertyline = (White(' ', exact=1).suppress() +
Combine(UDEV_TAG - '=' - Word(alphanums + '_=:@*.!-;, "') - Optional(pythonStyleComment)) +
Combine(UDEV_TAG - '=' - Optional(Word(alphanums + '_=:@*.!-;, "'))
- Optional(pythonStyleComment)) +
EOL)
propertycomment = White(' ', exact=1) + pythonStyleComment + EOL

Expand All @@ -87,7 +103,7 @@ def hwdb_grammar():
(EMPTYLINE ^ stringEnd()).suppress())
commentgroup = OneOrMore(COMMENTLINE).suppress() - EMPTYLINE.suppress()

grammar = OneOrMore(group('GROUPS*') ^ commentgroup) + stringEnd()
grammar = OneOrMore(Group(group)('GROUPS*') ^ commentgroup) + stringEnd()

return grammar

Expand All @@ -98,36 +114,41 @@ def property_grammar():
dpi_setting = (Optional('*')('DEFAULT') + INTEGER('DPI') + Suppress('@') + INTEGER('HZ'))('SETTINGS*')
mount_matrix_row = SIGNED_REAL + ',' + SIGNED_REAL + ',' + SIGNED_REAL
mount_matrix = (mount_matrix_row + ';' + mount_matrix_row + ';' + mount_matrix_row)('MOUNT_MATRIX')
xkb_setting = Optional(Word(alphanums + '+-/@._'))

props = (('MOUSE_DPI', Group(OneOrMore(dpi_setting))),
('MOUSE_WHEEL_CLICK_ANGLE', INTEGER),
('MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL', INTEGER),
('MOUSE_WHEEL_CLICK_COUNT', INTEGER),
('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', INTEGER),
('ID_INPUT', Literal('1')),
('ID_INPUT_ACCELEROMETER', Literal('1')),
('ID_INPUT_JOYSTICK', Literal('1')),
('ID_INPUT_KEY', Literal('1')),
('ID_INPUT_KEYBOARD', Literal('1')),
('ID_INPUT_MOUSE', Literal('1')),
('ID_INPUT_POINTINGSTICK', Literal('1')),
('ID_INPUT_SWITCH', Literal('1')),
('ID_INPUT_TABLET', Literal('1')),
('ID_INPUT_TABLET_PAD', Literal('1')),
('ID_INPUT_TOUCHPAD', Literal('1')),
('ID_INPUT_TOUCHSCREEN', Literal('1')),
('ID_INPUT_TRACKBALL', Literal('1')),
('MOUSE_WHEEL_TILT_HORIZONTAL', Literal('1')),
('MOUSE_WHEEL_TILT_VERTICAL', Literal('1')),
('ID_AUTOSUSPEND', Or((Literal('0'), Literal('1')))),
('ID_INPUT', Or((Literal('0'), Literal('1')))),
('ID_INPUT_ACCELEROMETER', Or((Literal('0'), Literal('1')))),
('ID_INPUT_JOYSTICK', Or((Literal('0'), Literal('1')))),
('ID_INPUT_KEY', Or((Literal('0'), Literal('1')))),
('ID_INPUT_KEYBOARD', Or((Literal('0'), Literal('1')))),
('ID_INPUT_MOUSE', Or((Literal('0'), Literal('1')))),
('ID_INPUT_POINTINGSTICK', Or((Literal('0'), Literal('1')))),
('ID_INPUT_SWITCH', Or((Literal('0'), Literal('1')))),
('ID_INPUT_TABLET', Or((Literal('0'), Literal('1')))),
('ID_INPUT_TABLET_PAD', Or((Literal('0'), Literal('1')))),
('ID_INPUT_TOUCHPAD', Or((Literal('0'), Literal('1')))),
('ID_INPUT_TOUCHSCREEN', Or((Literal('0'), Literal('1')))),
('ID_INPUT_TRACKBALL', Or((Literal('0'), Literal('1')))),
('MOUSE_WHEEL_TILT_HORIZONTAL', Or((Literal('0'), Literal('1')))),
('MOUSE_WHEEL_TILT_VERTICAL', Or((Literal('0'), Literal('1')))),
('POINTINGSTICK_SENSITIVITY', INTEGER),
('POINTINGSTICK_CONST_ACCEL', REAL),
('ID_INPUT_JOYSTICK_INTEGRATION', Or(('internal', 'external'))),
('ID_INPUT_TOUCHPAD_INTEGRATION', Or(('internal', 'external'))),
('XKB_FIXED_LAYOUT', STRING),
('XKB_FIXED_VARIANT', STRING),
('XKB_FIXED_LAYOUT', xkb_setting),
('XKB_FIXED_VARIANT', xkb_setting),
('XKB_FIXED_MODEL', xkb_setting),
('KEYBOARD_LED_NUMLOCK', Literal('0')),
('KEYBOARD_LED_CAPSLOCK', Literal('0')),
('ACCEL_MOUNT_MATRIX', mount_matrix),
('ACCEL_LOCATION', Or(('display', 'base'))),
('ID_TAG_MASTER_OF_SEAT', Literal('1')),
)
fixed_props = [Literal(name)('NAME') - Suppress('=') - val('VALUE')
for name, val in props]
Expand Down Expand Up @@ -222,7 +243,8 @@ def check_properties(groups):
elif parsed.NAME == 'ACCEL_MOUNT_MATRIX':
check_one_mount_matrix(prop, parsed.VALUE)
elif parsed.NAME.startswith('KEYBOARD_KEY_'):
check_one_keycode(prop, parsed.VALUE)
val = parsed.VALUE if isinstance(parsed.VALUE, str) else parsed.VALUE[0]
check_one_keycode(prop, val)

def print_summary(fname, groups):
print('{}: {} match groups, {} matches, {} properties'
Expand Down
26 changes: 17 additions & 9 deletions src/core/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "alloc-util.h"
#include "bus-common-errors.h"
#include "bus-error.h"
#include "string-util.h"
#include "terminal-util.h"
#include "transaction.h"
#include "dbus-unit.h"
Expand Down Expand Up @@ -322,22 +323,29 @@ _pure_ static bool unit_matters_to_anchor(Unit *u, Job *j) {
}

static char* merge_unit_ids(const char* unit_log_field, char **pairs) {
char **unit_id, **job_type, *ans = NULL;
size_t alloc = 0, size = 0, next;
_cleanup_free_ char *ans = NULL;
char **unit_id, **job_type;
size_t alloc = 0, size = 0;

STRV_FOREACH_PAIR(unit_id, job_type, pairs) {
size_t next;

if (size > 0)
ans[size - 1] = '\n';

next = strlen(unit_log_field) + strlen(*unit_id);
if (!GREEDY_REALLOC(ans, alloc, size + next + 1)) {
return mfree(ans);
return NULL;
}

sprintf(ans + size, "%s%s", unit_log_field, *unit_id);
if (*(unit_id+1))
ans[size + next] = '\n';
size += next + 1;
}

return ans;
if (!ans)
return strdup("");

return TAKE_PTR(ans);
}

static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsigned generation, sd_bus_error *e) {
Expand Down Expand Up @@ -395,7 +403,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
j->unit->id,
unit_id == array ? "ordering cycle" : "dependency",
*unit_id, *job_type,
unit_ids);
"%s", strna(unit_ids));

if (delete) {
const char *status;
Expand All @@ -404,7 +412,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
"MESSAGE=%s: Job %s/%s deleted to break ordering cycle starting with %s/%s",
j->unit->id, delete->unit->id, job_type_to_string(delete->type),
j->unit->id, job_type_to_string(j->type),
unit_ids);
"%s", strna(unit_ids));

if (log_get_show_color())
status = ANSI_HIGHLIGHT_RED " SKIP " ANSI_NORMAL;
Expand All @@ -420,7 +428,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
log_struct(LOG_ERR,
"MESSAGE=%s: Unable to break cycle starting with %s/%s",
j->unit->id, j->unit->id, job_type_to_string(j->type),
unit_ids);
"%s", strna(unit_ids));

return sd_bus_error_setf(e, BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC,
"Transaction order is cyclic. See system logs for details.");
Expand Down
21 changes: 10 additions & 11 deletions src/login/logind-dbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1414,30 +1414,29 @@ static int bus_manager_log_shutdown(
assert(unit_name);

if (streq(unit_name, SPECIAL_POWEROFF_TARGET)) {
p = "MESSAGE=System is powering down";
p = "System is powering down";
q = "SHUTDOWN=power-off";
} else if (streq(unit_name, SPECIAL_REBOOT_TARGET)) {
p = "MESSAGE=System is rebooting";
p = "System is rebooting";
q = "SHUTDOWN=reboot";
} else if (streq(unit_name, SPECIAL_HALT_TARGET)) {
p = "MESSAGE=System is halting";
p = "System is halting";
q = "SHUTDOWN=halt";
} else if (streq(unit_name, SPECIAL_KEXEC_TARGET)) {
p = "MESSAGE=System is rebooting with kexec";
p = "System is rebooting with kexec";
q = "SHUTDOWN=kexec";
} else {
p = "MESSAGE=System is shutting down";
p = "System is shutting down";
q = NULL;
}

if (isempty(m->wall_message))
p = strjoina(p, ".");
else
p = strjoina(p, " (", m->wall_message, ").");

return log_struct(LOG_NOTICE,
"MESSAGE_ID=" SD_MESSAGE_SHUTDOWN_STR,
p,
LOG_MESSAGE("%s%s%s%s.",
p,
m->wall_message ? " (" : "",
strempty(m->wall_message),
m->wall_message ? ")" : ""),
q);
}

Expand Down
8 changes: 7 additions & 1 deletion src/test/test-execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@

typedef void (*test_function_t)(Manager *m);

static int cld_dumped_to_killed(int code) {
/* Depending on the system, seccomp version, … some signals might result in dumping, others in plain
* killing. Let's ignore the difference here, and map both cases to CLD_KILLED */
return code == CLD_DUMPED ? CLD_KILLED : code;
}

static void wait_for_service_finish(Manager *m, Unit *unit) {
Service *service = NULL;
usec_t ts;
Expand Down Expand Up @@ -73,7 +79,7 @@ static void check_main_result(const char *func, Manager *m, Unit *unit, int stat
service->main_exec_status.status, status_expected);
abort();
}
if (service->main_exec_status.code != code_expected) {
if (cld_dumped_to_killed(service->main_exec_status.code) != cld_dumped_to_killed(code_expected)) {
log_error("%s: %s: exit code %d, expected %d",
func, unit->id,
service->main_exec_status.code, code_expected);
Expand Down
Loading
Loading