Skip to content

Commit

Permalink
Merge pull request #3949 from kinvolk/rata/idmap-improve-errors
Browse files Browse the repository at this point in the history
libct/nsenter: Show better errors for idmap mounts
  • Loading branch information
kolyshkin authored Aug 1, 2023
2 parents 14c7ab7 + 57f31c6 commit dbe8434
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions libcontainer/nsenter/nsexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,14 @@ void send_idmapsources(int sockfd, pid_t pid, char *idmap_src, int idmap_src_len
AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT);
if (fd_tree < 0) {
sane_kill(pid, SIGKILL);
if (errno == EINVAL)
bail("failed to use open_tree(2) with path: %s, the kernel doesn't supports ID-mapped mounts", idmap_src);
else
bail("failed to use open_tree(2) with path: %s", idmap_src);
if (errno == ENOSYS) {
bail("open_tree(2) failed, the kernel doesn't support ID-mapped mounts");
} else if (errno == EINVAL) {
bail("open_tree(2) failed with path: %s, the kernel doesn't support ID-mapped mounts",
idmap_src);
} else {
bail("open_tree(2) failed with path: %s", idmap_src);
}
}

struct mount_attr attr = {
Expand All @@ -713,10 +717,12 @@ void send_idmapsources(int sockfd, pid_t pid, char *idmap_src, int idmap_src_len
ret = sys_mount_setattr(fd_tree, "", AT_EMPTY_PATH, &attr, sizeof(attr));
if (ret < 0) {
sane_kill(pid, SIGKILL);
if (errno == EINVAL)
bail("failed to change mount attributes, maybe the filesystem doesn't supports ID-mapped mounts");
if (errno == ENOSYS)
bail("mount_setattr(2) failed, the kernel doesn't support ID-mapped mounts");
else if (errno == EINVAL)
bail("mount_setattr(2) failed with path: %s, maybe the filesystem doesn't support ID-mapped mounts", idmap_src);
else
bail("failed to change mount attributes");
bail("mount_setattr(2) failed with path: %s", idmap_src);
}

write_log(DEBUG, "~> sending idmap source: %s with mapping from: %s", idmap_src, proc_user_path);
Expand Down

0 comments on commit dbe8434

Please sign in to comment.