Fix errors found by coverity

This commit is contained in:
Dan Walsh 2013-10-04 14:55:58 -04:00
parent 2a9c9b49a7
commit 8dcd430104
2 changed files with 26 additions and 16 deletions

View File

@ -250,10 +250,10 @@ index 8823b1e..cfcd039 100644
hidden_def(semanage_seuser_set_sename)
diff --git a/libsemanage/src/seusers_local.c b/libsemanage/src/seusers_local.c
index e7cf12c..c77be73 100644
index e7cf12c..c9a9ab2 100644
--- a/libsemanage/src/seusers_local.c
+++ b/libsemanage/src/seusers_local.c
@@ -8,27 +8,149 @@ typedef struct semanage_seuser record_t;
@@ -8,27 +8,156 @@ typedef struct semanage_seuser record_t;
#include <sepol/policydb.h>
#include <sepol/context.h>
@ -314,8 +314,8 @@ index e7cf12c..c77be73 100644
+ char *proles = NULL;
+ char msg[1024];
+ const char *sep = "-";
+
+ strcpy(msg,"login");
+ int rc = -1;
+ strcpy(msg, "login");
+ if (seuser) {
+ name = semanage_seuser_get_name(seuser);
+ sename = semanage_seuser_get_sename(seuser);
@ -328,17 +328,19 @@ index e7cf12c..c77be73 100644
+ proles = semanage_user_roles(handle, psename);
+ }
+ if (audit_type != AUDIT_ROLE_REMOVE) {
+ if (!psename || strcmp(psename, sename) != 0) {
+ sprintf(msg,"%s%s%s",msg, sep,"sename");
+ if (sename && (!psename || strcmp(psename, sename) != 0)) {
+ strcat(msg,sep);
+ strcat(msg,"sename");
+ sep = ",";
+ }
+ if (!proles || strcmp(proles, roles) != 0) {
+ sprintf(msg,"%s%s%s",msg, sep,"role");
+ if (roles && (!proles || strcmp(proles, roles) != 0)) {
+ strcat(msg,sep);
+ strcat(msg,"role");
+ sep = ",";
+ }
+ if (!pmls || strcmp(pmls, mls) != 0) {
+ sprintf(msg,"%s%s%s",msg, sep,"range");
+ sep = ",";
+ if (mls && (!pmls || strcmp(pmls, mls) != 0)) {
+ strcat(msg,sep);
+ strcat(msg,"range");
+ }
+ }
+
@ -346,15 +348,20 @@ index e7cf12c..c77be73 100644
+ if (fd < 0)
+ {
+ /* If kernel doesn't support audit, bail out */
+ if (errno == EINVAL || errno == EPROTONOSUPPORT || errno == EAFNOSUPPORT)
+ return 0;
+ return fd;
+ if (errno == EINVAL || errno == EPROTONOSUPPORT || errno == EAFNOSUPPORT) {
+ rc = 0;
+ goto err;
+ }
+ rc = fd;
+ goto err;
+ }
+ audit_log_semanage_message(fd, audit_type, NULL, msg, name, 0, sename, roles, mls, psename, proles, pmls, NULL, NULL,NULL, success);
+ rc = 0;
+err:
+ audit_close(fd);
+ free(roles);
+ free(proles);
+ return 0;
+ return rc;
+}
int semanage_seuser_modify_local(semanage_handle_t * handle,

View File

@ -7,7 +7,7 @@
Summary: SELinux binary policy manipulation library
Name: libsemanage
Version: 2.1.10
Release: 12%{?dist}
Release: 13%{?dist}
License: LGPLv2+
Group: System Environment/Libraries
Source: libsemanage-%{version}.tgz
@ -179,6 +179,9 @@ rm -rf ${RPM_BUILD_ROOT}
%endif # if with_python3
%changelog
* Fri Oct 4 2013 Dan Walsh <dwalsh@redhat.com> - 2.1.10-13
- Fix errors found by coverity
* Wed Sep 25 2013 Dan Walsh <dwalsh@redhat.com> - 2.1.10-12
- Do not fail on missing SELinux User Record when adding login record