def processCurrentUser(self) : """ Run Stonix with the currently logged in user @author: Roy Nielsen """ fullStonixPath = os.path.join(getResourcesDir(), "stonix.app/Contents/MacOS/stonix") if self.args: command = [fullStonixPath] + self.args else: command = [fullStonixPath, "-G", "-dv"] retval = "" reterr = "" child_pid = os.fork() if child_pid == 0 : print "Child Process: PID# %s" % os.getpid() retval, reterr = system_call_retval(command, self.message_level) else: print "Exiting parent process: PID# %s" % os.getpid() self.reject() self.reject()
def processCurrentUser(self): """ Run Stonix with the currently logged in user @author: Roy Nielsen """ fullStonixPath = os.path.join(getResourcesDir(), "stonix.app/Contents/MacOS/stonix") if self.args: command = [fullStonixPath] + self.args else: command = [fullStonixPath, "-G", "-dv"] retval = "" reterr = "" child_pid = os.fork() if child_pid == 0: print "Child Process: PID# %s" % os.getpid() retval, reterr = system_call_retval(command, self.message_level) else: print "Exiting parent process: PID# %s" % os.getpid() self.reject() self.reject()
def isPassValid(self) : """ Set the admin username and password values of the class. Author: Roy Nielsen """ log_message("Entering isPassValid in admin_creds...", "verbose", self.message_level) ##### # Grab the QString out of the QLineEdit field myuser = self.ui.adminName.text() ##### # Convert myuser into a string self.username = "******" % myuser ##### # Grab the QString out of the QLineEdit field mypass = self.ui.passwordLineEdit.text() ##### # Convert mypass into a string self.password = "******" % mypass self.progress_bar.show() self.progress_bar.raise_() if isUserOnLocalSystem(self.username, self.message_level) : log_message("User: "******" is a valid user...", "verbose", self.message_level) if checkIfUserIsAdmin(self.username, self.message_level) : log_message("User: "******" is a valid admin...", "verbose", self.message_level) result = False result = authenticate(self.username, self.password, self.message_level) self.progress_bar.hide() if result : log_message("Authentication success...", "debug", self.message_level) ##### # Got a valid user, with valid password, call stonix with # runAsWithSudo - stonixPath is a link to the stonix app that is # in the resources directory stonixPath = os.path.join(getResourcesDir(), "stonix") ##### # Set up progress bar self.progress_bar.setLabelText("Running Stonix...") stonixFullPath = os.path.join(getResourcesDir(), "stonix.app/Contents/MacOS/stonix") self.hide() ##### # Attempt fork here, so we don't have the wrapper and stonix # running and in the Dock at the same time. child_pid = os.fork() if child_pid == 0 : print "Child Process: PID# %s" % os.getpid() if self.args: command = ["\"" + stonixFullPath + "\""] + self.args else: command = ["\"" + stonixFullPath + "\"", "-G", "-dv"] runAsWithSudo(self.username, self.password, command, self.message_level) else: print "Exiting parent process: PID# %s" % os.getpid() self.progress_bar.hide() QCoreApplication.quit() else : ##### # User is an admin, report invalid password and try again... self.progress_bar.hide() log_message("Authentication test FAILURE...", "normal", self.message_level) QMessageBox.warning(self, "Warning", "...Incorrect Password, please try again.", QMessageBox.Ok) else : ##### # Report user is not an admin self.progress_bar.hide() log_message("User: \"" + str(self.username) + "\" is not a " + \ "valid admin on this system", "normal", \ self.message_level) QMessageBox.warning(self, "Warning", "\"" + str(self.username) + \ "\" is not a valid admin for this " + \ "system, please try again.", \ QMessageBox.Ok) else : self.progress_bar.hide() log_message("User: \"" + str(self.username) + "\" is not a valid " + \ "user on this system.", "normal", self.message_level) QMessageBox.warning(self, "Warning", "\"" + str(self.username) + \ "\" is not a valid user on this " + \ "system, please try again.", \ QMessageBox.Ok) log_message("Finished isPassValid...", "verbose", self.message_level)
# Put something like stonix.py's processargs() functionality here. # Best possible thing is to put all the args stonix uses into # a list, then " ".join(args) when calling stonix... message_level = prog_args.get_msg_lvl() log_message("Message level is: " + message_level, "debug", message_level) myuid = os.getuid() user = getpass.getuser() os_vers = getOsVers(message_level).rstrip() ##### # get the path to a link that links to the # stonix.app/Contents/Resources/stonix binary blob compiled by # pyinstaller stonixFullPath = os.path.join(getResourcesDir().strip("\""), "stonix.app/Contents/MacOS/stonix") stonixfp = [stonixFullPath] if not arguments: cmd = stonixfp + ["-G"] else: cmd = stonixfp + arguments log_message("Command build: " + str(cmd)) log_message("#==--- Initializing stonix4mac.app with UID %d ---==#"%myuid, \ "normal", message_level) log_message("Message level is: " + str(message_level), "verbose",
# Put something like stonix.py's processargs() functionality here. # Best possible thing is to put all the args stonix uses into # a list, then " ".join(args) when calling stonix... message_level = prog_args.get_msg_lvl() log_message("Message level is: " + message_level, "debug", message_level) myuid = os.getuid() user = getpass.getuser() os_vers = getOsVers(message_level).rstrip() ##### # get the path to a link that links to the # stonix.app/Contents/Resources/stonix binary blob compiled by # pyinstaller stonixFullPath = os.path.join(getResourcesDir().strip("\""), "stonix.app/Contents/MacOS/stonix") stonixfp = [stonixFullPath] if not arguments: cmd = stonixfp +["-G"] else: cmd = stonixfp + arguments log_message("Command build: " + str(cmd)) log_message("#==--- Initializing stonix4mac.app with UID %d ---==#"%myuid, \ "normal", message_level) log_message("Message level is: " + str(message_level), "verbose", message_level)
def isPassValid(self): """ Set the admin username and password values of the class. Author: Roy Nielsen """ log_message("Entering isPassValid in admin_creds...", "verbose", self.message_level) ##### # Grab the QString out of the QLineEdit field myuser = self.ui.adminName.text() ##### # Convert myuser into a string self.username = "******" % myuser ##### # Grab the QString out of the QLineEdit field mypass = self.ui.passwordLineEdit.text() ##### # Convert mypass into a string self.password = "******" % mypass self.progress_bar.show() self.progress_bar.raise_() if isUserOnLocalSystem(self.username, self.message_level): log_message("User: "******" is a valid user...", "verbose", self.message_level) if checkIfUserIsAdmin(self.username, self.message_level): log_message( "User: "******" is a valid admin...", "verbose", self.message_level) result = False result = authenticate(self.username, self.password, self.message_level) self.progress_bar.hide() if result: log_message("Authentication success...", "debug", self.message_level) ##### # Got a valid user, with valid password, call stonix with # runAsWithSudo - stonixPath is a link to the stonix app that is # in the resources directory stonixPath = os.path.join(getResourcesDir(), "stonix") ##### # Set up progress bar self.progress_bar.setLabelText("Running Stonix...") stonixFullPath = os.path.join( getResourcesDir(), "stonix.app/Contents/MacOS/stonix") self.hide() ##### # Attempt fork here, so we don't have the wrapper and stonix # running and in the Dock at the same time. child_pid = os.fork() if child_pid == 0: print "Child Process: PID# %s" % os.getpid() if self.args: command = ["\"" + stonixFullPath + "\"" ] + self.args else: command = [ "\"" + stonixFullPath + "\"", "-G", "-dv" ] runAsWithSudo(self.username, self.password, command, self.message_level) else: print "Exiting parent process: PID# %s" % os.getpid() self.progress_bar.hide() QCoreApplication.quit() else: ##### # User is an admin, report invalid password and try again... self.progress_bar.hide() log_message("Authentication test FAILURE...", "normal", self.message_level) QMessageBox.warning( self, "Warning", "...Incorrect Password, please try again.", QMessageBox.Ok) else: ##### # Report user is not an admin self.progress_bar.hide() log_message("User: \"" + str(self.username) + "\" is not a " + \ "valid admin on this system", "normal", \ self.message_level) QMessageBox.warning(self, "Warning", "\"" + str(self.username) + \ "\" is not a valid admin for this " + \ "system, please try again.", \ QMessageBox.Ok) else: self.progress_bar.hide() log_message("User: \"" + str(self.username) + "\" is not a valid " + \ "user on this system.", "normal", self.message_level) QMessageBox.warning(self, "Warning", "\"" + str(self.username) + \ "\" is not a valid user on this " + \ "system, please try again.", \ QMessageBox.Ok) log_message("Finished isPassValid...", "verbose", self.message_level)