Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/autofs usr.sbin/autofs: Fix absolute path when crea...



details:   https://anonhg.NetBSD.org/src/rev/a49369e9403e
branches:  trunk
changeset: 365944:a49369e9403e
user:      tkusumi <tkusumi%NetBSD.org@localhost>
date:      Wed May 04 11:27:54 2022 +0000

description:
usr.sbin/autofs: Fix absolute path when creating a mountpoint

taken-from freebsd 63640b2f552c0476f50484635eb9888eafcd22dc

diffstat:

 usr.sbin/autofs/automount.c |  14 ++------------
 usr.sbin/autofs/common.c    |   6 +++---
 2 files changed, 5 insertions(+), 15 deletions(-)

diffs (64 lines):

diff -r 152e033d0f55 -r a49369e9403e usr.sbin/autofs/automount.c
--- a/usr.sbin/autofs/automount.c       Wed May 04 11:07:43 2022 +0000
+++ b/usr.sbin/autofs/automount.c       Wed May 04 11:27:54 2022 +0000
@@ -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 @@
 {
        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 -r 152e033d0f55 -r a49369e9403e usr.sbin/autofs/common.c
--- a/usr.sbin/autofs/common.c  Wed May 04 11:07:43 2022 +0000
+++ b/usr.sbin/autofs/common.c  Wed May 04 11:27:54 2022 +0000
@@ -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 @@
         */
        copy = tofree = checked_strdup(path + 1);
 
-       partial = checked_strdup("");
+       partial = checked_strdup("/");
        for (;;) {
                component = strsep(&copy, "/");
                if (component == NULL)



Home | Main Index | Thread Index | Old Index