Пример #1
0
def list_exists(listname):
    """Return true iff list `listname' exists."""
    # The existance of any of the following file proves the list exists
    # <wink>: config.pck, config.pck.last, config.db, config.db.last
    #
    # The former two are for 2.1alpha3 and beyond, while the latter two are
    # for all earlier versions.
    basepath = Site.get_listpath(listname)
    for ext in ('.pck', '.pck.last', '.db', '.db.last'):
        dbfile = os.path.join(basepath, 'config' + ext)
        if os.path.exists(dbfile):
            return True
    return False
Пример #2
0
def list_exists(listname):
    """Return true iff list `listname' exists."""
    # The existance of any of the following file proves the list exists
    # <wink>: config.pck, config.pck.last, config.db, config.db.last
    #
    # The former two are for 2.1alpha3 and beyond, while the latter two are
    # for all earlier versions.
    basepath = Site.get_listpath(listname)
    for ext in ('.pck', '.pck.last', '.db', '.db.last'):
        dbfile = os.path.join(basepath, 'config' + ext)
        if os.path.exists(dbfile):
            return True
    return False
Пример #3
0
def list_exists(listname):
    """Return true iff list `listname' exists."""
    # The existance of any of the following file proves the list exists
    # <wink>: config.pck, config.pck.last, config.db, config.db.last
    #
    # The former two are for 2.1alpha3 and beyond, while the latter two are
    # for all earlier versions.
    #
    # But first ensure the list name doesn't contain a path traversal
    # attack.
    if len(re.sub(mm_cfg.ACCEPTABLE_LISTNAME_CHARACTERS, '', listname)) > 0:
        syslog('mischief', 'Hostile listname: %s', listname)
        return False
    basepath = Site.get_listpath(listname)
    for ext in ('.pck', '.pck.last', '.db', '.db.last'):
        dbfile = os.path.join(basepath, 'config' + ext)
        if os.path.exists(dbfile):
            return True
    return False
Пример #4
0
def list_exists(listname):
    """Return true iff list `listname' exists."""
    # The existance of any of the following file proves the list exists
    # <wink>: config.pck, config.pck.last, config.db, config.db.last
    #
    # The former two are for 2.1alpha3 and beyond, while the latter two are
    # for all earlier versions.
    #
    # But first ensure the list name doesn't contain a path traversal
    # attack.
    if len(re.sub(mm_cfg.ACCEPTABLE_LISTNAME_CHARACTERS, "", listname)) > 0:
        syslog("mischief", "Hostile listname: %s", listname)
        return False
    basepath = Site.get_listpath(listname)
    for ext in (".pck", ".pck.last", ".db", ".db.last"):
        dbfile = os.path.join(basepath, "config" + ext)
        if os.path.exists(dbfile):
            return True
    return False
Пример #5
0
 def CheckHTMLArchiveDir(self):
     # We need to make sure that the archive directory has the right perms
     # for public vs private.  If it doesn't exist, or some weird
     # permissions errors prevent us from stating the directory, it's
     # pointless to try to fix the perms, so we just return -scott
     if mm_cfg.ARCHIVE_TO_MBOX == -1:
         # Archiving is completely disabled, don't require the skeleton.
         return
     pubdir = Site.get_archpath(self.internal_name(), public=True)
     privdir = self.archive_dir()
     pubmbox = pubdir + '.mbox'
     privmbox = privdir + '.mbox'
     if self.archive_private:
         breaklink(pubdir)
         breaklink(pubmbox)
     else:
         # BAW: privdir or privmbox could be nonexistant.  We'd get an
         # OSError, ENOENT which should be caught and reported properly.
         makelink(privdir, pubdir)
         # Only make this link if the site has enabled public mbox files
         if mm_cfg.PUBLIC_MBOX:
             makelink(privmbox, pubmbox)
Пример #6
0
 def CheckHTMLArchiveDir(self):
     # We need to make sure that the archive directory has the right perms
     # for public vs private.  If it doesn't exist, or some weird
     # permissions errors prevent us from stating the directory, it's
     # pointless to try to fix the perms, so we just return -scott
     if mm_cfg.ARCHIVE_TO_MBOX == -1:
         # Archiving is completely disabled, don't require the skeleton.
         return
     pubdir = Site.get_archpath(self.internal_name(), public=True)
     privdir = self.archive_dir()
     pubmbox = pubdir + '.mbox'
     privmbox = privdir + '.mbox'
     if self.archive_private:
         breaklink(pubdir)
         breaklink(pubmbox)
     else:
         # BAW: privdir or privmbox could be nonexistant.  We'd get an
         # OSError, ENOENT which should be caught and reported properly.
         makelink(privdir, pubdir)
         # Only make this link if the site has enabled public mbox files
         if mm_cfg.PUBLIC_MBOX:
             makelink(privmbox, pubmbox)
Пример #7
0
def list_names():
    """Return the names of all lists in default list directory."""
    # We don't currently support separate listings of virtual domains
    return Site.get_listnames()
Пример #8
0
	return

    if not Utils.list_exists(oldlistname):
            usage(1, "List '%s' not exists." % (oldlistname))

    if Utils.list_exists(newlistname):
            usage(1, "List '%s' already exists." % (newlistname))

    if verbose:
        print 'Renaming list %s to %s.' % (oldlistname, newlistname)

    oldmlist = MailList.MailList(oldlistname)
    if not oldmlist.Locked():
       oldmlist.Lock()
    
    oldlistpath = Site.get_listpath(oldlistname)
    lists_path = os.path.dirname(oldlistpath)
    newlistpath = lists_path + '/' + newlistname

    os.rename(oldlistpath, newlistpath)
    

    if verbose:
        print 'Assing archives of list %s to %s.' % (oldlistname, newlistname)
  
    oldarchdir = Site.get_archpath(oldlistname)
    arch_dir = os.path.dirname(oldarchdir)
    newarchdir = arch_dir + '/' + newlistname

    oldmbox = arch_dir + '/' + oldlistname + '.mbox'
    newmbox = arch_dir + '/' + newlistname + '.mbox'
Пример #9
0
 def archive_dir(self):
     return Site.get_archpath(self.internal_name())
Пример #10
0
 def archive_dir(self):
     return Site.get_archpath(self.internal_name())
Пример #11
0
def list_names():
    """Return the names of all lists in default list directory."""
    # We don't currently support separate listings of virtual domains
    return Site.get_listnames()