Bug 224601 - autofs: Make automount(8) call chdir("/") before create_directory()
Summary: autofs: Make automount(8) call chdir("/") before create_directory()
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-fs mailing list
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-12-26 18:06 UTC by kusumi.tomohiro
Modified: 2018-01-16 04:12 UTC (History)
2 users (show)

See Also:


Attachments
Fixes the issue. (1.91 KB, application/mbox)
2017-12-26 18:06 UTC, kusumi.tomohiro
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description kusumi.tomohiro 2017-12-26 18:06:14 UTC
Created attachment 189116 [details]
Fixes the issue.

Unlike automountd where the daemon is daemonized or lesser-daemonized,
an automount process isn't necessarily at /, and this results in
creating unneeded directories at the current directory.

In the example below, mounting autofs on /mnt/media fails because the
command mkdirs mnt/media instead of /mnt/media. If /mnt/media already
exists the command can mount autofs on /mnt/media, but it still mkdirs
unneeded directories mnt/media.

Calling chdir("/") before creation and restoring the directory after
creation avoids this.

--
[root@]~# automount -L
/mnt/media                -nosuid               -media               # indirect map referenced at /etc/auto_master:8
[root@]~# ls mnt
ls: mnt: No such file or directory
[root@]~# automount
automount: cannot mount map -media on /mnt/media: No such file or directory
[root@]~# mount | grep autofs
[root@]~# ls mnt
media
[root@]~# tree mnt
mnt
`-- media
Comment 1 Pedro F. Giffuni freebsd_committer 2018-01-16 04:12:13 UTC
Assign it to -fs list.