mailing list of musl libc
 help / color / mirror / code / Atom feed
* realpath after chroot
@ 2019-10-08 17:24 Reiner Herrmann
  2019-10-08 17:38 ` Rich Felker
  0 siblings, 1 reply; 8+ messages in thread
From: Reiner Herrmann @ 2019-10-08 17:24 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 717 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-10-09 16:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-08 17:24 realpath after chroot Reiner Herrmann
2019-10-08 17:38 ` Rich Felker
2019-10-08 17:49   ` Reiner Herrmann
2019-10-08 19:56   ` Markus Wichmann
2019-10-08 21:10     ` Rich Felker
2019-10-09  3:47       ` Markus Wichmann
2019-10-09 11:45         ` Rich Felker
2019-10-09 16:00           ` Markus Wichmann

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).