Check if the specified filename has correct permissions
19535
def check_permissions(self, filename):
        '''
        
        '''
        if salt.utils.platform.is_windows():
            return True

        # After we've ascertained we're not on windows
        groups = salt.utils.user.get_gid_list(self.opts['user'], include_default=False)
        fmode = os.stat(filename)

        if stat.S_IWOTH & fmode.st_mode:
            # don't allow others to write to the file
            return False

        if stat.S_IWGRP & fmode.st_mode:
            # if the group has write access only allow with permissive_pki_access
            if not self.opts.get('permissive_pki_access', False):
                return False
            elif os.getuid() == 0 and fmode.st_gid not in groups:
                # if salt is root it has to be in the group that has write access
                # this gives the group 'permission' to have write access
                return False

        return True
271353
def file_rights(filepath, mode=None, uid=None, gid=None):
    '''
        
    '''
    file_handle = os.open(filepath, os.O_RDONLY)
    if mode:
        os.fchmod(file_handle, mode)
    if uid:
        if not gid:
            gid = 0
        os.fchown(file_handle, uid, gid)
    os.close(file_handle)
453935
def is_file_encrypted(self, filename):
        '''
        
        '''
        if not os.path.exists(filename):
            print "Invalid filename %s. Does not exist" % filename
            return False

        fhandle = open(filename, "rb")
        data = fhandle.read()
        fhandle.close()

        if data.startswith(AnsiVault.HEADER):
            return True
        else:
            return False
256032
def has(*permissions, **kwargs):
    

    target = kwargs['target']

    kwargs['target'] = type_for(target)

    # TODO: Predicate evaluation?
    return target in filter_(*permissions, **kwargs)
255739
def validate_permission(self, key, permission):
        
        if permission.perm_name not in self.__possible_permissions__:
            raise AssertionError(
                "perm_name is not one of {}".format(self.__possible_permissions__)
            )
        return permission
209580
def isvalid(path, access=None, extensions=None, filetype=None, minsize=None):
    """"""
    return ((access is None or os.access(path, access)) and
            (extensions is None or checkext(path, extensions)) and
            (((filetype == 'all' and os.path.exists(path)) or
              (filetype == 'dir' and os.path.isdir(path)) or
              (filetype == 'file' and os.path.isfile(path))) or
             filetype is None) and
            (minsize is None or (not os.path.isfile(path) or
                                 os.path.getsize(path) > minsize)))
188486
def find_permission(self, name):
        
        return (
            self.get_session.query(self.permission_model).filter_by(name=name).first()
        )
1126036
def check_files_exist(filenames):
    ''''''
    files_not_found = [x for x in filenames if not os.path.exists(x)]
    if len(files_not_found):
        for filename in files_not_found:
            print('File not found: "', filename, '"', sep='', file=sys.stderr)
        raise Error('File(s) not found. Cannot continue')
440337
function existsFile(file, permission) {
    return Promise.resolve(fsPromise.accessAsync(file, permission))
      .then(() => true)
      .catch(() => false);
}
901386
def has_permission(self, perm):
        
        return self.user.superuser or self.auth.has_permission(perm)
136101
function checkFileExistsSync(filepath){
  var flag = true;

  try {
    fs.accessSync(filepath, fs.F_OK);
  } catch(e){
    flag = false;
  }

  return flag;
}
99422
protected function checkPermissions($file, $permissions = '0444')
    {
        if (substr(sprintf('%o', fileperms($file)), -4) === $permissions) {
            return true;
        }

        $vars = array('%name' => $file, '%perm' => $permissions);
        return $this->translation->text('File %name is not secure. The file permissions must be %perm', $vars);
    }
576133
def file_found(filename,force):
    """"""
    if os.path.exists(filename) and not force:
        logger.info("Found %s; skipping..."%filename)
        return True
    else:
        return False
298497
def check_public_permissions(payload):
    """"""
    allowed_public_permissions = ['view', 'add', 'download']
    for perm_type in ['add', 'remove']:
        for perm in payload.get('public', {}).get(perm_type, []):
            if perm not in allowed_public_permissions:
                raise exceptions.PermissionDenied("Permissions for public users are too open")
380970
function checkFile(fileName, contents) {
    forbiddenCode.forEach(function(forbiddenItem) {
        if (contents.indexOf(forbiddenItem) > -1) {
            /* eslint-disable */
            console.log('FAILURE: '.red + 'You left a '.reset + forbiddenItem.yellow + ' in '.reset + fileName.cyan);
            /* eslint-enable */
            errorFound = true;
        }
    });
}
447007
def check_create_folder(filename):
    """"""
    os.makedirs(os.path.dirname(filename), exist_ok=True)
356193
def overwrite_file_check(args, filename):
    """"""
    if not args['overwrite'] and os.path.exists(filename):
        # Confirm overwriting of the file, or modify filename
        if args['no_overwrite']:
            overwrite = False
        else:
            try:
                overwrite = confirm_input(input('Overwrite {0}? (yes/no): '
                                                .format(filename)))
            except (KeyboardInterrupt, EOFError):
                sys.exit()
        if not overwrite:
            new_filename = modify_filename_id(filename)
            while os.path.exists(new_filename):
                new_filename = modify_filename_id(new_filename)
            return new_filename
    return filename