为什么 uname -M 返回空字符串?

为什么 uname -M 返回空字符串?

在同一台机器(AIX 6.1)上,在 2 个不同的登录 shell(都是 ksh)中,使用不同的用户 ID,我可以这样做uname -M;在一个 shell 中我得到了系统模型。在另一个外壳中我得到空白!唯一的区别是用户 ID 以及环境。我不能把环境放在这里。

用户 1 Shell 示例:

$ uname -M
IBM,1234-567
$

用户 2 Shell 示例:

$ uname -M

$

我在两个壳上都做了桁架。有区别,但我不明白。这是坏的桁架:

truss uname -M
.. a bunch of execve's ripped out as it was searching the PATH for uname.
execve("/bin/uname", 0x2FF2155C, 0x20012EF8)     argc: 2
__loadx(0x03480000, 0x2FF21380, 0x00000108, 0xF0713968, 0x20000CD0) = 0x00000000
__loadx(0x0A040000, 0xD042D064, 0x0000008A, 0x20001254, 0x00000000) = 0x00000000
sbrk(0x00000000)                                = 0x200013D0
vmgetinfo(0x2FF20530, 7, 16)                    = 0
sbrk(0x00000000)                                = 0x200013D0
__libc_sbrk(0x00000000)                         = 0x200013D0
getuidx(4)                                      = 28633
getuidx(2)                                      = 28633
getuidx(1)                                      = 28633
getgidx(4)                                      = 100
getgidx(2)                                      = 100
getgidx(1)                                      = 100
getuidx(4)                                      = 28633
getuidx(2)                                      = 28633
getuidx(1)                                      = 28633
getgidx(4)                                      = 100
getgidx(2)                                      = 100
getgidx(1)                                      = 100
__loadx(0x01480080, 0x2FF1FEF0, 0x00000A50, 0x2FF20A60, 0x2FF22ED1) = 0xD0538128
__loadx(0x01480180, 0x2FF1FEF0, 0x00000A50, 0xF068921C, 0xF068914C) = 0xF0759FA0
__loadx(0x07080000, 0xF06891EC, 0xFFFFFFFF, 0xF0759FA0, 0x00000000) = 0xF075AF3C
__loadx(0x07080000, 0xF068912C, 0xFFFFFFFF, 0xF0759FA0, 0x00000000) = 0xF075AF48
__loadx(0x07080000, 0xF06891FC, 0xFFFFFFFF, 0xF0759FA0, 0x00000000) = 0xF075AF78
__loadx(0x07080000, 0xF068913C, 0xFFFFFFFF, 0xF0759FA0, 0x00000000) = 0xF075AF84
__loadx(0x07080000, 0xF06891BC, 0xFFFFFFFF, 0xF0759FA0, 0x00000000) = 0xF075AF54
__loadx(0x07080000, 0xF068915C, 0xFFFFFFFF, 0xF0759FA0, 0x00000000) = 0xF075AF6C
__loadx(0x07080000, 0xF06891CC, 0xFFFFFFFF, 0xF0759FA0, 0x00000000) = 0xF075AF90
__loadx(0x07080000, 0xF06891DC, 0xFFFFFFFF, 0xF0759FA0, 0x00000000) = 0xF075AFC0
__loadx(0x07080000, 0xF068916C, 0xFFFFFFFF, 0xF0759FA0, 0x00000000) = 0xF075AFA8
__loadx(0x07080000, 0xF068917C, 0xFFFFFFFF, 0xF0759FA0, 0x00000000) = 0xF075B020
getuidx(4)                                      = 28633
getuidx(2)                                      = 28633
getuidx(1)                                      = 28633
getgidx(4)                                      = 100
getgidx(2)                                      = 100
getgidx(1)                                      = 100
__loadx(0x01480080, 0x2FF1FEF0, 0x00000A50, 0x2FF20A60, 0x2FF22ED1) = 0xD0538128
getuidx(4)                                      = 28633
getuidx(2)                                      = 28633
getuidx(1)                                      = 28633
getgidx(4)                                      = 100
getgidx(2)                                      = 100
getgidx(1)                                      = 100
__loadx(0x01480080, 0x2FF1FEF0, 0x00000A50, 0x2FF20A60, 0x2FF22ED1) = 0xD0538128
getuidx(4)                                      = 28633
getuidx(2)                                      = 28633
getuidx(1)                                      = 28633
getgidx(4)                                      = 100
getgidx(2)                                      = 100
getgidx(1)                                      = 100
__loadx(0x01480080, 0x2FF1FEF0, 0x00000A50, 0x2FF20A60, 0x2FF22ED1) = 0xD0538128
getuidx(4)                                      = 28633
getuidx(2)                                      = 28633
getuidx(1)                                      = 28633
getgidx(4)                                      = 100
getgidx(2)                                      = 100
getgidx(1)                                      = 100
__loadx(0x01480080, 0x2FF1FEF0, 0x00000A50, 0x2FF20A60, 0x2FF22ED1) = 0xD0538128
access("/usr/lib/nls/msg/en_US/uname.cat", 0)   = 0
_getpid()                                       = 7405946
uname(0x2000132C)                               = 0
statx("CuAt", 0x2FF20870, 76, 0)                Err#2  ENOENT
kopen("CuAt", O_RDONLY)                         Err#2  ENOENT
kioctl(1, 22528, 0x00000000, 0x00000000)        = 0

kwrite(1, "\n", 1)                              = 1
__loadx(0x04000000, 0x2FF20970, 0x00000800, 0x0000D032, 0x00000000) = 0x00000000
kfcntl(1, F_GETFL, 0x00000001)                  = 67110914
kfcntl(2, F_GETFL, 0x2FF22FFC)                  = 67110914
_exit(0)

您可以看到kwrite最后仅打印出换行符"\n"

在良好的 truss 输出中,看起来 uname 正在从以下位置获取属性:

/etc/objrepos/CuAt

这引导我到lsattr命令及其他

为什么 uname -M 为空?什么环境变量会影响这个?

答案1

我得到了它。我正在扫描“良好”环境并看到这个环境变量:

export ODMDIR=/etc/objrepos

知道“好桁架”正在此处查找机器型号,我在坏 shell 中运行了此命令,现在 uname -M 可以工作:

$ uname -M
IBM,1234-567

抱歉我没有发布环境,但它很大并且包含很多敏感信息。

相关内容