def main(self): try: for item in self.sys_dependencies[ Version.system_package_manager()]: self.grep_system_packages(item) except DistutilsExecError as distutilsExecError: Logger.log( "ERROR", "Exception DistutilsExecError: " + str(distutilsExecError))
def clear_auto_login(clear, user): if len(sys.argv) > 2 and clear: Logger.log("ERROR", "Too many arguments for clear given. Exiting now.") sys.exit(1) if clear and user_present(user): remove_from_group(user) sys.exit(1) elif clear and not user_present(user): sys.exit(1)
def grep_system_packages(self, package_name): comm = subprocess.Popen( [self.system_query_command() + " " + str(package_name)], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.read() if not len(comm.strip()) == 0: Logger.log("INFO", "Package " + str(package_name) + " was found.") else: Logger.log("ERROR", "Package " + str(package_name) + " was not found.")
def cron_tab(self): #Count need to be 1 in order to write to the crontab. #Basically, checking for grep being None or not None will #not work in this case and we need to check for 2 occurances. count = 0 cmd = "/bin/bash /home/root/.ssh/is_sshm_running.sh" cron = CronTab(user='******') job = cron.new(command=cmd) job.minute.every(1) for job in cron: grep = re.search(r'\/is_sshm_running.sh', str(job)) if grep is not None: count += 1 #if count < 2 and self.install: if count < 2: Logger.log("INFO", "Installing crontab.") cron.write() Logger.log( "WARN", "Please nesure that the crontab was actually installed!") Logger.log( "WARN", "To do so please run(without quotes) => 'sudo crontab -l -u root'" )
'Your E-mail password is used to send an E-mail of the ip ' + 'of the user sshing into your box, successful or not.') (options, args) = parser.parse_args() _config_dict = {'email': options.email, 'password': options.password} _setup_options = { 'check': options.check, 'build': options.build, 'sdist': options.sdist, 'install': options.install } if all(not _setup_options[options] for options in _setup_options): if options.password is None or options.email is None: Logger.log("ERROR", "You must provide BOTH an E-mail AND password.") sys.exit(0) count = 0 for options in _setup_options: if sum([count + +_setup_options[opts] for opts in _setup_options]) == 2: Logger.log('ERROR', 'Only one base options is permitted at a time.') sys.exit(0) elif _setup_options['check']: Logger.log("INFO", "Grepping System Packages") Check().main() sys.exit(0) elif _setup_options['build']: Logger.log('INFO', 'Building setup!')
except DistutilsExecError as distutilsExecError: Logger.log( "ERROR", "Exception DistutilsExecError: " + str(distutilsExecError)) class PrepareBuild(object): def __init__(self, *args, **kwargs): cdll.LoadLibrary(args[0]).build() if __name__ == '__main__': path = str(os.getcwd()) + '/src/lib/shared/libbuild.so' Logger.log('INFO', 'Checking system dependencies.') check = Check() check.main() Logger.log('INFO', 'Building libraries.') path = str(os.getcwd()) + '/src/lib/shared/libbuild.so' cdll.LoadLibrary(path).build() Logger.log('INFO', 'Entering setup in setup.py') setup( name='sshmonitor', version='2.0.0', url='https://github.com/amboxer21/SSHMonitor', license='GPL-3.0', author='Anthony Guevara',
def auto_login(auto_login, user): if auto_login: Logger.log("INFO", "Automatically logging you in now.") add_to_roup(user)