【发布时间】:2012-12-17 22:53:39
【问题描述】:
背景:
我有一个每天新部署的应用程序——创建一个 VM,然后该系统的 root 创建一个“systemuser”,然后安装该应用程序。
它正在运行:
- CentOS 6
- RVM
- Ruby 1.8.7 on Rails
- 乘客
它的设置方式,我必须让 Ruby on Rails 自行安装,并安装乘客。为此,运行该服务的用户具有 sudo 权限,但其目的是仅允许安装期间所需的命令。出于安全和可维护性的原因,我们不能将 sudo 密码放在脚本中。
我的 /etc/sudoers 包括:
systemuser ALL = NOPASSWD: /usr/bin/env, /bin/bash, /usr/local/rvm/rubies/ruby-1.8.7-p358/bin/gem, /bin/cp, /bin/ln, /bin/mv, /bin/rm, /etc/init.d/httpd *
问题:
直到最近,它的一个变体效果很好。然而,最近某处发生了一些变化(?),并且 rvmsudo 命令不再在没有密码提示的情况下执行。
$ rvmsudo passenger-install-apache2-module
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for systemuser:
问题:
在 /etc/sudoers 中安装 rvm、ruby、bundler/gem,然后在 apache 上安装乘客 2 的最少命令集是什么?
是的,我已经阅读了https://rvm.io/integration/passenger/ 的“文档”
欢迎创造性的解决方案!我意识到有人可能会说这看起来像是一个非常老套的系统,我同意你的看法。但目前我很难在不了解此乘客安装脚本正在运行哪些命令的情况下对其进行改进。
从前面删除“env”和“bash”并添加“rvm”会更进一步:
systemuser ALL = NOPASSWD: /usr/local/rvm/bin/rvmsudo, /usr/local/rvm/gems/ruby-1.8.7-p358/bin/passenger-install-apache2-module, /bin/cp, /bin/ln, /bin/mv, /bin/rm, /etc/init.d/httpd *
运行这个:
$ rvmsudo passenger-install-apache2-module
[sudo] password for systemuser:
感谢您的关注!
【问题讨论】:
标签: bash rvm passenger sudo sudoers