Function: file-acl

file-acl is a function defined in fileio.c.

Signature

(file-acl FILENAME)

Documentation

Return ACL entries of file named FILENAME.

The entries are returned in a format suitable for use in set-file-acl but is otherwise undocumented and subject to change. Return nil if file does not exist.

Other relevant functions are documented in the file group.

View in manual

Probably introduced at or before Emacs version 24.4.

Shortdoc

;; file
(file-acl "/tmp/foo")
    e.g. => "user::rw-\ngroup::r--\nother::r--\n"

Source Code

// Defined in /usr/src/emacs/src/fileio.c
{
  Lisp_Object acl_string = Qnil;

#if USE_ACL
  Lisp_Object absname = expand_and_dir_to_file (filename);

  /* If the file name has special constructs in it,
     call the corresponding file name handler.  */
  Lisp_Object handler = Ffind_file_name_handler (absname, Qfile_acl);
  if (!NILP (handler))
    return call2 (handler, Qfile_acl, absname);

# ifdef HAVE_ACL_SET_FILE
#  ifndef HAVE_ACL_TYPE_EXTENDED
  acl_type_t ACL_TYPE_EXTENDED = ACL_TYPE_ACCESS;
#  endif
  acl_t acl = acl_get_file (SSDATA (ENCODE_FILE (absname)), ACL_TYPE_EXTENDED);
  if (acl == NULL)
    {
      if (errno == ENOENT || errno == ENOTDIR || !acl_errno_valid (errno))
	return Qnil;
      report_file_error ("Getting ACLs", absname);
    }
  char *str = acl_to_text (acl, NULL);
  if (str == NULL)
    {
      int err = errno;
      acl_free (acl);
      report_file_errno ("Getting ACLs", absname, err);
    }

  acl_string = build_string (str);
  acl_free (str);
  acl_free (acl);
# endif
#endif

  return acl_string;
}