2 Copyright (C) 2009 Andreas Gruenbacher <agruen@suse.de>
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 int main(int argc, char *argv[])
31 progname = basename(argv[0]);
34 printf("%s -- get access control lists of files\n"
35 "Usage: %s file ...\n",
40 for (n = 1; n < argc; n++) {
42 acl_t acl, default_acl;
43 char *acl_text, *default_acl_text, *token;
45 if (stat(argv[n], &st) != 0) {
46 fprintf(stderr, "%s: %s: %s\n",
47 progname, argv[n], strerror(errno));
52 acl = acl_get_file(argv[n], ACL_TYPE_ACCESS);
54 fprintf(stderr, "%s: getting acl of %s: %s\n",
55 progname, argv[n], strerror(errno));
59 acl_text = acl_to_text(acl, NULL);
62 if (S_ISDIR(st.st_mode)) {
63 default_acl = acl_get_file(argv[n], ACL_TYPE_DEFAULT);
64 if (default_acl == NULL) {
66 fprintf(stderr, "%s: getting default acl "
67 "of %s: %s\n", progname, argv[n],
72 default_acl_text = acl_to_text(default_acl, NULL);
73 acl_free(default_acl);
80 argv[n], st.st_uid, st.st_gid, acl_text);
82 if (S_ISDIR(st.st_mode)) {
83 token = strtok(default_acl_text, "\n");
85 printf("default:%s\n", token);
86 token = strtok(NULL, "\n");
88 acl_free(default_acl_text);