mirror of
https://github.com/systemd/systemd
synced 2026-03-30 19:54:51 +02:00
Compare commits
5 Commits
a94aa2b9c1
...
b98416e100
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b98416e100 | ||
|
|
c17e8ce9ec | ||
|
|
49a0931f62 | ||
|
|
3214129369 | ||
|
|
ba24ef86e7 |
@ -1412,7 +1412,7 @@ static int verb_log_control(int argc, char *argv[], void *userdata) {
|
|||||||
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(argc == 1 || argc == 2);
|
assert(IN_SET(argc, 1, 2));
|
||||||
|
|
||||||
r = acquire_bus(&bus, NULL);
|
r = acquire_bus(&bus, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@ -2284,7 +2284,7 @@ static int do_security(int argc, char *argv[], void *userdata) {
|
|||||||
if (r < 0 && r != -ENOENT)
|
if (r < 0 && r != -ENOENT)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (f != NULL) {
|
if (f) {
|
||||||
r = json_parse_file(f, pp, /*flags=*/ 0, &policy, &line, &column);
|
r = json_parse_file(f, pp, /*flags=*/ 0, &policy, &line, &column);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "[%s:%u:%u] Failed to parse JSON policy: %m", pp, line, column);
|
return log_error_errno(r, "[%s:%u:%u] Failed to parse JSON policy: %m", pp, line, column);
|
||||||
|
|||||||
@ -5,22 +5,12 @@
|
|||||||
|
|
||||||
#include "dirent-util.h"
|
#include "dirent-util.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
|
#include "stat-util.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
|
|
||||||
int stat_mode_to_dirent_type(mode_t mode) {
|
|
||||||
return
|
|
||||||
S_ISREG(mode) ? DT_REG :
|
|
||||||
S_ISDIR(mode) ? DT_DIR :
|
|
||||||
S_ISLNK(mode) ? DT_LNK :
|
|
||||||
S_ISFIFO(mode) ? DT_FIFO :
|
|
||||||
S_ISSOCK(mode) ? DT_SOCK :
|
|
||||||
S_ISCHR(mode) ? DT_CHR :
|
|
||||||
S_ISBLK(mode) ? DT_BLK :
|
|
||||||
DT_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int dirent_ensure_type(DIR *d, struct dirent *de) {
|
static int dirent_ensure_type(DIR *d, struct dirent *de) {
|
||||||
struct stat st;
|
STRUCT_STATX_DEFINE(sx);
|
||||||
|
int r;
|
||||||
|
|
||||||
assert(d);
|
assert(d);
|
||||||
assert(de);
|
assert(de);
|
||||||
@ -33,10 +23,17 @@ static int dirent_ensure_type(DIR *d, struct dirent *de) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fstatat(dirfd(d), de->d_name, &st, AT_SYMLINK_NOFOLLOW) < 0)
|
/* Let's ask only for the type, nothing else. */
|
||||||
return -errno;
|
r = statx_fallback(dirfd(d), de->d_name, AT_SYMLINK_NOFOLLOW|AT_NO_AUTOMOUNT, STATX_TYPE, &sx);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
de->d_type = stat_mode_to_dirent_type(st.st_mode);
|
assert(FLAGS_SET(sx.stx_mask, STATX_TYPE));
|
||||||
|
de->d_type = IFTODT(sx.stx_mode);
|
||||||
|
|
||||||
|
/* If the inode is passed too, update the field, i.e. report most recent data */
|
||||||
|
if (FLAGS_SET(sx.stx_mask, STATX_INO))
|
||||||
|
de->d_ino = sx.stx_ino;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -69,24 +66,40 @@ bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct dirent *readdir_ensure_type(DIR *d) {
|
struct dirent *readdir_ensure_type(DIR *d) {
|
||||||
struct dirent *de;
|
int r;
|
||||||
|
|
||||||
assert(d);
|
assert(d);
|
||||||
|
|
||||||
errno = 0;
|
/* Like readdir(), but fills in .d_type if it is DT_UNKNOWN */
|
||||||
de = readdir(d);
|
|
||||||
if (de)
|
|
||||||
(void) dirent_ensure_type(d, de);
|
|
||||||
return de;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct dirent *readdir_no_dot(DIR *dirp) {
|
|
||||||
struct dirent *d;
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
d = readdir_ensure_type(dirp);
|
struct dirent *de;
|
||||||
if (d && dot_or_dot_dot(d->d_name))
|
|
||||||
continue;
|
errno = 0;
|
||||||
return d;
|
de = readdir(d);
|
||||||
|
if (!de)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
r = dirent_ensure_type(d, de);
|
||||||
|
if (r >= 0)
|
||||||
|
return de;
|
||||||
|
if (r != -ENOENT) {
|
||||||
|
errno = -r; /* We want to be compatible with readdir(), hence propagate error via errno here */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Vanished by now? Then skip immedately to next */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct dirent *readdir_no_dot(DIR *d) {
|
||||||
|
assert(d);
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
struct dirent *de;
|
||||||
|
|
||||||
|
de = readdir_ensure_type(d);
|
||||||
|
if (!de || !dot_or_dot_dot(de->d_name))
|
||||||
|
return de;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,8 +8,6 @@
|
|||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
|
|
||||||
int stat_mode_to_dirent_type(mode_t mode);
|
|
||||||
|
|
||||||
bool dirent_is_file(const struct dirent *de) _pure_;
|
bool dirent_is_file(const struct dirent *de) _pure_;
|
||||||
bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) _pure_;
|
bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) _pure_;
|
||||||
|
|
||||||
|
|||||||
@ -290,7 +290,7 @@ int recurse_dir(
|
|||||||
/* Copy over the data we acquired through statx() if we acquired any */
|
/* Copy over the data we acquired through statx() if we acquired any */
|
||||||
if (sx.stx_mask & STATX_TYPE) {
|
if (sx.stx_mask & STATX_TYPE) {
|
||||||
assert(!!subdir == !!S_ISDIR(sx.stx_mode));
|
assert(!!subdir == !!S_ISDIR(sx.stx_mode));
|
||||||
de[i]->d_type = stat_mode_to_dirent_type(sx.stx_mode);
|
de[i]->d_type = IFTODT(sx.stx_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sx.stx_mask & STATX_INO)
|
if (sx.stx_mask & STATX_INO)
|
||||||
|
|||||||
@ -1004,7 +1004,7 @@ static int attach_luks2_by_pkcs11(
|
|||||||
bool headless,
|
bool headless,
|
||||||
uint32_t flags) {
|
uint32_t flags) {
|
||||||
|
|
||||||
int r = -ENOTSUP;
|
int r = -EOPNOTSUPP;
|
||||||
#if HAVE_LIBCRYPTSETUP_PLUGINS
|
#if HAVE_LIBCRYPTSETUP_PLUGINS
|
||||||
if (!crypt_get_type(cd) || strcmp(crypt_get_type(cd), CRYPT_LUKS2))
|
if (!crypt_get_type(cd) || strcmp(crypt_get_type(cd), CRYPT_LUKS2))
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Automatic PKCS#11 metadata requires LUKS2 device.");
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Automatic PKCS#11 metadata requires LUKS2 device.");
|
||||||
@ -1198,7 +1198,7 @@ static int attach_luks2_by_tpm2(
|
|||||||
.device = arg_tpm2_device
|
.device = arg_tpm2_device
|
||||||
};
|
};
|
||||||
|
|
||||||
if (crypt_token_external_path() == NULL)
|
if (!crypt_token_external_path())
|
||||||
return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||||
"Libcryptsetup has external plugins support disabled.");
|
"Libcryptsetup has external plugins support disabled.");
|
||||||
|
|
||||||
|
|||||||
@ -2540,7 +2540,7 @@ static int verb_log_level(int argc, char *argv[], void *userdata) {
|
|||||||
sd_bus *bus = userdata;
|
sd_bus *bus = userdata;
|
||||||
|
|
||||||
assert(bus);
|
assert(bus);
|
||||||
assert(argc == 1 || argc == 2);
|
assert(IN_SET(argc, 1, 2));
|
||||||
|
|
||||||
return verb_log_control_common(bus, "org.freedesktop.resolve1", argv[0], argc == 2 ? argv[1] : NULL);
|
return verb_log_control_common(bus, "org.freedesktop.resolve1", argv[0], argc == 2 ? argv[1] : NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1596,7 +1596,7 @@ int dissect_image(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m->verity_ready)
|
if (m->verity_ready)
|
||||||
m->verity_sig_ready = !!verity->root_hash_sig;
|
m->verity_sig_ready = verity->root_hash_sig;
|
||||||
|
|
||||||
} else if (m->partitions[verity->designator == PARTITION_USR ? PARTITION_USR_VERITY_SIG : PARTITION_ROOT_VERITY_SIG].found) {
|
} else if (m->partitions[verity->designator == PARTITION_USR ? PARTITION_USR_VERITY_SIG : PARTITION_ROOT_VERITY_SIG].found) {
|
||||||
|
|
||||||
|
|||||||
@ -529,7 +529,7 @@ int fork_agent(const char *name, int except[], size_t n_except, pid_t *ret_pid,
|
|||||||
* stdin around. */
|
* stdin around. */
|
||||||
fd = open("/dev/tty", O_WRONLY);
|
fd = open("/dev/tty", O_WRONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
if (errno != -ENXIO) {
|
if (errno != ENXIO) {
|
||||||
log_error_errno(errno, "Failed to open /dev/tty: %m");
|
log_error_errno(errno, "Failed to open /dev/tty: %m");
|
||||||
_exit(EXIT_FAILURE);
|
_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -219,9 +219,9 @@ int pkcs11_token_login_by_pin(
|
|||||||
return log_error_errno(SYNTHETIC_ERRNO(EIO),
|
return log_error_errno(SYNTHETIC_ERRNO(EIO),
|
||||||
"Failed to log into security token '%s': %s", token_label, p11_kit_strerror(rv));
|
"Failed to log into security token '%s': %s", token_label, p11_kit_strerror(rv));
|
||||||
|
|
||||||
log_notice("PIN for token '%s' is incorrect, please try again.", token_label);
|
return log_notice_errno(SYNTHETIC_ERRNO(ENOLCK),
|
||||||
|
"PIN for token '%s' is incorrect, please try again.",
|
||||||
return -ENOLCK;
|
token_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pkcs11_token_login(
|
int pkcs11_token_login(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user