Module Name: src
Committed By: tkusumi
Date: Wed May 4 11:27:54 UTC 2022
Modified Files:
src/usr.sbin/autofs: automount.c common.c
Log Message:
usr.sbin/autofs: Fix absolute path when creating a mountpoint
taken-from freebsd 63640b2f552c0476f50484635eb9888eafcd22dc
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/autofs/automount.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/autofs/common.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/autofs/automount.c
diff -u src/usr.sbin/autofs/automount.c:1.3 src/usr.sbin/autofs/automount.c:1.4
--- src/usr.sbin/autofs/automount.c:1.3 Mon Jan 15 14:38:06 2018
+++ src/usr.sbin/autofs/automount.c Wed May 4 11:27:54 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: automount.c,v 1.3 2018/01/15 14:38:06 christos Exp $ */
+/* $NetBSD: automount.c,v 1.4 2022/05/04 11:27:54 tkusumi Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: automount.c,v 1.3 2018/01/15 14:38:06 christos Exp $");
+__RCSID("$NetBSD: automount.c,v 1.4 2022/05/04 11:27:54 tkusumi Exp $");
#include <sys/types.h>
#include <sys/mount.h>
@@ -83,18 +83,8 @@ mount_autofs(const char *from, const cha
{
struct autofs_args args;
int error;
- char *cwd;
- /*
- * There is no guarantee we are at /, so chdir to /.
- */
- cwd = getcwd(NULL, 0);
- if (chdir("/") != 0)
- log_warn("failed to chdir to /");
create_directory(fspath);
- if (chdir(cwd) != 0)
- log_warn("failed to restore cwd");
- free(cwd);
log_debugx("mounting %s on %s, prefix \"%s\", options \"%s\"",
from, fspath, prefix, options);
Index: src/usr.sbin/autofs/common.c
diff -u src/usr.sbin/autofs/common.c:1.4 src/usr.sbin/autofs/common.c:1.5
--- src/usr.sbin/autofs/common.c:1.4 Tue Sep 14 20:40:55 2021
+++ src/usr.sbin/autofs/common.c Wed May 4 11:27:54 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: common.c,v 1.4 2021/09/14 20:40:55 rillig Exp $ */
+/* $NetBSD: common.c,v 1.5 2022/05/04 11:27:54 tkusumi Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
* $FreeBSD: head/usr.sbin/autofs/common.c 303527 2016-07-30 01:10:05Z bapt $
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: common.c,v 1.4 2021/09/14 20:40:55 rillig Exp $");
+__RCSID("$NetBSD: common.c,v 1.5 2022/05/04 11:27:54 tkusumi Exp $");
#include <sys/types.h>
#include <sys/stat.h>
@@ -132,7 +132,7 @@ create_directory(const char *path)
*/
copy = tofree = checked_strdup(path + 1);
- partial = checked_strdup("");
+ partial = checked_strdup("/");
for (;;) {
component = strsep(©, "/");
if (component == NULL)