Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

以nobody 用户启动时 user.home目录为/的情况启动失败 #572

Closed
chenshun00 opened this issue Mar 14, 2019 · 9 comments
Closed
Milestone

Comments

@chenshun00
Copy link

环境信息

  • arthas-boot.jar 或者 as.sh 的版本: 3.1.0
  • 目标进程的JVM版本: 1.8
  • 执行arthas-boot的版本: 1.7
$ java -jar arthas-boot.jar
[INFO] arthas-boot version: 3.1.0
[INFO] Found existing java process, please choose one and hit RETURN.
* [1]: 686 org.apache.catalina.startup.Bootstrap
  [2]: 18232 org.apache.catalina.startup.Bootstrap
  [3]: 25596 org.apache.catalina.startup.Bootstrap
   .....
  [18]: 8043 org.springframework.boot.loader.PropertiesLauncher

选择18

18
[ERROR] cannot create directory /.arthas/lib: maybe permission denied
[nobody@aliyun-app-168-151 logs]$

直接去根目录 / 了,肯定没有权限。询问arthas commit,是使用user.home 创建的文件夹,加上 -Duser.home=/home/xxxxx 启动成功.

查看真实的 user.home

public class AAA {
    public static void main(String[] args) {
        System.out.println(System.getProperty("user.home"));
        System.out.println(System.getProperty("user.name"));
        System.out.println(System.getProperty("user.dir"));
    }
}
javac AAA.java
[nobody@aliyun-app-xxxx-xxx] logs]$ java AAA
nobody
/
/path/tomcat/logs
@hengyunabc
Copy link
Collaborator

查了一些资料,的确 nobody 用户的 user.home/ 。后续版本可能加上一些判断,提示用户显式指定 user home ,或者切换用户。

@hengyunabc hengyunabc changed the title user.home目录为/的情况启动失败 以nobody 用户启动时 user.home目录为/的情况启动失败 Mar 14, 2019
@hengyunabc hengyunabc added this to the 3.1.1 milestone Apr 24, 2019
@hengyunabc
Copy link
Collaborator

@chenshun00 使用 --arthas-home 参数指定 arthas home 可以工作不?

@chenshun00
Copy link
Author

@hengyunabc 最新版本吗,等我测试一下

@hengyunabc
Copy link
Collaborator

@chenshun00 3.1.0 版本就有 --arthas-home ,可以 java -jar arthas-boot.jar -h打印帮助信息。

@chenshun00
Copy link
Author

@hengyunabc 还是不行,依赖了core

1、 wget https://alibaba.github.io/arthas/arthas-boot.jar
2、java -jar arthas-boot.jar 
    ---result [ERROR] cannot create directory /.arthas/lib: maybe permission denied
3、java -jar arthas-boot.jar --arthas-home /home/tomcat/arthas
    --- Exception in thread "main" java.lang.IllegalArgumentException: arthas-core.jar do not exist, arthas home: /home/tomcat/arthas
	at com.taobao.arthas.boot.Bootstrap.verifyArthasHome(Bootstrap.java:531)
	at com.taobao.arthas.boot.Bootstrap.main(Bootstrap.java:321)
4、java -jar -Duser.home=/home/tomcat/arthas arthas-boot.jar
    --- Attach process 11896 success

@hengyunabc
Copy link
Collaborator

hengyunabc commented May 9, 2019

在ubuntu下面测试了下,打印结果是:

public class AAA {
    public static void main(String[] args) {
        System.out.println(System.getProperty("user.home"));
        System.out.println(System.getProperty("user.name"));
        System.out.println(System.getProperty("user.dir"));
    }
}
/nonexistent
nobody
/

@hengyunabc
Copy link
Collaborator

hengyunabc commented May 9, 2019

这里有两个问题:

  1. 当用户只有一个arthas-boot.jar 时,启动需要找地方放arthas下载的内容,这里会失败
  2. arthas里的日志依赖~/logs/arthas 目录,还有一些 jad/dump 功能也依赖 user.home

目前下载完整的zip包,启动arthas-boot.jar,可以正常attach,但是应用stdout里会打印出:

Thu May 09 20:35:30 CST 2019 com.taobao.arthas.agent.ArthasClassloader@603005c5 JM.Log:INFO Log root path: /nonexistent/logs/
Thu May 09 20:35:30 CST 2019 com.taobao.arthas.agent.ArthasClassloader@603005c5 JM.Log:INFO Set arthas log path: /nonexistent/logs/arthas

但是实际上 /nonexistent/logs 目录是不存在的,所以实际上日志打印会失败。

@hengyunabc
Copy link
Collaborator

nobody用户启动的进程里,打印 System.out.println(new java.io.File("").getAbsoluteFile()); 结果是 / 。 也就是进程的工作目录也没办法写文件。。

@hengyunabc
Copy link
Collaborator

测试zip包:
arthas-3.1.1-SNAPSHOT-bin.zip

XhinLiang pushed a commit to XhinLiang/arthas-mvel that referenced this issue Aug 2, 2019
XhinLiang pushed a commit to XhinLiang/arthas-mvel that referenced this issue Aug 5, 2019
XhinLiang pushed a commit to XhinLiang/arthas-mvel that referenced this issue Aug 5, 2019
lzc-alioo pushed a commit to lzc-alioo/arthas that referenced this issue May 22, 2020
lzc-alioo pushed a commit to lzc-alioo/arthas that referenced this issue May 22, 2020
lzc-alioo pushed a commit to lzc-alioo/arthas that referenced this issue May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants