Browse Source

some bug fix

pull/26/head
广宏伟 9 years ago
parent
commit
b8ae0ed565
  1. 5
      docs/requirements.txt
  2. 1
      jperm/views.py
  3. 4
      jumpserver.conf
  4. BIN
      jumpserver/templatetags/__init__.pyc
  5. 107
      jumpserver/templatetags/mytags.py
  6. 48
      juser/user_api.py

5
docs/requirements.txt

@ -6,4 +6,7 @@ paramiko==1.15.2
ecdsa==0.13
MySQL-python==1.2.5
django-uuidfield==0.5.0
psutil==2.2.1
psutil==2.2.1
xlsxwriter==0.7.7
xlrd==0.9.4
django-bootstrap-form

1
jperm/views.py

@ -76,7 +76,6 @@ def perm_rule_detail(request):
return my_render('jperm/perm_rule_detail.html', render_data, request)
@require_role('admin')
def perm_rule_add(request):
"""

4
jumpserver.conf

@ -9,11 +9,11 @@ log = debug
host = 127.0.0.1
port = 3306
user = jumpserver
password =mysql1234
password = mysql234
database = jumpserver
[websocket]
web_socket_host = 127.0.0.1:3000
web_socket_host = j:3000
[mail]
mail_enable = 1

BIN
jumpserver/templatetags/__init__.pyc

Binary file not shown.

107
jumpserver/templatetags/mytags.py

@ -182,102 +182,17 @@ def asset_which_group(asset, member):
names = [members.name for members in member.all()]
return ','.join(names)
#
#
# @register.filter(name='get_user_asset_group')
# def get_user_asset_group(user):
# return user.get_asset_group()
#
#
# @register.filter(name='group_asset_list')
# def group_asset_list(group):
# return group.asset_set.all()
#
#
# @register.filter(name='group_asset_list_count')
# def group_asset_list_count(group):
# return group.asset_set.all().count()
#
#
# @register.filter(name='time_delta')
# def time_delta(time_before):
# delta = datetime.datetime.now() - time_before
# days = delta.days
# if days:
# return "%s 天前" % days
# else:
# hours = delta.seconds/3600
# if hours:
# return "%s 小时前" % hours
# else:
# mins = delta.seconds/60
# if mins:
# return '%s 分钟前' % mins
# else:
# return '%s 秒前' % delta.seconds
#
#
# @register.filter(name='sudo_cmd_list')
# def sudo_cmd_list(cmd_group_id):
# cmd_group = CmdGroup.objects.filter(id=cmd_group_id)
# if cmd_group:
# cmd_group = cmd_group[0]
# return cmd_group.cmd.split(',')
#
#
# @register.filter(name='sudo_cmd_count')
# def sudo_cmd_count(user_group_id):
# user_group = UserGroup.objects.filter(id=user_group_id)
# cmds = []
# if user_group:
# user_group = user_group[0]
# cmd_groups = []
#
# for perm in user_group.sudoperm_set.all():
# cmd_groups.extend(perm.cmd_group.all())
#
# for cmd_group in cmd_groups:
# cmds.extend(cmd_group.cmd.split(','))
# return len(set(cmds))
#
# else:
# return 0
#
#
# @register.filter(name='sudo_cmd_count')
# def sudo_cmd_count(user_group_id):
# user_group = UserGroup.objects.filter(id=user_group_id)
# cmds = []
# if user_group:
# user_group = user_group[0]
# cmd_groups = []
# for perm in user_group.sudoperm_set.all():
# cmd_groups.extend(perm.cmd_group.all())
#
# for cmd_group in cmd_groups:
# cmds.extend(cmd_group.cmd.split(','))
# return len(set(cmds))
# else:
# return 0
#
#
# @register.filter(name='sudo_cmd_ids')
# def sudo_cmd_ids(user_group_id):
# user_group = UserGroup.objects.filter(id=user_group_id)
# if user_group:
# user_group = user_group[0]
# cmd_groups = []
# for perm in user_group.sudoperm_set.all():
# cmd_groups.extend(perm.cmd_group.all())
# cmd_ids = [str(cmd_group.id) for cmd_group in cmd_groups]
# return ','.join(cmd_ids)
# else:
# return '0'
#
#
# @register.filter(name='cmd_group_split')
# def cmd_group_split(cmd_group):
# return cmd_group.cmd.split(',')
@register.filter(name='group_str2')
def groups_str2(group_list):
"""
将用户组列表转换为str
"""
if len(group_list) < 3:
return ' '.join([group.name for group in group_list])
else:
return '%s ...' % ' '.join([group.name for group in group_list[0:2]])
@register.filter(name='str_to_list')

48
juser/user_api.py

@ -132,7 +132,7 @@ def gen_ssh_key(username, password='',
if authorized_keys:
auth_key_dir = os.path.join(home, username, '.ssh')
is_dir(auth_key_dir, username, mode=0700)
mkdir(auth_key_dir, username, mode=0700)
authorized_key_file = os.path.join(auth_key_dir, 'authorized_keys')
with open(private_key_file+'.pub') as pub_f:
with open(authorized_key_file, 'w') as auth_f:
@ -203,49 +203,3 @@ def get_display_msg(user, password, ssh_key_pwd, ssh_key_login_need, send_mail_n
return msg
# def ldap_add_user(username, ldap_pwd):
# """
# add a user in ldap database
# 在LDAP中添加用户
# """
# user_dn = "uid=%s,ou=People,%s" % (username, LDAP_BASE_DN)
# password_sha512 = PyCrypt.gen_sha512(PyCrypt.random_pass(6), ldap_pwd)
# user = get_object(User, username=username)
# if not user:
# raise ServerError(u'用户 %s 不存在' % username)
#
# user_attr = {'uid': [str(username)],
# 'cn': [str(username)],
# 'objectClass': ['account', 'posixAccount', 'top', 'shadowAccount'],
# 'userPassword': ['{crypt}%s' % password_sha512],
# 'shadowLastChange': ['16328'],
# 'shadowMin': ['0'],
# 'shadowMax': ['99999'],
# 'shadowWarning': ['7'],
# 'loginShell': ['/bin/bash'],
# 'uidNumber': [str(user.id)],
# 'gidNumber': [str(user.id)],
# 'homeDirectory': [str('/home/%s' % username)]}
#
# group_dn = "cn=%s,ou=Group,%s" % (username, LDAP_BASE_DN)
# group_attr = {'objectClass': ['posixGroup', 'top'],
# 'cn': [str(username)],
# 'userPassword': ['{crypt}x'],
# 'gidNumber': [str(user.id)]}
#
# ldap_conn.add(user_dn, user_attr)
# ldap_conn.add(group_dn, group_attr)
# def ldap_del_user(username):
# """
# delete a user in ldap database
# 在ldap中删除某用户
# """
# user_dn = "uid=%s,ou=People,%s" % (username, LDAP_BASE_DN)
# group_dn = "cn=%s,ou=Group,%s" % (username, LDAP_BASE_DN)
# sudo_dn = 'cn=%s,ou=Sudoers,%s' % (username, LDAP_BASE_DN)
#
# ldap_conn.delete(user_dn)
# ldap_conn.delete(group_dn)
# ldap_conn.delete(sudo_dn)
Loading…
Cancel
Save