Skip to content

Commit dbe8434

Browse files
authored
Merge pull request #3949 from kinvolk/rata/idmap-improve-errors
libct/nsenter: Show better errors for idmap mounts
2 parents 14c7ab7 + 57f31c6 commit dbe8434

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

libcontainer/nsenter/nsexec.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,14 @@ void send_idmapsources(int sockfd, pid_t pid, char *idmap_src, int idmap_src_len
699699
AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT);
700700
if (fd_tree < 0) {
701701
sane_kill(pid, SIGKILL);
702-
if (errno == EINVAL)
703-
bail("failed to use open_tree(2) with path: %s, the kernel doesn't supports ID-mapped mounts", idmap_src);
704-
else
705-
bail("failed to use open_tree(2) with path: %s", idmap_src);
702+
if (errno == ENOSYS) {
703+
bail("open_tree(2) failed, the kernel doesn't support ID-mapped mounts");
704+
} else if (errno == EINVAL) {
705+
bail("open_tree(2) failed with path: %s, the kernel doesn't support ID-mapped mounts",
706+
idmap_src);
707+
} else {
708+
bail("open_tree(2) failed with path: %s", idmap_src);
709+
}
706710
}
707711

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

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

0 commit comments

Comments
 (0)