首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么udev规则导致密码设置冻结?

为什么udev规则导致密码设置冻结?
EN

Unix & Linux用户
提问于 2023-02-27 01:02:11
回答 1查看 69关注 0票数 1

我有一条规则,它运行一个脚本,每当驱动器从系统中删除时,就向我发送电子邮件:

代码语言:javascript
复制
SUBSYSTEM=="block", ACTION=="remove", ENV{DEVTYPE}=="disk",\
    RUN="/usr/sbin/disk-monitor.sh $env{DEVNAME}"

这是一个脚本:

代码语言:javascript
复制
#!/bin/bash

echo "Dropout detected $(date)" | mail -s "WARNING: Drive $1 has dropped out!" logger@gentooserver

它会导致某些密码设置命令冻结,如“密码安装关闭”和“完整性设置格式”。这一切为什么要发生?

代码语言:javascript
复制
cryptsetup --debug close offline1
# cryptsetup 2.4.3 processing "cryptsetup --debug close offline1"
# Running command close.
# Locking memory.
# Installing SIGINT/SIGTERM handler.
# Unblocking interruption on signal.
# Allocating crypt device context by device offline1.
# Initialising device-mapper backend library.
# dm version   [ opencount flush ]   [16384] (*1)
# dm versions   [ opencount flush ]   [16384] (*1)
# Detected dm-ioctl version 4.47.0.
# Detected dm-crypt version 1.24.0.
# Detected dm-integrity version 1.10.0.
# Device-mapper backend running with UDEV support enabled.
# dm status offline1  [ opencount noflush ]   [16384] (*1)
# Releasing device-mapper backend.
# Trying to open and read device /dev/sdk1 with direct-io.
# Allocating context for crypt device /dev/sdk1.
# Trying to open and read device /dev/sdk1 with direct-io.
# Initialising device-mapper backend library.
# dm versions   [ opencount flush ]   [16384] (*1)
# dm table offline1  [ opencount flush securedata ]   [16384] (*1)
# Trying to open and read device /dev/sdk1 with direct-io.
# dm versions   [ opencount flush ]   [16384] (*1)
# dm deps offline1  [ opencount flush ]   [16384] (*1)
# Crypto backend (OpenSSL 1.1.1t  7 Feb 2023) initialized in cryptsetup library version 2.4.3.
# Detected kernel Linux 6.1.12-gentoo-x86_64 x86_64.
# Reloading LUKS2 header (repair disabled).
# Acquiring read lock for device /dev/sdk1.
# Opening lock resource file /run/cryptsetup/L_8:161
# Verifying lock handle for /dev/sdk1.
# Device /dev/sdk1 READ lock taken.
# Trying to read primary LUKS2 header at offset 0x0.
# Opening locked device /dev/sdk1
# Verifying locked device handle (bdev)
# LUKS2 header version 2 of size 16384 bytes, checksum sha256.
# Checksum:a4bc53825c88a45b53709738107a718a9c4f896dfef90951cfd9d9cfe68dd259 (on-disk)
# Checksum:a4bc53825c88a45b53709738107a718a9c4f896dfef90951cfd9d9cfe68dd259 (in-memory)
# Trying to read secondary LUKS2 header at offset 0x4000.
# Reusing open ro fd on device /dev/sdk1
# LUKS2 header version 2 of size 16384 bytes, checksum sha256.
# Checksum:ca42f7c96748267f126f3ab48536dee1a05525aa1db10a1feb85a5a60e3338e8 (on-disk)
# Checksum:ca42f7c96748267f126f3ab48536dee1a05525aa1db10a1feb85a5a60e3338e8 (in-memory)
# Device size 4000785964544, offset 16777216.
# Device /dev/sdk1 READ lock released.
# PBKDF argon2id, time_ms 2000 (iterations 0), max_memory_kb 1048576, parallel_threads 4.
# Deactivating volume offline1.
# dm versions   [ opencount flush ]   [16384] (*1)
# dm status offline1  [ opencount noflush ]   [16384] (*1)
# dm versions   [ opencount flush ]   [16384] (*1)
# dm table offline1  [ opencount flush securedata ]   [16384] (*1)
# Trying to open and read device /dev/sdk1 with direct-io.
# dm versions   [ opencount flush ]   [16384] (*1)
# dm deps offline1  [ opencount flush ]   [16384] (*1)
# dm versions   [ opencount flush ]   [16384] (*1)
# dm table offline1  [ opencount flush securedata ]   [16384] (*1)
# dm versions   [ opencount flush ]   [16384] (*1)
# Udev cookie 0xd4d82bf (semid 5) created
# Udev cookie 0xd4d82bf (semid 5) incremented to 1
# Udev cookie 0xd4d82bf (semid 5) incremented to 2
# Udev cookie 0xd4d82bf (semid 5) assigned to REMOVE task(2) with flags DISABLE_LIBRARY_FALLBACK         (0x20)
# dm remove offline1  [ opencount flush retryremove ]   [16384] (*1)
# Udev cookie 0xd4d82bf (semid 5) decremented to 1
# Udev cookie 0xd4d82bf (semid 5) waiting for zero //hangs here

