[ovs-dev] Fix build when HAVE_LIBCAPNG is not defined.
diff mbox

Message ID 1443713356-17985-1-git-send-email-rbryant@redhat.com
State Accepted
Headers show

Commit Message

Russell Bryant Oct. 1, 2015, 3:29 p.m. UTC
The function daemon_become_new_user_linux was conditionally defined but
then used in code unconditionally.  If HAVE_LIBCAPNG is not defined, the
function would never be called, but it still must exist.

Adjust the #if guard around the function to be around the body of the
function instead of outside of its definition to ensure the function is
always defined, even if empty.

This issue was introduced in e91b927d8966bfcb9768225392324dde4fd7d7f6.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
---
 lib/daemon-unix.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Ben Pfaff Oct. 1, 2015, 3:52 p.m. UTC | #1
On Thu, Oct 01, 2015 at 11:29:16AM -0400, Russell Bryant wrote:
> The function daemon_become_new_user_linux was conditionally defined but
> then used in code unconditionally.  If HAVE_LIBCAPNG is not defined, the
> function would never be called, but it still must exist.
> 
> Adjust the #if guard around the function to be around the body of the
> function instead of outside of its definition to ensure the function is
> always defined, even if empty.
> 
> This issue was introduced in e91b927d8966bfcb9768225392324dde4fd7d7f6.
> 
> Signed-off-by: Russell Bryant <rbryant@redhat.com>

Applied, thanks!
Andy Zhou Oct. 1, 2015, 6:48 p.m. UTC | #2
Russell,

Thanks for the fix. I have libcap-ng installed on my system and forgot
to test compiling without it. Sorry.

andy

On Thu, Oct 1, 2015 at 8:52 AM, Ben Pfaff <blp@nicira.com> wrote:
> On Thu, Oct 01, 2015 at 11:29:16AM -0400, Russell Bryant wrote:
>> The function daemon_become_new_user_linux was conditionally defined but
>> then used in code unconditionally.  If HAVE_LIBCAPNG is not defined, the
>> function would never be called, but it still must exist.
>>
>> Adjust the #if guard around the function to be around the body of the
>> function instead of outside of its definition to ensure the function is
>> always defined, even if empty.
>>
>> This issue was introduced in e91b927d8966bfcb9768225392324dde4fd7d7f6.
>>
>> Signed-off-by: Russell Bryant <rbryant@redhat.com>
>
> Applied, thanks!
Russell Bryant Oct. 1, 2015, 7:41 p.m. UTC | #3
Andy, no problem!  It was an easy fix.  That's the life of working
against master.  :-)

I'm going to look into updating the RPM spec file for the new
dependency, as well.
Andy Zhou Oct. 1, 2015, 8:07 p.m. UTC | #4
> I'm going to look into updating the RPM spec file for the new
> dependency, as well.
What do you plan to change there? I also plan to update the packaging scripts
so that 1) it will create 'ovs' user and group on the box, 2) OVS daemons
will run as the ovs user, using the facilities just committed.  If you
are talking
about libcap-ng dependency, I can add that as well in my changes.
Russell Bryant Oct. 1, 2015, 8:19 p.m. UTC | #5
On 10/01/2015 04:07 PM, Andy Zhou wrote:
>> I'm going to look into updating the RPM spec file for the new
>> dependency, as well.
> What do you plan to change there? I also plan to update the packaging scripts
> so that 1) it will create 'ovs' user and group on the box, 2) OVS daemons
> will run as the ovs user, using the facilities just committed.  If you
> are talking
> about libcap-ng dependency, I can add that as well in my changes.
> 

I was just doing the basics for now, building against the lib.  I didn't
touch the systemd units yet.

http://openvswitch.org/pipermail/dev/2015-October/060795.html

Patch
diff mbox

diff --git a/lib/daemon-unix.c b/lib/daemon-unix.c
index 6438061..868e2c9 100644
--- a/lib/daemon-unix.c
+++ b/lib/daemon-unix.c
@@ -804,10 +804,10 @@  daemon_become_new_user_unix(void)
 
 /* Linux specific implementation of daemon_become_new_user()
  * using libcap-ng.   */
-#if defined __linux__ &&  HAVE_LIBCAPNG
 static void
-daemon_become_new_user_linux(bool access_datapath)
+daemon_become_new_user_linux(bool access_datapath OVS_UNUSED)
 {
+#if defined __linux__ &&  HAVE_LIBCAPNG
     int ret;
 
     ret = capng_get_caps_process();
@@ -847,8 +847,8 @@  daemon_become_new_user_linux(bool access_datapath)
         VLOG_FATAL("%s: libcap-ng fail to switch to user and group "
                    "%d:%d, aborting", pidfile, uid, gid);
     }
-}
 #endif
+}
 
 static void
 daemon_become_new_user__(bool access_datapath)