【问题标题】:EACCES (Permission denied @ rb_sysopen on ElasticBeanStalkEACCES(ElasticBeanStalk 上的权限被拒绝@rb_sysopen
【发布时间】:2018-07-10 05:38:39
【问题描述】:

我有一个 Rails ActiveJob 尝试写入一些文件。当控制器调用 ActiveJob 时,它失败并出现上述错误,尝试写入文件如下:Errno::EACCES (Permission denied @ rb_sysopen - /home/ec2-user/scrubarea/landing/5mBs8mq85ZFKVnqijeKZuNuh)。

即使目录有 777 权限也会发生这种情况。

但是,如果我 ssh 进入 EC2 映像,访问 Rails 控制台并使用 perform_now 运行作业,它就可以工作。

是否有其他 AWS 安全措施不允许应用程序写入文件?

【问题讨论】:

  • 它看起来取决于用户的权限,请在手动运行时检查用户,在系统运行时检查用户。
  • 手动运行,它是 EC2-USER,在 Rails 应用程序下运行,它是 webapp。我尝试将目录的所有权更改为 webapp,但这没有用。我尝试将 webapp 添加到 EC2-USER 组,但没有奏效。
  • 但是,当我更改环境参数以将文件发送到 /var/tmp/scrubarea 时,它确实起作用了!也许这是正确的答案,因为这些文件是短暂的,因为它们作为工作的最后一步被复制到 S3。
  • 您的意思是只需将文件移动到/var/tmp/scrubarea即可解决问题?
  • 这只是其中之一。我按照你的建议做了——以 ec2-user 身份运行时深入研究权限,而不是在用户 webapp 下运行 Rails 作业时。我终于解决了它,我将命令放入 .ebextensions 配置文件以创建scrubarea目录,然后执行 chmod 以允许为 ec2-user 组写入,然后执行 chmod 以便 ec2-user 拥有目录,最后,将 webapp 添加到 ec2-user 组。

标签: ruby-on-rails amazon-web-services access-denied rails-activejob


【解决方案1】:
commands:
  01_set_scrubarea:
    command: mkdir /var/tmp/scrubarea
    ignoreErrors: true
  05_set_landing:
    command: mkdir /var/tmp/scrubarea/cleanpool
    ignoreErrors: true
  10_set_cleanpool:
    command: mkdir /var/tmp/scrubarea/landing
    ignoreErrors: true
  15_change_security_scrubarea:
    command: chmod 775 /var/tmp/scrubarea
  17_change_security_cleanpool:
    command: chmod 775 /var/tmp/scrubarea/cleanpool
  19_change_security_landing:
    command: chmod 775 /var/tmp/scrubarea/landing
  20_change_owner:
    command: chown --verbose --recursive ec2-user:ec2-user /var/tmp/scrubarea
  25_add_to_group:
    command: usermod -a -G ec2-user webapp

【讨论】:

    猜你喜欢
    • 2019-02-13
    • 1970-01-01
    • 2020-12-17
    • 2018-09-10
    • 1970-01-01
    • 2020-06-03
    • 2014-05-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多