Example #1
0
import html
import cgi
import sys
import os
import funct
import sql

funct.head("Admin area: users manage")
funct.check_config()
funct.check_login()
funct.page_for_admin()

form = cgi.FieldStorage()

USERS = sql.select_users()
GROUPS = sql.select_groups()
SERVERS = sql.select_servers(full=1)
ROLES = sql.select_roles()

print('<script src="/inc/users.js"></script>'
	'<div id="tabs">'
			'<ul>'
				'<li><a href="#users">Users</a></li>'
				'<li><a href="#groups">Groups</a></li>'
				'<li><a href="#servers">Servers</a></li>'
				'<li><a href="#roles">Roles</a></li>'
			'</ul>'
			'<div id="users">'
				'<table class="overview" id="ajax-users">'
					'<tr class="overviewHead">'
						'<td class="padding10 first-collumn">Login name</td>'
Example #2
0
import os, http.cookies
import cgi
from jinja2 import Environment, FileSystemLoader

env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('hapservers.html')

print('Content-type: text/html\n')
funct.check_login()

try:
    cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
    user_id = cookie.get('uuid')
    user = sql.get_user_name_by_uuid(user_id.value)
    users = sql.select_users()
    groups = sql.select_groups()
    token = sql.get_token(user_id.value)
    cmd = "ps ax |grep -e 'keep_alive.py' |grep -v grep |wc -l"
    keep_alive, stderr = funct.subprocess_execute(cmd)
except:
    pass

form = cgi.FieldStorage()
serv = form.getvalue('serv')

if serv:
    servers = sql.select_servers(server=serv)
    autorefresh = 1
    hap_configs_dir = funct.get_config_var('configs',
                                           'haproxy_save_configs_dir')
else:
Example #3
0
	role = form.getvalue('newrole')
	group = form.getvalue('newgroupuser')
	new_user = form.getvalue('newusername')	
	page = form.getvalue('page')	
	activeuser = form.getvalue('activeuser')	
	role_id = sql.get_role_id_by_name(role)
	
	if sql.check_group(group, role_id):
		if funct.is_admin(level=role_id):
			if sql.add_user(new_user, email, password, role, group, activeuser):
				from jinja2 import Environment, FileSystemLoader
				env = Environment(loader=FileSystemLoader('templates/'))
				template = env.get_template('ajax/new_user.html')

				template = template.render(users=sql.select_users(user=new_user),
											groups=sql.select_groups(),
											page=page,
											roles=sql.select_roles())
				print(template)
				funct.logging('a new user '+new_user, ' has created ', haproxywi=1, login=1)
		else:
			funct.logging(new_user, ' tried to privilege escalation', haproxywi=1, login=1)
			
			
if form.getvalue('userdel') is not None:
	userdel = form.getvalue('userdel')
	user = sql.select_users(id=userdel)
	for u in user:
		username = u[1]
	if sql.delete_user(userdel):
		funct.logging(username, ' has deleted user ', haproxywi=1, login=1)