Force localfs_dir to be an absolute path - fixes PR install/14130.

Put disklabel info into /tmp/disktab in case / isn't writable,
fixes PR 17347.  Note the /etc/disktab isn't the target /etc anyway...
This commit is contained in:
dsl 2003-07-27 08:57:27 +00:00
parent deeae012af
commit faefcd3805
3 changed files with 19 additions and 13 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: disks.c,v 1.66 2003/07/27 07:45:08 dsl Exp $ */
/* $NetBSD: disks.c,v 1.67 2003/07/27 08:57:27 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -263,7 +263,7 @@ write_disklabel (void)
#ifdef DISKLABEL_CMD
/* disklabel the disk */
return run_prog(RUN_DISPLAY, MSG_cmdfail,
"%s %s %s", DISKLABEL_CMD, diskdev, bsddiskname);
"%s -f /tmp/disktab %s %s", DISKLABEL_CMD, diskdev, bsddiskname);
#else
return 0;
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: savenewlabel.c,v 1.4 2003/07/07 12:30:22 dsl Exp $ */
/* $NetBSD: savenewlabel.c,v 1.5 2003/07/27 08:57:27 dsl Exp $ */
/*
* Copyright 1997 Jonathan Stone
@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: savenewlabel.c,v 1.4 2003/07/07 12:30:22 dsl Exp $");
__RCSID("$NetBSD: savenewlabel.c,v 1.5 2003/07/27 08:57:27 dsl Exp $");
#endif
#include <sys/types.h>
@ -59,12 +59,8 @@ savenewlabel(partinfo *lp, int nparts)
FILE *f;
int i;
#ifdef DEBUG
f = fopen("/tmp/disktab", "a");
#else
/* Create the disktab.preinstall */
f = fopen("/etc/disktab", "w");
#endif
f = fopen("/tmp/disktab", "w");
if (logging)
(void)fprintf(logfp, "Creating disklabel %s\n", bsddiskname);
scripting_fprintf(NULL, "cat <<EOF >>/etc/disktab\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: util.c,v 1.108 2003/07/27 07:45:09 dsl Exp $ */
/* $NetBSD: util.c,v 1.109 2003/07/27 08:57:27 dsl Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -421,8 +421,18 @@ get_via_localdir(void)
process_menu(MENU_localdirsource, NULL);
/* Complain if not a directory or distribution files absent */
while ((dir_exists_p(localfs_dir) == 0 && (errmsg = MSG_badlocalsetdir)) ||
(distribution_sets_exist_p(localfs_dir) == 0 && (errmsg = MSG_badsetdir))) {
for (;;) {
/*
* We have to have an absolute path ('cos pax runs in a
* different directory), make it so.
*/
if (localfs_dir[0] != '/') {
memmove(localfs_dir + 1, localfs_dir, sizeof localfs_dir - 1);
localfs_dir[0] = '/';
}
if ((errmsg = MSG_badlocalsetdir, dir_exists_p(localfs_dir)) &&
(errmsg = MSG_badsetdir, distribution_sets_exist_p(localfs_dir)))
break;
process_menu(MENU_localdirbad, &errmsg);
if (!yesno)
return (0);
@ -431,7 +441,7 @@ get_via_localdir(void)
}
/* return location, don't clean... */
strlcpy(ext_dir, localfs_dir, STRSIZE);
strlcpy(ext_dir, localfs_dir, sizeof ext_dir);
clean_dist_dir = 0;
mnt2_mounted = 0;
return 1;