aboutsummaryrefslogtreecommitdiffstats
path: root/test/test-chroot-symlink.c
blob: 469cb49f42b4f2332eb2c1e3753ae5f79087fc60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 * Test that stat'ing absolute/relative symlinks in a chroot environment works
 * SPDX-License-Identifier: LGPL-2.1-only
 *
 */
#define _GNU_SOURCE

#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
    struct stat buf;

    if (argc != 2) {
        perror("args");
	return 2;
    }
    if (chroot(argv[1]) == -1) {
        perror("chroot");
        return 1;
    }
    if (stat("symlink", &buf) == -1) {
        perror("stat symlink");
        return 1;
    }
    return 0;
}