diff options
author | rwatson <rwatson@FreeBSD.org> | 2002-12-18 21:05:15 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2002-12-18 21:05:15 +0000 |
commit | 98da0e02a3e0c12f5c517934448737b2743cf417 (patch) | |
tree | 1f428bb43f978d58bd7aa1f2dec7a07119cbc04a /bin/ls | |
parent | fd4a464ac4051c332c2942e10f0baa8f8277aa61 (diff) | |
download | FreeBSD-src-98da0e02a3e0c12f5c517934448737b2743cf417.zip FreeBSD-src-98da0e02a3e0c12f5c517934448737b2743cf417.tar.gz |
Improve handling of symlink targets when listing MAC labels: don't
do the wrong thing when the symlink doesn't have a target, by
considering !f_label in the construction of ch_options.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
Diffstat (limited to 'bin/ls')
-rw-r--r-- | bin/ls/ls.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/bin/ls/ls.c b/bin/ls/ls.c index 7097caa..dc22f97 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -448,7 +448,8 @@ traverse(int argc, char *argv[], int options) * If not recursing down this tree and don't need stat info, just get * the names. */ - ch_options = !f_recursive && options & FTS_NOSTAT ? FTS_NAMEONLY : 0; + ch_options = !f_recursive && !f_label && + options & FTS_NOSTAT ? FTS_NAMEONLY : 0; while ((p = fts_read(ftsp)) != NULL) switch (p->fts_info) { @@ -691,7 +692,9 @@ display(FTSENT *p, FTSENT *list, int options) error = mac_prepare_file_label(&label); if (error == -1) { - warn("%s", cur->fts_name); + warn("MAC label for %s/%s", + cur->fts_parent->fts_path, + cur->fts_name); goto label_out; } @@ -700,8 +703,8 @@ display(FTSENT *p, FTSENT *list, int options) "%s", cur->fts_name); else snprintf(name, sizeof(name), - "%s/%s", cur->fts_parent->fts_accpath, - cur->fts_name); + "%s/%s", cur->fts_parent-> + fts_accpath, cur->fts_name); if (options & FTS_LOGICAL) error = mac_get_file(name, @@ -710,7 +713,9 @@ display(FTSENT *p, FTSENT *list, int options) error = mac_get_link(name, label); if (error == -1) { - warn("%s", cur->fts_name); + warn("MAC label for %s/%s", + cur->fts_parent->fts_path, + cur->fts_name); mac_free(label); goto label_out; } @@ -718,7 +723,9 @@ display(FTSENT *p, FTSENT *list, int options) error = mac_to_text(label, &labelstr); if (error == -1) { - warn("%s", cur->fts_name); + warn("MAC label for %s/%s", + cur->fts_parent->fts_path, + cur->fts_name); mac_free(label); goto label_out; } |