Skip to contentSkip to conversation

mcstrans: remove unused getpeercon_raw() call

PATCH Superseded Yuli Khodorkovskiy 2 participants 3 messages Oct 24, 2018 SELinux security module

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mcstrans: remove unused getpeercon_raw() call

There is a call to getpeercon_raw() in mcstransd, but nothing is done with the context. The purpose of process_request() is to translate a context and we would like that to succeed even if, for some reason, getpeercon_raw() fails.

---
 mcstrans/src/mcstransd.c | 6 ------
 1 file changed, 6 deletions(-)
mcstrans/src/mcstransd.c +0 -6
index d7fc5dea..abbdea7e 100644
@@ -142,13 +142,8 @@ process_request(int fd, uint32_t function, char *data1, char *UNUSED(data2))
 {
 	int32_t result;
 	char *out = NULL;
-	char *peercon = NULL;
 	int ret;
 
-	ret = getpeercon_raw(fd, &peercon);
-	if (ret < 0)
-		return ret;
-
 	/* TODO: Check if MLS clearance (in peercon) dominates the MLS label
 	 * (in the request input).
 	 */
@@ -184,7 +179,6 @@ process_request(int fd, uint32_t function, char *data1, char *UNUSED(data2))
 	}
 
 	free(out);
-	freecon(peercon);
 
 	return ret;
 }
Signature · 1 line
2.19.0
#1 lore raw
Quoted 4 lines · Yuli Khodorkovskiy

There is a call to getpeercon_raw() in mcstransd, but nothing is done with the context. The purpose of process_request() is to translate a context and we would like that to succeed even if, for some reason, getpeercon_raw() fails.

If we are going to remove that, then shouldn't we also remove the TODO comment about performing a check using the peercon?

Quoted 34 lines
---
  mcstrans/src/mcstransd.c | 6 ------
  1 file changed, 6 deletions(-)
mcstrans/src/mcstransd.c +0 -6
index d7fc5dea..abbdea7e 100644
@@ -142,13 +142,8 @@ process_request(int fd, uint32_t function, char *data1, char *UNUSED(data2))
  {
  	int32_t result;
  	char *out = NULL;
-	char *peercon = NULL;
  	int ret;
 
-	ret = getpeercon_raw(fd, &peercon);
-	if (ret < 0)
-		return ret;
-
  	/* TODO: Check if MLS clearance (in peercon) dominates the MLS label
  	 * (in the request input).
  	 */
@@ -184,7 +179,6 @@ process_request(int fd, uint32_t function, char *data1, char *UNUSED(data2))
  	}
 
  	free(out);
-	freecon(peercon);
 
  	return ret;
  }
#2 lore raw

Yeah, good point. I’ll resend.

Quoted 39 lines · Stephen Smalley
Quoted 4 lines · Yuli Khodorkovskiy

There is a call to getpeercon_raw() in mcstransd, but nothing is done with the context. The purpose of process_request() is to translate a context and we would like that to succeed even if, for some reason, getpeercon_raw() fails.

If we are going to remove that, then shouldn't we also remove the TODO comment about performing a check using the peercon?

Quoted 28 lines
---
 mcstrans/src/mcstransd.c | 6 ------
 1 file changed, 6 deletions(-)
mcstrans/src/mcstransd.c +0 -5
index d7fc5dea..abbdea7e 100644
@@ -142,13 +142,8 @@ process_request(int fd, uint32_t function, char *data1, char *UNUSED(data2))
 {
 	int32_t result;
 	char *out = NULL;
-	char *peercon = NULL;
 	int ret;
 -	ret = getpeercon_raw(fd, &peercon);
-	if (ret < 0)
-		return ret;
-
 	/* TODO: Check if MLS clearance (in peercon) dominates the MLS label
 	 * (in the request input).
 	 */
@@ -184,7 +179,6 @@ process_request(int fd, uint32_t function, char *data1, char *UNUSED(data2))
 	}
   	free(out);
-	freecon(peercon);
   	return ret;
 }