MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / set_root_pwd

Method set_root_pwd

class/databaseModel/sqlserverModel.py:394–415  ·  view source on GitHub ↗

@设置sa密码

(self, args)

Source from the content-addressed store, hash-verified

392 return public.returnMsg(True, '')
393
394 def set_root_pwd(self, args):
395 """
396 @设置sa密码
397 """
398 password = public.trim(args['password'])
399 try:
400 if not password:
401 return public.returnMsg(False, '修改失败,数据库[' + username + ']密码不能为空.')
402 if len(re.search("^[\w@\.]+$", password).groups()) > 0:
403 return public.returnMsg(False, 'sa密码不能为空或带有特殊符号')
404 except:
405 return public.returnMsg(False, 'sa密码不能为空或带有特殊符号')
406
407 mssql_obj = panelMssql.panelMssql()
408 result = mssql_obj.execute("EXEC sp_password NULL, '%s', 'sa'" % password)
409
410 isError = self.IsSqlError(result)
411 if isError != None: return isError
412
413 public.writeFile('data/sa.pl', password)
414 session['config']['mssql_sa'] = password
415 return public.returnMsg(True, '修改sa密码成功!')
416
417 def get_database_size_by_id(self, args):
418 """

Callers

nothing calls this directly

Calls 6

returnMsgMethod · 0.80
writeFileMethod · 0.80
trimMethod · 0.45
searchMethod · 0.45
executeMethod · 0.45
IsSqlErrorMethod · 0.45

Tested by

no test coverage detected