示例#1
0
    def stop(self):
        for iface in Interface.objects.all():
            if not iface.configured:
                logger.debug("%s is not configured" % iface.name)
                continue

            with root():
                run('/sbin/ifdown --force %s' % iface.name)
示例#2
0
文件: module.py 项目: exekias/droplet
    def stop(self):
        for iface in Interface.objects.all():
            if not iface.configured:
                logger.debug("%s is not configured" % iface.name)
                continue

            with root():
                run('/sbin/ifdown --force %s' % iface.name)
示例#3
0
文件: module.py 项目: exekias/droplet
    def save(self):

        # Save con files
        self.smbconf.write()

        with root():
            shutil.copy2(self.SMB_KRB5CONF_FILE, self.KRB5CONF_FILE)
            # XXX FIXME move this to network
            run("echo 'nameserver 127.0.0.1' > /etc/resolv.conf")
示例#4
0
    def save(self):

        # Save con files
        self.smbconf.write()

        with root():
            shutil.copy2(self.SMB_KRB5CONF_FILE, self.KRB5CONF_FILE)
            # XXX FIXME move this to network
            run("echo 'nameserver 127.0.0.1' > /etc/resolv.conf")
示例#5
0
文件: module.py 项目: exekias/droplet
    def start(self):
        for iface in Interface.objects.all():
            if not iface.configured:
                logger.debug("%s is not configured" % iface.name)
                continue

            with root():
                # we run ifup in background
                # it can wait indefinitely for DHCP requests
                run('/sbin/ifup --force %s' % iface.name, background=True)
示例#6
0
    def start(self):
        for iface in Interface.objects.all():
            if not iface.configured:
                logger.debug("%s is not configured" % iface.name)
                continue

            with root():
                # we run ifup in background
                # it can wait indefinitely for DHCP requests
                run('/sbin/ifup --force %s' % iface.name, background=True)
示例#7
0
def samdb_connect():
    """
    Open and return a SamDB connection
    """
    with root():
        lp = samba.param.LoadParm()
    lp.load("/etc/samba/smb.conf")
    creds = Credentials()
    creds.guess(lp)
    session = system_session()
    samdb = SamDB("/var/lib/samba/private/sam.ldb",
                  session_info=session,
                  credentials=creds,
                  lp=lp)
    return samdb
示例#8
0
文件: module.py 项目: exekias/droplet
    def install(self):
        """
        Installation procedure, it writes basic smb.conf and uses samba-tool to
        provision the domain
        """
        domain_settings = DomainSettings.get()

        with root():
            if os.path.exists(self.SMBCONF_FILE):
                os.remove(self.SMBCONF_FILE)

            if domain_settings.mode == "ad":
                domain_settings.adminpass = make_password(15)
                domain_settings.save()

                run(
                    "samba-tool domain provision "
                    "--domain='%s' "
                    "--workgroup='%s' "
                    "--realm='%s' "
                    "--use-xattrs=yes "
                    "--use-rfc2307 "
                    "--server-role='domain controller' "
                    "--use-ntvfs "
                    "--adminpass='******'"
                    % (
                        domain_settings.domain,
                        domain_settings.workgroup,
                        domain_settings.realm,
                        domain_settings.adminpass,
                    )
                )

                self.smbconf.write()

                shutil.copy2(self.SMB_KRB5CONF_FILE, self.KRB5CONF_FILE)

                # XXX FIXME move this to network
                run("echo 'nameserver 127.0.0.1' > /etc/resolv.conf")
                # TODO manage shares
                run("touch /etc/samba/shares.conf")

            elif domain_settings.mode == "member":
                # TODO
                pass
示例#9
0
    def install(self):
        """
        Installation procedure, it writes basic smb.conf and uses samba-tool to
        provision the domain
        """
        domain_settings = DomainSettings.get()

        with root():
            if os.path.exists(self.SMBCONF_FILE):
                os.remove(self.SMBCONF_FILE)

            if domain_settings.mode == 'ad':
                domain_settings.adminpass = make_password(15)
                domain_settings.save()

                run("samba-tool domain provision "
                    "--domain='%s' "
                    "--workgroup='%s' "
                    "--realm='%s' "
                    "--use-xattrs=yes "
                    "--use-rfc2307 "
                    "--server-role='domain controller' "
                    "--use-ntvfs "
                    "--adminpass='******'" %
                    (domain_settings.domain, domain_settings.workgroup,
                     domain_settings.realm, domain_settings.adminpass))

                self.smbconf.write()

                shutil.copy2(self.SMB_KRB5CONF_FILE, self.KRB5CONF_FILE)

                # XXX FIXME move this to network
                run("echo 'nameserver 127.0.0.1' > /etc/resolv.conf")
                # TODO manage shares
                run("touch /etc/samba/shares.conf")

            elif domain_settings.mode == 'member':
                # TODO
                pass
示例#10
0
    def test_with_root(self):
        set_euid()
        self.assertNotEqual(os.geteuid(), 0)

        with root():
            self.assertEqual(os.getuid(), 0)
示例#11
0
 def tearDown(self):
     with root():
         shutil.rmtree(self.tmpdir)
示例#12
0
    def test_with_root(self):
        set_euid()
        self.assertNotEqual(os.geteuid(), 0)

        with root():
            self.assertEqual(os.getuid(), 0)
示例#13
0
 def tearDown(self):
     with root():
         shutil.rmtree(self.tmpdir)