Read data directly from /dev/log Unix Domain Socket

泄露秘密 提交于 2019-12-02 11:26:29

Since you cannot connect to an existing server socket as mentioned in the log traces, then you haven't bound one one the mentioned file, so try creating an AF_UNIX server socket then connect to it.

It could be done in a separate class:

public class DevLogServer {

  public static void main(String[] args) throws IOException {

    final File socketFile = new File("/dev/log");
    AFUNIXServerSocket server = AFUNIXServerSocket.newInstance();
    try {
      server.bind(new AFUNIXSocketAddress(socketFile));
    } catch (Exception e) {
      throw e;
    }

  }

}

Edit as per @Ankit comment:

You may also need to make sure the syslod daemon is stopped by runnig below command in a terminal window:

sudo service syslog stop

You may alternatively need to grand write permission to the /dev directory.

Are You starting your application with root priviledges ?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!