core: Fix compilation error when privilege drop is not supported
Refs: #4833
Change-Id: I2ccc80b31eb5642d66b28e205143243e006f18ca
diff --git a/core/privilege-helper.cpp b/core/privilege-helper.cpp
index 112d971..8652347 100644
--- a/core/privilege-helper.cpp
+++ b/core/privilege-helper.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -121,10 +121,10 @@
void
PrivilegeHelper::drop()
{
+#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
if (::geteuid() == s_normalUid && ::getegid() == s_normalGid)
return;
-#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
NFD_LOG_TRACE("dropping to effective gid=" << s_normalGid);
if (::setegid(s_normalGid) != 0)
throw Error("Failed to drop to effective gid=" + to_string(s_normalGid));
@@ -142,10 +142,10 @@
void
PrivilegeHelper::raise()
{
+#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
if (::geteuid() == s_privilegedUid && ::getegid() == s_privilegedGid)
return;
-#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
NFD_LOG_TRACE("elevating to effective uid=" << s_privilegedUid);
if (::seteuid(s_privilegedUid) != 0)
throw Error("Failed to elevate to effective uid=" + to_string(s_privilegedUid));