Quote mount point when resizing btrfs (#782681)

A user had a btrfs file system mounted by automounter on a mount point
like "/mount/$USER/File System Label" which included white space
characters.  Resizing the file system while online failed like this:

    Grow /dev/sdb1 from 1.00 GiB to 1.50 GiB
    + calibrate /dev/sdb1
    + grow partition from 1.00 GiB to 1.50 GiB
    + grow file system to fill the partition
      + btrfs filesystem resize 1:max /mount/USER/File System Label
          btrfs filesystem resize: too many arguments
          usage: btrfs filesystem resize [devid:][+/-]<newsize>[kKmMgGtTpPeE]|[devid:]max <path>

So mount points not created by GParted should be considered under user
control and need quoting when used as parameters in command lines.
Strictly speaking, mount points created by GParted itself, by
FileSystem::mk_temp_dir(), are safe and don't need quoting.  However it
is simpler and safer just to quote all uses of mount points in command
lines, rather than risk missing some.

Bug 782681 - btrfs partitions mounted with whitespace cannot be resized
This commit is contained in:
Mike Fleetwood 2017-05-19 08:27:36 +01:00 committed by Curtis Gedak
parent 75131d85a5
commit 618c1a202d
1 changed files with 5 additions and 5 deletions

View File

@ -320,7 +320,7 @@ bool btrfs::resize( const Partition & partition_new, OperationDetail & operation
mount_point = mk_temp_dir( "", operationdetail ) ;
if ( mount_point .empty() )
return false ;
success &= ! execute_command( "mount -v -t btrfs " + path + " " + mount_point,
success &= ! execute_command( "mount -v -t btrfs " + path + " \"" + mount_point + "\"",
operationdetail, EXEC_CHECK_STATUS );
}
else
@ -336,9 +336,9 @@ bool btrfs::resize( const Partition & partition_new, OperationDetail & operation
size = "max" ;
Glib::ustring cmd ;
if ( btrfs_found )
cmd = "btrfs filesystem resize " + devid_str + ":" + size + " " + mount_point ;
cmd = "btrfs filesystem resize " + devid_str + ":" + size + " \"" + mount_point + "\"";
else
cmd = "btrfsctl -r " + devid_str + ":" + size + " " + mount_point ;
cmd = "btrfsctl -r " + devid_str + ":" + size + " \"" + mount_point + "\"";
exit_status = execute_command( cmd, operationdetail );
bool resize_succeeded = ( exit_status == 0 ) ;
if ( resize_to_same_size_fails )
@ -365,8 +365,8 @@ bool btrfs::resize( const Partition & partition_new, OperationDetail & operation
success &= resize_succeeded ;
if ( ! partition_new .busy )
success &= ! execute_command( "umount -v " + mount_point, operationdetail,
EXEC_CHECK_STATUS );
success &= ! execute_command( "umount -v \"" + mount_point + "\"",
operationdetail, EXEC_CHECK_STATUS );
}
if ( ! partition_new .busy )