Before=sockets.target
[Socket]
-ListenStream=/run/aul/daemons/.amd-sock
+ListenStream=@org.tizen.appfw.amd
SocketMode=0777
-DirectoryMode=0777
[Install]
WantedBy=sockets.target
}
struct sockaddr_un addr = { 0, };
+ socklen_t len = 0;
addr.sun_family = AF_UNIX;
snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", path.c_str());
- unlink(path.c_str());
+ if (addr.sun_path[0] == '@') {
+ len = offsetof(struct sockaddr_un, sun_path) + path.length();
+ addr.sun_path[0] = '\0';
+ } else {
+ len = sizeof(struct sockaddr_un);
+ unlink(path.c_str());
+ }
struct sockaddr* addr_ptr = reinterpret_cast<struct sockaddr*>(&addr);
- int ret = bind(fd, addr_ptr, sizeof(addr));
+ int ret = bind(fd, addr_ptr, len);
if (ret != 0) {
ret = -errno;
_E("bind() is failed. path(%s), errno(%d)", path.c_str(), errno);
bundle *b;
char path[PATH_MAX];
+ //TODO(Abstract Socket Issue): replace file-based setup check
snprintf(path, sizeof(path), "%s/%d/%s",
PATH_AUL_DAEMONS, uid, LAUNCHPAD_PROCESS_POOL_SOCK);
if (access(path, F_OK) != 0) {
#include "amd_util.h"
#include "amd_socket.h"
-#define PATH_AMD_SOCK "/run/aul/daemons/.amd-sock"
+#define PATH_AMD_SOCK "@org.tizen.appfw.amd"
int _create_sock_activation(void)
{
{
int fd;
struct sockaddr_un addr;
+ socklen_t len;
fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (fd < 0) {
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", PATH_AMD_SOCK);
- unlink(addr.sun_path);
+ len = offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path);
+ addr.sun_path[0] = '\0';
- if (bind(fd, (struct sockaddr *)&addr, sizeof(addr))) {
+ if (bind(fd, (struct sockaddr *)&addr, len)) {
_E("bind error: %d", errno);
close(fd);
return -1;
{
int fd = -1;
struct sockaddr_un saddr = { 0, };
+ socklen_t len = 0;
int retry = 1;
int ret = -1;
}
saddr.sun_family = AF_UNIX;
- snprintf(saddr.sun_path, sizeof(saddr.sun_path),
- "/run/aul/daemons/%d/%s", uid, pad_type);
+ if (pad_type[0] == '@') {
+ snprintf(saddr.sun_path, sizeof(saddr.sun_path), "%s-%d", pad_type, uid);
+ len = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path);
+ saddr.sun_path[0] = '\0';
+ } else {
+ snprintf(saddr.sun_path, sizeof(saddr.sun_path),
+ "/run/aul/daemons/%d/%s", uid, pad_type);
+ len = sizeof(struct sockaddr_un);
+ }
+
retry_con:
- ret = __connect_client_sock(fd, (struct sockaddr *)&saddr,
- sizeof(saddr), 100 * 1000);
+ ret = __connect_client_sock(fd, (struct sockaddr *)&saddr, len, 100 * 1000);
if (ret < -1) {
_E("maybe peer not launched or peer dead\n");
if (retry > 0) {
extern "C" {
#endif
-#define LAUNCHPAD_PROCESS_POOL_SOCK ".launchpad-process-pool-sock"
+#define LAUNCHPAD_PROCESS_POOL_SOCK "@org.tizen.appfw.launchpad-process-pool"
int _create_sock_activation(void);
};
std::string GetEndpoint(uid_t uid, const std::string& name) {
- return "/run/aul/daemons/" + std::to_string(uid) + "/" + name;
+ if (name[0] == '@') {
+ return name + "-" + std::to_string(uid);
+ } else {
+ return "/run/aul/daemons/" + std::to_string(uid) + "/" + name;
+ }
}
tizen_base::Parcel CreateParcel(int cmd, int opt, bundle* request) {
}
bool RequestManager::Init() {
+ int marker;
+
amd_fd_ = _create_sock_activation();
if (amd_fd_ == -1) {
_D("Create server socket without socket activation");
}
}
+ // TODO(Abstract Socket Issue): file-based socket check
+ marker = open("/run/aul/daemons/.amd-sock", O_RDWR | O_CREAT,
+ S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ close(marker);
+
amd_io_ = g_io_channel_unix_new(amd_fd_);
if (amd_io_ == nullptr) {
_E("Failed to create gio channel");
fcntl(GetFd(), F_SETFL, flag | O_NONBLOCK);
struct sockaddr_un sockaddr = { 0, };
+ socklen_t len = 0;
sockaddr.sun_family = AF_UNIX;
snprintf(sockaddr.sun_path, sizeof(sockaddr.sun_path), "%s",
endpoint.c_str());
+ if (sockaddr.sun_path[0] == '@') {
+ len = offsetof(sockaddr_un, sun_path) + strlen(sockaddr.sun_path);
+ sockaddr.sun_path[0] = '\0';
+ } else {
+ len = sizeof(struct sockaddr_un);
+ }
struct sockaddr* sockaddr_ptr = reinterpret_cast<struct sockaddr*>(&sockaddr);
- socklen_t len = static_cast<socklen_t>(sizeof(sockaddr));
int ret;
int retry = 2;
}
struct sockaddr_un addr = { 0, };
+ socklen_t len = 0;
addr.sun_family = AF_UNIX;
snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", path.c_str());
- unlink(path.c_str());
+ if (addr.sun_path[0] == '@') {
+ len = offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path);
+ addr.sun_path[0] = '\0';
+ } else {
+ len = sizeof(struct sockaddr_un);
+ unlink(path.c_str());
+ }
struct sockaddr* addr_ptr = reinterpret_cast<struct sockaddr*>(&addr);
- int ret = bind(fd, addr_ptr, sizeof(addr));
+ int ret = bind(fd, addr_ptr, len);
if (ret != 0) {
ret = -errno;
_E("bind() is failed. path(%s), errno(%d)", path.c_str(), errno);