All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gril: Really use given uid/gid to open ril socket
@ 2016-03-23  9:58 Alfonso Sanchez-Beato
  2016-03-24 14:29 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Alfonso Sanchez-Beato @ 2016-03-23  9:58 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1294 bytes --]

---
 gril/gril.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/gril/gril.c b/gril/gril.c
index fa1a780..297a772 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;
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gril: Really use given uid/gid to open ril socket
  2016-03-23  9:58 [PATCH] gril: Really use given uid/gid to open ril socket Alfonso Sanchez-Beato
@ 2016-03-24 14:29 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2016-03-24 14:29 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 208 bytes --]

Hi Alfonso,

On 03/23/2016 04:58 AM, Alfonso Sanchez-Beato wrote:
> ---
>   gril/gril.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
>

Applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-24 14:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-23  9:58 [PATCH] gril: Really use given uid/gid to open ril socket Alfonso Sanchez-Beato
2016-03-24 14:29 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.