File bsc#1177916-0001-Refactor-libcrmcommon-remember-when-IPC-client-is-ro.patch of Package pacemaker.23975

From ae780515cd4db1e6f23db9f75a628ce9c39bdd49 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Fri, 9 Jun 2017 12:35:36 -0500
Subject: [PATCH] Refactor: libcrmcommon: remember when IPC client is root or
 cluster user

will allow using a different eviction threshold
---
 include/crm/common/ipcs.h |  3 ++-
 lib/common/ipc.c          | 13 ++++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

Index: pacemaker-1.1.16+20170320.77ea74d/include/crm/common/ipcs.h
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/include/crm/common/ipcs.h
+++ pacemaker-1.1.16+20170320.77ea74d/include/crm/common/ipcs.h
@@ -60,7 +60,8 @@ struct crm_remote_s {
 
 enum crm_client_flags
 {
-    crm_client_flag_ipc_proxied = 0x00001, /* ipc_proxy code only */
+    crm_client_flag_ipc_proxied    = 0x00001, /* ipc_proxy code only */
+    crm_client_flag_ipc_privileged = 0x00002, /* root or cluster user */
 };
 
 struct crm_client_s {
Index: pacemaker-1.1.16+20170320.77ea74d/lib/common/ipc.c
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/lib/common/ipc.c
+++ pacemaker-1.1.16+20170320.77ea74d/lib/common/ipc.c
@@ -317,6 +317,7 @@ crm_client_disconnect_all(qb_ipcs_servic
 crm_client_t *
 crm_client_new(qb_ipcs_connection_t * c, uid_t uid_client, gid_t gid_client)
 {
+    static gid_t uid_cluster = 0;
     static gid_t gid_cluster = 0;
 
     crm_client_t *client = NULL;
@@ -326,11 +327,12 @@ crm_client_new(qb_ipcs_connection_t * c,
         return NULL;
     }
 
-    if (gid_cluster == 0) {
-        if(crm_user_lookup(CRM_DAEMON_USER, NULL, &gid_cluster) < 0) {
+    if (uid_cluster == 0) {
+        if (crm_user_lookup(CRM_DAEMON_USER, &uid_cluster, &gid_cluster) < 0) {
             static bool have_error = FALSE;
             if(have_error == FALSE) {
-                crm_warn("Could not find group for user %s", CRM_DAEMON_USER);
+                crm_warn("Could not find user and group IDs for user %s",
+                         CRM_DAEMON_USER);
                 have_error = TRUE;
             }
         }
@@ -353,6 +355,11 @@ crm_client_new(qb_ipcs_connection_t * c,
 
     client->id = crm_generate_uuid();
 
+    if ((uid_client == 0) || (uid_client == uid_cluster)) {
+        /* Remember when a connection came from root or hacluster */
+        set_bit(client->flags, crm_client_flag_ipc_privileged);
+    }
+
     crm_debug("Connecting %p for uid=%d gid=%d pid=%u id=%s", c, uid_client, gid_client, client->pid, client->id);
 
 #if ENABLE_ACL
openSUSE Build Service is sponsored by