modify the sudoers file under etc directory
command
=================
sudo visudo
add the following line at the end of the file like for user saiful
saiful ALL=NOPASSWD: /usr/sbin/mkdir,/usr/sbin/touch
Category: Unix Server
Unix Server related all
MAC OS XのSIPを無効化する
https://book.mynavi.jp/macfan/detail_summary/id=44838
OS Xの最新バージョンエルキャピタンでは、SIP(System Integrity Protection)という新機能によってシステムが保護されている。これによってセキュリティは強固になるが、システムのライブラリなどをユーザ側で いじれなくなった。たとえばシステムアイコンの変更などができなくなったわけだが、どうしても変更したい場合のSIPの無効化方法をお伝えする。
今回はわかりやすい具体例として、「LiteIcon」というフリーのアイコン変更ソフトの挙動を見てみよう。SIPが有効な状態でLiteIconを起動しようとすると、以下のようなメッセージが表示される。
SIPが有効なのでシステムアイコンは変更できない、という内容だ。そのままLiteIconを動かすと変更対象にシステムアイコンがない状態となる。
さて、ここからが本題。SIPを無効にすればシステムアイコンは変更できる。まずはMacを再起動して起動時に[コマンド]キー+[R]キーを押しながら起動して、リカバリモードを立ち上げよう。
[ユーティリティ]メニューから[ターミナル]を選択し、
csrutil disable
とコマンドを入力して実行しよう。これでSIPは無効化される。
再起動後はこのように警告が表示されることもなく、システムアイコンの変更ができるようになっている。とはいえSIPを切りっぱなしではせっかくのシステ ム保護が意味を為さないので、一時的に無効化し、アイコンの変更などの必要な作業をしたら、再びSIPを有効にするのが良いだろう。有効にするには、同様 の手順でリカバリモードからターミナルに入った後に、
csrutil enable
と入力すれば良い。
Sending mail while user login and logout in MAC OS
Making postfix mail server start while MAC system startup
and Sending mail while user login and logout in MAC OS
=========================================================
vi /System/Library/LaunchDaemons/org.postfix.master.plist
Edit the file as bellow
————————
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
<key>Label</key>
<string>org.postfix.master</string>
<key>KeepAlive</key>
<true/>
<key>Program</key>
<string>/usr/libexec/postfix/master</string>
<key>ProgramArguments</key>
<array>
<string>master</string>
</array>
<key>QueueDirectories</key>
<array>
<string>/var/spool/postfix/maildrop</string>
</array>
<key>AbandonProcessGroup</key>
<true/>
</dict>
</plist>
Set load the file when MAC system starts up
——————————————-
launchctl load /System/Library/LanuchDaemons/org.postfix.master.plist
Create autodaily directory
————————–
mkdir /usr/libexec/autodaily
Create the log file
———————
vi /usr/libexec/autodaily/log.log
chmod 0777 log.log
Create autodailyLogin.sh and autodailyLogout.sh file
—————————————————-
cd /usr/libexec/autodaily/
vi autodailyLogin.sh
Enter the followings in the file
——————————–
#!/bin/bash
# Created by Saiful Takeshi
# Environment variables #################################################
DEST_EMAIL=”saiful_takeshi@number-1.co.jp,hanamitsu_makoto@number-1.co.jp”
USER_NAME=”CHUMAN SHOUHEI”
TODAY=$(date +%Y/%m/%d)
EVENT_TIME=$(date “+DATE: %Y-%m-%d%nTIME: %H:%M:%S”)
LOGGEDIN_SUBJECT=”[MAC Login] : $TODAY : $USER_NAME”
LOGGEDIN_BODY=”$USER_NAME has Logged In successfully at \n$EVENT_TIME.”
# Functions ##########
function loggedin(){
echo “$LOGGEDIN_BODY” | mail -s “$LOGGEDIN_SUBJECT” $DEST_EMAIL
return 0
}
loggedin;
echo “Login at $EVENT_TIME” >> log.log
Create autodailyLogin.sh and autodailyLogout.sh file
—————————————————-
vi /usr/libexec/autodaily/autodailyLogout.sh
Enter the followings in this file
————————————-
#!/bin/bash
# Created by Saiful Takeshi
# Environment variables #################################################
DEST_EMAIL=”saiful_takeshi@number-1.co.jp,hanamitsu_makoto@number-1.co.jp”
USER_NAME=”CHUMAN SHOUHEI”
TODAY=$(date +%Y/%m/%d)
#EVENT_TIME=$(date +%Y/%m/%d-%H:%M:%S)
EVENT_TIME=$(date “+DATE: %Y-%m-%d%nTIME: %H:%M:%S”)
LOGGEDOUT_SUBJECT=”[MAC Logout] : $TODAY : $USER_NAME”
LOGGEDOUT_BODY=”$USER_NAME san has Logged Out successfully at \n$EVENT_TIME.”
# Functions ##########
function loggedout(){
echo “$LOGGEDOUT_BODY” | mail -s “$LOGGEDOUT_SUBJECT” $DEST_EMAIL
return 0
}
loggedout;
echo “logout at $EVENT_TIME” >> log.log
Make both file as executable
———————————
chmod +x autodailyLogin.sh
chmod +x autodailyLogout.sh
Checking the script is ok or not(execute)
—————————————–
sh autodailyLogin.sh
sh autodailyLogout.sh
—————————–
Show the default setting for login and logout
———————————————
defaults read
Add the login hook event as execute the autodailyLogin.sh file when login
——————————————————————–
sudo defaults write com.apple.loginwindow LoginHook /usr/libexec/autodaily/autodailyLogin.sh
Add the logout hook event as execute the autodailyLogout.sh file when logout
——————————————————————–
sudo defaults write com.apple.loginwindow LogoutHook /usr/libexec/autodaily/autodailyLogout.sh
Now check the mac machine by login and logout
========================================
Summary command
========================================
#launch FTP
sudo launchctl load -w /System/Library/LaunchDaemons/ftp.plist
#copy postfix file
sudo cp /System/Library/LaunchDaemons/org.postfix.master.plist /System/Library/LaunchDaemons/org.postfix.master.plist_bk
#Edit postfix plist file
sudo vi /System/Library/LaunchDaemons/org.postfix.master.plist
#unload load postfix
sudo launchctl unload -w /System/Library/LaunchDaemons/org.postfix.master.plist
sudo launchctl load -w /System/Library/LaunchDaemons/org.postfix.master.plist
#autodailylogin.sh and autodailylogout.sh file
cd /usr/libexec
sudo mkdir autodaily
sudo chmod 0777 autodaily/
cd autodaily/
sudo chmod 0777 log.log
#edit files
sudo vi autodailylogin.sh
sudo vi autodailylogout.sh
#permission change to execute
sudo chmod +x autodailylogin.sh
sudo chmod +x autodailylogout.sh
Add the login hook event as execute the autodailyLogin.sh file when login
——————————————————————–
sudo defaults write com.apple.loginwindow LoginHook /usr/libexec/autodaily/autodailyLogin.sh
Add the logout hook event as execute the autodailyLogout.sh file when logout
——————————————————————–
sudo defaults write com.apple.loginwindow LogoutHook /usr/libexec/autodaily/autodailyLogout.sh