Dont use --no-same-owner when extracting tar archives

This flag is missing on OpenBSD and is the default on other platforms
when extracting as non-root. Make the uname/gname taringo field empty so
when extracting as root files will always be owned by root.
This commit is contained in:
Kovid Goyal 2022-03-07 12:10:45 +05:30
parent 0e7f1d60d6
commit b0ea960159
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 2 additions and 2 deletions

View File

@ -65,7 +65,7 @@ def serialize_env(env: Dict[str, str], base_env: Dict[str, str]) -> bytes:
def make_tarfile(ssh_opts: SSHOptions, base_env: Dict[str, str]) -> bytes: def make_tarfile(ssh_opts: SSHOptions, base_env: Dict[str, str]) -> bytes:
def normalize_tarinfo(tarinfo: tarfile.TarInfo) -> tarfile.TarInfo: def normalize_tarinfo(tarinfo: tarfile.TarInfo) -> tarfile.TarInfo:
tarinfo.uname = tarinfo.gname = 'kitty' tarinfo.uname = tarinfo.gname = ''
tarinfo.uid = tarinfo.gid = 0 tarinfo.uid = tarinfo.gid = 0
return tarinfo return tarinfo

View File

@ -126,7 +126,7 @@ untar_and_read_env() {
tdir=$(command mktemp -d "$HOME/.kitty-ssh-kitten-untar-XXXXXXXXXXXX") tdir=$(command mktemp -d "$HOME/.kitty-ssh-kitten-untar-XXXXXXXXXXXX")
[ $? = 0 ] || die "Creating temp directory failed" [ $? = 0 ] || die "Creating temp directory failed"
read_n_bytes_from_tty "$1" | command base64 -d | command tar xpjf - --no-same-owner -C "$tdir" read_n_bytes_from_tty "$1" | command base64 -d | command tar xpjf - -C "$tdir"
data_file="$tdir/data.sh" data_file="$tdir/data.sh"
[ -f "$data_file" ] && . "$data_file" [ -f "$data_file" ] && . "$data_file"
data_dir="$HOME/$KITTY_SSH_KITTEN_DATA_DIR" data_dir="$HOME/$KITTY_SSH_KITTEN_DATA_DIR"