dhcp/dhcp-4.2.3-paranoia.patch
Jiri Popelka 6e67a560a8 Write lease file AFTER changing of the effective user/group ID.
Move omshell from dhcp-common to main package (where it originally was).
2011-10-26 19:40:23 +02:00

111 lines
2.6 KiB
Diff

diff -up dhcp-4.2.3/server/dhcpd.c.paranoia dhcp-4.2.3/server/dhcpd.c
--- dhcp-4.2.3/server/dhcpd.c.paranoia 2011-10-26 19:10:08.162925489 +0200
+++ dhcp-4.2.3/server/dhcpd.c 2011-10-26 19:12:34.541095509 +0200
@@ -699,11 +699,11 @@ main(int argc, char **argv) {
group_write_hook = group_writer;
- /* Start up the database... */
- db_startup (lftest);
-
- if (lftest)
+ if (lftest) {
+ /* Start up the database... */
+ db_startup (lftest);
exit (0);
+ }
/* Discover all the network interfaces and initialize them. */
discover_interfaces(DISCOVER_SERVER);
@@ -743,24 +743,6 @@ main(int argc, char **argv) {
#if defined (TRACING)
trace_seed_stash (trace_srandom, seed + cur_time);
#endif
- postdb_startup ();
-
-#ifdef DHCPv6
- /*
- * Set server DHCPv6 identifier.
- * See dhcpv6.c for discussion of setting DUID.
- */
- if (set_server_duid_from_option() == ISC_R_SUCCESS) {
- write_server_duid();
- } else {
- if (!server_duid_isset()) {
- if (generate_new_server_duid() != ISC_R_SUCCESS) {
- log_fatal("Unable to set server identifier.");
- }
- write_server_duid();
- }
- }
-#endif /* DHCPv6 */
#ifndef DEBUG
if (daemon) {
@@ -771,22 +753,6 @@ main(int argc, char **argv) {
exit (0);
}
-#if defined (PARANOIA)
- /* change uid to the specified one */
-
- if (set_gid) {
- if (setgroups (0, (void *)0))
- log_fatal ("setgroups: %m");
- if (setgid (set_gid))
- log_fatal ("setgid(%d): %m", (int) set_gid);
- }
-
- if (set_uid) {
- if (setuid (set_uid))
- log_fatal ("setuid(%d): %m", (int) set_uid);
- }
-#endif /* PARANOIA */
-
/*
* Deal with pid files. If the user told us
* not to write a file we don't read one either
@@ -823,6 +789,42 @@ main(int argc, char **argv) {
}
}
+#if defined (PARANOIA)
+ /* change uid to the specified one */
+
+ if (set_gid) {
+ if (setgroups (0, (void *)0))
+ log_fatal ("setgroups: %m");
+ if (setgid (set_gid))
+ log_fatal ("setgid(%d): %m", (int) set_gid);
+ }
+
+ if (set_uid) {
+ if (setuid (set_uid))
+ log_fatal ("setuid(%d): %m", (int) set_uid);
+ }
+#endif /* PARANOIA */
+
+ db_startup(lftest);
+ postdb_startup ();
+
+#ifdef DHCPv6
+ /*
+ * Set server DHCPv6 identifier.
+ * See dhcpv6.c for discussion of setting DUID.
+ */
+ if (set_server_duid_from_option() == ISC_R_SUCCESS) {
+ write_server_duid();
+ } else {
+ if (!server_duid_isset()) {
+ if (generate_new_server_duid() != ISC_R_SUCCESS) {
+ log_fatal("Unable to set server identifier.");
+ }
+ write_server_duid();
+ }
+ }
+#endif /* DHCPv6 */
+
/* If we were requested to log to stdout on the command line,
keep doing so; otherwise, stop. */
if (log_perror == -1)