From d5f18dc2341b29617d46f4805d16eff3b0a546ef Mon Sep 17 00:00:00 2001 From: Rob Spoor Date: Thu, 2 Mar 2023 14:56:08 +0100 Subject: [PATCH] Don't actually set the owner or group --- .../filesystems/sftp/server/FixedSftpSubsystem.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/github/robtimus/filesystems/sftp/server/FixedSftpSubsystem.java b/src/test/java/com/github/robtimus/filesystems/sftp/server/FixedSftpSubsystem.java index 15c5ada..8351c23 100644 --- a/src/test/java/com/github/robtimus/filesystems/sftp/server/FixedSftpSubsystem.java +++ b/src/test/java/com/github/robtimus/filesystems/sftp/server/FixedSftpSubsystem.java @@ -18,6 +18,7 @@ package com.github.robtimus.filesystems.sftp.server; import java.io.IOException; +import java.nio.file.LinkOption; import java.nio.file.Path; import java.util.Collection; import java.util.Map; @@ -39,7 +40,7 @@ * * @author Rob Spoor */ -@SuppressWarnings("javadoc") +@SuppressWarnings({ "javadoc", "nls" }) public class FixedSftpSubsystem extends SftpSubsystem { public FixedSftpSubsystem(ChannelSession channel, SftpSubsystemConfigurator configurator) { @@ -52,6 +53,15 @@ protected Map doStat(int id, String path, int flags) throws IOEx return resolveFileAttributes(p, flags, IoUtils.getLinkOptions(true)); } + @Override + protected void setFileAttribute(Path file, String view, String attribute, Object value, LinkOption... options) throws IOException { + if ("uid".equals(attribute) || "gid".equals(attribute)) { + // Don't actually set the owner or group; it will be ignored on Windows but fails on Linux due to non-matching values + return; + } + super.setFileAttribute(file, view, attribute, value, options); + } + public static final class Factory extends SftpSubsystemFactory { @Override