diff options
author | tjr <tjr@FreeBSD.org> | 2002-11-03 23:22:34 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-11-03 23:22:34 +0000 |
commit | a743b5e38f147e7abd37782544a0cabf73fdb6cc (patch) | |
tree | 98ca6a347728a727899dd793fd7cde4446e4fc49 /bin/getfacl | |
parent | 50217c83e5586c657e69745ba08162ad05de7e09 (diff) | |
download | FreeBSD-src-a743b5e38f147e7abd37782544a0cabf73fdb6cc.zip FreeBSD-src-a743b5e38f147e7abd37782544a0cabf73fdb6cc.tar.gz |
- Consistent use of warn() vs. perror().
- Gracefully handle the case where standard input is missing
a newline at EOF.
- Exit with status 1 instead of -1 (really 255) on error.
- Add a Diagnostics section to the manual page documenting
exit status.
Approved by: rwatson
Diffstat (limited to 'bin/getfacl')
-rw-r--r-- | bin/getfacl/getfacl.1 | 2 | ||||
-rw-r--r-- | bin/getfacl/getfacl.c | 17 |
2 files changed, 10 insertions, 9 deletions
diff --git a/bin/getfacl/getfacl.1 b/bin/getfacl/getfacl.1 index aff3e93..291999a 100644 --- a/bin/getfacl/getfacl.1 +++ b/bin/getfacl/getfacl.1 @@ -89,6 +89,8 @@ Retrieve ACL for the directory Retrieve the default ACL for the directory .Pa / , if any. +.Sh DIAGNOSTICS +.Ex -std .Sh SEE ALSO .Xr setfacl 1 , .Xr acl 3 , diff --git a/bin/getfacl/getfacl.c b/bin/getfacl/getfacl.c index 7becd17..22406d5 100644 --- a/bin/getfacl/getfacl.c +++ b/bin/getfacl/getfacl.c @@ -156,7 +156,7 @@ print_acl(char *path, acl_type_t type) error = stat(path, &sb); if (error == -1) { - perror(path); + warn("%s", path); return(-1); } @@ -178,14 +178,14 @@ print_acl(char *path, acl_type_t type) return(0); acl = acl_from_stat(sb); if (!acl) { - perror("acl_from_stat()"); + warn("acl_from_stat()"); return(-1); } } acl_text = acl_to_text(acl, 0); if (!acl_text) { - perror(path); + warn("%s", path); return(-1); } @@ -200,13 +200,12 @@ print_acl(char *path, acl_type_t type) static int print_acl_from_stdin(acl_type_t type) { - char pathname[PATH_MAX]; + char *p, pathname[PATH_MAX]; int carried_error = 0; - pathname[sizeof(pathname) - 1] = '\0'; while (fgets(pathname, (int)sizeof(pathname), stdin)) { - /* remove the \n */ - pathname[strlen(pathname) - 1] = '\0'; + if ((p = strchr(pathname, '\n')) != NULL) + *p = '\0'; if (print_acl(pathname, type) == -1) { carried_error = -1; } @@ -236,7 +235,7 @@ main(int argc, char *argv[]) if (argc == 0) { error = print_acl_from_stdin(type); - return(error); + return(error ? 1 : 0); } for (i = 0; i < argc; i++) { @@ -251,5 +250,5 @@ main(int argc, char *argv[]) } } - return(carried_error); + return(carried_error ? 1 : 0); } |