- Run nscd in the foreground w/ syslogging, fix systemd config (#770869)

This commit is contained in:
Jeff Law 2012-02-03 13:42:46 -07:00
parent 92f446a92e
commit af740e08c9
2 changed files with 127 additions and 2 deletions

121
glibc-rh770869.patch Normal file
View File

@ -0,0 +1,121 @@
diff -rup a/fedora/nscd.service b/fedora/nscd.service
--- a/fedora/nscd.service 2011-10-19 05:04:41.000000000 -0600
+++ b/fedora/nscd.service 2012-02-03 13:40:37.070063851 -0700
@@ -3,16 +3,15 @@ Description=Name Service Cache Daemon
After=syslog.target
[Service]
-Type=forking
EnvironmentFile=-/etc/sysconfig/nscd
-ExecStart=/usr/sbin/nscd $NSCD_OPTIONS
+ExecStart=/usr/sbin/nscd --foreground $NSCD_OPTIONS
ExecStop=/usr/sbin/nscd --shutdown
ExecReload=/usr/sbin/nscd -i passwd
ExecReload=/usr/sbin/nscd -i group
ExecReload=/usr/sbin/nscd -i hosts
-ExecReload=/usr/sbin/nscd -i service
+ExecReload=/usr/sbin/nscd -i services
+ExecReload=/usr/sbin/nscd -i netgroup
Restart=always
-PIDFile=/run/nscd/nscd.pid
[Install]
WantedBy=multi-user.target
diff -rup a/nscd/nscd.c b/nscd/nscd.c
--- a/nscd/nscd.c 2012-01-01 05:16:32.000000000 -0700
+++ b/nscd/nscd.c 2012-02-03 13:07:50.509740586 -0700
@@ -72,7 +72,12 @@ thread_info_t thread_info;
int do_shutdown;
int disabled_passwd;
int disabled_group;
-int go_background = 1;
+
+/* Default is to daemonize. Set to 1 to run in foreground in
+ debugging mode, or negative to run in foreground but otherwise
+ behave like a daemon, i.e., detach from terminal and use
+ syslog. */
+static int run_in_foreground = 0;
static const char *conffile = _PATH_NSCDCONF;
@@ -104,6 +109,8 @@ static const struct argp_option options[
N_("Read configuration data from NAME") },
{ "debug", 'd', NULL, 0,
N_("Do not fork and display messages on the current tty") },
+ { "foreground", 'F', NULL, 0,
+ N_("Do not fork, but otherwise behave like a deamon") },
{ "nthreads", 't', N_("NUMBER"), 0, N_("Start NUMBER threads") },
{ "shutdown", 'K', NULL, 0, N_("Shut the server down") },
{ "statistics", 'g', NULL, 0, N_("Print current configuration statistics") },
@@ -174,16 +181,22 @@ main (int argc, char **argv)
/* Determine page size. */
pagesize_m1 = getpagesize () - 1;
- /* Behave like a daemon. */
- if (go_background)
+ if (run_in_foreground <= 0)
{
int i;
+ pid_t pid;
- pid_t pid = fork ();
- if (pid == -1)
- error (EXIT_FAILURE, errno, _("cannot fork"));
- if (pid != 0)
- exit (0);
+ /* Behave like a daemon. */
+ if (!run_in_foreground)
+ {
+ pid = fork ();
+ if (pid == -1)
+ error (EXIT_FAILURE, errno, _("cannot fork"));
+ if (pid != 0)
+ exit (0);
+ }
+ else
+ fprintf (stderr, _("further output sent to syslog\n"));
int nullfd = open (_PATH_DEVNULL, O_RDWR);
if (nullfd != -1)
@@ -234,11 +247,14 @@ main (int argc, char **argv)
for (i = min_close_fd; i < getdtablesize (); i++)
close (i);
- pid = fork ();
- if (pid == -1)
- error (EXIT_FAILURE, errno, _("cannot fork"));
- if (pid != 0)
- exit (0);
+ if (!run_in_foreground)
+ {
+ pid = fork ();
+ if (pid == -1)
+ error (EXIT_FAILURE, errno, _("cannot fork"));
+ if (pid != 0)
+ exit (0);
+ }
setsid ();
@@ -260,7 +276,7 @@ main (int argc, char **argv)
signal (SIGTSTP, SIG_IGN);
}
else
- /* In foreground mode we are not paranoid. */
+ /* In debug mode we are not paranoid. */
paranoia = 0;
signal (SIGINT, termination_handler);
@@ -309,7 +325,11 @@ parse_opt (int key, char *arg, struct ar
{
case 'd':
++debug_level;
- go_background = 0;
+ run_in_foreground = 1;
+ break;
+
+ case 'F':
+ run_in_foreground = -1;
break;
case 'f':

View File

@ -28,7 +28,7 @@
Summary: The GNU libc libraries
Name: glibc
Version: %{glibcversion}
Release: 10%{?dist}
Release: 11%{?dist}
# GPLv2+ is used in a bunch of programs, LGPLv2+ is used for libraries.
# Things that are linked directly into dynamically linked programs
# and shared libraries (e.g. crt files, lib*_nonshared.a) have an additional
@ -72,6 +72,8 @@ Patch18: %{name}-rh657588.patch
Patch19: %{name}-rh787201.patch
# Sent upstream, awaiting feedback
Patch20: %{name}-rh741105.patch
# Sent upstream, awaiting feedback
Patch21: %{name}-rh770869.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Obsoletes: glibc-profile < 2.4
@ -310,6 +312,7 @@ rm -rf %{glibcportsdir}
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
# A lot of programs still misuse memcpy when they have to use
# memmove. The memcpy implementation below is not tolerant at
@ -1162,7 +1165,8 @@ rm -f *.filelist*
%endif
%changelog
* Fri Feb 3 2012 Jeff Law <law@redhat.com> - 2.15-10
* Fri Feb 3 2012 Jeff Law <law@redhat.com> - 2.15-11
- Run nscd in the foreground w/ syslogging, fix systemd config (#770869)
- Avoid mapping past end of shared object (#741105)
- Turn off -mno-minimal-toc on PPC (#787201)
- Remove hunk from glibc-rh657588.patch that didn't belong