aboutsummaryrefslogtreecommitdiff
path: root/filesystem/mountpoint.go
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-11-27 11:07:38 -0800
committerEric Biggers <ebiggers@google.com>2019-11-27 11:07:38 -0800
commit2a45549820a4e364d000ac62362d2feafbb0b3c1 (patch)
treec70b8e254f291869e7d9374ed886866803fbf38d /filesystem/mountpoint.go
parent9c2cc186ecce7d0bb6e220b0312222ce93090790 (diff)
Allow filesystem links to contain leading/trailing whitespace
To make manually editing linked protectors slightly more user-friendly, automatically strip any leading or trailing whitespace. E.g. treat "UUID=3a6d9a76-47f0-4f13-81bf-3332fbe984fb\n" the same as "UUID=3a6d9a76-47f0-4f13-81bf-3332fbe984fb". Update https://github.com/google/fscrypt/issues/115
Diffstat (limited to 'filesystem/mountpoint.go')
-rw-r--r--filesystem/mountpoint.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/filesystem/mountpoint.go b/filesystem/mountpoint.go
index d9dbf37..6119be8 100644
--- a/filesystem/mountpoint.go
+++ b/filesystem/mountpoint.go
@@ -282,7 +282,7 @@ func GetMount(mountpoint string) (*Mount, error) {
return mnt, nil
}
-// getMountsFromLink returns the Mount object which matches the provided link.
+// getMountFromLink returns the Mount object which matches the provided link.
// This link is formatted as a tag (e.g. <token>=<value>) similar to how they
// appear in "/etc/fstab". Currently, only "UUID" tokens are supported. An error
// is returned if the link is invalid or we cannot load the required mount data.
@@ -290,6 +290,7 @@ func GetMount(mountpoint string) (*Mount, error) {
// functions, run UpdateMountInfo to see the change.
func getMountFromLink(link string) (*Mount, error) {
// Parse the link
+ link = strings.TrimSpace(link)
linkComponents := strings.Split(link, "=")
if len(linkComponents) != 2 {
return nil, errors.Wrapf(ErrFollowLink, "link %q format is invalid", link)