Solaris 10 root轉換成角色後權限的測試

上篇提到root轉換成角色後,無論遠端、本機皆無法登入,
可以提高系統的安全,而且Solaris的角色有另一個特色,
並非帳號授予root角色,該帳號就擁有root角色的權限,
而是讓帳號擁有切換到root角色的權限,下面就來測試看看。

以一般帳號登入Solaris
$ id
uid=102(keven) gid=1(other)

查看帳號擁有那些角色
$ roles
root

在/etc新增一個空白的文件,結果權限不足,
所以並非擁有root角色就等於該帳號擁有root權限
$ touch /etc/cc.txt
touch: cannot create /etc/cc.txt: Permission denied

接著利用排程來測試root角色及一般帳號的差異
$ at 14:00 Apr 14
at> touch /etc/bb.txt
at> <EOT>
commands will be executed using /bin/sh
job 1428991200.a at Tue Apr 14 14:00:00 2015

因為keven帳號有授權root角色,所以可以切換到root
$ su - root
Password:
Oracle Corporation SunOS 5.10 Generic Patch January 2005
# at 14:00 Apr 14
at> touch /etc/aa.txt
at> <EOT>
commands will be executed using /sbin/sh
job 1428991201.a at Tue Apr 14 14:00:00 2015

時間到了14:00,觀察一下結果。

只有在root角色下的排程有完成新增文件的目的
$ ls /etc/aa.txt
/etc/aa.txt
$ ls /etc/bb.txt
/etc/bb.txt: No such file or directory


查看log可以發現root、keven兩個排程都有正確被執行,
但是非root角色執行完後卻回傳錯誤碼rc=1
>  CMD: 1428991200.a
>  keven 28140 a Tue Apr 14 14:00:00 2015
<  keven 28140 a Tue Apr 14 14:00:00 2015 rc=1
>  CMD: 1428991201.a
>  root 28151 a Tue Apr 14 14:00:01 2015
<  root 28151 a Tue Apr 14 14:00:01 2015

Windows 11安裝時跳過網路連線