Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Jul 2017 05:30:32 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r320587 - stable/10/usr.sbin/rpc.lockd
Message-ID:  <201707030530.v635UWYw011921@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Mon Jul  3 05:30:31 2017
New Revision: 320587
URL: https://svnweb.freebsd.org/changeset/base/320587

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

Modified:
  stable/10/usr.sbin/rpc.lockd/lock_proc.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/rpc.lockd/lock_proc.c
==============================================================================
--- stable/10/usr.sbin/rpc.lockd/lock_proc.c	Mon Jul  3 05:22:10 2017	(r320586)
+++ stable/10/usr.sbin/rpc.lockd/lock_proc.c	Mon Jul  3 05:30:31 2017	(r320587)
@@ -283,7 +283,10 @@ get_client(host_addr, 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.
@@ -292,7 +295,10 @@ get_client(host_addr, 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?201707030530.v635UWYw011921>