Environment-Variables

為什麼 uname -M 返回一個空字元串?

  • April 22, 2013

在完全相同的機器(AIX 6.1)上,在 2 個不同的登錄 shell(都是 ksh)中,使用不同的使用者 ID,我可以這樣做uname -M;在一個外殼中,我得到了系統模型。在另一個外殼中,我得到了空白!唯一的區別是使用者 ID 和環境。我不能把環境放在這裡。

範例使用者 1 外殼:

$ uname -M
IBM,1234-567
$

範例使用者 2 外殼:

$ 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 為空白?哪些環境變數會影響這一點?

我得到了它。我正在掃描“好”環境並看到了這個環境變數:

export ODMDIR=/etc/objrepos

知道“好桁架”在這裡尋找機器型號,我在壞殼中執行了這個命令,現在 uname -M 工作:

$ uname -M
IBM,1234-567

對不起,我沒有發布環境,但它很大並且包含很多敏感資訊。

引用自:https://unix.stackexchange.com/questions/73045