Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flags to print ACLs and file flags #170

Open
lilyball opened this issue Apr 26, 2017 · 4 comments
Open

Flags to print ACLs and file flags #170

lilyball opened this issue Apr 26, 2017 · 4 comments
Assignees
Labels
feature request New features to add to exa os › macos macOS stuff

Comments

@lilyball
Copy link
Contributor

macOS's ls has -e to print ACLs and -O to print file flags (e.g. hidden). It would be great if exa could offer the same flags, at least on macOS.

@ogham ogham added feature request New features to add to exa os › macos macOS stuff labels Apr 4, 2021
@ogham ogham self-assigned this Apr 4, 2021
@hguandl
Copy link

hguandl commented Aug 23, 2021

Hi, I have found out a snippet to print the file flags, which calls strtofflags(3). Here is the example:

use std::fs;
use std::os::macos::fs::MetadataExt;
use std::os::raw::c_char;

#[cfg(target_os = "macos")]
extern "C" {
    fn fflagstostr(flags: u32) -> *const c_char;
}

fn main() -> std::io::Result<()> {
    let attr = fs::metadata("/Users/hguandl/Library")?;

    let flag_str = unsafe {
        let c_buf = fflagstostr(attr.st_flags());
        CStr::from_ptr(c_buf)
    };

    println!("{}", flag_str.to_str().unwrap());

    Ok(())
}
$ cargo run
hidden

@lukasjuhrich
Copy link

lukasjuhrich commented Mar 12, 2022

Would it make sense to split off a separate feature request asking for a + indicator? Similarly to the t indicator for a sticky bit, ls adds a + in the case any acl's are present:

Example with acls
root@gutenberg ~ # ls -ld . 
drwx--x---+  13 root root 4096 Mar 12 18:36 .
root@gutenberg ~ # exa -ld .
drwx--x--- - root 12 Mar 18:36 .
root@gutenberg ~ # getfacl -psc .   
user::rwx
user:reprepro:--x
group::---
mask::--x
other::---
Example without acls
root@gutenberg ~ # ls -ld .config
drwx------ 5 root root 4096 Dec 30  2020 .config
root@gutenberg ~ # exa -ld .config
drwx------ - root 30 Dec  2020 .config
root@gutenberg ~ # getfacl -psc .config
root@gutenberg ~ #
Related: #142

@perobertson
Copy link

On Linux ls adds a . for files without an ACL and + when there is one. Instead of adding a new flag to be able to show them it could be added to the -l option to match what ls does.

-rw-r--r--. 1 root root 57 Aug 31 13:43 no-acl.txt
-rw-r--r--+ 1 root root 57 Sep 12 17:11 acl.txt

@vsczpv
Copy link

vsczpv commented Jul 12, 2023

In the meantime, the -@ option used to show extended attributes already shows if a file has an ACL or not.

$ exa -l
.rw-r--r--@ 0 user 12 jul 15:28 acl.txt
.rw-r--r--  0 user 12 jul 15:28 no-acl.txt
$ exa -l -@
.rw-r--r--@ 0 user 12 jul 15:28 acl.txt
                                    └── system.posix_acl_access (len 44)
.rw-r--r--  0 user 12 jul 15:28 no-acl.txt

Though it would be nice to indicate ACLs with the plus sign, just as ls does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New features to add to exa os › macos macOS stuff
Projects
None yet
Development

No branches or pull requests

6 participants