summaryrefslogtreecommitdiff
path: root/gril
diff options
context:
space:
mode:
Diffstat (limited to 'gril')
-rw-r--r--gril/gril.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/gril/gril.c b/gril/gril.c
index fa1a7801..297a7720 100644
--- a/gril/gril.c
+++ b/gril/gril.c
@@ -824,14 +824,15 @@ static struct ril_s *create_ril(const char *sock_path, unsigned int uid,
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, sock_path, sizeof(addr.sun_path) - 1);
- if (uid != 0 && seteuid(uid) < 0)
- ofono_error("%s: seteuid(%d) failed: %s (%d)",
- __func__, uid, strerror(errno), errno);
-
+ /* Drop root user last, otherwise we won't be able to change egid */
if (gid != 0 && setegid(gid) < 0)
ofono_error("%s: setegid(%d) failed: %s (%d)",
__func__, gid, strerror(errno), errno);
+ if (uid != 0 && seteuid(uid) < 0)
+ ofono_error("%s: seteuid(%d) failed: %s (%d)",
+ __func__, uid, strerror(errno), errno);
+
r = connect(sk, (struct sockaddr *) &addr, sizeof(addr));
/* Switch back to root as needed */
@@ -1053,7 +1054,7 @@ GRil *g_ril_new_with_ucred(const char *sock_path, enum ofono_ril_vendor vendor,
if (ril == NULL)
return NULL;
- ril->parent = create_ril(sock_path, 0, 0);
+ ril->parent = create_ril(sock_path, uid, gid);
if (ril->parent == NULL) {
g_free(ril);
return NULL;