mirror of
https://github.com/systemd/systemd.git
synced 2024-11-24 10:43:35 +08:00
nspawn: when generating a machine name from an image name, truncate .raw suffix
Let's prettify the machine name we generate for image-based containers: let's chop off the .raw suffix before using it as machine name.
This commit is contained in:
parent
18b5886e56
commit
4827ab4854
@ -1951,10 +1951,22 @@ static int determine_names(void) {
|
||||
}
|
||||
|
||||
if (!arg_machine) {
|
||||
|
||||
if (arg_directory && path_equal(arg_directory, "/"))
|
||||
arg_machine = gethostname_malloc();
|
||||
else
|
||||
arg_machine = strdup(basename(arg_image ?: arg_directory));
|
||||
else {
|
||||
if (arg_image) {
|
||||
char *e;
|
||||
|
||||
arg_machine = strdup(basename(arg_image));
|
||||
|
||||
/* Truncate suffix if there is one */
|
||||
e = endswith(arg_machine, ".raw");
|
||||
if (e)
|
||||
*e = 0;
|
||||
} else
|
||||
arg_machine = strdup(basename(arg_directory));
|
||||
}
|
||||
if (!arg_machine)
|
||||
return log_oom();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user