"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cobbler/modules/authz_configfile.py" between
cobbler-2.8.4.tar.gz and cobbler-3.0.0.tar.gz

About: cobbler is a Linux installation and deployment server that allows for rapid setup of network installation environments. It can help with installation, DNS, DHCP, package updates, power management, configuration management orchestration, and much more.

authz_configfile.py  (cobbler-2.8.4):authz_configfile.py  (cobbler-3.0.0)
skipping to change at line 16 skipping to change at line 16
This software may be freely redistributed under the terms of the GNU This software may be freely redistributed under the terms of the GNU
general public license. general public license.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA. 02110-1301 USA.
""" """
import ConfigParser from future import standard_library
standard_library.install_aliases()
from builtins import str
from configparser import SafeConfigParser
import os import os
CONFIG_FILE='/etc/cobbler/users.conf' CONFIG_FILE = '/etc/cobbler/users.conf'
def register(): def register():
""" """
The mandatory cobbler module registration hook. The mandatory cobbler module registration hook.
""" """
return "authz" return "authz"
def __parse_config(): def __parse_config():
if not os.path.exists(CONFIG_FILE): if not os.path.exists(CONFIG_FILE):
return [] return []
config = ConfigParser.SafeConfigParser() config = SafeConfigParser()
config.read(CONFIG_FILE) config.read(CONFIG_FILE)
alldata = {} alldata = {}
groups = config.sections() groups = config.sections()
for g in groups: for g in groups:
alldata[str(g)] = {} alldata[str(g)] = {}
opts = config.options(g) opts = config.options(g)
for o in opts: for o in opts:
alldata[g][o] = 1 alldata[g][o] = 1
return alldata return alldata
def authorize(api_handle,user,resource,arg1=None,arg2=None): def authorize(api_handle, user, resource, arg1=None, arg2=None):
""" """
Validate a user against a resource. Validate a user against a resource.
All users in the file are permitted by this module. All users in the file are permitted by this module.
""" """
# FIXME: this must be modified to use the new ACL engine # FIXME: this must be modified to use the new ACL engine
data = __parse_config() data = __parse_config()
for g in data: for g in data:
if user.lower() in data[g]: if user.lower() in data[g]:
return 1 return 1
return 0 return 0
if __name__ == "__main__": if __name__ == "__main__":
print __parse_config() print((__parse_config()))
 End of changes. 8 change blocks. 
10 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)