Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuler committed Feb 23, 2016
2 parents 2691cc0 + 09e86f0 commit 18e66f5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions templates/jperm/role_sudo.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 18e66f5

Please sign in to comment.