通过 strace 运行时命令的退出状态不同

通过 strace 运行时命令的退出状态不同

我可以使用以下命令正常挂载/卸载 FTP 作为文件系统:

└──> curlftpfs -o codepage=windows-1250 anonymous:[email protected] /home/marek/ftpfs
└──> ls /home/marek/ftpfs/
1 2 3
└──> fusermount -u /home/marek/ftpfs
└──> ls /home/marek/ftpfs/
└──>

但是当我发出问题时,curlftpfs没有strace安装任何东西,并且进程以状态 1 退出:

└──> strace -f curlftpfs -o codepage=windows-1250 anonymous:[email protected] /home/marek/ftpfs
└──> echo $0
1
└──> ls /home/marek/ftpfs/
└──>

最后几行strace(完整输出是这里):

[pid  9619] mprotect(0x7f08780b2000, 4096, PROT_READ) = 0
[pid  9619] mprotect(0x7f08782bd000, 4096, PROT_READ) = 0
[pid  9619] munmap(0x7f0878e8d000, 135950) = 0
[pid  9619] open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 6
[pid  9619] lseek(6, 0, SEEK_CUR)       = 0
[pid  9619] fstat(6, {st_mode=S_IFREG|0644, st_size=2290, ...}) = 0
[pid  9619] mmap(NULL, 2290, PROT_READ, MAP_SHARED, 6, 0) = 0x7f0878eae000
[pid  9619] lseek(6, 2290, SEEK_SET)    = 2290
[pid  9619] munmap(0x7f0878eae000, 2290) = 0
[pid  9619] close(6)                    = 0
[pid  9619] getgid()                    = 1000
[pid  9619] getuid()                    = 1000
[pid  9619] openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 6
[pid  9619] getdents(6, /* 2 entries */, 32768) = 48
[pid  9619] getdents(6, /* 0 entries */, 32768) = 0
[pid  9619] close(6)                    = 0
[pid  9619] mount("curlftpfs#ftp://anonymous:[email protected]/", ".", "fuse", MS_NOSUID|MS_NODEV, "fd=3,rootmode=40000,user_id=1000"...) = -1 EPERM (Operation not permitted)
[pid  9619] write(2, "fusermount: mount failed: Operat"..., 50fusermount: mount failed: Operation not permitted
) = 50
[pid  9619] close(3)                    = 0
[pid  9619] exit_group(1)               = ?
[pid  9618] <... recvmsg resumed> {msg_name(0)=NULL, msg_iov(1)=[{"", 1}], msg_controllen=0, msg_flags=0}, 0) = 0
[pid  9618] close(6)                    = 0
[pid  9618] wait4(9619,  <unfinished ...>
[pid  9619] +++ exited with 1 +++
<... wait4 resumed> NULL, 0, NULL)      = 9619
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=9619, si_uid=1000, si_status=1, si_utime=0, si_stime=0} ---
sendto(4, "QUIT\r\n", 6, MSG_NOSIGNAL, NULL, 0) = 6
poll([{fd=4, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 1000) = 1 ([{fd=4, revents=POLLIN|POLLRDNORM}])
recvfrom(4, "221 Bye\r\n", 16384, 0, NULL, NULL) = 9
close(4)                                = 0
close(3)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++

答案1

我不熟悉这个可执行文件,但我的猜测是它需要以特权运行(可能是 suid root 或类似的)。 strace -f 无法以特权运行此类进程,除非 strace 本身以 root 身份运行并且您可能需要 -u 选项。

相关内容