When creating a relative symlink (-lr), use the originally provided `to_name'

to create and metalog, rather than using the realpath(3) modified version.
Fixes a problem with -lr when -ddestdir contains a symlink.

Add some XXX comments reminding us that the `from_name' in a symlink may
point outside of destdir in the metalog, even though our build process
doesn't trigger this.
This commit is contained in:
lukem 2005-05-10 01:24:42 +00:00
parent 885dad801d
commit 1282d958b8

View File

@ -1,4 +1,4 @@
/* $NetBSD: xinstall.c,v 1.89 2005/05/08 23:05:02 lukem Exp $ */
/* $NetBSD: xinstall.c,v 1.90 2005/05/10 01:24:42 lukem Exp $ */
/*
* Copyright (c) 1987, 1993
@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\
#if 0
static char sccsid[] = "@(#)xinstall.c 8.1 (Berkeley) 7/21/93";
#else
__RCSID("$NetBSD: xinstall.c,v 1.89 2005/05/08 23:05:02 lukem Exp $");
__RCSID("$NetBSD: xinstall.c,v 1.90 2005/05/10 01:24:42 lukem Exp $");
#endif
#endif /* not lint */
@ -506,6 +506,7 @@ makelink(char *from_name, char *to_name)
if (realpath(from_name, src) == NULL)
err(1, "%s: realpath", from_name);
do_symlink(src, to_name);
/* XXX: src may point outside of destdir */
metadata_log(to_name, "link", NULL, src, NULL);
return;
}
@ -546,8 +547,9 @@ makelink(char *from_name, char *to_name)
(void)strlcat(lnk, ++s, sizeof(lnk));
do_symlink(lnk, dst);
metadata_log(dst, "link", NULL, lnk, NULL);
do_symlink(lnk, to_name);
/* XXX: lnk may point outside of destdir */
metadata_log(to_name, "link", NULL, lnk, NULL);
return;
}
@ -556,6 +558,7 @@ makelink(char *from_name, char *to_name)
* try the names the user provided
*/
do_symlink(from_name, to_name);
/* XXX: from_name may point outside of destdir */
metadata_log(to_name, "link", NULL, from_name, NULL);
}