简体   繁体   English

system():为什么我在EMACS中使用R时没有像在bash终端中那样使用相同的权限?

[英]system(): why do I not have the same permissions when using R in EMACS as I do in the bash terminal?

update: the error only occurs when logged into R from within emacs 更新:只有从emacs中登录到R时才会出现错误

what works: 什么有效:

When I ssh into a remote server and run 当我进入远程服务器并运行时

$ ./foo.rb

from the bash shell, it works. 从bash shell,它的工作原理。 Furthermore, if I launch R and execute $ R 此外,如果我启动R并执行$ R.

system('./foo.rb') 系统( './ foo.rb')

I am in a group with permission to read/write/execute the file. 我在一个有权读取/写入/执行文件的组中。 File permissions are -rwxrwx--- 文件权限是-rwxrwx---

what doesn't work: 什么行不通:

Launch emacs and start an R session: 启动emacs并启动R会话:

  • Mx R
  • ssh-myserver: . ssh-myserver: .

    system('./foo.rb') 系统( './ foo.rb')

I get the following error: 我收到以下错误:

ruby: Permission denied -- foo.rb (LoadError)

why is this? 为什么是这样? Is there a way to work around this? 有办法解决这个问题吗?

I can not find any information from ?system or ?system2 我找不到来自?system?system2任何信息


Here is the output from sessionInfo() 这是sessionInfo()的输出

> sessionInfo()
R version 2.12.2 (2011-02-25)
Platform: x86_64-redhat-linux-gnu (64-bit)

locale:
[1] C

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] PECAn_0.1.1      xtable_1.5-6     gridExtra_0.7    RMySQL_0.7-5    
 [5] DBI_0.2-5        ggplot2_0.8.9    proto_0.3-8      reshape_0.8.3   
 [9] plyr_1.6         rjags_2.2.0-2    coda_0.13-5      lattice_0.19-17 
[13] randtoolbox_1.09 rngWELL_0.9      MASS_7.3-11      XML_3.2-0       

loaded via a namespace (and not attached):
[1] digest_0.4.2
Warning message:
'DESCRIPTION' file has 'Encoding' field and re-encoding is not possible 

output of 'id' and 'env' from ssh and emacs, per comment by @sarnold (changed user names, group names, and ip addresses) 来自ssh和emacs的'id'和'env'的输出,@sarnold的每条评论(更改的用户名,组名和IP地址)

1. server 服务器

1.1 'id' 1.1'id'

 uid=1668(dleb) gid=1668(dleb) groups=117(ebusers),159(lab_admin),166(lab),1340(pal_web),1668(dleb)

1.2 'env' 1.2'env'

LC_PAPER=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
SHELL=/usr/local/bin/system-specific
KDE_NO_IPV6=1
SSH_CLIENT=888.888.888.88 51857 22
NCARG_FONTCAPS=/usr/lib64/ncarg/fontcaps
LC_NUMERIC=en_US.UTF-8
USER=dleb
LS_COLORS=
LC_TELEPHONE=en_US.UTF-8
KDEDIR=/usr
NCARG_GRAPHCAPS=/usr/lib64/ncarg/graphcaps
MAIL=/var/mail/dleb
PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin
LC_IDENTIFICATION=en_US.UTF-8
LC_COLLATE=en_US.UTF-8
R_LIBS=/home/a-m/dleb/lib/R
PWD=/home/dleb
NCARG_ROOT=/usr
KDE_IS_PRELINKED=1
LANG=en_US.UTF-8
NCARG_DATABASE=/usr/lib64/ncarg/database
MODULEPATH=/usr/share/Modules/modulefiles:/etc/modulefiles
LOADEDMODULES=
LC_MEASUREMENT=en_US.UTF-8
NCARG_LIB=/usr/lib64/ncarg
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
NCARG_NCARG=/usr/share/ncarg
SHLVL=1
HOME=/home/a-m/dleb
LOGNAME=dleb
CVS_RSH=ssh
SSH_CONNECTION=888.888.888.88 51857 999.999.999.99 22
LC_CTYPE=en_US.UTF-8
MODULESHOME=/usr/share/Modules
LESSOPEN=|/usr/bin/lesspipe.sh %s
DISPLAY=localhost:15.0
LC_TIME=en_US.UTF-8
G_BROKEN_FILENAMES=1
LC_NAME=en_US.UTF-8
_=/bin/env

emacs/ess R session emacs / ess R session

2.1 system('id') 2.1系统('id')

