int nameLength = socketName.length();
if ((dirLength + nameLength + 2) > STRERR_BUFSIZE)
{
+ /*LCOV_EXCL_START*/
DSLOG_WRN("DSUtilSocket", "Size of buffer is not enough. dir:%s name:%s", xdgDir, socketName);
return;
+ /*LCOV_EXCL_STOP*/
}
//snprintf(socket_path, sizeof(socket_path), "%s/%s", dir, name);
res = chmod(socketPath.c_str(), 509);
if (res < 0)
{
+ /*LCOV_EXCL_START*/
DSLOG_WRN("DSUtilSocket", "Could not change modes of socket file:%s (%s)", socketPath.c_str(), strerror_r(errno, buf, STRERR_BUFSIZE));
//PRCTL("[Winsys] Could not chane modes of socket file: %s", socketPath.c_str());
return;
+ /*LCOV_EXCL_STOP*/
}
res = chown(socketPath.c_str(), uid, gid);
if (res < 0)
{
+ /*LCOV_EXCL_START*/
DSLOG_WRN("DSUtilSocket", "Could not change owner of socket file:%s (%s)", socketPath.c_str(), strerror_r(errno, buf, STRERR_BUFSIZE));
//PRCTL("[Winsys] Could not change owner of socket file: %s", socketPath.c_str());
return;
+ /*LCOV_EXCL_STOP*/
}
}
buf = (char *)malloc(bufLen);
if (buf == NULL)
{
+ /*LCOV_EXCL_START*/
DSLOG_WRN("DSUtilSocket", "failed to create buffer");
return 0;
+ /*LCOV_EXCL_STOP*/
}
u = (struct ::passwd *)malloc(sizeof(struct passwd));
if (!u)
{
+ /*LCOV_EXCL_START*/
DSLOG_WRN("DSUtilSocket", "failed to create password struct");
free(buf);
return 0;
+ /*LCOV_EXCL_STOP*/
}
ret = getpwnam_r(name.c_str(), u, buf, bufLen, &uRes);
if (uRes == nullptr)
{
+ /*LCOV_EXCL_START*/
if (ret == 0) DSLOG_WRN("DSUtilSocket", "password not found");
else DSLOG_WRN("DSUtilSocket", "errno returned by getpwnam_r is %d", ret);
free(buf);
free(u);
return 0;
+ /*LCOV_EXCL_STOP*/
}
ret = u->pw_uid;
free(buf);
buf = (char *)malloc(bufLen);
if (buf == nullptr)
{
+ /*LCOV_EXCL_START*/
DSLOG_WRN("DSUtilSocket", "failed to create buffer");
return 0;
+ /*LCOV_EXCL_STOP*/
}
g = (struct ::group *)malloc(sizeof(struct group));
if (!g)
{
+ /*LCOV_EXCL_START*/
DSLOG_WRN("DSUtilSocket", "failed to create group struct");
free(buf);
return 0;
+ /*LCOV_EXCL_STOP*/
}
ret = getgrnam_r(name.c_str(), g, buf, bufLen, &grpRes);
if (grpRes == NULL)
{
+ /*LCOV_EXCL_START*/
if (ret == 0) DSLOG_WRN("DSUtilSocket", "Group not found");
else DSLOG_WRN("DSUtilSocket", "errno returned by getpwnam_r is %d", ret);
free(buf);
free(g);
return 0;
+ /*LCOV_EXCL_STOP*/
}
ret = g->gr_gid;