Beispiel #1
0
 def authorize_action(self, file_action):
     # The user might be OK.
     if (utils.check_auth(self.model.user, self.hutch) and
         (not file_action
          or utils.check_ssh(self.model.user, self.hutch) == file_action)):
         return True
     # If the user isn't OK, give him or her a chance to authenticate.
     if self.model.user == self.myuid:
         self.doAuthenticate()
     if (utils.check_auth(self.model.user, self.hutch) and
         (not file_action
          or utils.check_ssh(self.model.user, self.hutch) == file_action)):
         return True
     QtWidgets.QMessageBox.critical(
         None, "Error",
         "Action not authorized for user %s" % self.model.user,
         QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok)
     return False
Beispiel #2
0
 def authenticate_user(self, user, password):
     if user == "":
         user = self.myuid
     need_su = self.myuid != user
     if not utils.check_ssh(user, self.hutch):
         if self.model.userIO != None:
             try:
                 os.close(self.model.userIO)
             except:
                 pass
         self.model.userIO = None
         self.ui.userLabel.setText("User: "******"/usr/bin/ssh", [
                     "ssh", user + "@" + utils.COMMITHOST, "/bin/tcsh",
                     "-if"
                 ])
             else:
                 os.execv("/usr/bin/ssh",
                          ["ssh", utils.COMMITHOST, "/bin/tcsh", "-if"])
         except:
             pass
         print "Say what?  execv failed?"
         sys.exit(0)
     l = utils.read_until(fd, "(assword:|> )").group(1)
     if l != "> ":
         os.write(fd, password + "\n")
         l = utils.read_until(fd, "> ")
     if utils.KINIT != None and password != "":
         os.write(fd, utils.KINIT + "\n")
         l = utils.read_until(fd, ": ")
         os.write(fd, password + "\n")
         l = utils.read_until(fd, "> ")
     self.model.user = user
     if self.model.userIO != None:
         try:
             os.close(self.model.userIO)
         except:
             pass
     self.model.userIO = fd
     if need_su:
         self.utimer.start(10 * 60000)  # Let's go for 10 minutes.
     self.ui.userLabel.setText("User: " + user)
Beispiel #3
0
 def authenticate_user(self, user, password):
     if user == "":
         user = self.myuid
     need_su = self.myuid != user
     if not utils.check_ssh(user, self.hutch):
         if self.model.userIO != None:
             try:
                 os.close(self.model.userIO)
             except:
                 pass
         self.model.userIO = None
         self.ui.userLabel.setText("User: "******".")[0]:
                     os.execv("/usr/bin/su",
                              ["su", user, "-c", "/bin/tcsh -if"])
                 else:
                     os.execv("/usr/bin/ssh", [
                         "ssh", user + "@" + utils.COMMITHOST, "/bin/tcsh",
                         "-if"
                     ])
             else:
                 if utils.COMMITHOST == socket.gethostname().split(".")[0]:
                     print "C"
                     os.execv("/bin/tcsh", ["tcsh", "-if"])
                 else:
                     print "D"
                     os.execv("/usr/bin/ssh",
                              ["ssh", utils.COMMITHOST, "/bin/tcsh", "-if"])
         except:
             pass
         print "Say what?  execv failed?"
         sys.exit(0)
     l = utils.read_until(fd, "(assword:|> )").group(1)
     if l != "> ":
         os.write(fd, password + "\n")
         l = utils.read_until(fd, "> ")
     if utils.KINIT != None and password != "":
         os.write(fd, utils.KINIT + "\n")
         l = utils.read_until(fd, ": ")
         os.write(fd, password + "\n")
         l = utils.read_until(fd, "> ")
     #
     # Sigh.  Someone once had a file named time.py in their home
     # directory.  So let's go somewhere where we know the files.
     #
     os.write(fd, "cd %s\n" % utils.TMP_DIR)
     l = utils.read_until(fd, "> ")
     self.model.user = user
     if self.model.userIO != None:
         try:
             os.close(self.model.userIO)
         except:
             pass
     self.model.userIO = fd
     if need_su:
         self.utimer.start(10 * 60000)  # Let's go for 10 minutes.
     self.ui.userLabel.setText("User: " + user)
Beispiel #4
0
def operations_deploy():
    """Performs a system-level setup on a host and installs APP on it"""
    check_ssh()
    check_sudo()
    prepare_install_and_check()
Beispiel #5
0
def user_deploy():
    """Compiles and installs APP in a user-owned directory."""
    check_ssh()
    install_and_check()