2019年8月11日 星期日

Run License Daemon on Solaris 10 Non-global Zone

Reference:
Dtrace Saves the Day
How to Use DTrace
Find Inode Of a File
Using DTrace to change OS version

狀況:
在 Solaris Zone 啟動 license daemon 時,Vendor daemon 有錯誤訊息
 7/05 14:17:03 (lmgrd) Started cdslmd
 7/05 14:17:03 (cdslmd) Cannot open daemon lock file
 7/05 14:17:03 (lmgrd) MULTIPLE "cdslmd" servers running.


解法:(參考 Dtrace Saves the Day)
1. 在 zone 啟用 dtrace 權限 (參考 How to Use DTrace) (PS: Solaris 10, 11 才有 dtrace)
2. 給特定帳號 dtrace 權限
=> echo “flexlm::::defaultpriv=basic,dtrace_user” >>/etc/user_attr
3. 製作 dtrace script 修正 inode 問題
=> 原作者少了黃色的部分
=> 找出 根目錄 / 的 .. 的 inode 指令 (參考 Find Inode Of a File)
指令:ls -ali /  (需要紅色框起來的 inode value)

#!/usr/sbin/dtrace -Cs
/* line 7 number must be be changed to the zonename and process name */
/* line 16 number must be be changed to the inode of root dir's .. */
#pragma D option destructive
#include <dirent.h>
syscall::getdents*:entry
/zonename == "zonename" && execname == "procname"/
{
        self->buf = arg1;
}
syscall::getdents*:return
/self->buf && arg1 > 0/
{
/* modify first entry of ls(1) getdents() */
this->dep = (struct dirent *)copyin(self->buf, sizeof (struct dirent));
this->dep->d_ino = 281374;
copyout(this->dep, self->buf, sizeof (struct dirent));
exit(0);
}
syscall::getdents*:return
/self->buf/
{
self->buf = 0;
}

4. 如果程式不支援 Solaris 5.10,再用 dtrace 暫時修改 uname (參考 Using DTrace to change OS version)
=> 原作者黃色的部分有筆誤

#!/usr/sbin/dtrace -qws
/* line 7 number must be be changed to the zonename and process name */
/* line 16 number changed to the version that you need */
#pragma D option destructive

syscall::uname:entry
/zonename == "zonename" && execname == "procname"/
{
        self->addr = arg0;
}
syscall::uname:return

/self->addr && arg0 > 0/
{
/* modify first entry of ls(1) getdents() */
copyoutstr("5.9", self->addr+(257*2), 257);
exit(0);
}

5. 用背景執行上面的(兩個) dtrace script,並等待 10 秒後,再啟動 license daemon。

沒有留言:

張貼留言