[patch] Fix privilege dropping

David Zeuthen david at fubar.dk
Wed Apr 13 20:21:21 PDT 2005


On Wed, 2005-04-13 at 11:47 +0200, Martin Pitt wrote:
> Hi!
> 
> hal 0.5 does not start by default when compiled with
> --with-hal-user=hal:
> 
> $ sudo hald --verbose=yes --daemon=no
> 11:41:34.425 [I] hald.c:498: hal 0.5.0
> 11:41:34.426 [I] hald.c:502: Will not daemonize
> 11:41:34.434 [I] osspec.c:305: sysfs mount point is '/sys'
> 11:41:34.434 [I] osspec.c:310: proc mount point is '/proc'
> *** [DIE] osspec.c:osspec_init():328 : Unable to bind to netlink socket
> 
> Indeed the last action requires root privileges. Unfortunately
> capability handling was removed from drop_privileges(), but as an easy
> workaround it helps to drop the privilieges after the osspec_init()
> call. There is not overwhelmingly much code between the old and new
> point of priv dropping (device probing happens later), so this can
> probably even stay like this.
> 
> Thanks for considering,

Thanks for the patch, I've committed it. Note that --retain-privileges
is going away soon as described here

 http://lists.freedesktop.org/archives/hal/2005-February/002163.html

which means we'll have a small master process running as uid 0 (should
make it easy to audit) to invoke helpers, callouts and so forth. The
main hald process will be a child running as the unprivileged hal user.

Cheers,
David

> 
> Martin
> 
> diff -ruN hal-0.5.0-old/hald/hald.c hal-0.5.0/hald/hald.c
> --- hal-0.5.0-old/hald/hald.c   2005-02-28 20:43:29.000000000 +0100
> +++ hal-0.5.0/hald/hald.c       2005-04-13 11:39:51.569169608 +0200
> @@ -490,9 +490,6 @@
>         /* will fork into two; only the child will return here if we are successful */
>         /*master_slave_setup ();*/
> 
> -       if (!retain_privs)
> -               drop_privileges();
> -
>         loop = g_main_loop_new (NULL, FALSE);
> 
>         HAL_INFO ((PACKAGE_STRING));
> @@ -593,6 +590,9 @@
>         /* initialize operating system specific parts */
>         osspec_init ();
> 
> +       if (!retain_privs)
> +               drop_privileges();
> +
>         hald_is_initialising = TRUE;
> 
>         /* detect devices */
> 
> 
> _______________________________________________
> hal mailing list
> hal at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/hal

_______________________________________________
hal mailing list
hal at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/hal



More information about the Hal mailing list