コード例 #1
0
  public String start() throws Exception {
    authSocket = createLocalSocketAddress();
    address = new UnixSocketAddress(new File(authSocket));
    channel = UnixServerSocketChannel.open();
    channel.configureBlocking(false);
    socket = channel.socket();
    socket.bind(address);
    selector = NativeSelectorProvider.getInstance().openSelector();

    channel.register(selector, SelectionKey.OP_ACCEPT, new SshAgentServerSocketHandler());

    POSIXFactory.getPOSIX().chmod(authSocket, 0600);
    if (!new File(authSocket).exists()) {
      throw new IllegalStateException(
          "failed to create "
              + authSocket
              + " of length "
              + authSocket.length()
              + " (check UNIX_PATH_MAX)");
    }

    thread = new Thread(new AgentSocketAcceptor(), "SSH Agent socket acceptor " + authSocket);
    thread.setDaemon(true);
    thread.start();
    return authSocket;
  }
コード例 #2
0
 public static boolean hasNonTTYInput() {
   POSIX posix = POSIXFactory.getPOSIX();
   return !posix.isatty(FileDescriptor.in);
 }