Commit 3b5daf19 authored by yumaojun's avatar yumaojun

1. 修复freebsd 推送带sudo规则的用户时 , sudo 路径引发的问题。

parent 4645029a
......@@ -4,6 +4,13 @@
real_file=/etc/sudoers
tmp_file=$(mktemp /tmp/XXXXXXX)
# fixed sudoers file path in bsd
isbsd=$(uname -a | grep -i 'freebsd' &> /dev/null && echo "yes" || echo "no")
if [ $isbsd == "yes" ]; then
real_file=/usr/local/etc/sudoers
fi
# Backup sudoers file
cp ${real_file} ${tmp_file}
......@@ -13,7 +20,6 @@ add_cmd_alias() {
{% for sudo_name, sudo_cmd in sudo_alias.items %}
{% if sudo_name != 'ALL' %}
if $(grep '^Cmnd_Alias \<{{ sudo_name }}\>' ${sudo_file} &> /dev/null); then
isbsd=$(uname -a | grep -i 'freebsd' &> /dev/null && echo "yes" || echo "no")
if [ $isbsd == "yes" ]; then
sed -i .bk 's@^Cmnd_Alias \<{{ sudo_name }}\>.*@Cmnd_Alias {{ sudo_name }} = {{ sudo_cmd }}@g' ${sudo_file}
else
......@@ -32,7 +38,6 @@ add_role_chosen() {
sudo_file=$1
{% for user, alias in sudo_user.items %}
if $(grep '^{{ user }}\>' ${sudo_file} &> /dev/null); then
isbsd=$(uname -a | grep -i 'freebsd' &> /dev/null && echo "yes" || echo "no")
if [ $isbsd == "yes" ]; then
sed -i .bk 's@^{{ user }}\>.*@{{ user }} ALL = (root) NOPASSWD: {{ alias }}@g' ${sudo_file}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment