【问题标题】:VSTS-Agent cannot chmodVSTS-Agent 不能 chmod
【发布时间】:2018-06-21 17:17:58
【问题描述】:

(目标机器:RedHat 7)

我使用“复制文件”任务,使用“覆盖”选项时效果很好

但是当不使用该选项时,当 vstsagent 尝试对已经存在的某些文件进行 chmod 时,我收到 EPERM 权限被拒绝

有一个明显的安全策略禁止除 root(和 sudo 命令)之外的任何其他操作在文件系统上执行 chmod

我们如何在不影响系统安全的情况下解决这个问题?

谢谢

2018-06-19T13:03:59.9255736Z ##[section]Starting: Copy Files to: /data/apache/var/www/html/******
2018-06-19T13:03:59.9380638Z ==============================================================================
2018-06-19T13:03:59.9408913Z Task         : Copy Files
2018-06-19T13:03:59.9437816Z Description  : Copy files from source folder to target folder using match patterns (The match patterns will only match file paths, not folder paths)
2018-06-19T13:03:59.9466225Z Version      : 2.117.0
2018-06-19T13:03:59.9494054Z Author       : Microsoft Corporation
2018-06-19T13:03:59.9522338Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=708389)
2018-06-19T13:03:59.9550616Z ==============================================================================
2018-06-19T13:04:00.5528521Z found 7 files
2018-06-19T13:04:00.5585656Z Copying /home/saehqvsts/vstsagent2/_work/r3/a/artifact/drop/delete_files.sh to /data/apache/var/www/html/******/delete_files.sh
2018-06-19T13:04:00.5743041Z Copying /home/saehqvsts/vstsagent2/_work/r3/a/artifact/drop/images/home/blog-image01.png to /data/apache/var/www/html/******/images/home/blog-image01.png
2018-06-19T13:04:00.5773633Z Copying /home/saehqvsts/vstsagent2/_work/r3/a/artifact/drop/images/home/blog-image02.png to /data/apache/var/www/html/******/images/home/blog-image02.png
2018-06-19T13:04:00.5803794Z Copying /home/saehqvsts/vstsagent2/_work/r3/a/artifact/drop/images/home/blog-image03.png to /data/apache/var/www/html/******/images/home/blog-image03.png
2018-06-19T13:04:00.5833235Z Copying /home/saehqvsts/vstsagent2/_work/r3/a/artifact/drop/index.php to /data/apache/var/www/html/******/index.php
2018-06-19T13:04:00.5861627Z shell.js: internal error
2018-06-19T13:04:00.5890403Z Error: EPERM: operation not permitted, chmod '/data/apache/var/www/html/******/index.php'
2018-06-19T13:04:00.5918532Z     at Error (native)
2018-06-19T13:04:00.5946236Z     at Object.fs.chmodSync (fs.js:1168:18)
2018-06-19T13:04:00.5975560Z     at copyFileSync (/home/saehqvsts/vstsagent2/_work/_tasks/CopyFiles_5bfb729a-a7c8-4a78-a7c3-8d717bb7c13c/2.117.0/node_modules/shelljs/src/cp.js:41:6)
2018-06-19T13:04:00.6005484Z     at /home/saehqvsts/vstsagent2/_work/_tasks/CopyFiles_5bfb729a-a7c8-4a78-a7c3-8d717bb7c13c/2.117.0/node_modules/shelljs/src/cp.js:198:5
2018-06-19T13:04:00.6034026Z     at Array.forEach (native)
2018-06-19T13:04:00.6063516Z     at Object._cp (/home/saehqvsts/vstsagent2/_work/_tasks/CopyFiles_5bfb729a-a7c8-4a78-a7c3-8d717bb7c13c/2.117.0/node_modules/shelljs/src/cp.js:157:11)
2018-06-19T13:04:00.6094451Z     at Object.cp (/home/saehqvsts/vstsagent2/_work/_tasks/CopyFiles_5bfb729a-a7c8-4a78-a7c3-8d717bb7c13c/2.117.0/node_modules/shelljs/src/common.js:186:23)
2018-06-19T13:04:00.6124783Z     at Object.cp (/home/saehqvsts/vstsagent2/_work/_tasks/CopyFiles_5bfb729a-a7c8-4a78-a7c3-8d717bb7c13c/2.117.0/node_modules/vsts-task-lib/task.js:827:15)
2018-06-19T13:04:00.6154870Z     at matchedFiles.forEach.err (/home/saehqvsts/vstsagent2/_work/_tasks/CopyFiles_5bfb729a-a7c8-4a78-a7c3-8d717bb7c13c/2.117.0/copyfiles.js:119:20)
2018-06-19T13:04:00.6183521Z     at Array.forEach (native)
2018-06-19T13:04:00.6774571Z ##[error]Exit code 1 returned from process: file name '/home/saehqvsts/vstsagent2/externals/node/bin/node', arguments '"/home/saehqvsts/vstsagent2/_work/_tasks/CopyFiles_5bfb729a-a7c8-4a78-a7c3-8d717bb7c13c/2.117.0/copyfiles.js"'.
2018-06-19T13:04:00.6890413Z ##[section]Finishing: Copy Files to: /data/apache/var/www/html/******

【问题讨论】:

    标签: azure-devops


    【解决方案1】:

    那是因为文件已经存在,您只需清理该路径中的现有文件或使用“Overwrite”选项覆盖它们。

    【讨论】:

    • 如果这么简单我就不会在这里发布一个线程:-)...我实际上需要明显地勾选覆盖选项...实际上很奇怪代理正在尝试一个 chmod在不应该触及这些文件的情况下已经存在的文件上,因此勾选了覆盖选项
    • @user7082181 不幸的是,这是为复制文件任务设计的,如果您想勾选覆盖选项,那么您需要先编写脚本或使用命令行清理现有文件...
    • @user7082181 你解决了这个问题吗?有更新吗?
    • nop...我可以选择创建自己的插件,但是在 vstsagent 文件夹中进行 chmod 更简单,然后将文件复制到目标文件夹中...实际上很安静,因为它绕过安全性,但至少它可以工作
    猜你喜欢
    • 1970-01-01
    • 2017-11-27
    • 2016-03-08
    • 1970-01-01
    • 2014-02-04
    • 1970-01-01
    • 2018-03-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多