这是有史以来最奇怪的错误 - 每个目录的Python os.listdir()都失败了:
Python 2.5.2 (r252:60911, Jan 20 2010, 23:14:04)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.listdir("/")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 2] No such file or directory: '/'
>>> os.listdir("/tmp")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 2] No such file or directory: '/tmp'
>>> os.listdir(os.getcwd())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 2] No such file or directory: '/srv'
Ubuntu Linux 8.04。这突然出现在正常运行的服务器上,所以我怀疑文件系统损坏。但我已经重新编译了Python解释器。我还测试了两种不同的解释器版本。
这是一个运行os.listdir(“/ tmp”)的简单脚本的一个strace:
strace python test.py
execve("/usr/bin/python", ["python", "test.py"], [/* 17 vars */]) = 0
brk(0) = 0x75b000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24b35000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24b33000
access("/etc/ld.so.preload", R_OK) = 0
open("/etc/ld.so.preload", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=22, ...}) = 0
mmap(NULL, 22, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = 0x7feb24b32000
close(3) = 0
open("/lib/libncom.so.4.0.1", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\25\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=13176, ...}) = 0
mmap(NULL, 2107936, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7feb24716000
mprotect(0x7feb24719000, 2093056, PROT_NONE) = 0
mmap(0x7feb24918000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7feb24918000
close(3) = 0
munmap(0x7feb24b32000, 22) = 0
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=18355, ...}) = 0
mmap(NULL, 18355, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7feb24b2e000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libpthread.so.0", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260W\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=130224, ...}) = 0
mmap(NULL, 2208624, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7feb244fa000
mprotect(0x7feb24510000, 2097152, PROT_NONE) = 0
mmap(0x7feb24710000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7feb24710000
mmap(0x7feb24712000, 13168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7feb24712000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libdl.so.2", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0 \16\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=14624, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24b2d000
mmap(NULL, 2109728, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7feb242f6000
mprotect(0x7feb242f8000, 2097152, PROT_NONE) = 0
mmap(0x7feb244f8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7feb244f8000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libutil.so.1", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240\16\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=10584, ...}) = 0
mmap(NULL, 2105624, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7feb240f3000
mprotect(0x7feb240f5000, 2093056, PROT_NONE) = 0
mmap(0x7feb242f4000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0x7feb242f4000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libm.so.6", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260>\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=526560, ...}) = 0
mmap(NULL, 2621672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7feb23e72000
mprotect(0x7feb23ef2000, 2093056, PROT_NONE) = 0
mmap(0x7feb240f1000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7f000) = 0x7feb240f1000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\342"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1436976, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24b2c000
mmap(NULL, 3543672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7feb23b10000
mprotect(0x7feb23c68000, 2097152, PROT_NONE) = 0
mmap(0x7feb23e68000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x158000) = 0x7feb23e68000
mmap(0x7feb23e6d000, 17016, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7feb23e6d000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24b2b000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24b2a000
arch_prctl(ARCH_SET_FS, 0x7feb24b2a6e0) = 0
mprotect(0x7feb23e68000, 12288, PROT_READ) = 0
munmap(0x7feb24b2e000, 18355) = 0
set_tid_address(0x7feb24b2a770) = 11879
set_robust_list(0x7feb24b2a780, 0x18) = 0
futex(0x7fff2cb3530c, 0x81 /* FUTEX_??? */, 1) = 0
rt_sigaction(SIGRTMIN, {0x7feb244ff2d0, [], SA_RESTORER|SA_SIGINFO, 0x7feb245087d0}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x7feb244ff350, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7feb245087d0}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
futex(0x7feb244f910c, 0x81 /* FUTEX_??? */, 2147483647) = 0
brk(0) = 0x75b000
brk(0x77c000) = 0x77c000
open("test.py", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=30, ...}) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24ae9000
open("/proc/meminfo", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24b32000
read(4, "MemTotal: 1692120 kB\nMemFre"..., 1024) = 630
close(4) = 0
munmap(0x7feb24b32000, 4096) = 0
fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
stat("/usr/lib/kde4/bin/python", 0x7fff2cb31d70) = -1 ENOENT (No such file or directory)
stat("/usr/local/sbin/python", 0x7fff2cb31d70) = -1 ENOENT (No such file or directory)
stat("/usr/local/bin/python", 0x7fff2cb31d70) = -1 ENOENT (No such file or directory)
stat("/usr/sbin/python", 0x7fff2cb31d70) = -1 ENOENT (No such file or directory)
stat("/usr/bin/python", {st_mode=S_IFREG|0755, st_size=1387928, ...}) = 0
readlink("/usr/bin/python", "python2.5", 4096) = 9
readlink("/usr/bin/python2.5", 0x7fff2cb31e00, 4096) = -1 EINVAL (Invalid argument)
stat("/usr/bin/Modules/Setup", 0x7fff2cb31d70) = -1 ENOENT (No such file or directory)
stat("/usr/bin/lib/python2.5/os.py", 0x7fff2cb31d70) = -1 ENOENT (No such file or directory)
stat("/usr/bin/lib/python2.5/os.pyc", 0x7fff2cb31d70) = -1 ENOENT (No such file or directory)
stat("/usr/lib/python2.5/os.py", {st_mode=S_IFREG|0644, st_size=24624, ...}) = 0
stat("/usr/bin/Modules/Setup", 0x7fff2cb31d70) = -1 ENOENT (No such file or directory)
stat("/usr/bin/lib/python2.5/lib-dynload", 0x7fff2cb31d70) = -1 ENOENT (No such file or directory)
stat("/usr/lib/python2.5/lib-dynload", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
brk(0x79e000) = 0x79e000
rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGXFSZ, {SIG_IGN}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGHUP, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGINT, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGQUIT, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGILL, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGTRAP, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGABRT, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGBUS, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGFPE, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGKILL, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGUSR1, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGSEGV, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGUSR2, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGPIPE, NULL, {SIG_IGN}, 8) = 0
rt_sigaction(SIGALRM, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGTERM, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGSTKFLT, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGCONT, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGSTOP, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGTSTP, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGTTIN, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGTTOU, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGURG, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGXCPU, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGXFSZ, NULL, {SIG_IGN}, 8) = 0
rt_sigaction(SIGVTALRM, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGPROF, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGWINCH, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGIO, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGPWR, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGSYS, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_2, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_3, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_4, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_5, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_6, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_7, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_8, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_9, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_10, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_11, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_12, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_13, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_14, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_15, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_16, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_17, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_18, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_19, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_20, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_21, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_22, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_23, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_24, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_25, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_26, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_27, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_28, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_29, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_30, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_31, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGRT_32, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGINT, {0x4b8450, [], SA_RESTORER, 0x7feb245087d0}, {SIG_DFL}, 8) = 0
stat("/usr/lib/python25.zip", 0x7fff2cb2d750) = -1 ENOENT (No such file or directory)
stat("/usr/lib", {st_mode=S_IFDIR|0755, st_size=20480, ...}) = 0
stat("/usr/lib/python25.zip", 0x7fff2cb307d0) = -1 ENOENT (No such file or directory)
stat("/usr/lib/python2.5/", {st_mode=S_IFDIR|0755, st_size=20480, ...}) = 0
stat("/usr/lib/python2.5/", {st_mode=S_IFDIR|0755, st_size=20480, ...}) = 0
stat("/usr/lib/python2.5/site", 0x7fff2cb30ae0) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/site.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/sitemodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/site.py", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=14109, ...}) = 0
open("/usr/lib/python2.5/site.pyc", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=14300, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24b32000
read(5, "\263\362\r\n\f\241WKc\0\0\0\0\0\0\0\0\6\0\0\0@\0\0\0s\f"..., 4096) = 4096
fstat(5, {st_mode=S_IFREG|0644, st_size=14300, ...}) = 0
read(5, "\0\0sD\0\0\0Return a set containing a"..., 8192) = 8192
read(5, "|\2\0i\5\0d\5\0\203\1\0oW\0\1y\21\0|\1\0i\6\0|\2\0\203"..., 4096) = 2012
read(5, "", 4096) = 0
close(5) = 0
munmap(0x7feb24b32000, 4096) = 0
stat("/usr/lib/python2.5/os", 0x7fff2cb2d520) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/os.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/osmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/os.py", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=24624, ...}) = 0
open("/usr/lib/python2.5/os.pyc", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=24645, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24b32000
read(6, "\263\362\r\n\376\240WKc\0\0\0\0\0\0\0\0\36\0\0\0@\0\0\0"..., 4096) = 4096
fstat(6, {st_mode=S_IFREG|0644, st_size=24645, ...}) = 0
read(6, "|\1\0\203\2\0\1d\1\0S(\2\0\0\0s\2\1\0\0makedirs(pa"..., 20480) = 20480
read(6, "\n\r\n\r\4\t\t\t\f\35\3\r\3\t\n\t\f\35\4\r\1\r\1\17\n\21"..., 4096) = 69
read(6, "", 4096) = 0
close(6) = 0
munmap(0x7feb24b32000, 4096) = 0
mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24aa8000
brk(0x7c1000) = 0x7c1000
stat("/usr/lib/python2.5/posixpath", 0x7fff2cb29f60) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/posixpath.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/posixpathmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/posixpath.py", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=13777, ...}) = 0
open("/usr/lib/python2.5/posixpath.pyc", O_RDONLY) = 7
fstat(7, {st_mode=S_IFREG|0644, st_size=12355, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24aa7000
read(7, "\263\362\r\n\376\240WKc\0\0\0\0\0\0\0\0\'\0\0\0@\0\0\0"..., 4096) = 4096
fstat(7, {st_mode=S_IFREG|0644, st_size=12355, ...}) = 0
read(7, "b/python2.5/posixpath.pyR\t\0\0\0\211\0\0"..., 8192) = 8192
read(7, "\1\6\1\6\1\6\7\t\10\t\t\t\22\t\17\t\r\t\10\t\7\t\7\t\r"..., 4096) = 67
read(7, "", 4096) = 0
close(7) = 0
munmap(0x7feb24aa7000, 4096) = 0
stat("/usr/lib/python2.5/stat", 0x7fff2cb269a0) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/stat.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/statmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/stat.py", O_RDONLY) = 7
fstat(7, {st_mode=S_IFREG|0644, st_size=1667, ...}) = 0
open("/usr/lib/python2.5/stat.pyc", O_RDONLY) = 8
fstat(8, {st_mode=S_IFREG|0644, st_size=2424, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24aa7000
read(8, "\263\362\r\n\376\240WKc\0\0\0\0\0\0\0\0\1\0\0\0@\0\0\0"..., 4096) = 2424
fstat(8, {st_mode=S_IFREG|0644, st_size=2424, ...}) = 0
read(8, "", 4096) = 0
close(8) = 0
munmap(0x7feb24aa7000, 4096) = 0
close(7) = 0
close(6) = 0
stat("/usr/lib/python2.5/UserDict", 0x7fff2cb29f60) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/UserDict.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/UserDictmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/UserDict.py", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=5729, ...}) = 0
open("/usr/lib/python2.5/UserDict.pyc", O_RDONLY) = 7
fstat(7, {st_mode=S_IFREG|0644, st_size=8772, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24aa7000
read(7, "\263\362\r\n\376\240WKc\0\0\0\0\0\0\0\0\3\0\0\0@\0\0\0"..., 4096) = 4096
fstat(7, {st_mode=S_IFREG|0644, st_size=8772, ...}) = 0
read(7, "hon2.5/UserDict.pyR*\0\0\0C\0\0\0s\2\0\0\0"..., 4096) = 4096
read(7, "Ni\1\0\0\0(\6\0\0\0R\2\0\0\0R\v\0\0\0R7\0\0\0R\6\0\0\0"..., 4096) = 580
read(7, "", 4096) = 0
close(7) = 0
munmap(0x7feb24aa7000, 4096) = 0
close(6) = 0
stat("/usr/lib/python2.5/copy_reg", 0x7fff2cb29f60) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/copy_reg.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/copy_regmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/copy_reg.py", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=6729, ...}) = 0
open("/usr/lib/python2.5/copy_reg.pyc", O_RDONLY) = 7
fstat(7, {st_mode=S_IFREG|0644, st_size=5124, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24aa7000
read(7, "\263\362\r\n\376\240WKc\0\0\0\0\0\0\0\0\10\0\0\0@\0\0\0"..., 4096) = 4096
fstat(7, {st_mode=S_IFREG|0644, st_size=5124, ...}) = 0
read(7, " already in use for key %s(\5\0\0\0t"..., 4096) = 1028
read(7, "", 4096) = 0
close(7) = 0
munmap(0x7feb24aa7000, 4096) = 0
stat("/usr/lib/python2.5/types", 0x7fff2cb269a0) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/types.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/typesmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/types.py", O_RDONLY) = 7
fstat(7, {st_mode=S_IFREG|0644, st_size=2542, ...}) = 0
open("/usr/lib/python2.5/types.pyc", O_RDONLY) = 8
fstat(8, {st_mode=S_IFREG|0644, st_size=2708, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24aa7000
read(8, "\263\362\r\n\376\240WKc\0\0\0\0\0\0\0\0\23\0\0\0@\0\0\0"..., 4096) = 2708
fstat(8, {st_mode=S_IFREG|0644, st_size=2708, ...}) = 0
read(8, "", 4096) = 0
close(8) = 0
munmap(0x7feb24aa7000, 4096) = 0
close(7) = 0
close(6) = 0
close(5) = 0
stat("/usr/local/lib/python2.5/site-packages", {st_mode=S_IFDIR|S_ISGID|0775, st_size=4096, ...}) = 0
open("/usr/local/lib/python2.5/site-packages", O_RDONLY|O_NONBLOCK|O_DIRECTORY|0x80000) = 5
fstat(5, {st_mode=S_IFDIR|S_ISGID|0775, st_size=4096, ...}) = 0
fcntl(5, F_GETFD) = 0x1 (flags FD_CLOEXEC)
getdents(5, /* 2 entries */, 4096) = 48
stat("/proc/..", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/proc/.", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
getdents(5, /* 0 entries */, 4096) = 0
close(5) = 0
stat("/usr/local/lib/site-python", 0x7fff2cb310f0) = -1 ENOENT (No such file
...剪辑...
open("/usr/lib/python2.5/encodings/types.py", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/encodings/types.pyc", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/lib/python2.5/encodings/encodings", 0x7fff2cb2c5e0) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/encodings/encodings.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/encodings/encodingsmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/encodings/encodings.py", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/encodings/encodings.pyc", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/lib/python2.5/encodings/aliases", 0x7fff2cb2c5d0) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/encodings/aliases.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/encodings/aliasesmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/encodings/aliases.py", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=14337, ...}) = 0
open("/usr/lib/python2.5/encodings/aliases.pyc", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=9100, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24a61000
read(6, "\263\362\r\n\0\241WKc\0\0\0\0\0\0\0\0\4\0\0\0@\0\0\0sx"..., 4096) = 4096
fstat(6, {st_mode=S_IFREG|0644, st_size=9100, ...}) = 0
read(6, "t\6\0\0\0cp1258t\4\0\0\0001258t\f\0\0\0windows"..., 4096) = 4096
read(6, "let\25\0\0\0unicodelittleunmarkedt\10\0\0"..., 4096) = 908
read(6, "", 4096) = 0
close(6) = 0
munmap(0x7feb24a61000, 4096) = 0
close(5) = 0
close(4) = 0
stat("/usr/lib/python2.5/encodings/utf_8", 0x7fff2cb30860) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/encodings/utf_8.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/encodings/utf_8module.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.5/encodings/utf_8.py", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=1005, ...}) = 0
open("/usr/lib/python2.5/encodings/utf_8.pyc", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=1950, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24a61000
read(5, "\263\362\r\n\0\241WKc\0\0\0\0\0\0\0\0\4\0\0\0@\0\0\0s\230"..., 4096) = 1950
fstat(5, {st_mode=S_IFREG|0644, st_size=1950, ...}) = 0
read(5, "", 4096) = 0
close(5) = 0
munmap(0x7feb24a61000, 4096) = 0
close(4) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
readlink("test.py", 0x7fff2cb331a0, 4096) = -1 EINVAL (Invalid argument)
getcwd("/root", 4096) = 6
lstat("/root/test.py", {st_mode=S_IFREG|0644, st_size=30, ...}) = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff2cb35130) = -1 ENOTTY (Inappropriate ioctl for device)
fstat(3, {st_mode=S_IFREG|0644, st_size=30, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24a61000
lseek(3, 0, SEEK_CUR) = 0
read(3, "import os\nos.listdir(\"/tmp\")\n\n", 4096) = 30
lseek(3, 30, SEEK_SET) = 30
read(3, "", 4096) = 0
close(3) = 0
munmap(0x7feb24a61000, 4096) = 0
open("/tmp", O_RDONLY|O_NONBLOCK|O_DIRECTORY|0x80000) = 3
fstat(3, {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
getdents(3, /* 6 entries */, 4096) = 200
open("/proc/../cmdline", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/proc/redirect.log", 0x7fff2cb31cb0) = -1 ENOENT (No such file or directory)
stat("/proc/.", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
stat("/proc/php_errors.log", 0x7fff2cb31cb0) = -1 ENOENT (No such file or directory)
getdents(3, /* 0 entries */, 4096) = 0
close(3) = 0
write(2, "Traceback (most recent call last"..., 35Traceback (most recent call last):
) = 35
open("test.py", O_RDONLY) = 3
write(2, " File \"test.py\", line 2, in <mo"..., 38 File "test.py", line 2, in <module>
) = 38
fstat(3, {st_mode=S_IFREG|0644, st_size=30, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7feb24a61000
read(3, "import os\nos.listdir(\"/tmp\")\n\n", 4096) = 30
write(2, " ", 4 ) = 4
write(2, "os.listdir(\"/tmp\")\n", 19os.listdir("/tmp")
) = 19
close(3) = 0
munmap(0x7feb24a61000, 4096) = 0
write(2, "OSError", 7OSError) = 7
write(2, ": ", 2: ) = 2
write(2, "[Errno 2] No such file or direct"..., 43[Errno 2] No such file or directory: '/tmp') = 43
write(2, "\n", 1
) = 1
rt_sigaction(SIGINT, {SIG_DFL}, {0x4b8450, [], SA_RESTORER, 0x7feb245087d0}, 8) = 0
exit_group(1) = ?
Process 11879 detached
答案 0 :(得分:7)
这是由rootkit引起的。我只是在我管理的Debian(lenny)服务器上看同样的问题。看看strace的顶部:
open("/etc/ld.so.preload", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=22, ...}) = 0
mmap(NULL, 22, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = 0x7feb24b32000
close(3) = 0
open("/lib/libncom.so.4.0.1", O_RDONLY) = 3
libncom不应该在系统上。它隐藏了一些文件,包括它自己和/etc/ld.preload.so。 有一个错误是libncom(?)导致它为每个readdir返回ENOENT,这反过来导致python os.listdir()失败。没有它,我根本就不会注意到它。
据我所知,此类事情的最佳做法是取一份取证副本并重新安装。
答案 1 :(得分:1)
open("/etc/ld.so.preload", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=22, ...}) = 0
mmap(NULL, 22, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = 0x7feb24b32000
close(3) = 0
open("/lib/libncom.so.4.0.1", O_RDONLY) = 3
这是由rootkit引起的。 rootkit有一些bug。在受到这个rootkit的影响之后...你运行find / -name ls
...然后会显示一些错误:
find: /: No such file or directory
如何修复:
rm -rf \`cat /etc/ld.so.preload\` ; > /etc/ld.so.preload ; reboot
重启后......你会发现os.listdir()
工作.....