udev日志:

代码语言:javascript
复制
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: dm-2: Device is queued (SEQNUM=4516, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: dm-2: Device ready for processing (SEQNUM=4516, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: Successfully forked off 'n/a' as PID 8410.
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: dm-2: Worker [8410] is forked for processing SEQNUM=4516.
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: 252:2: Device is queued (SEQNUM=4517, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: 252:2: Device ready for processing (SEQNUM=4517, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Processing device (SEQNUM=4516, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Removing watch handle 50.
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: Successfully forked off 'n/a' as PID 8411.
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: 252:2: Worker [8411] is forked for processing SEQNUM=4517.
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: dm-2: Device is queued (SEQNUM=4518, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: dm-2: SEQNUM=4518 blocked by SEQNUM=4516
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: /usr/lib/udev/rules.d/95-dm-notify.rules:12 RUN '/sbin/dmsetup udevcomplete $env{DM_COOKIE}'
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: /usr/lib/udev/rules.d/disk-monitor.rules:4 RUN '/usr/sbin/disk-monitor.sh $env{DEVNAME}'
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: No reference left for '/dev/mapper/offline1', removing
Feb 26 18:51:38 gentoodesktop systemd-udevd[8411]: 252:2: Processing device (SEQNUM=4517, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: No reference left for '/dev/disk/by-id/dm-name-offline1', removing
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: No reference left for '/dev/disk/by-id/dm-uuid-CRYPT-LUKS2-f2eafcc2880e4d34afa3132486d1d6ae-offline1', removing
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: No reference left for '/dev/disk/by-uuid/5d5633e2-2f7c-49de-babf-f3ed263a3c8b', removing
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Running command "/usr/sbin/disk-monitor.sh /dev/dm-2"
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Starting '/usr/sbin/disk-monitor.sh /dev/dm-2'
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: Successfully forked off '(spawn)' as PID 8412.
Feb 26 18:51:38 gentoodesktop systemd-udevd[8411]: 252:2: Device processed (SEQNUM=4517, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[8411]: 252:2: sd-device-monitor(worker): Passed 167 byte to netlink monitor.
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Process '/usr/sbin/disk-monitor.sh /dev/dm-2' succeeded.
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Device processed (SEQNUM=4516, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: sd-device-monitor(worker): Passed 963 byte to netlink monitor.
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: dm-2: Device ready for processing (SEQNUM=4518, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: dm-2: sd-device-monitor(manager): Passed 230 byte to netlink monitor.
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Processing device (SEQNUM=4518, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Removing watch handle -1.
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: /usr/lib/udev/rules.d/disk-monitor.rules:4 RUN '/usr/sbin/disk-monitor.sh $env{DEVNAME}'
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Running command "/usr/sbin/disk-monitor.sh /dev/dm-2"
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Starting '/usr/sbin/disk-monitor.sh /dev/dm-2'
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: Successfully forked off '(spawn)' as PID 8419.
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Process '/usr/sbin/disk-monitor.sh /dev/dm-2' succeeded.
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: Device processed (SEQNUM=4518, ACTION=remove)
Feb 26 18:51:38 gentoodesktop systemd-udevd[8410]: dm-2: sd-device-monitor(worker): Passed 230 byte to netlink monitor.
Feb 26 18:51:38 gentoodesktop systemd-udevd[7823]: No events are queued, removing /run/udev/queue.
Feb 26 18:51:42 gentoodesktop systemd-udevd[7823]: Cleanup idle workers
Feb 26 18:51:42 gentoodesktop systemd-udevd[8411]: Unload kernel module index.
Feb 26 18:51:42 gentoodesktop systemd-udevd[8410]: Unload kernel module index.
Feb 26 18:51:42 gentoodesktop systemd-udevd[8410]: Unloaded link configuration context.
Feb 26 18:51:42 gentoodesktop systemd-udevd[8411]: Unloaded link configuration context.
Feb 26 18:51:42 gentoodesktop systemd-udevd[7823]: Worker [8411] exited.
Feb 26 18:51:42 gentoodesktop systemd-udevd[7823]: Worker [8410] exited.
Feb 26 18:51:46 gentoodesktop systemd-udevd[7823]: Cleanup idle workers
EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2023-02-27 10:39:21

我认为这里的问题是,您的RUN=script指令覆盖了一个现有的指令,这是dmcrypt正常工作所必需的。尝试使用RUN+="/usr/sbin/disk-monitor.sh $env{DEVNAME}"是否更好(注意+)。

它真的是DEVNAME吗?man udev告诉我关于$dev$devpath$devnode的事情,但没有告诉我块设备可能具有的DEVNAME属性。

票数 3
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/737044

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档