Source1004: %{name}-test.manifest
BuildRequires: cmake
BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(libsmack)
BuildRequires: pkgconfig(libsystemd)
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(cynara-client)
PKG_CHECK_MODULES(SERVER_DEP
REQUIRED
hal-api-security
- libsmack
libsystemd
cynara-client
cynara-creds-socket
SET(SERVER_SOURCES
main/generic-socket-manager.cpp
main/server-main.cpp
- main/smack-check.cpp
main/socket-manager.cpp
service/password.cpp
service/password-manager.cpp
+++ /dev/null
-/*
- * Authentication password
- *
- * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jooseong Lee <jooseong.lee@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-#ifndef _SMACK_CHECK_H_
-#define _SMACK_CHECK_H_
-
-#include <string>
-
-namespace AuthPasswd {
-
-extern const std::string CLIENT_WHITELIST;
-extern const std::string ADMIN_CLIENT_WHITELIST;
-
-/*
- * A very simple runtime check for SMACK on the platform
- * Returns 1 if SMACK is present, 0 otherwise. If SMACK_ENABLED is not defined
- * It returns 0.
- */
-int smack_check(void);
-
-} // namespace AuthPasswd
-
-#endif // _SMACK_CHECK_H_
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-/*
- * @file smack-check.cpp
- * @author Jooseong Lee (jooseong.lee@samsung.com)
- * @version 1.0
- * @brief Check smck is enabled on device.
- */
-#include "smack-check.h"
-
-#include <fstream>
-#include <sys/smack.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-
-#include <dpl/log/log.h>
-#include <error-description.h>
-
-namespace AuthPasswd {
-
-const char COMMENT = '#';
-const std::string CLIENT_WHITELIST = "/etc/auth-fw/client-whitelist";
-const std::string ADMIN_CLIENT_WHITELIST = "/etc/auth-fw/admin-client-whitelist";
-
-int smack_runtime_check(void)
-{
- static int smack_present = -1;
-
- if (-1 == smack_present) {
- if (NULL == smack_smackfs_path()) {
- LogDebug("no smack found on device");
- smack_present = 0;
- } else {
- LogDebug("found smack on device");
- smack_present = 1;
- }
- }
-
- return smack_present;
-}
-
-int smack_check(void)
-{
-#ifndef SMACK_ENABLED
- return 0;
-#else
- return smack_runtime_check();
-#endif
-}
-
-} // namespace AuthPasswd
#include <sys/signalfd.h>
#include <sys/types.h>
#include <sys/socket.h>
-#include <sys/smack.h>
#include <linux/xattr.h>
#include <sys/un.h>
#include <sys/stat.h>
#include <dpl/assert.h>
#include <error-description.h>
-#include <smack-check.h>
#include <socket-manager.h>
namespace {
ThrowMsg(Exception::InitFailed, "Error in socket: " << errnoToString(err));
}
- if (smack_check()) {
- LogInfo("Set up smack label: " << desc.smackLabel);
-
- if (0 != smack_set_label_for_file(sockfd, XATTR_NAME_SMACKIPIN, desc.smackLabel.c_str())) {
- LogError("Error in smack_set_label_for_file");
- ThrowMsg(Exception::InitFailed, "Error in smack_set_label_for_file");
- }
- } else {
- LogInfo("No smack on platform. Socket won't be securied with smack label!");
- }
-
int flags;
if (-1 == (flags = fcntl(sockfd, F_GETFL, 0)))