]>
git.proxmox.com Git - systemd.git/blob - src/test/test-acl-util.c
2 This file is part of systemd.
4 Copyright 2015 Zbigniew Jędrzejewski-Szmek
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
28 #include "string-util.h"
29 #include "user-util.h"
31 static void test_add_acls_for_user(void) {
32 char fn
[] = "/tmp/test-empty.XXXXXX";
33 _cleanup_close_
int fd
= -1;
38 fd
= mkostemp_safe(fn
, O_RDWR
|O_CLOEXEC
);
41 /* Use the mode that user journal files use */
42 assert_se(fchmod(fd
, 0640) == 0);
44 cmd
= strjoina("ls -l ", fn
);
45 assert_se(system(cmd
) == 0);
47 cmd
= strjoina("getfacl -p ", fn
);
48 assert_se(system(cmd
) == 0);
51 const char *nobody
= "nobody";
52 r
= get_user_creds(&nobody
, &uid
, NULL
, NULL
, NULL
);
58 r
= add_acls_for_user(fd
, uid
);
61 cmd
= strjoina("ls -l ", fn
);
62 assert_se(system(cmd
) == 0);
64 cmd
= strjoina("getfacl -p ", fn
);
65 assert_se(system(cmd
) == 0);
67 /* set the acls again */
69 r
= add_acls_for_user(fd
, uid
);
72 cmd
= strjoina("ls -l ", fn
);
73 assert_se(system(cmd
) == 0);
75 cmd
= strjoina("getfacl -p ", fn
);
76 assert_se(system(cmd
) == 0);
81 int main(int argc
, char **argv
) {
82 test_add_acls_for_user();