/src/helpers/session/session.cpp
https://gitlab.com/github-cloud-corporation/cynara · C++ · 43 lines · 14 code · 6 blank · 23 comment · 1 complexity · 100036a2c2eb43182ae3c925621cfaea MD5 · raw file
- /*
- * Copyright (c) 2014 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 src/helpers/session/session.cpp
- * @author Radoslaw Bartosiak <r.bartosiak@samsung.com>
- * @author Aleksander Zdyb <a.zdyb@samsung.com>
- * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
- * @version 1.0
- * @brief Implementation of external libcynara-session API
- */
- #include <cstring>
- #include <string>
- #include <sys/stat.h>
- #include <attributes/attributes.h>
- #include <cynara-session.h>
- CYNARA_API
- char *cynara_session_from_pid(pid_t client_pid) {
- std::string path = std::string("/proc/") + std::to_string(client_pid);
- struct stat st;
- if (stat(path.c_str(), &st) < 0)
- return nullptr;
- std::string session = std::to_string(st.st_ctim.tv_sec) + path;
- return strdup(session.c_str());
- }