Git init
[framework/base/acl.git] / packaging / 04-print_useful_error_from_read_acl_comments.patch
1 commit fd34ef53234f465bf12cd51ca3a7bb056856e3dd
2 Author: Brandon Philips <brandon@ifup.org>
3 Date:   Thu Dec 17 13:36:57 2009 -0800
4
5     setfacl: print useful error from read_acl_comments
6     
7     restore()'s fail path expects errno to contain the error but that is not
8     the case with read_acl_comments().
9     
10     Fix up the error path in restore() and have read_acl_comments() return
11     EINVAL which makes more sense in this case.
12     
13     Signed-off-by: Brandon Philips <bphilips@suse.de>
14
15 diff --git a/setfacl/parse.c b/setfacl/parse.c
16 index 4df1a19..b333beb 100644
17 --- a/setfacl/parse.c
18 +++ b/setfacl/parse.c
19 @@ -527,7 +527,7 @@ read_acl_comments(
20  fail:
21         if (path_p && *path_p)
22                 free(*path_p);
23 -       return -1;
24 +       return -EINVAL;
25  }
26  
27  
28 diff --git a/setfacl/setfacl.c b/setfacl/setfacl.c
29 index 56b0aa4..802f060 100644
30 --- a/setfacl/setfacl.c
31 +++ b/setfacl/setfacl.c
32 @@ -136,8 +136,10 @@ restore(
33                 backup_line = line;
34                 error = read_acl_comments(file, &line, &path_p, &uid, &gid,
35                                           &flags);
36 -               if (error < 0)
37 +               if (error < 0) {
38 +                       error = -error;
39                         goto fail;
40 +               }
41                 if (error == 0)
42                         return status;
43  
44 @@ -158,10 +160,10 @@ restore(
45                 }
46  
47                 if (!(args.seq = seq_init()))
48 -                       goto fail;
49 +                       goto fail_errno;
50                 if (seq_append_cmd(args.seq, CMD_REMOVE_ACL, ACL_TYPE_ACCESS) ||
51                     seq_append_cmd(args.seq, CMD_REMOVE_ACL, ACL_TYPE_DEFAULT))
52 -                       goto fail;
53 +                       goto fail_errno;
54  
55                 error = read_acl_seq(file, args.seq, CMD_ENTRY_REPLACE,
56                                      SEQ_PARSE_WITH_PERM |
57 @@ -249,9 +251,11 @@ getout:
58         }
59         return status;
60  
61 +fail_errno:
62 +       error = errno;
63  fail:
64         fprintf(stderr, "%s: %s: %s\n", progname, xquote(filename, "\n\r"),
65 -               strerror(errno));
66 +               strerror(error));
67         status = 1;
68         goto getout;
69  }