mirror of https://github.com/jumpserver/jumpserver
fix sudo bug
parent
a73fa7811c
commit
08cbaa1622
|
@ -701,7 +701,7 @@ class Nav(object):
|
|||
break
|
||||
|
||||
if not file_path:
|
||||
print "文件路径为空"
|
||||
color_print("文件路径为空")
|
||||
continue
|
||||
|
||||
runner.run('fetch', module_args='src=%s dest=%s' % (file_path, tmp_dir), pattern=pattern)
|
||||
|
|
|
@ -5,15 +5,15 @@ real_file=/etc/sudoers
|
|||
tmp_file=$(mktemp /tmp/XXXXXXX)
|
||||
|
||||
# Backup sudoers file
|
||||
cp ${sudo_file} ${sudo_file_bak}
|
||||
cp ${real_file} ${tmp_file}
|
||||
|
||||
# Add Command Aliases
|
||||
add_cmd_alias() {
|
||||
sudo_file=$1
|
||||
{% for sudo_name, sudo_cmd in sudo_alias.items %}
|
||||
{% if sudo_name != 'ALL' %}
|
||||
if $(grep '^Cmnd_Alias {{ sudo_name }}' ${sudo_file} &> /dev/null); then
|
||||
sed -i 's@^Cmnd_Alias.*{{ sudo_name }}.*@Cmnd_Alias {{ sudo_name }} = {{ sudo_cmd }}@g' ${sudo_file}
|
||||
if $(grep '^Cmnd_Alias \<{{ sudo_name }}\>' ${sudo_file} &> /dev/null); then
|
||||
sed -i 's@^Cmnd_Alias \<{{ sudo_name }}\>.*@Cmnd_Alias {{ sudo_name }} = {{ sudo_cmd }}@g' ${sudo_file}
|
||||
else
|
||||
echo "Cmnd_Alias {{ sudo_name }} = {{ sudo_cmd }}" >> ${sudo_file}
|
||||
fi
|
||||
|
@ -26,8 +26,8 @@ add_cmd_alias() {
|
|||
add_role_chosen() {
|
||||
sudo_file=$1
|
||||
{% for user, alias in sudo_user.items %}
|
||||
if $(grep '^{{ user }}.*' ${sudo_file} &> /dev/null); then
|
||||
sed -i 's@^{{ user }}.*@{{ user }} ALL = (root) NOPASSWD: {{ alias }}@g' ${sudo_file}
|
||||
if $(grep '^{{ user }}\>' ${sudo_file} &> /dev/null); then
|
||||
sed -i 's@^{{ user }}\>.*@{{ user }} ALL = (root) NOPASSWD: {{ alias }}@g' ${sudo_file}
|
||||
else
|
||||
echo "{{ user }} ALL = (root) NOPASSWD: {{ alias }}" >> ${sudo_file}
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue