Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Jun 2017 07:02:53 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r320093 - head/usr.sbin/rpc.lockd
Message-ID:  <201706190702.v5J72rAC094925@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Mon Jun 19 07:02:52 2017
New Revision: 320093
URL: https://svnweb.freebsd.org/changeset/base/320093

Log:
  Check return value of seteuid() and bail out if we fail.
  
  MFC after:	2 weeks

Modified:
  head/usr.sbin/rpc.lockd/lock_proc.c

Modified: head/usr.sbin/rpc.lockd/lock_proc.c
==============================================================================
--- head/usr.sbin/rpc.lockd/lock_proc.c	Mon Jun 19 06:48:21 2017	(r320092)
+++ head/usr.sbin/rpc.lockd/lock_proc.c	Mon Jun 19 07:02:52 2017	(r320093)
@@ -276,7 +276,10 @@ get_client(struct sockaddr *host_addr, rpcvers_t vers)
 
 	/* Regain root privileges, for bindresvport. */
 	old_euid = geteuid();
-	seteuid(0);
+	if (seteuid(0) != 0) {
+		syslog(LOG_ERR, "seteuid(0) failed");
+		return NULL;
+	}
 
 	/*
 	 * Bind the client FD to a reserved port.
@@ -285,7 +288,10 @@ get_client(struct sockaddr *host_addr, rpcvers_t vers)
 	bindresvport(clnt_fd, NULL);
 
 	/* Drop root privileges again. */
-	seteuid(old_euid);
+	if (seteuid(old_euid) != 0) {
+		syslog(LOG_ERR, "seteuid(%d) failed", old_euid);
+		return NULL;
+	}
 
 	/* Success - update the cache entry */
 	clnt_cache_ptr[clnt_cache_next_to_use] = client;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706190702.v5J72rAC094925>