nspawn: give better message when invoked as non-root without arguments
When invoked as non-root, we would suggest re-running as root without any further hint. But this immediately spawns a machine from the local directory, which can be rather surprising. So let's give a better hint. (In general, I don't think commandline programs should do "significant" things when invoked without any arguments. In this regard it would be better if systemd-nspawn would not spawn a machine from the current directory if called with no arguments and at least "-D ." would be required.)
This commit is contained in:
parent
fe79f107ef
commit
38ee19c04b
|
@ -5134,9 +5134,12 @@ static int run(int argc, char *argv[]) {
|
|||
if (r <= 0)
|
||||
goto finish;
|
||||
|
||||
r = must_be_root();
|
||||
if (r < 0)
|
||||
if (geteuid() != 0) {
|
||||
r = log_warning_errno(SYNTHETIC_ERRNO(EPERM),
|
||||
argc >= 2 ? "Need to be root." :
|
||||
"Need to be root (and some arguments are usually required).\nHint: try --help");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
r = cant_be_in_netns();
|
||||
if (r < 0)
|
||||
|
|
Loading…
Reference in New Issue