@@ -40,7 +40,7 @@ t HEAD "containers/${CTR}/archive?path=%2Fnon%2Fexistent%2Fpath" 404
4040t HEAD " containers/${CTR} /archive?path=%2Fetc%2Fpasswd" 200
4141
4242# Send tarfile to container...
43- t PUT " /containers/${CTR} /archive?path=%2Ftmp%2F" ${HELLO_TAR} 200 ' '
43+ t PUT " /containers/${CTR} /archive?path=%2Ftmp%2F©UIDGID=true " ${HELLO_TAR} 200 ' '
4444
4545# ...and 'exec cat file' to confirm that it got extracted into place.
4646cat > $TMPD /exec.json << EOF
8080
8181t POST containers/${CTR} /exec $TMPD /exec.json 201 .Id~[0-9a-f]\\ {64\\ }
8282eid=$( jq -r ' .Id' <<< " $output" )
83- t POST exec/$eid /start 200 $' \001\012 ' 1042:1043
83+ t POST exec/$eid /start 200
84+
85+ output_uidgid=$( grep -o ' [0-9]*:[0-9]*' <<< " $output" )
86+ is " $output_uidgid " " 1042:1043" " UID:GID preserved with copyUIDGID=true"
87+
88+
89+ FILE_NAME=test1
90+ TAR_PATH=" ${TMPD} /${FILE_NAME} .tar"
91+ echo " Hello2_$( random_string 8) " > ${TMPD} /${FILE_NAME} .txt
92+ tar --owner=2001 --group=2002 --format=posix -C $TMPD -cvf ${TAR_PATH} ${FILE_NAME} .txt & > /dev/null
93+
94+ t PUT " /containers/${CTR} /archive?path=%2Ftmp%2F" ${TAR_PATH} 200 ' '
95+
96+ cat > $TMPD /exec.json << EOF
97+ { "AttachStdout":true,"Cmd":["stat","-c","%u:%g","/tmp/${FILE_NAME} .txt"]}
98+ EOF
99+ t POST containers/${CTR} /exec $TMPD /exec.json 201 .Id~[0-9a-f]\\ {64\\ }
100+ eid=$( jq -r ' .Id' <<< " $output" )
101+ t POST exec/$eid /start 200
102+
103+ output_uidgid=$( grep -o ' [0-9]*:[0-9]*' <<< " $output" )
104+ is " $output_uidgid " " 0:0" " UID:GID chowned to container user without copyUIDGID"
105+
106+ # --- libpod
107+ FILE_NAME=test3
108+ TAR_PATH=" ${TMPD} /${FILE_NAME} .tar"
109+ echo " test3_$( random_string 8) " > ${TMPD} /${FILE_NAME} .txt
110+ tar --owner=4001 --group=4002 --format=posix -C $TMPD -cvf ${TAR_PATH} ${FILE_NAME} .txt & > /dev/null
111+ t PUT " libpod/containers/${CTR} /archive?path=%2Ftmp%2F" ${TAR_PATH} 200 ' '
112+
113+ cat > $TMPD /exec.json << EOF
114+ { "AttachStdout":true,"Cmd":["stat","-c","%u:%g","/tmp/${FILE_NAME} .txt"]}
115+ EOF
116+ t POST containers/${CTR} /exec $TMPD /exec.json 201 .Id~[0-9a-f]\\ {64\\ }
117+ eid=$( jq -r ' .Id' <<< " $output" )
118+ t POST exec/$eid /start 200
119+
120+ output_uidgid=$( grep -o ' [0-9]*:[0-9]*' <<< " $output" )
121+ is " $output_uidgid " " 0:0" " libpod API: UID:GID chowned to container user"
84122
85123cleanUpArchiveTest
0 commit comments