Esempio n. 1
0
 def add(self, host_name):
     isHost(host_name)
     login = self.__getLogin(host_name)
     password = host_name
     if self.base.options.password:
         password = self.base.options.password
         if password == 'random':
             password = random_password()
     database = self.__getDbName(host_name)
     try:
         self.cursor.execute(
             "CREATE DATABASE `%s` CHARACTER SET utf8 COLLATE utf8_general_ci;"
             % database)
         self.cursor.execute(
          "GRANT ALL ON %s.* TO '%s'@'%%' IDENTIFIED BY '%s';" % \
           (database, login, password)
         )
         self.cursor.execute(
          "GRANT ALL ON %s.* TO '%s'@'127.0.0.1' IDENTIFIED BY '%s';" % \
           (database, login, password)
         )
         self.cursor.execute(
          "GRANT ALL ON %s.* TO '%s'@'localhost' IDENTIFIED BY '%s';" %\
          (database, login, password)
         )
         self.cursor.execute('FLUSH PRIVILEGES;')
     except Exception, msg:
         error_message(msg)
Esempio n. 2
0
File: mysql.py Progetto: Zypan/ahc
	def add(self, host_name):
		isHost(host_name)
		login = self.__getLogin(host_name)
		password = host_name
		if self.base.options.password:
			password = self.base.options.password
			if password == 'random':
				password = random_password()
		database = self.__getDbName(host_name)
		try:
			self.cursor.execute("CREATE DATABASE `%s` CHARACTER SET utf8 COLLATE utf8_general_ci;" % database)
			self.cursor.execute(
				"GRANT ALL ON %s.* TO '%s'@'%%' IDENTIFIED BY '%s';" % \
					(database, login, password)
			)
			self.cursor.execute(
				"GRANT ALL ON %s.* TO '%s'@'127.0.0.1' IDENTIFIED BY '%s';" % \
					(database, login, password)
			)
			self.cursor.execute(
				"GRANT ALL ON %s.* TO '%s'@'localhost' IDENTIFIED BY '%s';" %\
				(database, login, password)
			)
			self.cursor.execute('FLUSH PRIVILEGES;')
		except Exception, msg:
			error_message(msg)
Esempio n. 3
0
File: ftp.py Progetto: saidiahd/ahc
	def add(self, host_name):
		isHost(host_name)
		login = host_name
		password = host_name
		folder = self.__getFolder(host_name)
		if self.base.options.user:
			login = self.base.options.user
		if self.base.options.password:
			password = self.base.options.password
			if password == 'random':
				password = random_password()
		if fileExists(folder):
			if not self.__userExists(login):
				self.cursor.execute(
					"INSERT INTO `accounts` (`username`, `pass`) \
						VALUES('%s', PASSWORD('%s'))" % (login, password)
				)
				self.__addUserConfig(login, folder)
				info_message(
					"User '%s' successfully added! Password: %s" % (login, password)
				)
				service_restart(self.config['init'])
			else:
				error_message("Login already used!")
		else:
			error_message("Project folder not found!")
Esempio n. 4
0
    def add(self, host_name):
        isHost(host_name)
        login = host_name
        password = host_name
        folder = self.__getFolder(host_name)
        if self.base.options.user:
            login = self.base.options.user
        if self.base.options.password:
            password = self.base.options.password
            if password == 'random':
                password = random_password()
        if fileExists(folder):
            if not self.__userExists(login):
                self.cursor.execute(
                    "INSERT INTO `accounts` (`username`, `pass`) \
						VALUES('%s', PASSWORD('%s'))" % (login, password))
                self.__addUserConfig(login, folder)
                info_message("User '%s' successfully added! Password: %s" %
                             (login, password))
                service_restart(self.config['init'])
            else:
                error_message("Login already used!")
        else:
            error_message("Project folder not found!")