Exemple #1
0
def create_home_directory():
    from applications.controlies.modules.SSHConnection import SSHConnection

    #c = SSHConnection(request.vars['host'],request.vars['user'],request.vars['password'])
    c = SSHConnection("servidor","root",request.vars['password'])
    response = c.process()
    print request.vars
    if response != True:
		return dict(response = response)

    l=conecta()
    u = Users(l,"","","","",request.vars['username'],"","","","")
    responseUser = u.getUserData()
    l.close()

    homeDirectory = Utils.homeDirectory(request.vars['type'])+responseUser["user"]
			
    c.exec_command("cp -r /etc/skel "+homeDirectory)
    c.exec_command("chown -R "+responseUser["uidnumber"]+":"+responseUser["gidnumber"]+" "+homeDirectory)

    try:
		if request.vars["trustRelationship"] == "on":
			dir_ssh = "/var/web2py/applications/controlies"
			Utils.generateRSAkeys(dir_ssh)
			c.open_ftp()
			c.removeFile("/tmp/controlIES_rsa.pub")
			c.putFile(dir_ssh+"/.ssh/id_rsa.pub","/tmp/controlIES_rsa.pub")
			c.exec_command('cat /tmp/controlIES_rsa.pub >> /root/.ssh/authorized_keys')
			c.close_ftp()
    except:
		pass

    c.close()    
    return dict(response = "OK")       
Exemple #2
0
def index():

    try:
        dir_ssh = "/var/web2py/applications/controlies"
        # dir_ssh = "/home/manu/proyectos/controlies/applications/controlies"
        if not os.path.isfile(dir_ssh + "/.ssh/id_rsa.pub"):
            Utils.generateRSAkeys(dir_ssh)
    except:
        pass

    return dict()
Exemple #3
0
def index():

    try:
        dir_ssh = "/var/web2py/applications/controlies"
        #dir_ssh = "/home/manu/proyectos/controlies/applications/controlies"
        if not os.path.isfile(dir_ssh + "/.ssh/id_rsa.pub"):
            Utils.generateRSAkeys(dir_ssh)
    except:
        pass

    return dict()
Exemple #4
0
def make_directory(username, type, c):
    l=conecta()
    u = Users(l,"","","","",username,"","","","")
    responseUser = u.getUserData()
    l.close()

    homeDirectory = Utils.homeDirectory(request.vars['type'])+responseUser["user"]
    if type=="staff":
        c.exec_command("test ! -d /home/profesor/staff && mkdir /home/profesor/staff; chown root:staff /home/profesor/staff")

    c.exec_command("cp -r /etc/skel "+homeDirectory+"; chown -R "+responseUser["user"]+":"+responseUser["user"]+" "+homeDirectory)
Exemple #5
0
def create_home_directory():
    # c = SSHConnection(request.vars['host'],request.vars['user'],request.vars['password'])
    c = SSHConnection("servidor", "root", request.vars["password"])
    response = c.process()

    if response != True:
        return dict(response=response)

    make_directory(request.vars["username"], request.vars["type"], c)

    try:
        if request.vars["trustRelationship"] == "on":
            dir_ssh = "/var/web2py/applications/controlies"
            Utils.generateRSAkeys(dir_ssh)
            c.open_ftp()
            c.removeFile("/tmp/controlIES_rsa.pub")
            c.putFile(dir_ssh + "/.ssh/id_rsa.pub", "/tmp/controlIES_rsa.pub")
            c.exec_command("cat /tmp/controlIES_rsa.pub >> /root/.ssh/authorized_keys")
            c.close_ftp()
    except:
        pass

    c.close()
    return dict(response="OK")
Exemple #6
0
def create_home_directory():
    #c = SSHConnection(request.vars['host'],request.vars['user'],request.vars['password'])
    c = SSHConnection("servidor","root",request.vars['password'])
    response = c.process()

    if response != True:
        return dict(response = response)

    make_directory(request.vars['username'],request.vars['type'], c)

    try:
        if request.vars["trustRelationship"] == "on":
            dir_ssh = "/var/web2py/applications/controlies"
            Utils.generateRSAkeys(dir_ssh)
            c.open_ftp()
            c.removeFile("/tmp/controlIES_rsa.pub")
            c.putFile(dir_ssh+"/.ssh/id_rsa.pub","/tmp/controlIES_rsa.pub")
            c.exec_command('cat /tmp/controlIES_rsa.pub >> /root/.ssh/authorized_keys')
            c.close_ftp()
    except:
        pass

    c.close()    
    return dict(response = "OK")       
Exemple #7
0
def create_home_directory_withoutpass():
    from applications.controlies.modules.SSHConnection import SSHConnection

    c = SSHConnection("servidor","root","")
    response = c.connectWithoutPass("/var/web2py/applications/controlies/.ssh/id_rsa")

    if response != True:
		return dict(response = response)
		
    l=conecta()
    u = Users(l,"","","","",request.vars['username'],"","","","")
    responseUser = u.getUserData()
    l.close()

    homeDirectory = Utils.homeDirectory(request.vars['type'])+responseUser["user"]
			
    c.exec_command("cp -r /etc/skel "+homeDirectory)
    c.exec_command("chown -R "+responseUser["uidnumber"]+":"+responseUser["gidnumber"]+" "+homeDirectory)
    c.close()

    return dict(response = "OK")
Exemple #8
0
def make_directory(username, type, c):
    l = conecta()
    u = Users(l, "", "", "", "", username, "", "", "", "")
    responseUser = u.getUserData()
    l.close()

    homeDirectory = Utils.homeDirectory(request.vars["type"]) + responseUser["user"]
    if type == "staff":
        c.exec_command(
            "test ! -d /home/profesor/staff && mkdir /home/profesor/staff; chown root:staff /home/profesor/staff"
        )

    c.exec_command(
        "cp -r /etc/skel "
        + homeDirectory
        + "; chown -R "
        + responseUser["user"]
        + ":"
        + responseUser["user"]
        + " "
        + homeDirectory
    )