[systemd-devel] [PATCH 2/3] install: don't allow to enable/disable templates

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Thu Aug 8 09:11:42 PDT 2013


On Thu, Aug 08, 2013 at 03:19:09PM +0200, Michal Sekletar wrote:
> Calling enable on template units doesn't make sense since it is possible
> to enable instances directly and users are not forced to use Alias=
> trickery anymore.
Hm, I'm having trouble with parsing this commit message. Can you
explicitly say what this patch changes (remembering that git log
is read by people who are not familiar with the codebase and just
care about the changes in semantics)?

Zbyszek

> ---
>  src/shared/install.c | 20 ++++++++++++++++++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/src/shared/install.c b/src/shared/install.c
> index 07e06c4..5cda794 100644
> --- a/src/shared/install.c
> +++ b/src/shared/install.c
> @@ -1470,9 +1470,11 @@ int unit_file_enable(
>  
>          _cleanup_lookup_paths_free_ LookupPaths paths = {};
>          _cleanup_install_context_done_ InstallContext c = {};
> -        char **i;
> +        InstallInfo *v;
> +        char **i, *k;
>          _cleanup_free_ char *config_path = NULL;
>          int r;
> +        Iterator j;
>  
>          assert(scope >= 0);
>          assert(scope < _UNIT_FILE_SCOPE_MAX);
> @@ -1491,6 +1493,12 @@ int unit_file_enable(
>                          return r;
>          }
>  
> +        HASHMAP_FOREACH_KEY(v, k, c.will_install, j) {
> +                r = unit_name_is_valid(k, false);
> +                if (!r)
> +                        return -EINVAL;
> +        }
> +
>          /* This will return the number of symlink rules that were
>          supposed to be created, not the ones actually created. This is
>          useful to determine whether the passed files had any
> @@ -1509,10 +1517,12 @@ int unit_file_disable(
>  
>          _cleanup_lookup_paths_free_ LookupPaths paths = {};
>          _cleanup_install_context_done_ InstallContext c = {};
> -        char **i;
> +        InstallInfo *v;
> +        char **i, *k;
>          _cleanup_free_ char *config_path = NULL;
>          _cleanup_set_free_free_ Set *remove_symlinks_to = NULL;
>          int r, q;
> +        Iterator j;
>  
>          assert(scope >= 0);
>          assert(scope < _UNIT_FILE_SCOPE_MAX);
> @@ -1531,6 +1541,12 @@ int unit_file_disable(
>                          return r;
>          }
>  
> +        HASHMAP_FOREACH_KEY(v, k, c.will_install, j) {
> +                r = unit_name_is_valid(k, false);
> +                if (!r)
> +                        return -EINVAL;
> +        }
> +
>          r = install_context_mark_for_removal(&c, &paths, &remove_symlinks_to, config_path, root_dir);
>  
>          q = remove_marked_symlinks(remove_symlinks_to, config_path, changes, n_changes, files);
> -- 
> 1.8.3.1
> 
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
> 


More information about the systemd-devel mailing list