You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "uttamgupta (via GitHub)" <gi...@apache.org> on 2025/04/02 18:46:37 UTC

[I] Throws exception if home folder doesn't exist. [mina-sshd]

uttamgupta opened a new issue, #717:
URL: https://github.com/apache/mina-sshd/issues/717

   ### Version
   
   2.14.0
   
   ### Bug description
   
   In our environment, few users don't have home folder and it set to /dev/null . But SshClient tries to read config file and it throws exception.
   
   Although it expects exception NoSuchFileException. see code snippet from file FileSnapshot.java
   `public static FileSnapshot save(Path file, LinkOption... options) throws IOException {
           BasicFileAttributes attributes = null;
           Instant now = Instant.now();
           try {
               attributes = Files.readAttributes(file, BasicFileAttributes.class, options);
           } catch (NoSuchFileException e) {
               return NO_FILE;
           }
           if (attributes == null) {
               return NO_FILE;
           }
           return new FileSnapshot(now, attributes.lastModifiedTime(), attributes.size(), attributes.fileKey());
       }`
   
   
   
   ### Actual behavior
   
   ```
   java.nio.file.FileSystemException: /dev/null/.ssh/config: Not a directory
   	at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)
   	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
   	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
   	at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
   	at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:171)
   	at java.base/java.nio.file.Files.readAttributes(Files.java:1853)
   	at org.apache.sshd.common.util.io.FileSnapshot.save(FileSnapshot.java:145)
   	at org.apache.sshd.common.util.io.ModifiableFileWatcher.checkReloadRequired(ModifiableFileWatcher.java:109)
   	at org.apache.sshd.client.config.hosts.ConfigFileHostEntryResolver.resolveEffectiveResolver(ConfigFileHostEntryResolver.java:79)
   	at org.apache.sshd.client.config.hosts.ConfigFileHostEntryResolver.resolveEffectiveHost(ConfigFileHostEntryResolver.java:59)
   	at org.apache.sshd.client.SshClient.resolveHost(SshClient.java:735)
   	at org.apache.sshd.client.SshClient.connect(SshClient.java:543)
   	at org.apache.sshd.client.session.ClientSessionCreator.connect(ClientSessionCreator.java:74)
   	at org.apache.sshd.client.session.ClientSessionCreator.connect(ClientSessionCreator.java:57)
   ```
   
   ### Expected behavior
   
   I think it should also expect "Not a directory" .
   
   ### Relevant log output
   
   ```Shell
   
   ```
   
   ### Other information
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


Re: [I] Throws exception if home folder doesn't exist. [mina-sshd]

Posted by "uttamgupta (via GitHub)" <gi...@apache.org>.
uttamgupta closed issue #717: Throws exception if home folder doesn't exist.
URL: https://github.com/apache/mina-sshd/issues/717


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


Re: [I] Throws exception if home folder doesn't exist. [mina-sshd]

Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on issue #717:
URL: https://github.com/apache/mina-sshd/issues/717#issuecomment-2773449887

   If you don't have a home directory then don't use a `ConfigFileHostEntryResolver`. Configure your own.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


Re: [I] Throws exception if home folder doesn't exist. [mina-sshd]

Posted by "uttamgupta (via GitHub)" <gi...@apache.org>.
uttamgupta commented on issue #717:
URL: https://github.com/apache/mina-sshd/issues/717#issuecomment-2773595044

   > ConfigFileHostEntryResolver
   
   Thanks I have tested with my sample code and it worked - 
   `public class CustomConfigFileHostEntryResolver implements HostConfigEntryResolver {
       @Override
       public HostConfigEntry resolveEffectiveHost(String host, int port, SocketAddress localAddress, String username, String proxyJump, AttributeRepository context) throws IOException {
           return null;
       }
   }`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org