Search code examples
linuxelixirelixir-mixelixir-iex

IEx block with sudo and System.cmd("mount")


Some precision :

$> iex --version
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false]

IEx 1.4.4

$> mix --version
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false]

Mix 1.4.4

I'm a french people and i don't understand why

$> iex -S mix

have some bugs with :

$> sudo iex -S mix

I want execute the command in IEx :

System.cmd("mount", ["-t", "ecryptfs", ".private", "private", "-o", ~s(key=passphrase,passphrase_passwd="pass",ecryptfs_enable_filename_crypto=n,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_passthrough=n)], [stderr_to_stdout: true])

For test and mount a ecryptfs partition. In

$> iex -S mix
iex(2)> System.cmd("mount", ["-t", "ecryptfs", ".private", "private", "-o", ~s(key=passphrase,passphrase_passwd="pass",ecryptfs_enable_filename_crypto=n,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_passthrough=n)], [stderr_to_stdout: true])

{"mount: mount : seul le superutilisateur peut utiliser l'option « --options »\n",1}

And I have the correct value, unprivileged mount.

With:

$> sudo iex -S mix
iex(2)> System.cmd("mount", ["-t", "ecryptfs", ".private", "private", "-o", ~s(key=passphrase,passphrase_passwd="pass",ecryptfs_enable_filename_crypto=n,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_passthrough=n)], [stderr_to_stdout: true])

The command bugs and prints anything. It just block. Without return error code, without anything, just blocking. IEx don't print anything.

I have a screenshot for that bug :

enter image description here


Solution

  • Okay, System.cmd don't want to quote in argument. Okay. :/