Skip to content

Commit

Permalink
Revert "libmount: exec mount helpers with posixly correct argument or…
Browse files Browse the repository at this point in the history
…der"

The change is not backwardly compatible, see util-linux#3355

This reverts commit 2d680b7.
  • Loading branch information
karelzak committed Jan 13, 2025
1 parent b4ea645 commit fc9c938
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 30 deletions.
26 changes: 12 additions & 14 deletions libmount/src/context_mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,33 +430,31 @@ static int exec_helper(struct libmnt_context *cxt)
type = mnt_fs_get_fstype(cxt->fs);

args[i++] = cxt->helper; /* 1 */
args[i++] = mnt_fs_get_srcpath(cxt->fs);/* 2 */
args[i++] = mnt_fs_get_target(cxt->fs); /* 3 */

if (mnt_context_is_sloppy(cxt))
args[i++] = "-s"; /* 2 */
args[i++] = "-s"; /* 4 */
if (mnt_context_is_fake(cxt))
args[i++] = "-f"; /* 3 */
args[i++] = "-f"; /* 5 */
if (mnt_context_is_nomtab(cxt))
args[i++] = "-n"; /* 4 */
args[i++] = "-n"; /* 6 */
if (mnt_context_is_verbose(cxt))
args[i++] = "-v"; /* 5 */
args[i++] = "-v"; /* 7 */
if (o) {
args[i++] = "-o"; /* 6 */
args[i++] = o; /* 7 */
args[i++] = "-o"; /* 8 */
args[i++] = o; /* 9 */
}
if (type
&& strchr(type, '.')
&& !endswith(cxt->helper, type)) {
args[i++] = "-t"; /* 8 */
args[i++] = type; /* 9 */
args[i++] = "-t"; /* 10 */
args[i++] = type; /* 11 */
}
if (namespace) {
args[i++] = "-N"; /* 10 */
args[i++] = namespace; /* 11 */
args[i++] = "-N"; /* 12 */
args[i++] = namespace; /* 13 */
}

args[i++] = mnt_fs_get_srcpath(cxt->fs);/* 12 */
args[i++] = mnt_fs_get_target(cxt->fs); /* 13 */

args[i] = NULL; /* 14 */
for (i = 0; args[i]; i++)
DBG(CXT, ul_debugobj(cxt, "argv[%d] = \"%s\"",
Expand Down
21 changes: 10 additions & 11 deletions libmount/src/context_umount.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,30 +711,29 @@ static int exec_helper(struct libmnt_context *cxt)
type = mnt_fs_get_fstype(cxt->fs);

args[i++] = cxt->helper; /* 1 */
args[i++] = mnt_fs_get_target(cxt->fs); /* 2 */

if (mnt_context_is_nomtab(cxt))
args[i++] = "-n"; /* 2 */
args[i++] = "-n"; /* 3 */
if (mnt_context_is_lazy(cxt))
args[i++] = "-l"; /* 3 */
args[i++] = "-l"; /* 4 */
if (mnt_context_is_force(cxt))
args[i++] = "-f"; /* 4 */
args[i++] = "-f"; /* 5 */
if (mnt_context_is_verbose(cxt))
args[i++] = "-v"; /* 5 */
args[i++] = "-v"; /* 6 */
if (mnt_context_is_rdonly_umount(cxt))
args[i++] = "-r"; /* 6 */
args[i++] = "-r"; /* 7 */
if (type
&& strchr(type, '.')
&& !endswith(cxt->helper, type)) {
args[i++] = "-t"; /* 7 */
args[i++] = type; /* 8 */
args[i++] = "-t"; /* 8 */
args[i++] = type; /* 9 */
}
if (namespace) {
args[i++] = "-N"; /* 9 */
args[i++] = namespace; /* 10 */
args[i++] = "-N"; /* 10 */
args[i++] = namespace; /* 11 */
}

args[i++] = mnt_fs_get_target(cxt->fs); /* 11 */

args[i] = NULL; /* 12 */
for (i = 0; args[i]; i++)
DBG(CXT, ul_debugobj(cxt, "argv[%d] = \"%s\"",
Expand Down
2 changes: 1 addition & 1 deletion tests/expected/mount/special-basic
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/sbin/mount.mytest called with "-o rw /foo /bar"
/sbin/mount.mytest called with "/foo /bar -o rw"
2 changes: 1 addition & 1 deletion tests/expected/mount/special-multi-types
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/sbin/mount.mytest called with "-o rw /foo /bar"
/sbin/mount.mytest called with "/foo /bar -o rw"
2 changes: 1 addition & 1 deletion tests/expected/mount/special-options
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/sbin/mount.mytest called with "-o rw,foo /foo /bar"
/sbin/mount.mytest called with "/foo /bar -o rw,foo"
2 changes: 1 addition & 1 deletion tests/expected/mount/special-user
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/sbin/mount.mytest called with "-o rw,user,noexec,nosuid,nodev,abc /foo /bar"
/sbin/mount.mytest called with "/foo /bar -o rw,user,noexec,nosuid,nodev,abc"
2 changes: 1 addition & 1 deletion tests/expected/mount/special-username
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/sbin/mount.mytest called with "-o rw,user=name,abc /foo /bar"
/sbin/mount.mytest called with "/foo /bar -o rw,user=name,abc"

0 comments on commit fc9c938

Please sign in to comment.