Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(4)  |  Call(3)  |  Derive(0)  |  Import(1)
Checks whether f is a file owned by this uid, set to mode 0600 or
0700, and all its parents pass checkPrivateDir.  Raises MixFatalError
if the assumptions are not met; else return None.  If 'fix' is true,
repair permissions on the file rather than raising MixFatalError.

        def checkPrivateFile(fn, fix=1):
    """Checks whether f is a file owned by this uid, set to mode 0600 or
       0700, and all its parents pass checkPrivateDir.  Raises MixFatalError
       if the assumptions are not met; else return None.  If 'fix' is true,
       repair permissions on the file rather than raising MixFatalError."""
    parent, _ = os.path.split(fn)
    checkPrivateDir(parent)
    try:
        st = os.stat(fn)
    except OSError, e:
        if e.errno == errno.EEXIST:
            raise MixFatalError("Nonexistent file %s" % fn)
        else:
            raise MixFatalError("Couldn't stat file %s: %s" % (fn, e))
    if not st:
        raise MixFatalError("Nonexistent file %s" % fn)
    if not os.path.isfile(fn):
        raise MixFatalError("%s is not a regular file" % fn)

    if _CHECK_UID:
        me = os.getuid()
        if st[stat.ST_UID] != me:
            ownerName = _uidToName(st[stat.ST_UID])
            myName = _uidToName(me)
            raise MixFilePermissionError(
                "File %s is owned by %s, but Mixminion is running as %s"
                % (fn, ownerName, myName))
    mode = st[stat.ST_MODE] & 0777
    if _CHECK_MODE and mode not in (0700, 0600):
        if not fix:
            raise MixFilePermissionError("Bad permissions (mode %o) on file %s"
                                         % (mode & 0777, fn))
        newmode = {0:0600,0100:0700}[(mode & 0100)]
        LOG.warn("Repairing permissions on file %s" % fn)
        os.chmod(fn, newmode)
        


src/m/i/mixminion-HEAD/lib/mixminion/server/ServerKeys.py   mixminion(Download)
from mixminion.ServerInfo import ServerInfo, PACKET_KEY_BYTES, MMTP_KEY_BYTES,\
     signServerInfo
from mixminion.Common import AtomicFile, LOG, MixError, MixFatalError, \
     ceilDiv, createPrivateDir, checkPrivateFile, englishSequence, \
     formatBase64, formatDate, formatTime, previousMidnight, readFile, \
        bits = self.config['Server']['IdentityKeyBits']
        if os.path.exists(fn):
            checkPrivateFile(fn)
            key = mixminion.Crypto.pk_PEM_load(fn, password)
            keylen = key.get_modulus_bytes()*8
        fn = os.path.join(self.keyDir, "pinger.seed")
        if os.path.exists(fn):
            checkPrivateFile(fn)
            r = readFile(fn)
            if len(r) == mixminion.Crypto.DIGEST_LEN:
    def checkKeys(self):
        """Check whether all the required keys exist and are private."""
        checkPrivateFile(self.packetKeyFile)
 
    def load(self, password=None):