File 0020-dhcp-4.2.x-chown-server-leases.bnc868253.patch of Package dhcp

References: bnc#868253

--- dhcp-4.2.x/server/dhcpd.c
+++ dhcp-4.2.x/server/dhcpd.c	2014/06/10 01:59:13
@@ -783,8 +783,19 @@ main(int argc, char **argv) {
 	}
  
 #if defined (PARANOIA)
-	/* change uid to the specified one */
+	/* ensure, the leases db is owned by the run user/group */
+	if (set_gid || set_uid) {
+		char backfname[512];
+
+		chown(path_dhcpd_db, set_uid ? set_uid : -1,
+				     set_gid ? set_gid : -1);
 
+		snprintf (backfname, sizeof backfname, "%s~", path_dhcpd_db);
+		chown(backfname,     set_uid ? set_uid : -1,
+				     set_gid ? set_gid : -1);
+	}
+
+	/* change uid to the specified one */
 	if (set_gid) {
 		/* setgroups is done, OK */
 		if (setgroups (0, (void *)0))