Fix retrieving of current process credentials for off-line client 76/93176/2
authorRafal Krypa <r.krypa@samsung.com>
Thu, 20 Oct 2016 16:32:04 +0000 (18:32 +0200)
committerRafal Krypa <r.krypa@samsung.com>
Fri, 21 Oct 2016 06:28:56 +0000 (08:28 +0200)
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

index 171326ea8182f6680948687253600096aa4187a9..9bf8d708d404296178ca34e710221e6e596dfb6a 100644 (file)
@@ -22,6 +22,7 @@
 #include <unistd.h>
 #include <sys/socket.h>
 
+#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)