更清洁的方式来重启daemontools服务

时间:2014-08-18 08:53:51

标签: linux centos daemon svc start-stop-daemon

在我们的产品中,我们使用daemontools创建了服务。我的一项服务看起来像这样,

/service/test/run
/service/test/log/run (has multilog command to log into ./main dir)
/service/test/log/main/..

所有进程及其目录都归root用户所有。现在有一个安全要求可以像这样改变,

  1. 服务应该以非root用户身份运行。
  2. 日志主目录应仅对用户和组可读。
  3. 为此,我必须更改'log'目录下的'run'文件。另外我需要更改它下面'main'目录的权限。

    请注意,'/ service'下的所有这些文件都归test-1.0-0.rpm所有。当我更新我的rpm时,它会覆盖现有的运行文件并出现这样的错误,

    multilog: fatal: unable to lock directory ./main: access denied
    

    我知道我们不应该在运行时覆盖'run'文件。我计划在我的rpm脚本%post部分

    中执行这些步骤
    //Stop service
    svc -d /service/test/log
    
    //Moving the main directory
    mv /service/test/log/main /service/test/log/main_old
    
    //Updated run file has code to create main with limited permissions.
    
    //Start service
    svc -u /service/test/log
    

    在一些文章中,他们建议在'log / main'下重新创建'lock'文件。没有移动'main'目录,还有其他更干净的方法吗?如果没有,采用上述步骤是否安全?

0 个答案:

没有答案