[systemd-devel] [PATCHv2] cg_path_get_user_unit(): Did not correctly parse user-unit templates.

Lennart Poettering lennart at poettering.net
Tue Feb 3 17:20:44 PST 2015


On Tue, 03.02.15 20:07, Luke Shumaker (lukeshu at sbcglobal.net) wrote:

> It ran either skip_session() or skip_user_manager(), then ran skip_slices()
> iff skip_session() ran.  It needs to run skip_slices() in either case.
> 
> Included is a test case demonstrating why.

Thanks! Applied!

> ---
>  src/shared/cgroup-util.c    | 18 ++++++++----------
>  src/test/test-cgroup-util.c |  1 +
>  2 files changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
> index 0d3cc53..d34e1fa 100644
> --- a/src/shared/cgroup-util.c
> +++ b/src/shared/cgroup-util.c
> @@ -1251,17 +1251,15 @@ int cg_path_get_user_unit(const char *path, char **unit) {
>          /* Skip slices, if there are any */
>          e = skip_slices(path);
>  
> -        /* Skip the session scope... */
> +        /* Skip the session scope or user manager... */
>          t = skip_session(e);
> -        if (t)
> -                /* ... and skip more slices if there's one */
> -                e = skip_slices(t);
> -        else {
> -                /* ... or require a user manager unit to be there */
> -                e = skip_user_manager(e);
> -                if (!e)
> -                        return -ENOENT;
> -        }
> +        if (!t)
> +                t = skip_user_manager(e);
> +        if (!t)
> +                return -ENOENT;
> +
> +        /* ... and skip more slices if there are any */
> +        e = skip_slices(t);
>  
>          return cg_path_decode_unit(e, unit);
>  }
> diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c
> index 58eb744..67eeeb5 100644
> --- a/src/test/test-cgroup-util.c
> +++ b/src/test/test-cgroup-util.c
> @@ -93,6 +93,7 @@ static void test_path_get_user_unit(void) {
>          check_p_g_u_u("/meh.service", -ENOENT, NULL);
>          check_p_g_u_u("/session-3.scope/_cpu.service", 0, "cpu.service");
>          check_p_g_u_u("/user.slice/user-1000.slice/user at 1000.service/server.service", 0, "server.service");
> +        check_p_g_u_u("/user.slice/user-1000.slice/user at 1000.service/foobar.slice/foobar at pie.service", 0, "foobar at pie.service");
>          check_p_g_u_u("/user.slice/user-1000.slice/user at .service/server.service", -ENOENT, NULL);
>  }
>  
> -- 
> 2.2.2
> 
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list