static DirectoryOwnership validate_directory_fd(
int fd,
+ const char *path, /* purely for logging purposes */
uid_t peer_uid,
uid_t *ret_current_owner_uid) {
if (st.st_uid == 0) {
*ret_current_owner_uid = st.st_uid;
if (peer_uid == 0) {
- log_debug("Directory file descriptor points to root owned directory, who is also the peer.");
+ log_debug("Directory file descriptor points to root owned directory (%s), who is also the peer.", strna(path));
return DIRECTORY_IS_ROOT_PEER_OWNED;
}
- log_debug("Directory file descriptor points to root owned directory.");
+ log_debug("Directory file descriptor points to root owned directory (%s).", strna(path));
return DIRECTORY_IS_ROOT_OWNED;
}
if (st.st_uid == peer_uid) {
- log_debug("Directory file descriptor points to peer owned directory.");
+ log_debug("Directory file descriptor points to peer owned directory (%s).", strna(path));
*ret_current_owner_uid = st.st_uid;
return DIRECTORY_IS_PEER_OWNED;
}
/* If the peer is root, then it doesn't matter if we find a parent owned by root, let's shortcut things. */
if (peer_uid == 0) {
- log_debug("Directory file descriptor is owned by foreign UID range, and peer is root.");
+ log_debug("Directory referenced by file descriptor is owned by foreign UID range, and peer is root.");
*ret_current_owner_uid = st.st_uid;
return DIRECTORY_IS_FOREIGN_OWNED;
}
if (r < 0)
return log_debug_errno(r, "Failed to get client UID: %m");
+ /* Get path of the fd, to improve logging */
+ _cleanup_free_ char *directory_path = NULL;
+ (void) fd_get_path(directory_fd, &directory_path);
+
uid_t current_owner_uid;
- DirectoryOwnership owned_by = validate_directory_fd(directory_fd, peer_uid, ¤t_owner_uid);
+ DirectoryOwnership owned_by = validate_directory_fd(directory_fd, directory_path, peer_uid, ¤t_owner_uid);
if (owned_by == -EREMOTEIO)
return sd_varlink_errorbo(link, "io.systemd.MountFileSystem.BadFileDescriptorFlags", SD_JSON_BUILD_PAIR_STRING("parameter", "directoryFileDescriptor"));
if (owned_by < 0)
assert(p.mode > 0);
}
- _cleanup_free_ char *directory_path = NULL;
- (void) fd_get_path(directory_fd, &directory_path);
-
log_debug("Mounting '%s' with mapping mode: %s", strna(directory_path), mount_map_mode_to_string(p.mode));
const char *polkit_details[] = {