No need to use KEEP_ERRNO() macro around pjdlog functions, as they don't

modify errno.

MFC after:	3 days
This commit is contained in:
Pawel Jakub Dawidek 2011-09-27 07:52:39 +00:00
parent 611ff617cf
commit 1ebc0407fc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=225781
2 changed files with 20 additions and 23 deletions

View File

@ -298,8 +298,7 @@ tcp_connect(void *ctx, int timeout)
flags = fcntl(tctx->tc_fd, F_GETFL);
if (flags == -1) {
KEEP_ERRNO(pjdlog_common(LOG_DEBUG, 1, errno,
"fcntl(F_GETFL) failed"));
pjdlog_common(LOG_DEBUG, 1, errno, "fcntl(F_GETFL) failed");
return (errno);
}
/*
@ -308,8 +307,8 @@ tcp_connect(void *ctx, int timeout)
*/
flags |= O_NONBLOCK;
if (fcntl(tctx->tc_fd, F_SETFL, flags) == -1) {
KEEP_ERRNO(pjdlog_common(LOG_DEBUG, 1, errno,
"fcntl(F_SETFL, O_NONBLOCK) failed"));
pjdlog_common(LOG_DEBUG, 1, errno,
"fcntl(F_SETFL, O_NONBLOCK) failed");
return (errno);
}

View File

@ -87,14 +87,13 @@ provinfo(struct hast_resource *res, bool dowrite)
res->hr_localfd = open(res->hr_localpath,
dowrite ? O_RDWR : O_RDONLY);
if (res->hr_localfd < 0) {
KEEP_ERRNO(pjdlog_errno(LOG_ERR, "Unable to open %s",
res->hr_localpath));
pjdlog_errno(LOG_ERR, "Unable to open %s",
res->hr_localpath);
return (-1);
}
}
if (fstat(res->hr_localfd, &sb) < 0) {
KEEP_ERRNO(pjdlog_errno(LOG_ERR, "Unable to stat %s",
res->hr_localpath));
pjdlog_errno(LOG_ERR, "Unable to stat %s", res->hr_localpath);
return (-1);
}
if (S_ISCHR(sb.st_mode)) {
@ -103,16 +102,16 @@ provinfo(struct hast_resource *res, bool dowrite)
*/
if (ioctl(res->hr_localfd, DIOCGMEDIASIZE,
&res->hr_local_mediasize) < 0) {
KEEP_ERRNO(pjdlog_errno(LOG_ERR,
pjdlog_errno(LOG_ERR,
"Unable obtain provider %s mediasize",
res->hr_localpath));
res->hr_localpath);
return (-1);
}
if (ioctl(res->hr_localfd, DIOCGSECTORSIZE,
&res->hr_local_sectorsize) < 0) {
KEEP_ERRNO(pjdlog_errno(LOG_ERR,
pjdlog_errno(LOG_ERR,
"Unable obtain provider %s sectorsize",
res->hr_localpath));
res->hr_localpath);
return (-1);
}
} else if (S_ISREG(sb.st_mode)) {
@ -169,8 +168,8 @@ drop_privs(struct hast_resource *res)
pw = getpwnam(HAST_USER);
if (pw == NULL) {
if (errno != 0) {
KEEP_ERRNO(pjdlog_errno(LOG_ERR,
"Unable to find info about '%s' user", HAST_USER));
pjdlog_errno(LOG_ERR,
"Unable to find info about '%s' user", HAST_USER);
return (-1);
} else {
pjdlog_error("'%s' user doesn't exist.", HAST_USER);
@ -201,28 +200,27 @@ drop_privs(struct hast_resource *res)
pjdlog_errno(LOG_WARNING,
"Unable to jail to directory to %s", pw->pw_dir);
if (chroot(pw->pw_dir) == -1) {
KEEP_ERRNO(pjdlog_errno(LOG_ERR,
pjdlog_errno(LOG_ERR,
"Unable to change root directory to %s",
pw->pw_dir));
pw->pw_dir);
return (-1);
}
}
PJDLOG_VERIFY(chdir("/") == 0);
gidset[0] = pw->pw_gid;
if (setgroups(1, gidset) == -1) {
KEEP_ERRNO(pjdlog_errno(LOG_ERR,
"Unable to set groups to gid %u",
(unsigned int)pw->pw_gid));
pjdlog_errno(LOG_ERR, "Unable to set groups to gid %u",
(unsigned int)pw->pw_gid);
return (-1);
}
if (setgid(pw->pw_gid) == -1) {
KEEP_ERRNO(pjdlog_errno(LOG_ERR, "Unable to set gid to %u",
(unsigned int)pw->pw_gid));
pjdlog_errno(LOG_ERR, "Unable to set gid to %u",
(unsigned int)pw->pw_gid);
return (-1);
}
if (setuid(pw->pw_uid) == -1) {
KEEP_ERRNO(pjdlog_errno(LOG_ERR, "Unable to set uid to %u",
(unsigned int)pw->pw_uid));
pjdlog_errno(LOG_ERR, "Unable to set uid to %u",
(unsigned int)pw->pw_uid);
return (-1);
}