From 5628820aad1597d6c95795148f19b1e219c2967f Mon Sep 17 00:00:00 2001 From: tkusumi Date: Wed, 4 May 2022 11:27:54 +0000 Subject: [PATCH] usr.sbin/autofs: Fix absolute path when creating a mountpoint taken-from freebsd 63640b2f552c0476f50484635eb9888eafcd22dc --- usr.sbin/autofs/automount.c | 14 ++------------ usr.sbin/autofs/common.c | 6 +++--- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/usr.sbin/autofs/automount.c b/usr.sbin/autofs/automount.c index d269775cbc97..0e6a93f44b8f 100644 --- a/usr.sbin/autofs/automount.c +++ b/usr.sbin/autofs/automount.c @@ -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 -__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 #include @@ -83,18 +83,8 @@ mount_autofs(const char *from, const char *fspath, const char *options, { 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); diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c index cb82e44383c0..5eea6dbf3d8e 100644 --- a/usr.sbin/autofs/common.c +++ b/usr.sbin/autofs/common.c @@ -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 -__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 #include @@ -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)