Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Tue, 8 Oct 2019 19:24:02 +0200
From: Reiner Herrmann <reiner@...ner-h.de>
To: musl@...ts.openwall.com
Subject: realpath after chroot

Hi,

I noticed that realpath is no longer working after chroot is called.
With the example from below I get the following output with musl 1.1.23:

# ./a.out
/
No such file or directory

With glibc it is working as I would expect:

# ./a.out
/
/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <unistd.h>
#include <errno.h>

int main() {
	char *p = realpath("/", NULL);
	if (!p) {
		printf("%s\n", strerror(errno));
	} else {
		printf("%s\n", p);
		free(p);
	}

	if (chroot("/tmp") == -1)
		printf("chroot failed\n");

	p = realpath("/", NULL);
	if (!p) {
		printf("%s\n", strerror(errno));
	} else {
		printf("%s\n", p);
		free(p);
	}

	return 0;
}


Kind regards,
  Reiner

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.