[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] ls - colorize files with capabilities
From: |
Kamil Dudka |
Subject: |
Re: [PATCH] ls - colorize files with capabilities |
Date: |
Tue, 22 Jul 2008 13:00:25 +0200 |
User-agent: |
KMail/1.9.9 |
On Monday 21 July 2008 17:43:52 you wrote:
> Kamil Dudka <address@hidden> wrote:
> Don't pessimize your code because doing it cleanly might not work.
> Have no fear ;-), and do it cleanly.
> The documentation ("man cap_to_text") appears to guarantee
> the required semantics, so it ought to work.
> If in doubt, test it with valgrind.
Ok, rewritten to do it cleanly...
> > /* Returns whether any color sequence was printed. */
> > static bool
> > print_color_indicator (const char *name, mode_t mode, int linkok,
> > @@ -3923,6 +3963,8 @@ print_color_indicator (const char *name, mode_t
> > mode, int linkok, type = C_SETUID;
> > else if ((mode & S_ISGID) != 0)
> > type = C_SETGID;
> > + else if (has_capability (name))
> > + type = C_CAP;
> > else if ((mode & S_IXUGO) != 0)
> > type = C_EXEC;
> > }
Caused by mixing tabs and spaces in original code, which I didn't recognized
at first glance. Fixed...
> Oops. Mangled indentation.
> BTW, I noticed something similar in your dd patch.
> Do you use unusual TAB-stop settings?
I guess usual TAB-stop for coreutils is 8, noexpandtab - I am changing
my .vimrc...
> Otherwise, so far, so good. Whenever we add a new ls-color-related
> capability, the corresponding list in dircolors.c must be updated
> to match. Otherwise, "make check-ls-dircolors" will fail. Also,
> dircolors.hin must be updated to add a brief description.
Fixed, make check-ls-dircolors now passes...
> And of course, we'll need at least one test.
> To test it, you'll have to require a cap-related
> command-line tool (i.e., skip the test if it doesn't
> exist -- there are similar functions in test-lib.sh,
> e.g., require_strace_ and require_acl_), and then run
> LS_COLORS='...' ls --color=always file-with-cap > out
> and confirm that the expected (new) mark-up is present.
> See tests/ls/stat-free-symlinks for a similar test that
> runs ls with a custom LS_COLORS setting.
I have made new test ls/capability which need to be run under root - only root
can set capability of file.
> And here you thought this would be simple.
Of course it was simple - that's why I am working on it ;-)
Kamil
coreutils-libcap.patch
Description: Text Data