当我使用该id
命令时,它不会解析为用户名和组名(因为admin
它有效):
用户backup
和admin
:
backup
:
# id
uid=1005 gid=100 groups=100
admin
:
# id
uid=0(admin) gid=0(administrators) groups=0(administrators),100(everyone)
/etc/passwd
:
# cat /etc/passwd
admin:x:0:0:administrator:/share/homes/admin:/bin/sh
guest:x:65534:65534:guest:/share/homes/guest:/bin/sh
httpdusr:x:99:0:Apache httpd user:/share/homes/httpdusr:/bin/sh
backup:x:1005:100:Linux User,,,:/share/homes/backup:/bin/sh
sshd:x:501:501:Linux User,,,:/tmp:/bin/false
etc/passwd
权限看起来像这样:
# ls -l passwd
lrwxrwxrwx 1 admin administ 13 Mar 12 23:27 passwd -> config/passwd
# ls -l config/passwd
-rw-r--r-- 1 admin administ 519 Mar 6 09:55 config/passwd
# ls -l config
lrwxrwxrwx 1 admin administ 21 Apr 3 21:47 config -> /mnt/HDA_ROOT/.config/
# ls -ld /mnt/HDA_ROOT/.conf*
-rw-r--r-- 1 admin administ 274 Apr 3 21:47 /mnt/HDA_ROOT/.conf
drw-r--r-- 31 admin administ 4096 Apr 11 10:50 /mnt/HDA_ROOT/.config/
# ls -l /mnt/HDA_ROOT/.config/passwd
-rw-r--r-- 1 admin administ 519 Mar 6 09:55 /mnt/HDA_ROOT/.config/passwd
ls
也无法解析名称和组:
backup
:
# ls -l
lrwxrwxrwx 1 0 0 28 Feb 26 14:20 @Recycle -> /share/homes/@Recycle/backup
drwxr-xr-x 2 1005 100 4096 Apr 10 21:40 test
admin
:
# ls -l
lrwxrwxrwx 1 admin administ 28 Feb 26 14:20 @Recycle -> /share/homes/@Recycle/backup/
drwxr-xr-x 2 backup everyone 4096 Apr 10 21:40 test/
nsswitch.conf 看起来像这样:
# cat /etc/nsswitch.conf
passwd: compat winbind
shadow: compat
group: compat winbind
hosts: files dns wins
bootparams: files
ethers: files
netmasks: files
networks: files
protocols: files
rpc: files
services: files
netgroup: files
publickey: files
automount: files
aliases: files
原因可能是什么?
系统是QNAP,固件4.2.4,我相信这是基于busybox 1.x的。
编辑:看来我无法读取passwd
文件:
# su backup
# cat /mnt/HDA_ROOT/.config/passwd
cat: can't open '/mnt/HDA_ROOT/.config/passwd': Permission denied
不过权限好像没问题..
# su admin
# ls -l /mnt/HDA_ROOT/.config/passwd
-rw-r--r-- 1 admin administ 519 Mar 6 09:55 /mnt/HDA_ROOT/.config/passwd
答案1
您对该/mnt/HDA_ROOT/.config
目录的权限错误。以下是通往 的目录的正确权限集/etc/passwd
,取自我们此处的 QNAP:
drwxr-xr-x 18 admin administ 1024 Mar 17 16:28 /
drwxr-xr-x 24 admin administ 2048 Mar 18 03:00 /etc/
lrwxrwxrwx 1 admin administ 21 Mar 17 16:25 /etc/config -> /mnt/HDA_ROOT/.config/
-rw-r--r-- 1 admin administ 227 Feb 21 2016 /etc/config/passwd
drwxr-xr-x 30 admin administ 4096 Apr 11 04:00 /mnt/HDA_ROOT/.config/
与您的相比,您/mnt/HDA_ROOT/.config
缺少读取和执行权限。用这个命令修复
chmod a=rx,u+w /mnt/HDA_ROOT/.config # or chmod 755 ...
下次重新启动后,如果权限恢复到损坏的设置,并向 QNAP 技术支持提出请求,则值得关注这一点。