Esempio n. 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)
Esempio n. 2
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)
Esempio n. 3
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")
Esempio n. 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")
Esempio n. 5
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)
Esempio n. 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)
Esempio n. 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
Esempio n. 8
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
Esempio n. 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
Esempio n. 10
0
    def test_with_root(self):
        set_euid()
        self.assertNotEqual(os.geteuid(), 0)

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

        with root():
            self.assertEqual(os.getuid(), 0)
Esempio n. 13
0
 def tearDown(self):
     with root():
         shutil.rmtree(self.tmpdir)