From: Imran Zaman Date: Wed, 20 Nov 2013 12:18:16 +0000 (+0200) Subject: create gumd group on installation and use it to set effective group id X-Git-Tag: upstream/1.0.8^2~77 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=43c060789b5e21b1b8208e8629efba8ea49e6b5d;p=platform%2Fupstream%2Fgumd.git create gumd group on installation and use it to set effective group id --- diff --git a/dists/debian/gumd.postinst b/dists/debian/gumd.postinst index bc32f01..2b758c9 100644 --- a/dists/debian/gumd.postinst +++ b/dists/debian/gumd.postinst @@ -21,6 +21,7 @@ set -e case "$1" in configure) ldconfig + groupadd -f -r gumd ;; abort-upgrade|abort-remove|abort-deconfigure) diff --git a/dists/rpm/gum-suse.spec b/dists/rpm/gum-suse.spec index 3168f1f..f24866d 100644 --- a/dists/rpm/gum-suse.spec +++ b/dists/rpm/gum-suse.spec @@ -114,7 +114,7 @@ rm -rf %{buildroot} %post /sbin/ldconfig chmod u+s %{_bindir}/%{name}d - +groupadd -f -r gumd %postun -p /sbin/ldconfig diff --git a/dists/rpm/gum-tizen.spec b/dists/rpm/gum-tizen.spec index 2071fd1..8641048 100644 --- a/dists/rpm/gum-tizen.spec +++ b/dists/rpm/gum-tizen.spec @@ -118,7 +118,7 @@ rm -rf %{buildroot} %post /sbin/ldconfig chmod u+s %{_bindir}/%{name}d - +groupadd -f -r gumd %postun -p /sbin/ldconfig diff --git a/src/daemon/main.c b/src/daemon/main.c index a613c94..9b0ecbf 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "common/gum-log.h" @@ -71,12 +72,6 @@ _start_dbus_server ( { #ifdef GUM_BUS_TYPE_P2P - DBG ("Before: real uid %d effective uid %d", getuid (), geteuid ()); - if (seteuid (getuid())) - WARN ("seteuid() failed"); - if (setegid (getgid())) - WARN ("setegid() failed"); - DBG ("After: real gid %d effective gid %d", getgid (), getegid ()); _server = GUMD_DBUS_SERVER (gumd_dbus_server_p2p_new ()); #else _server = GUMD_DBUS_SERVER (gumd_dbus_server_msg_bus_new ()); @@ -152,6 +147,17 @@ main (int argc, char **argv) GOptionEntry opt_entries[] = { {NULL } }; + gid_t daemon_gid; + struct group *daemon_group; + + DBG ("Before set: r-gid %d e-gid %d", getgid (), getegid ()); + daemon_gid = getgid (); + daemon_group = getgrnam ("gumd"); + if (daemon_group) + daemon_gid = daemon_group->gr_gid; + if (setegid (daemon_gid)) + WARN ("setegid() failed"); + DBG ("After set: r-gid %d e-gid %d", getgid (), getegid ()); #if !GLIB_CHECK_VERSION (2, 36, 0) g_type_init ();