diff mbox

libsemanage: Return commit number if save-previous false

Message ID 20180122163811.16512-1-richard_c_haines@btinternet.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Richard Haines Jan. 22, 2018, 4:38 p.m. UTC
Stop overwriting the commit number for the default save-previous flag
setting (false) in semanage.conf.

Allows semodule -v -i <policy> to show the correct commit number.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
---
 libsemanage/src/semanage_store.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stephen Smalley Jan. 25, 2018, 3:08 p.m. UTC | #1
On Mon, 2018-01-22 at 16:38 +0000, Richard Haines wrote:
> Stop overwriting the commit number for the default save-previous flag
> setting (false) in semanage.conf.
> 
> Allows semodule -v -i <policy> to show the correct commit number.

Thanks, applied.  I was concerned that this could possibly break buggy
callers (e.g. if they were handling any non-zero return as an error),
but since the man page does document the return convention and a quick
look at callers suggests they do the right thing, I applied this. I
guess we'll see if anyone complains.

> 
> Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
> ---
>  libsemanage/src/semanage_store.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libsemanage/src/semanage_store.c
> b/libsemanage/src/semanage_store.c
> index 37ff5ace..936e6495 100644
> --- a/libsemanage/src/semanage_store.c
> +++ b/libsemanage/src/semanage_store.c
> @@ -1740,9 +1740,9 @@ static int
> semanage_commit_sandbox(semanage_handle_t * sh)
>  
>  	if (!sh->conf->save_previous) {
>  		int errsv = errno;
> -		retval = semanage_remove_directory(backup);
> -		if (retval < 0) {
> +		if (semanage_remove_directory(backup) != 0) {
>  			ERR(sh, "Could not delete previous directory
> %s.", backup);
> +			retval = -1;
>  			goto cleanup;
>  		}
>  		errno = errsv;
diff mbox

Patch

diff --git a/libsemanage/src/semanage_store.c b/libsemanage/src/semanage_store.c
index 37ff5ace..936e6495 100644
--- a/libsemanage/src/semanage_store.c
+++ b/libsemanage/src/semanage_store.c
@@ -1740,9 +1740,9 @@  static int semanage_commit_sandbox(semanage_handle_t * sh)
 
 	if (!sh->conf->save_previous) {
 		int errsv = errno;
-		retval = semanage_remove_directory(backup);
-		if (retval < 0) {
+		if (semanage_remove_directory(backup) != 0) {
 			ERR(sh, "Could not delete previous directory %s.", backup);
+			retval = -1;
 			goto cleanup;
 		}
 		errno = errsv;