uid=1668(dleb) gid=1668(dleb) groups=117(ebusers),159(lab_admin),166(lab),1340(pal_web),1668(dleb)

2.2 system('env') 2.2系统('env')

LN_S=ln -s
R_TEXI2DVICMD=/usr/bin/texi2dvi
LC_PAPER=en_US.UTF-8
SED=/bin/sed
LC_ADDRESS=en_US.UTF-8
R_PDFVIEWER=/usr/bin/xdg-open
LC_MONETARY=en_US.UTF-8
HOSTNAME=ebi-forecast
R_INCLUDE_DIR=/usr/include/R
R_PRINTCMD=lpr
SHELL=/usr/local/bin/system-specific
TERM=dumb
AWK=gawk
HISTSIZE=1
R_RD4DVI=ae
SSH_CLIENT=888.888.888.88 51159 22
KDE_NO_IPV6=1
R_RD4PDF=times,hyper
R_PAPERSIZE=a4
NCARG_FONTCAPS=/usr/lib64/ncarg/fontcaps
PERL=/usr/bin/perl
LC_NUMERIC=en_US.UTF-8
SSH_TTY=/dev/pts/14
LC_ALL=C
EMACS=t
USER=dleb
LC_TELEPHONE=en_US.UTF-8
LS_COLORS=
LD_LIBRARY_PATH=/usr/lib64/R/lib:/usr/local/lib64:/usr/lib/jvm/jre/lib/amd64/server:/usr/lib/jvm/jre/lib/amd64:/usr/lib/jvm/java/lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/lib
TAR=/bin/gtar
ENV=
R_ZIPCMD=/usr/bin/zip
KDEDIR=/usr
PAGER=/usr/bin/less
NCARG_GRAPHCAPS=/usr/lib64/ncarg/graphcaps
R_GZIPCMD=/usr/bin/gzip
PATH=/bin:/usr/bin:/usr/sbin:/usr/local/bin
LC_COLLATE=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
EGREP=/bin/grep -E
PWD=/home/a-m/dleb/pecan
INPUTRC=/etc/inputrc
R_LIBS=/home/a-m/dleb/lib/R
NCARG_ROOT=/usr
R_SHARE_DIR=/usr/share/R
WHICH=/usr/bin/which
EDITOR=vi
LANG=en_US.UTF-8
KDE_IS_PRELINKED=1
R_LIBS_SITE=/usr/local/lib/R/site-library:/usr/local/lib/R/library:/usr/lib64/R/library:/usr/share/R/library
M    ODULEPATH=/usr/share/Modules/modulefiles:/etc/modulefiles
NCARG_DATABASE=/usr/lib64/ncarg/database
LC_MEASUREMENT=en_US.UTF-8
LOADEDMODULES=
PS3=
R_BROWSER=/usr/bin/xdg-open
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
NCARG_LIB=/usr/lib64/ncarg
HOME=/home/a-m/dleb
SHLVL=1
NCARG_NCARG=/usr/share/ncarg
R_ARCH=
TR=/usr/bin/tr
MAKE=make
R_UNZIPCMD=/usr/bin/unzip
LOGNAME=dleb
CVS_RSH=ssh
LC_CTYPE=en_US.UTF-8
SSH_CONNECTION=888.888.888.88 51159 999.999.999.99 22
R_BZIPCMD=/usr/bin/bzip2
MODULESHOME=/usr/share/Modules
LESSOPEN=|/usr/bin/lesspipe.sh %s
PROMPT_COMMAND=
R_HOME=/usr/lib64/R
DISPLAY=localhost:22.0
R_PLATFORM=x86_64-redhat-linux-gnu
INSIDE_EMACS=23.2.1,tramp:2.1.18-23.2
R_LIBS_USER=~/R/x86_64-redhat-linux-gnu-library/2.12
LC_TIME=en_US.UTF-8
R_DOC_DIR=/usr/share/doc/R-2.12.2
R_SESSION_TMPDIR=/tmp/RtmpqA6bpJ
HISTFILE=/home/a-m/dleb/.tramp_history
G_BROKEN_FILENAMES=1
LC_NAME=en_US.UTF-8
_=/bin/env

Assuming you started up R as the same user, you do. 假设您以相同的用户启动R,那么就可以。 You error is not coming from a permissions problem for foo.rb , however, or else your shell would be giving the error. 但是,您的错误不是来自foo.rb的权限问题,否则您的shell将提供错误。 (ie sh: ./test.rb: Permission denied ; see example below). (即sh: ./test.rb: Permission denied ;请参阅下面的示例)。 Here, ruby itself is giving the error. 在这里,ruby本身就是错误。 Without knowing exactly what is in your foo.rb , I would suggest digging in there to see what it is trying to load/source, and checking the permissions on those. 如果不确切知道你的foo.rb中有什么内容,我建议你foo.rb那里查看它正在尝试加载/获取的内容,并检查这些内容的权限。

