]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-acl-util.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
11 #include "string-util.h"
12 #include "user-util.h"
14 static void test_add_acls_for_user(void) {
15 char fn
[] = "/tmp/test-empty.XXXXXX";
16 _cleanup_close_
int fd
= -1;
21 fd
= mkostemp_safe(fn
);
24 /* Use the mode that user journal files use */
25 assert_se(fchmod(fd
, 0640) == 0);
27 cmd
= strjoina("ls -l ", fn
);
28 assert_se(system(cmd
) == 0);
30 cmd
= strjoina("getfacl -p ", fn
);
31 assert_se(system(cmd
) == 0);
34 const char *nobody
= NOBODY_USER_NAME
;
35 r
= get_user_creds(&nobody
, &uid
, NULL
, NULL
, NULL
, 0);
41 r
= add_acls_for_user(fd
, uid
);
44 cmd
= strjoina("ls -l ", fn
);
45 assert_se(system(cmd
) == 0);
47 cmd
= strjoina("getfacl -p ", fn
);
48 assert_se(system(cmd
) == 0);
50 /* set the acls again */
52 r
= add_acls_for_user(fd
, uid
);
55 cmd
= strjoina("ls -l ", fn
);
56 assert_se(system(cmd
) == 0);
58 cmd
= strjoina("getfacl -p ", fn
);
59 assert_se(system(cmd
) == 0);
64 int main(int argc
, char **argv
) {
65 test_add_acls_for_user();