mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Merge branch 'bug-2257'
This commit is contained in:
commit
a4fcbef2a4
12
share/pkgs/CentOS/opennebula.sudoers
Normal file
12
share/pkgs/CentOS/opennebula.sudoers
Normal file
@ -0,0 +1,12 @@
|
||||
Defaults !requiretty
|
||||
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
Cmnd_Alias ONE_MISC = /bin/dd, /sbin/mkfs, /bin/sync
|
||||
Cmnd_Alias ONE_NET = /usr/sbin/brctl, /sbin/ebtables, /sbin/iptables, /sbin/ip, /sbin/vconfig
|
||||
Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay
|
||||
Cmnd_Alias ONE_ISCSI = /sbin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm
|
||||
Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl
|
||||
Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm
|
||||
|
||||
oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN
|
||||
|
11
share/pkgs/Debian/opennebula.sudoers
Normal file
11
share/pkgs/Debian/opennebula.sudoers
Normal file
@ -0,0 +1,11 @@
|
||||
Defaults !requiretty
|
||||
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
Cmnd_Alias ONE_MISC = /bin/dd, /sbin/mkfs, /bin/sync
|
||||
Cmnd_Alias ONE_NET = /sbin/brctl, /sbin/ebtables, /sbin/iptables, /sbin/ip, /sbin/vconfig
|
||||
Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay
|
||||
Cmnd_Alias ONE_ISCSI = /usr/bin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm
|
||||
Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl
|
||||
Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm
|
||||
|
||||
oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN
|
11
share/pkgs/Ubuntu/opennebula.sudoers
Normal file
11
share/pkgs/Ubuntu/opennebula.sudoers
Normal file
@ -0,0 +1,11 @@
|
||||
Defaults !requiretty
|
||||
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
Cmnd_Alias ONE_MISC = /bin/dd, /sbin/mkfs, /bin/sync
|
||||
Cmnd_Alias ONE_NET = /sbin/brctl, /sbin/ebtables, /sbin/iptables, /sbin/ip, /sbin/vconfig
|
||||
Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay
|
||||
Cmnd_Alias ONE_ISCSI = /usr/bin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm
|
||||
Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl
|
||||
Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm
|
||||
|
||||
oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN
|
11
share/pkgs/openSUSE/opennebula.sudoers
Normal file
11
share/pkgs/openSUSE/opennebula.sudoers
Normal file
@ -0,0 +1,11 @@
|
||||
Defaults !requiretty
|
||||
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
Cmnd_Alias ONE_MISC = /usr/bin/dd, /sbin/mkfs, /usr/bin/sync
|
||||
Cmnd_Alias ONE_NET = /sbin/brctl, /usr/sbin/ebtables, /usr/sbin/iptables, /sbin/ip, /sbin/vconfig
|
||||
Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay
|
||||
Cmnd_Alias ONE_ISCSI = /sbin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm
|
||||
Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl
|
||||
Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm
|
||||
|
||||
oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN
|
71
share/sudoers/sudo_commands.rb
Normal file
71
share/sudoers/sudo_commands.rb
Normal file
@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require "erb"
|
||||
|
||||
KEYS = [:MISC , :NET , :LVM , :ISCSI , :OVS , :XEN]
|
||||
|
||||
CMDS = {
|
||||
:MISC => %w(dd mkfs sync),
|
||||
:NET => %w(brctl ebtables iptables ip vconfig),
|
||||
:LVM => %w(lvcreate lvremove lvrename lvs vgdisplay),
|
||||
:ISCSI => %w(iscsiadm tgt-admin tgtadm),
|
||||
:OVS => %w(ovs-ofctl ovs-vsctl),
|
||||
:XEN => %w(xentop xl xm)
|
||||
}
|
||||
|
||||
abs_cmds = {}
|
||||
not_found_cmds = []
|
||||
|
||||
KEYS.each do |label|
|
||||
cmds = CMDS[label]
|
||||
|
||||
_abs_cmds = []
|
||||
cmds.each do |cmd|
|
||||
abs_cmd = `which #{cmd} 2>/dev/null`
|
||||
|
||||
if !abs_cmd.empty?
|
||||
_abs_cmds << abs_cmd.strip
|
||||
else
|
||||
not_found_cmds << cmd
|
||||
end
|
||||
end
|
||||
|
||||
abs_cmds["ONE_#{label}"] = _abs_cmds
|
||||
end
|
||||
|
||||
abs_cmds.reject!{|k,v| v.empty?}
|
||||
|
||||
puts ERB.new(DATA.read,nil, "<>").result(binding)
|
||||
|
||||
if !not_found_cmds.empty?
|
||||
STDERR.puts "\n---\n\nNot found:"
|
||||
not_found_cmds.each{|cmd| STDERR.puts("- #{cmd}")}
|
||||
end
|
||||
|
||||
__END__
|
||||
Defaults !requiretty
|
||||
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
<% KEYS.each do |k|; l = "ONE_#{k}"; v = abs_cmds[l] %>
|
||||
<% if !v.nil? %>
|
||||
Cmnd_Alias <%= l %> = <%= v.join(", ") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
oneadmin ALL=(ALL) NOPASSWD: <%= KEYS.select{|k| !abs_cmds["ONE_#{k}"].nil?}.collect{|k| "ONE_#{k}"}.join(", ") %>
|
@ -30,16 +30,16 @@ CONF = {
|
||||
}
|
||||
|
||||
COMMANDS = {
|
||||
:ebtables => "sudo /sbin/ebtables",
|
||||
:iptables => "sudo /sbin/iptables",
|
||||
:brctl => "sudo /sbin/brctl",
|
||||
:ip => "sudo /sbin/ip",
|
||||
:vconfig => "sudo /sbin/vconfig",
|
||||
:ebtables => "sudo ebtables",
|
||||
:iptables => "sudo iptables",
|
||||
:brctl => "sudo brctl",
|
||||
:ip => "sudo ip",
|
||||
:vconfig => "sudo vconfig",
|
||||
:virsh => "virsh -c qemu:///system",
|
||||
:xm => "sudo /usr/sbin/xm",
|
||||
:ovs_vsctl=> "sudo /usr/bin/ovs-vsctl",
|
||||
:ovs_ofctl=> "sudo /usr/bin/ovs-ofctl",
|
||||
:lsmod => "/sbin/lsmod"
|
||||
:xm => "sudo xm",
|
||||
:ovs_vsctl=> "sudo ovs-vsctl",
|
||||
:ovs_ofctl=> "sudo ovs-ofctl",
|
||||
:lsmod => "lsmod"
|
||||
}
|
||||
|
||||
class VM
|
||||
|
Loading…
x
Reference in New Issue
Block a user