#!/usr/bin/env ruby

puts 'Hello world'

Now in R.... 现在在R ....

> system('ls -l test.rb')
-rw-r--r--  1 jcolby  staff  40 Oct 21 08:23 test.rb
> system('./test.rb')
sh: ./test.rb: Permission denied
> system('chmod a+x test.rb')
> system('./test.rb')
Hello world

I presume the M ODULEPATH in the Emacs-derived output is simply a copy and paste typo. 我认为Emacs派生输出中的M ODULEPATH只是一个复制和粘贴拼写错误。

The differences between the two env outputs is much greater than I expected; 两者之间的差异env输出比我预期要大得多; I've selected the ones that look slightly suspicious to me: 我选择了那些看起来有些可疑的东西:

$ diff -u works fails
--- works   2011-10-24 15:04:02.000000000 -0700
+++ fails   2011-10-24 15:12:36.000000000 -0700
...
+LD_LIBRARY_PATH=/usr/lib64/R/lib:/usr/local/lib64:/usr/lib/jvm/jre/lib/amd64/server:/usr/lib/jvm/jre/lib/amd64:/usr/lib/jvm/java/lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/lib
...
-PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin
-PWD=/home/dleb
...
+PATH=/bin:/usr/bin:/usr/sbin:/usr/local/bin
...
+PWD=/home/a-m/dleb/pecan
...

In the emacs-derived session, your LD_LIBRARY_PATH environment variable may be changing specifics of which dynamically linked libraries are being used when executing ruby . 在emacs派生的会话中, LD_LIBRARY_PATH环境变量可能正在更改执行ruby时正在使用的动态链接库的细节。 If you ssh in to your server and execute your foo.rb with the changed LD_LIBRARY_PATH , does it work or fail? 如果你ssh到您的服务器,并执行你的foo.rb与改变LD_LIBRARY_PATH ,它的工作原理还是失败?

LD_LIBRARY_PATH=/usr/lib64/R/lib:/usr/local/lib64:/usr/lib/jvm/jre/lib/amd64/server:/usr/lib/jvm/jre/lib/amd64:/usr/lib/jvm/java/lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/lib ./foo.rb

The PATH environment variable between the two sessions is different; 两个会话之间的PATH环境变量是不同的; perhaps you have permission to execute /usr/local/bin/ruby (or the libraries in /usr/local/lib/ruby/ ) but not /usr/bin/ruby (or the libraries in /usr/lib/ruby/ ). 也许您有权执行/usr/local/bin/ruby (或/usr/local/lib/ruby/ )但不能执行/usr/bin/ruby (或/usr/lib/ruby/的库) 。 Does your script use #!env ruby or does it use #!/usr/bin/ruby (or some other fixed path)? 你的脚本是使用#!env ruby还是使用#!/usr/bin/ruby (或其他一些固定路径)?

Your pwd in one instance is /home/dleb , the other /home/am/dleb/pecan -- but HOME is set to /home/am/dleb on both systems. 你的pwd在一个实例中是/home/dleb ,另一个/home/am/dleb/pecan - 但是在两个系统上HOME都设置为/home/am/dleb Is /home/dleb a symbolic link or does it actually exist separate from /home/am/dleb ? /home/dleb是一个符号链接还是实际上与/home/am/dleb分开存在? (This really is grasping at straws -- I don't think this is it, but this problem is baffling.) (这确实是抓救命稻草-我不认为这是它,但这个问题莫名其妙。)

One last thing to consider: is your server confined with a tool such as AppArmor , SELinux , TOMOYO , or SMACK ? 最后要考虑的一件事是:您的服务器是否受限于AppArmorSELinuxTOMOYOSMACK等工具 Any of these mandatory access control tools can prevent an application from writing in specific locations, perhaps they aren't yet configured for your site. 任何这些强制访问控制工具都可以阻止应用程序在特定位置写入,可能还没有为您的站点配置它们。 Check dmesg(1) output to see if there are any rejection messages, most or all these tools log to dmesg(1) if auditd(8) isn't running. 检查dmesg(1)输出以查看是否有任何拒绝消息,如果auditd(8)未运行,则大多数或所有这些工具都会记录到dmesg(1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM