Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uid < 0 always false check #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions daemon/main.cpp
Expand Up @@ -449,9 +449,9 @@ static void onHttpRequest(StatServer *ss, HttpRequestHolder const &req)
req->onError_.connect(boost::bind(printRequest, req, ss));
}

static uid_t dropped_uid()
static int dropped_uid()
{
uid_t uid = -1;
int uid = -1;
try
{
uid = boost::lexical_cast<int>(user.get());
Expand All @@ -466,12 +466,12 @@ static uid_t dropped_uid()
void drop_privileges()
{
LogSpam << "drop_privileges()";
uid_t uid = dropped_uid();
int uid = dropped_uid();
if (uid < 0)
{
throw std::runtime_error("User " + user.get() + " is not known.");
}
if ((geteuid() != uid) && (seteuid(uid) < 0))
if ((int(geteuid()) != uid) && (seteuid(uid) < 0))
{
throw std::runtime_error("Could not seteuid(" + boost::lexical_cast<std::string>(uid) + ").");
}
Expand Down