Copy: keep the archive's owners on PUT /containers/{id}/archive, as Docker does (#594)
Co-authored-by: Randy Fay <randy@randyfay.com>
This commit is contained in:
1 parent
099f22ce83
commit
a7c2a1e375
7 files changed
+251
-36
No files matched your search
@@ -272,41 +272,21 @@ fn ask(chan: &OwnedFd, kind: char, spec: &CopySpec<'_>) -> io::Result<()> {
|
||||
|
||||
/// Unpacks the archive that follows into `spec.path`, a directory.
|
||||
fn copy_in(conn: &mut fs::File, spec: &CopySpec<'_>) -> io::Result<()> {
|
||||
let dest = std::path::Path::new(spec.path);
|
||||
let (path, user) = if spec.flags & copy_flags::KEEP_OWNERS != 0 {
|
||||
spec.path.split_once('\0').unwrap_or((spec.path, ""))
|
||||
} else {
|
||||
(spec.path, "")
|
||||
};
|
||||
let dest = std::path::Path::new(path);
|
||||
match fs::metadata(dest) {
|
||||
Ok(m) if m.is_dir() => {}
|
||||
Ok(_) => return Err(io::Error::new(io::ErrorKind::InvalidInput, format!("notdir: extraction point is not a directory: {}", spec.path))),
|
||||
Err(_) => return Err(io::Error::new(io::ErrorKind::NotFound, format!("notfound: Could not find the file {} in container {}", spec.path, spec.id))),
|
||||
Ok(_) => return Err(io::Error::new(io::ErrorKind::InvalidInput, format!("notdir: extraction point is not a directory: {path}"))),
|
||||
Err(_) => return Err(io::Error::new(io::ErrorKind::NotFound, format!("notfound: Could not find the file {path} in container {}", spec.id))),
|
||||
}
|
||||
let owner = if user.is_empty() { None } else { Some(resolve_copy_user_in(std::path::Path::new("/"), user)?) };
|
||||
let source: Box<dyn Read + '_> = if spec.flags & copy_flags::CHUNKED != 0 { Box::new(Chunks::new(&mut *conn)) } else { Box::new(&mut *conn) };
|
||||
let mut reader = BufReader::with_capacity(256 * 1024, source);
|
||||
{
|
||||
let mut archive = tar::Archive::new(&mut reader);
|
||||
archive.set_preserve_permissions(true);
|
||||
archive.set_preserve_mtime(true);
|
||||
archive.set_preserve_ownerships(spec.flags & copy_flags::KEEP_OWNERS != 0);
|
||||
archive.set_unpack_xattrs(false);
|
||||
archive.set_overwrite(true);
|
||||
for entry in archive.entries()? {
|
||||
let mut entry = entry?;
|
||||
if spec.flags & copy_flags::NO_OVERWRITE_DIR_NON_DIR != 0 {
|
||||
let target = dest.join(entry.path()?);
|
||||
if let Ok(m) = fs::symlink_metadata(&target) {
|
||||
if m.is_dir() != entry.header().entry_type().is_dir() {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::AlreadyExists,
|
||||
format!("cannot overwrite {} {} with {}", if m.is_dir() { "directory" } else { "non-directory" }, target.display(), if m.is_dir() { "non-directory" } else { "directory" }),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
let path = entry.path()?.into_owned();
|
||||
// `docker cp` and the classic build's context keep a time of 0.
|
||||
if entry.unpack_in(dest)? {
|
||||
super::layers::keep_zero_time(dest, &path, entry.header())?;
|
||||
}
|
||||
}
|
||||
}
|
||||
unpack_in(&mut reader, dest, spec.flags, owner)?;
|
||||
// The archive's trailing padding: read it so the host's writes complete.
|
||||
io::copy(&mut reader, &mut io::sink())?;
|
||||
drop(reader);
|
||||
@@ -315,6 +295,115 @@ fn copy_in(conn: &mut fs::File, spec: &CopySpec<'_>) -> io::Result<()> {
|
||||
conn.write_all(&out)
|
||||
}
|
||||
|
||||
/// Moby's `applyTarCopyUserOptions` (`getUIDGID`): resolves a container's
|
||||
/// non-empty `Config.User` (`user[:group]`) against its `/etc/passwd` and
|
||||
/// `/etc/group` when `copyUIDGID` (`docker cp -a`) is set.
|
||||
fn resolve_copy_user_in(root: &std::path::Path, user: &str) -> io::Result<(libc::uid_t, libc::gid_t)> {
|
||||
let (u, g) = user.split_once(':').unwrap_or((user, ""));
|
||||
let (mut uid, mut gid) = (0, 0);
|
||||
if !u.is_empty() {
|
||||
let passwd = fs::read_to_string(root.join("etc/passwd")).unwrap_or_default();
|
||||
if let Ok(id) = u.parse::<u32>()
|
||||
&& id <= i32::MAX as u32
|
||||
{
|
||||
uid = id;
|
||||
gid = passwd
|
||||
.lines()
|
||||
.find_map(|l| {
|
||||
let mut f = l.split(':');
|
||||
(f.nth(2)?.parse::<u32>().ok()? == id).then(|| f.next()?.parse::<u32>().ok()).flatten()
|
||||
})
|
||||
.unwrap_or(0);
|
||||
} else {
|
||||
(uid, gid) = passwd
|
||||
.lines()
|
||||
.find_map(|l| {
|
||||
let mut f = l.split(':');
|
||||
if f.next()? != u {
|
||||
return None;
|
||||
}
|
||||
Some((f.nth(1)?.parse::<u32>().ok()?, f.next()?.parse::<u32>().ok()?))
|
||||
})
|
||||
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, format!("failed to look up user {u:?} in container")))?;
|
||||
}
|
||||
}
|
||||
if !g.is_empty() {
|
||||
if let Ok(id) = g.parse::<u32>()
|
||||
&& id <= i32::MAX as u32
|
||||
{
|
||||
gid = id;
|
||||
} else {
|
||||
let group = fs::read_to_string(root.join("etc/group")).unwrap_or_default();
|
||||
gid = group
|
||||
.lines()
|
||||
.find_map(|l| {
|
||||
let mut f = l.split(':');
|
||||
if f.next()? != g {
|
||||
return None;
|
||||
}
|
||||
f.nth(1)?.parse::<u32>().ok()
|
||||
})
|
||||
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, format!("failed to look up group {g:?} in container")))?;
|
||||
}
|
||||
}
|
||||
Ok((uid, gid))
|
||||
}
|
||||
|
||||
fn unpack_in(reader: impl Read, dest: &std::path::Path, flags: u32, owner: Option<(libc::uid_t, libc::gid_t)>) -> io::Result<()> {
|
||||
let mut archive = tar::Archive::new(reader);
|
||||
archive.set_preserve_permissions(true);
|
||||
archive.set_preserve_mtime(true);
|
||||
// Moby's `defaultTarCopyOptions` preserves the archive's header UID/GID
|
||||
// (`ChownOpts == nil`); when `copyUIDGID` (`docker cp -a`) is set on a
|
||||
// container with a non-empty `Config.User`, `applyTarCopyUserOptions`
|
||||
// sets `ChownOpts` (`owner`) to chown every unpacked entry to that user.
|
||||
archive.set_preserve_ownerships(owner.is_none());
|
||||
archive.set_unpack_xattrs(false);
|
||||
archive.set_overwrite(true);
|
||||
for entry in archive.entries()? {
|
||||
let mut entry = entry?;
|
||||
if flags & copy_flags::NO_OVERWRITE_DIR_NON_DIR != 0 {
|
||||
let target = dest.join(entry.path()?);
|
||||
if let Ok(m) = fs::symlink_metadata(&target)
|
||||
&& m.is_dir() != entry.header().entry_type().is_dir()
|
||||
{
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::AlreadyExists,
|
||||
format!("cannot overwrite {} {} with {}", if m.is_dir() { "directory" } else { "non-directory" }, target.display(), if m.is_dir() { "non-directory" } else { "directory" }),
|
||||
));
|
||||
}
|
||||
}
|
||||
let path = entry.path()?.into_owned();
|
||||
// `docker cp` and the classic build's context keep a time of 0.
|
||||
if entry.unpack_in(dest)? {
|
||||
if let Some((uid, gid)) = owner
|
||||
&& !entry.header().entry_type().is_pax_global_extensions()
|
||||
{
|
||||
let mut file_dst = dest.to_path_buf();
|
||||
for part in path.components() {
|
||||
if let std::path::Component::Normal(p) = part {
|
||||
file_dst.push(p);
|
||||
}
|
||||
}
|
||||
if file_dst != dest {
|
||||
let c = sys::cstr(&file_dst)?;
|
||||
// SAFETY: valid NUL-terminated path inside the container chroot.
|
||||
sys::check(unsafe { libc::lchown(c.as_ptr(), uid, gid) } as _, "lchown")?;
|
||||
if !fs::symlink_metadata(&file_dst)?.file_type().is_symlink()
|
||||
&& let Ok(mode) = entry.header().mode()
|
||||
&& mode & 0o6000 != 0
|
||||
{
|
||||
// SAFETY: valid NUL-terminated non-symlink path.
|
||||
sys::check(unsafe { libc::chmod(c.as_ptr(), (mode & 0o7777) as libc::mode_t) } as _, "chmod")?;
|
||||
}
|
||||
}
|
||||
}
|
||||
super::layers::keep_zero_time(dest, &path, entry.header())?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// A `copy_flags::CHUNKED` archive: chunks of `len: u32 LE | bytes`, read
|
||||
/// as one stream that ends at the empty chunk, with the connection still
|
||||
/// open for the answer.
|
||||
@@ -640,4 +729,90 @@ mod tests {
|
||||
let err = Chunks::new(&wire[..]).read_to_end(&mut Vec::new()).unwrap_err();
|
||||
assert_eq!(err.kind(), io::ErrorKind::UnexpectedEof);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unpack_in_keeps_owners_and_does_not_chown_symlink_targets() {
|
||||
// SAFETY: a plain getter.
|
||||
if unsafe { libc::geteuid() } != 0 {
|
||||
eprintln!("skipped: needs root to keep owners");
|
||||
return;
|
||||
}
|
||||
let dest = std::env::temp_dir().join(format!("kiri-copy-owners-{}", std::process::id()));
|
||||
let _ = fs::remove_dir_all(&dest);
|
||||
fs::create_dir_all(&dest).unwrap();
|
||||
fs::write(dest.join("target"), b"stay").unwrap();
|
||||
std::os::unix::fs::symlink("target", dest.join("replaced")).unwrap();
|
||||
|
||||
let mut b = tar::Builder::new(Vec::new());
|
||||
let h = |kind: tar::EntryType, size: u64, mode: u32| {
|
||||
let mut h = tar::Header::new_gnu();
|
||||
h.set_entry_type(kind);
|
||||
h.set_size(size);
|
||||
h.set_mode(mode);
|
||||
h.set_uid(1234);
|
||||
h.set_gid(1235);
|
||||
h.set_mtime(1_700_000_000);
|
||||
h.set_cksum();
|
||||
h
|
||||
};
|
||||
b.append_data(&mut h(tar::EntryType::Directory, 0, 0o750), "dir", &[][..]).unwrap();
|
||||
b.append_data(&mut h(tar::EntryType::Regular, 3, 0o600), "dir/owned.pem", &b"key"[..]).unwrap();
|
||||
b.append_link(&mut h(tar::EntryType::Symlink, 0, 0o777), "link", "target").unwrap();
|
||||
b.append_data(&mut h(tar::EntryType::Regular, 3, 0o640), "replaced", &b"new"[..]).unwrap();
|
||||
let bytes = b.into_inner().unwrap();
|
||||
|
||||
unpack_in(&bytes[..], &dest, 0, None).unwrap();
|
||||
|
||||
let meta = |p: &str| fs::symlink_metadata(dest.join(p)).unwrap();
|
||||
let dir = meta("dir");
|
||||
assert_eq!((dir.uid(), dir.gid(), dir.mode() & 0o777), (1234, 1235, 0o750));
|
||||
let pem = meta("dir/owned.pem");
|
||||
assert_eq!((pem.uid(), pem.gid(), pem.mode() & 0o777), (1234, 1235, 0o600));
|
||||
assert_eq!(fs::read(dest.join("dir/owned.pem")).unwrap(), b"key");
|
||||
let link = meta("link");
|
||||
assert!(link.file_type().is_symlink());
|
||||
assert_eq!((link.uid(), link.gid()), (1234, 1235));
|
||||
let replaced = meta("replaced");
|
||||
assert!(replaced.file_type().is_file());
|
||||
assert_eq!((replaced.uid(), replaced.gid(), replaced.mode() & 0o777), (1234, 1235, 0o640));
|
||||
assert_eq!(fs::read(dest.join("replaced")).unwrap(), b"new");
|
||||
let target = meta("target");
|
||||
assert_eq!((target.uid(), target.gid()), (0, 0));
|
||||
assert_eq!(fs::read(dest.join("target")).unwrap(), b"stay");
|
||||
|
||||
unpack_in(&bytes[..], &dest, 0, Some((2375, 2376))).unwrap();
|
||||
assert_eq!((meta("dir").uid(), meta("dir").gid()), (2375, 2376));
|
||||
assert_eq!((meta("dir/owned.pem").uid(), meta("dir/owned.pem").gid(), meta("dir/owned.pem").mode() & 0o777), (2375, 2376, 0o600));
|
||||
assert_eq!((meta("link").uid(), meta("link").gid()), (2375, 2376));
|
||||
assert_eq!((meta("target").uid(), meta("target").gid()), (0, 0));
|
||||
|
||||
let _ = fs::remove_dir_all(&dest);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolve_copy_user_matches_moby_get_uid_gid() {
|
||||
let root = std::env::temp_dir().join(format!("kiri-copy-user-{}", std::process::id()));
|
||||
let _ = fs::remove_dir_all(&root);
|
||||
fs::create_dir_all(root.join("etc")).unwrap();
|
||||
fs::write(root.join("etc/passwd"), "root:x:0:0:root:/root:/bin/sh\ntestuser:x:2375:2376::/home/testuser:/bin/sh\n").unwrap();
|
||||
fs::write(root.join("etc/group"), "root:x:0:\ntestgroup:x:2376:\n").unwrap();
|
||||
|
||||
for (spec, want) in [
|
||||
("7777:", (7777, 0)),
|
||||
(":7777", (0, 7777)),
|
||||
("2375", (2375, 2376)),
|
||||
("7777", (7777, 0)),
|
||||
("2375:2376", (2375, 2376)),
|
||||
("testuser:testgroup", (2375, 2376)),
|
||||
("testuser", (2375, 2376)),
|
||||
("testuser:7777", (2375, 7777)),
|
||||
("7777:testgroup", (7777, 2376)),
|
||||
] {
|
||||
assert_eq!(resolve_copy_user_in(&root, spec).unwrap(), want, "{spec}");
|
||||
}
|
||||
assert!(resolve_copy_user_in(&root, "nosuchuser").is_err());
|
||||
assert!(resolve_copy_user_in(&root, "testuser:nosuchgroup").is_err());
|
||||
|
||||
let _ = fs::remove_dir_all(&root);
|
||||
}
|
||||
}
|
||||
@@ -260,7 +260,11 @@ pub mod copy_op {
|
||||
}
|
||||
|
||||
pub mod copy_flags {
|
||||
/// Keep the archive's owners (`docker cp -a`); otherwise root owns everything.
|
||||
/// `docker cp -a` (`copyUIDGID`): chown unpacked entries to the
|
||||
/// container's `Config.User` when one is set (Moby's
|
||||
/// `applyTarCopyUserOptions`), sent as `"<path>\0<user>"` in
|
||||
/// `CopySpec::path`. Without `-a`, or when `Config.User` is empty, the
|
||||
/// archive's header UID/GID are kept.
|
||||
pub const KEEP_OWNERS: u32 = 1;
|
||||
/// Refuse to replace a directory with a file or the reverse.
|
||||
pub const NO_OVERWRITE_DIR_NON_DIR: u32 = 2;
|
||||
|
||||
@@ -3464,11 +3464,15 @@ fn upload_reader<'a>(head: Vec<u8>, rest: impl io::Read + 'a) -> Result<Box<dyn
|
||||
|
||||
fn archive_put(req: &Request, engine: &Engine, id: &str, w: &mut UnixStream, r: &mut BufReader<UnixStream>) -> io::Result<Next> {
|
||||
use kiri_proto::copy_flags;
|
||||
let path = req.query("path").unwrap_or("/");
|
||||
let raw_path = req.query("path").unwrap_or("/");
|
||||
let mut flags = copy_flags::CHUNKED;
|
||||
if req.flag("copyUIDGID") {
|
||||
let path = if req.flag("copyUIDGID") {
|
||||
flags |= copy_flags::KEEP_OWNERS;
|
||||
}
|
||||
let user = engine.with(id, |c| c.spec.user.clone()).unwrap_or_default();
|
||||
if user.is_empty() { raw_path.to_owned() } else { format!("{raw_path}\0{user}") }
|
||||
} else {
|
||||
raw_path.to_owned()
|
||||
};
|
||||
if req.flag("noOverwriteDirNonDir") {
|
||||
flags |= copy_flags::NO_OVERWRITE_DIR_NON_DIR;
|
||||
}
|
||||
@@ -3485,7 +3489,7 @@ fn archive_put(req: &Request, engine: &Engine, id: &str, w: &mut UnixStream, r:
|
||||
return Ok(Next::Close);
|
||||
}
|
||||
};
|
||||
let stream = match engine.copy(id, kiri_proto::copy_op::IN, path, flags) {
|
||||
let stream = match engine.copy(id, kiri_proto::copy_op::IN, &path, flags) {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
error_closing(w, e)?;
|
||||
|
||||
@@ -13,6 +13,12 @@ A log of every merged bug fix in Kiri, newest first, together with any later bug
|
||||
|
||||
## Fixes
|
||||
|
||||
### #595 Copy: keep the archive's owners on PUT /containers/{id}/archive, and chown to Config.User on copyUIDGID (unreleased)
|
||||
- Fixes: #594 PUT /containers/{id}/archive (docker cp) gives files to root; Docker keeps the archive's owners
|
||||
- Caused: none known
|
||||
- Caused by: -
|
||||
- Check: `cp-in-keeps-owner`, `cp-in-keeps-dir-and-symlink-owner`, `cp-in-copy-uidgid`
|
||||
|
||||
### #673 Layers: an empty number in a tar header is 0, as in Docker, so servicebus-emulator unpacks (unreleased)
|
||||
- Fixes: #618 Layers: an empty number in a tar header is 0, as in Docker, so servicebus-emulator unpacks
|
||||
- Caused: none known
|
||||
|
||||
+18
-1
@@ -1245,7 +1245,24 @@ $D run -d --name cpc alpine sleep 120 >/dev/null
|
||||
t cp-in-file "one" bash -c "$D cp $CPD/a.txt cpc:/tmp/ && $D exec cpc cat /tmp/a.txt"
|
||||
t cp-in-dir "two" bash -c "$D cp $CPD/dir cpc:/tmp/ && $D exec cpc cat /tmp/dir/sub/b.txt"
|
||||
t cp-in-rename "one" bash -c "$D cp $CPD/a.txt cpc:/tmp/renamed.txt && $D exec cpc cat /tmp/renamed.txt"
|
||||
t cp-in-root-owner "0 0" bash -c "$D exec cpc stat -c '%u %g' /tmp/a.txt"
|
||||
# The archive's owners are kept, as Docker keeps them without -a (#594): DDEV
|
||||
# puts its mkcert key (mode 0600) in a container this way for the web user,
|
||||
# and a symlink's owner is set on the link itself, never on its target.
|
||||
OWNED='import io,sys,tarfile
|
||||
b=io.BytesIO(); t=tarfile.open(fileobj=b,mode="w"); f=tarfile.TarInfo("owned.pem"); f.size=3; f.mode=0o600; f.uid=1234; f.gid=1235
|
||||
t.addfile(f,io.BytesIO(b"key")); t.close(); sys.stdout.buffer.write(b.getvalue())'
|
||||
t cp-in-keeps-owner "1234 1235 600 key" bash -c "python3 -c '$OWNED' | $D cp - cpc:/tmp/ && echo \$($D exec cpc stat -c '%u %g %a' /tmp/owned.pem) \$($D exec -u 1234 cpc cat /tmp/owned.pem)"
|
||||
OWNED_TREE='import io,sys,tarfile
|
||||
b=io.BytesIO(); t=tarfile.open(fileobj=b,mode="w")
|
||||
d=tarfile.TarInfo("owned-dir"); d.type=tarfile.DIRTYPE; d.mode=0o750; d.uid=1234; d.gid=1235; t.addfile(d)
|
||||
s=tarfile.TarInfo("owned-link"); s.type=tarfile.SYMTYPE; s.linkname="/etc/hostname"; s.uid=1234; s.gid=1235; t.addfile(s)
|
||||
f=tarfile.TarInfo("owned-over"); f.size=3; f.mode=0o640; f.uid=1234; f.gid=1235; t.addfile(f,io.BytesIO(b"new"))
|
||||
t.close(); sys.stdout.buffer.write(b.getvalue())'
|
||||
t cp-in-keeps-dir-and-symlink-owner "dir=1234:1235:750 link=1234:1235 over=1234:1235:regular file targets=0:0:0:0" bash -c "$D exec cpc ln -sf /etc/alpine-release /tmp/owned-over && python3 -c '$OWNED_TREE' | curl -s --unix-socket $(printf %q "$SOCK") -X PUT --data-binary @- 'http://d/v1.47/containers/cpc/archive?path=/tmp' && $D exec cpc sh -c 'echo \"dir=\$(stat -c %u:%g:%a /tmp/owned-dir) link=\$(stat -c %u:%g /tmp/owned-link) over=\$(stat -c %u:%g:%F /tmp/owned-over) targets=\$(stat -c %u:%g /etc/hostname):\$(stat -c %u:%g /etc/alpine-release)\"'"
|
||||
# With -a (copyUIDGID), Moby's applyTarCopyUserOptions chowns unpacked entries
|
||||
# to the container's Config.User when set, while keeping tar header owners
|
||||
# without -a or when Config.User is empty.
|
||||
t cp-in-copy-uidgid "no-a=1234:1235 with-a=1000:1000 default-a=1234:1235" bash -c "$D run -d --name cpu -u 1000:1000 alpine sleep 120 >/dev/null && python3 -c '$OWNED' | $D cp - cpu:/tmp/ && $D cp -a $CPD/a.txt cpu:/tmp/a.txt && python3 -c '$OWNED' | $D cp -a - cpc:/tmp/ && echo \"no-a=\$($D exec cpu stat -c %u:%g /tmp/owned.pem) with-a=\$($D exec cpu stat -c %u:%g /tmp/a.txt) default-a=\$($D exec cpc stat -c %u:%g /tmp/owned.pem)\"; $D rm -f cpu >/dev/null 2>&1"
|
||||
# A time of 0 stays 0, as Docker unpacks it (the tar crate would make it 1).
|
||||
t cp-in-zero-time "time 0" bash -c "echo z > $CPD/z && TZ=UTC touch -t 197001010000.00 $CPD/z && tar -C $CPD -cf - z | $D cp - cpc:/tmp/ && echo time \$($D exec cpc stat -c %Y /tmp/z)"
|
||||
t cp-out-file "fromctr" bash -c "$D exec cpc sh -c 'echo fromctr > /etc/motd2' && $D cp cpc:/etc/motd2 $CPD/ && cat $CPD/motd2"
|
||||
|
||||
@@ -96,6 +96,12 @@ t import-empty-numbers "ok 0:0" "id=\$(docker create alpine true); docker export
|
||||
t session-own "SID=1" "docker run --rm alpine sh -c 'echo SID=\$(cut -d\" \" -f6 /proc/1/stat)'"
|
||||
t exec-session-own "own" "docker exec web sh -c 's=\$(cut -d\" \" -f6 /proc/\$\$/stat); [ \"\$s\" = \"\$\$\" ] && echo own || echo \"session \$s\"'"
|
||||
t cp "copied" "echo copied > /tmp/x && docker cp /tmp/x web:/tmp/x && docker exec web cat /tmp/x"
|
||||
# PUT /containers/{id}/archive and docker cp keep the archive's owners without
|
||||
# copyUIDGID (-a), as Docker does (#594), and lchown symlinks without touching
|
||||
# their targets; with -a (copyUIDGID), entries are chowned to Config.User when set.
|
||||
t cp-in-keeps-owner "1234 1235 600 key" "rm -rf /tmp/cpo && mkdir -p /tmp/cpo && printf key > /tmp/cpo/owned.pem && chmod 600 /tmp/cpo/owned.pem && chown 1234:1235 /tmp/cpo/owned.pem && tar -C /tmp/cpo -cf - owned.pem | docker cp - web:/tmp/ && echo \$(docker exec web stat -c '%u %g %a' /tmp/owned.pem) \$(docker exec -u 1234 web cat /tmp/owned.pem)"
|
||||
t cp-in-keeps-dir-and-symlink-owner "dir=1234:1235:750 link=1234:1235 over=1234:1235:regular file targets=0:0:0:0" "mkdir -p /tmp/cpo/owned-dir && chmod 750 /tmp/cpo/owned-dir && ln -sf /etc/hostname /tmp/cpo/owned-link && printf new > /tmp/cpo/owned-over && chmod 640 /tmp/cpo/owned-over && chown -Rh 1234:1235 /tmp/cpo && docker exec web ln -sf /etc/alpine-release /tmp/owned-over && tar -C /tmp/cpo -cf - owned-dir owned-link owned-over | curl -s --unix-socket /root/.kiri/run/docker.sock -X PUT --data-binary @- 'http://d/v1.47/containers/web/archive?path=/tmp' && docker exec web sh -c 'echo \"dir=\$(stat -c %u:%g:%a /tmp/owned-dir) link=\$(stat -c %u:%g /tmp/owned-link) over=\$(stat -c %u:%g:%F /tmp/owned-over) targets=\$(stat -c %u:%g /etc/hostname):\$(stat -c %u:%g /etc/alpine-release)\"'"
|
||||
t cp-in-copy-uidgid "no-a=1234:1235 with-a=1000:1000 default-a=1234:1235" "docker rm -f cpu >/dev/null 2>&1; docker run -d --name cpu -u 1000:1000 alpine sleep 120 >/dev/null && tar -C /tmp/cpo -cf - owned.pem | docker cp - cpu:/tmp/ && docker cp -a /tmp/x cpu:/tmp/x && tar -C /tmp/cpo -cf - owned.pem | docker cp -a - web:/tmp/ && echo \"no-a=\$(docker exec cpu stat -c %u:%g /tmp/owned.pem) with-a=\$(docker exec cpu stat -c %u:%g /tmp/x) default-a=\$(docker exec web stat -c %u:%g /tmp/owned.pem)\"; rm -rf /tmp/cpo; docker rm -f cpu >/dev/null 2>&1"
|
||||
# What Testcontainers needs (#222, #121); see tests/testcontainers-api.py.
|
||||
for c in version cmd keepalive close follow follow-created timestamps; do
|
||||
t "testcontainers-$c" "ok $c" "for i in \$(seq 60); do command -v python3 >/dev/null && break; sleep 1; done; python3 /testcontainers-api.py /root/.kiri/run/docker.sock $c"
|
||||
|
||||
@@ -218,3 +218,6 @@ seccomp-unconfined-api-warnings #516 POST /containers/create returned empty Warn
|
||||
seccomp-default-no-warning #516 a default container without seccomp=unconfined must return empty Warnings
|
||||
seccomp-unconfined-io-uring-blocked #516 io_uring_setup must stay blocked with EPERM even under seccomp=unconfined
|
||||
import-empty-numbers #618 a layer whose header left size, uid or gid empty did not unpack: "numeric field was not a number" (servicebus-emulator)
|
||||
cp-in-keeps-owner #594 PUT /containers/{id}/archive and docker cp without -a gave files to root instead of keeping the archive's owners, so a mode-0600 file uploaded for a non-root user (DDEV's mkcert CA key) was unreadable to that user
|
||||
cp-in-keeps-dir-and-symlink-owner #594 PUT /containers/{id}/archive without copyUIDGID must keep directory and symlink owners from the tar headers without chowning symlink targets
|
||||
cp-in-copy-uidgid #594 PUT /containers/{id}/archive with copyUIDGID (docker cp -a) must chown unpacked entries to the container's Config.User when set while keeping tar header owners without -a or when Config.User is empty
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 52.
|
Reference in new issue
Block a user