mirror of https://github.com/jumpserver/jumpserver
修改配置文件为相对路径,不用再指定目录了
parent
838b10d3b6
commit
54da30d93b
|
@ -0,0 +1,7 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="Project Default" />
|
||||
<option name="myLocal" value="false" />
|
||||
<inspection_tool class="SqlDialectInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
|
@ -0,0 +1,7 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="PROJECT_PROFILE" value="Project Default" />
|
||||
<option name="USE_PROJECT_PROFILE" value="true" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
|
@ -2,7 +2,7 @@
|
|||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 2.7.6 (C:/Python27/python.exe)" jdkType="Python SDK" />
|
||||
<orderEntry type="jdk" jdkName="Python 2.7.8 (C:\Python27\python.exe)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
#!/usr/bin/python
|
||||
# coding: utf-8
|
||||
|
||||
cur_dir = os.path.dirname(__file__)
|
||||
sys.path.append('%s/webroot/AutoSA/' % cur_dir)
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'AutoSa.settings'
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import MySQLdb
|
||||
import pexpect
|
||||
import struct
|
||||
import fcntl
|
||||
import termios
|
||||
|
@ -17,10 +20,11 @@ from binascii import b2a_hex, a2b_hex
|
|||
import ConfigParser
|
||||
import paramiko
|
||||
import pxssh
|
||||
from UserManage.models import User
|
||||
|
||||
|
||||
base_dir = "/opt/jumpserver/"
|
||||
cf = ConfigParser.ConfigParser()
|
||||
cf.read('%s/jumpserver.conf' % base_dir)
|
||||
cf.read('%s/jumpserver.conf' % cur_dir)
|
||||
|
||||
db_host = cf.get('db', 'host')
|
||||
db_port = cf.getint('db', 'port')
|
||||
|
@ -34,6 +38,8 @@ assets_user_table = cf.get('jumpserver', 'assets_user_table')
|
|||
key = cf.get('jumpserver', 'key')
|
||||
|
||||
|
||||
|
||||
|
||||
class PyCrypt(object):
|
||||
"""It's used to encrypt and decrypt password."""
|
||||
def __init__(self, key):
|
||||
|
@ -112,8 +118,11 @@ def connect(host, port, user, password):
|
|||
log_date_dir = '%s/%s' % (log_dir, time.strftime('%Y%m%d'))
|
||||
if not os.path.isdir(log_date_dir):
|
||||
os.mkdir(log_date_dir)
|
||||
logfile = open("%s/%s_%s" % (log_date_dir, host, user), 'a')
|
||||
logfile.write('\n\n%s\n\n' % time.strftime('%Y%m%d_%H%M%S'))
|
||||
logfile = open("%s/%s_%s_%s" % (log_date_dir, host, user, time.strftime('%Y%m%d%H%M%S')), 'a')
|
||||
db, cursor = connect_db(db_user, db_password, db_db, db_host, db_port)
|
||||
cursor.execute('insert into logs (Fuser, Fhost, Flogfile, Fstart_time) value (%s, %s, %s, UNIX_TIMESTAMP())'
|
||||
% (user, host, logfile))
|
||||
logfile.write('\n%s\n' % time.strftime('%Y/%m/%d %H:%M:%S'))
|
||||
try:
|
||||
global foo
|
||||
foo = pxssh.pxssh()
|
||||
|
@ -122,10 +131,13 @@ def connect(host, port, user, password):
|
|||
foo.sendline('')
|
||||
signal.signal(signal.SIGWINCH, sigwinch_passthrough)
|
||||
foo.interact(escape_character=chr(28))
|
||||
cursor.execute('update logs set Ffindsh=True, Fend_time=UNIX_TIMESTAMP() where Flogfile=%s' % logfile)
|
||||
except pxssh.ExceptionPxssh as e:
|
||||
print('登录失败: %s' % e)
|
||||
cursor.execute('update logs set Ffindsh=2 where Flogfile=%s' % logfile)
|
||||
except KeyboardInterrupt:
|
||||
foo.logout()
|
||||
cursor.execute('update logs set Ffindsh=True, Fend_time=UNIX_TIMESTAMP() where Flogfile=%s ' % logfile)
|
||||
|
||||
|
||||
def ip_all_select(username):
|
||||
|
|
|
@ -12,16 +12,16 @@ https://docs.djangoproject.com/en/1.6/ref/settings/
|
|||
import os
|
||||
import ConfigParser
|
||||
|
||||
base_dir = "/opt/jumpserver/"
|
||||
cf = ConfigParser.ConfigParser()
|
||||
cf.read('%s/jumpserver.conf' % base_dir)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||
CONF_DIR = os.path.dirname(os.path.dirname(BASE_DIR))
|
||||
CF = ConfigParser.ConfigParser()
|
||||
CF.read('%s/jumpserver.conf' % CONF_DIR)
|
||||
|
||||
db_host = cf.get('db', 'host')
|
||||
db_port = cf.getint('db', 'port')
|
||||
db_user = cf.get('db', 'user')
|
||||
db_password = cf.get('db', 'password')
|
||||
db_db = cf.get('db', 'db')
|
||||
DB_HOST = CF.get('db', 'host')
|
||||
DB_PORT = CF.getint('db', 'port')
|
||||
DB_USER = CF.get('db', 'user')
|
||||
DB_PASSWORD = CF.get('db', 'password')
|
||||
DB_DB = CF.get('db', 'db')
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
|
||||
|
@ -71,11 +71,11 @@ WSGI_APPLICATION = 'AutoSa.wsgi.application'
|
|||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': db_db,
|
||||
'USER': db_user,
|
||||
'PASSWORD': db_password,
|
||||
'HOST': db_host,
|
||||
'PORT': db_port,
|
||||
'NAME': DB_DB,
|
||||
'USER': DB_USER,
|
||||
'PASSWORD': DB_PASSWORD,
|
||||
'HOST': DB_HOST,
|
||||
'PORT': DB_PORT,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,3 +23,16 @@ class User(models.Model):
|
|||
return self.username
|
||||
|
||||
|
||||
class Logs(models.Model):
|
||||
user = models.CharField(max_length=50)
|
||||
host = models.CharField(max_length=20)
|
||||
logfile = models.CharField(max_length=1000)
|
||||
finish = models.SmallIntegerField(max_length=4)
|
||||
start_time = models.IntegerField()
|
||||
end_time = models.IntegerField()
|
||||
|
||||
def __unicode__(self):
|
||||
return self.logfile
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue