From 7e3a5bea4556adbb77952c512093dc8097e99d2f Mon Sep 17 00:00:00 2001 From: Rafal Krypa Date: Thu, 20 Oct 2016 18:32:04 +0200 Subject: Fix retrieving of current process credentials for off-line client Try to work even if fetching Smack label of current process fails in off-line client mode. In most cases it won't be needed anyway. It is needed for proper image building by mic. When mic is run on system that doesn't support Smack natively (e.g. developer's workstation), fetching process Smack label will fail. Somehow it managed to work despite that problem until now, but libsmack 1.3.0 has better checks in function smack_new_label_from_self, validating the label before sending it to the caller. Change-Id: I3a96851cab5e71bde749c68413b967571690e162 --- src/common/credentials.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/credentials.cpp b/src/common/credentials.cpp index 171326ea..9bf8d708 100644 --- a/src/common/credentials.cpp +++ b/src/common/credentials.cpp @@ -22,6 +22,7 @@ #include #include +#include "smack-check.h" #include "smack-labels.h" #include "credentials.h" @@ -30,7 +31,7 @@ namespace SecurityManager { Credentials Credentials::getCredentialsFromSelf(void) { return Credentials(getpid(), geteuid(), getegid(), - SmackLabels::getSmackLabelFromSelf()); + smack_check() ? SmackLabels::getSmackLabelFromSelf() : ""); } Credentials Credentials::getCredentialsFromSocket(int sock) -- cgit v1.2.3