- Fix nscd cache invalidation Resolves: #506628
- Preserve timestamps during (make install)
This commit is contained in:
parent
0dc75dd084
commit
90333f2423
393
libuser-0.56.10-nscd.patch
Normal file
393
libuser-0.56.10-nscd.patch
Normal file
@ -0,0 +1,393 @@
|
||||
diff -ur libuser/apps/apputil.c libuser-0.56.10/apps/apputil.c
|
||||
--- libuser/apps/apputil.c 2008-02-26 18:10:51.000000000 +0100
|
||||
+++ libuser-0.56.10/apps/apputil.c 2009-06-23 16:24:31.413046399 +0200
|
||||
@@ -31,9 +31,11 @@
|
||||
#include <pwd.h>
|
||||
#include <security/pam_appl.h>
|
||||
#include <security/pam_misc.h>
|
||||
+#include <spawn.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
+#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
#ifdef WITH_SELINUX
|
||||
@@ -670,33 +672,32 @@
|
||||
exit(1);
|
||||
}
|
||||
|
||||
-/* Send nscd an arbitrary signal. */
|
||||
-static void
|
||||
-lu_signal_nscd(int signum)
|
||||
-{
|
||||
- FILE *fp;
|
||||
- /* If it's running, then its PID is in this file. Open it. */
|
||||
- if ((fp = fopen("/var/run/nscd.pid", "r")) != NULL) {
|
||||
- char buf[LINE_MAX];
|
||||
-
|
||||
- /* Read the PID. */
|
||||
- memset(buf, 0, sizeof(buf));
|
||||
- /* If the PID is sane, send it a signal. */
|
||||
- if (fgets(buf, sizeof(buf), fp) != NULL && strlen(buf) > 0) {
|
||||
- pid_t pid = atol(buf);
|
||||
- if (pid != 0) {
|
||||
- kill(pid, signum);
|
||||
- }
|
||||
- }
|
||||
- fclose(fp);
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-/* Send nscd a SIGHUP. */
|
||||
+/* Flush the specified nscd cache */
|
||||
void
|
||||
-lu_hup_nscd()
|
||||
+lu_nscd_flush_cache (const char *table)
|
||||
{
|
||||
- lu_signal_nscd(SIGHUP);
|
||||
+ static char *const envp[] = { NULL };
|
||||
+
|
||||
+ posix_spawn_file_actions_t fa;
|
||||
+ char *argv[4];
|
||||
+ pid_t pid;
|
||||
+
|
||||
+ if (posix_spawn_file_actions_init(&fa) != 0
|
||||
+ || posix_spawn_file_actions_addopen(&fa, STDERR_FILENO, "/dev/null",
|
||||
+ O_RDWR, 0) != 0)
|
||||
+ return;
|
||||
+
|
||||
+ argv[0] = NSCD;
|
||||
+ argv[1] = "-i";
|
||||
+ argv[2] = (char *)table;
|
||||
+ argv[3] = NULL;
|
||||
+ if (posix_spawn(&pid, argv[0], &fa, NULL, argv, envp) != 0)
|
||||
+ return;
|
||||
+ posix_spawn_file_actions_destroy(&fa);
|
||||
+
|
||||
+ /* Wait for the spawned process to exit */
|
||||
+ while (waitpid(pid, NULL, 0) == -1 && errno == EINTR)
|
||||
+ ; /* Nothing */
|
||||
}
|
||||
|
||||
/* Create a mail spool for the user. */
|
||||
diff -ur libuser/apps/apputil.h libuser-0.56.10/apps/apputil.h
|
||||
--- libuser/apps/apputil.h 2008-02-26 18:10:51.000000000 +0100
|
||||
+++ libuser-0.56.10/apps/apputil.h 2009-06-23 16:24:31.414044511 +0200
|
||||
@@ -41,7 +41,7 @@
|
||||
void lu_authenticate_unprivileged(const char *user, const char *appname)
|
||||
G_GNUC_INTERNAL;
|
||||
|
||||
-void lu_hup_nscd(void) G_GNUC_INTERNAL;
|
||||
+void lu_nscd_flush_cache (const char *table) G_GNUC_INTERNAL;
|
||||
|
||||
gboolean lu_mailspool_create_remove(struct lu_context *ctx, struct lu_ent *ent,
|
||||
gboolean action) G_GNUC_INTERNAL;
|
||||
diff -ur libuser/apps/lgroupadd.c libuser-0.56.10/apps/lgroupadd.c
|
||||
--- libuser/apps/lgroupadd.c 2008-02-26 18:10:51.000000000 +0100
|
||||
+++ libuser-0.56.10/apps/lgroupadd.c 2009-06-23 16:24:31.415043321 +0200
|
||||
@@ -126,7 +126,7 @@
|
||||
return 2;
|
||||
}
|
||||
|
||||
- lu_hup_nscd();
|
||||
+ lu_nscd_flush_cache("group");
|
||||
|
||||
lu_ent_free(ent);
|
||||
|
||||
diff -ur libuser/apps/lgroupdel.c libuser-0.56.10/apps/lgroupdel.c
|
||||
--- libuser/apps/lgroupdel.c 2008-02-26 18:10:51.000000000 +0100
|
||||
+++ libuser-0.56.10/apps/lgroupdel.c 2009-06-23 16:24:31.415043321 +0200
|
||||
@@ -91,7 +91,7 @@
|
||||
return 3;
|
||||
}
|
||||
|
||||
- lu_hup_nscd();
|
||||
+ lu_nscd_flush_cache("group");
|
||||
|
||||
lu_ent_free(ent);
|
||||
|
||||
diff -ur libuser/apps/lgroupmod.c libuser-0.56.10/apps/lgroupmod.c
|
||||
--- libuser/apps/lgroupmod.c 2008-02-26 18:10:51.000000000 +0100
|
||||
+++ libuser-0.56.10/apps/lgroupmod.c 2009-06-23 16:24:31.415043321 +0200
|
||||
@@ -191,7 +191,6 @@
|
||||
lu_ent_add(ent, LU_ADMINISTRATORNAME, &val);
|
||||
g_value_reset(&val);
|
||||
}
|
||||
- lu_hup_nscd();
|
||||
g_strfreev(admins);
|
||||
}
|
||||
g_value_unset(&val);
|
||||
@@ -206,7 +205,6 @@
|
||||
lu_ent_del(ent, LU_ADMINISTRATORNAME, &val);
|
||||
g_value_reset(&val);
|
||||
}
|
||||
- lu_hup_nscd();
|
||||
g_strfreev(admins);
|
||||
}
|
||||
g_value_unset(&val);
|
||||
@@ -222,7 +220,6 @@
|
||||
lu_ent_add(ent, LU_MEMBERNAME, &val);
|
||||
g_value_reset(&val);
|
||||
}
|
||||
- lu_hup_nscd();
|
||||
g_strfreev(members);
|
||||
}
|
||||
g_value_unset(&val);
|
||||
@@ -237,7 +234,6 @@
|
||||
lu_ent_del(ent, LU_MEMBERNAME, &val);
|
||||
g_value_reset(&val);
|
||||
}
|
||||
- lu_hup_nscd();
|
||||
g_strfreev(members);
|
||||
}
|
||||
g_value_unset(&val);
|
||||
@@ -276,10 +272,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
- lu_hup_nscd();
|
||||
-
|
||||
lu_ent_free(ent);
|
||||
|
||||
+ lu_nscd_flush_cache("group");
|
||||
+
|
||||
if (oldGidNumber != LU_VALUE_INVALID_ID &&
|
||||
gidNumber != LU_VALUE_INVALID_ID && users != NULL) {
|
||||
size_t i;
|
||||
@@ -304,13 +300,13 @@
|
||||
lu_user_modify(ctx, ent, &error);
|
||||
if (error != NULL)
|
||||
lu_error_free(&error);
|
||||
- lu_hup_nscd();
|
||||
}
|
||||
}
|
||||
}
|
||||
-
|
||||
g_value_unset(&val);
|
||||
lu_ent_free(ent);
|
||||
+
|
||||
+ lu_nscd_flush_cache("passwd");
|
||||
}
|
||||
|
||||
lu_end(ctx);
|
||||
diff -ur libuser/apps/lchage.c libuser-0.56.10/apps/lchage.c
|
||||
--- libuser/apps/lchage.c 2008-02-26 18:10:51.000000000 +0100
|
||||
+++ libuser-0.56.10/apps/lchage.c 2009-06-23 16:24:31.414044511 +0200
|
||||
@@ -256,7 +256,7 @@
|
||||
return 3;
|
||||
}
|
||||
|
||||
- lu_hup_nscd();
|
||||
+ lu_nscd_flush_cache("passwd");
|
||||
}
|
||||
|
||||
lu_ent_free(ent);
|
||||
diff -ur libuser/apps/lchfn.c libuser-0.56.10/apps/lchfn.c
|
||||
--- libuser/apps/lchfn.c 2008-02-26 18:10:51.000000000 +0100
|
||||
+++ libuser-0.56.10/apps/lchfn.c 2009-06-23 16:24:31.414044511 +0200
|
||||
@@ -294,7 +294,7 @@
|
||||
/* Try to save our changes. */
|
||||
if (lu_user_modify(ctx, ent, &error)) {
|
||||
g_print(_("Finger information changed.\n"));
|
||||
- lu_hup_nscd();
|
||||
+ lu_nscd_flush_cache("passwd");
|
||||
} else {
|
||||
fprintf(stderr, _("Finger information not changed: %s.\n"),
|
||||
lu_strerror(error));
|
||||
diff -ur libuser/apps/lchsh.c libuser-0.56.10/apps/lchsh.c
|
||||
--- libuser/apps/lchsh.c 2008-02-26 18:10:51.000000000 +0100
|
||||
+++ libuser-0.56.10/apps/lchsh.c 2009-06-23 16:24:31.415043321 +0200
|
||||
@@ -135,7 +135,7 @@
|
||||
/* Modify the user's record in the information store. */
|
||||
if (lu_user_modify(ctx, ent, &error)) {
|
||||
g_print(_("Shell changed.\n"));
|
||||
- lu_hup_nscd();
|
||||
+ lu_nscd_flush_cache("passwd");
|
||||
} else {
|
||||
fprintf(stderr, _("Shell not changed: %s\n"),
|
||||
lu_strerror(error));
|
||||
|
||||
diff -ur libuser/apps/lnewusers.c libuser-0.56.10/apps/lnewusers.c
|
||||
--- libuser/apps/lnewusers.c 2008-02-26 18:10:51.000000000 +0100
|
||||
+++ libuser-0.56.10/apps/lnewusers.c 2009-06-23 16:24:31.416044296 +0200
|
||||
@@ -207,6 +207,7 @@
|
||||
/* Try to create the group, and if it works, get its
|
||||
* GID, which we need to give to this user. */
|
||||
if (lu_group_add(ctx, ent, &error)) {
|
||||
+ lu_nscd_flush_cache("group");
|
||||
values = lu_ent_get(ent, LU_GIDNUMBER);
|
||||
value = g_value_array_get_nth(values, 0);
|
||||
gid = lu_value_get_id(value);
|
||||
@@ -267,7 +268,6 @@
|
||||
|
||||
/* Now try to add the user's account. */
|
||||
if (lu_user_add(ctx, ent, &error)) {
|
||||
- lu_hup_nscd();
|
||||
if (!lu_user_setpass(ctx, ent, fields[1], FALSE,
|
||||
&error)) {
|
||||
fprintf(stderr,
|
||||
@@ -278,6 +278,7 @@
|
||||
lu_error_free(&error);
|
||||
}
|
||||
}
|
||||
+ lu_nscd_flush_cache("passwd");
|
||||
/* Unless the nocreatehomedirs flag was given, attempt
|
||||
* to create the user's home directory. */
|
||||
if (!nocreatehome) {
|
||||
diff -ur libuser/apps/lpasswd.c libuser-0.56.10/apps/lpasswd.c
|
||||
--- libuser/apps/lpasswd.c 2008-02-26 18:10:51.000000000 +0100
|
||||
+++ libuser-0.56.10/apps/lpasswd.c 2009-06-23 16:24:31.416044296 +0200
|
||||
@@ -188,6 +188,7 @@
|
||||
lu_strerror(error));
|
||||
return 3;
|
||||
}
|
||||
+ lu_nscd_flush_cache("passwd");
|
||||
} else {
|
||||
if (lu_group_setpass(ctx, ent, password, is_crypted, &error)
|
||||
== FALSE) {
|
||||
@@ -196,6 +197,7 @@
|
||||
lu_strerror(error));
|
||||
return 3;
|
||||
}
|
||||
+ lu_nscd_flush_cache("group");
|
||||
}
|
||||
|
||||
lu_ent_free(ent);
|
||||
diff -ur libuser/apps/luseradd.c libuser-0.56.10/apps/luseradd.c
|
||||
--- libuser/apps/luseradd.c 2009-02-19 23:42:33.000000000 +0100
|
||||
+++ libuser-0.56.10/apps/luseradd.c 2009-06-23 16:24:31.417040103 +0200
|
||||
@@ -183,7 +183,7 @@
|
||||
|
||||
/* Try to add the group. */
|
||||
if (lu_group_add(ctx, groupEnt, &error))
|
||||
- lu_hup_nscd();
|
||||
+ lu_nscd_flush_cache("group");
|
||||
else {
|
||||
/* Aargh! Abandon all hope. */
|
||||
fprintf(stderr, _("Error creating group `%s': %s\n"),
|
||||
@@ -265,8 +265,6 @@
|
||||
return 3;
|
||||
}
|
||||
|
||||
- lu_hup_nscd();
|
||||
-
|
||||
if (userPassword != NULL) {
|
||||
if (lu_user_setpass(ctx, ent, userPassword, FALSE, &error)
|
||||
== FALSE) {
|
||||
@@ -287,6 +285,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ lu_nscd_flush_cache("passwd");
|
||||
+
|
||||
/* If we don't have the the don't-create-home flag, create the user's
|
||||
* home directory. */
|
||||
if (!dont_create_home) {
|
||||
diff -ur libuser/apps/luserdel.c libuser-0.56.10/apps/luserdel.c
|
||||
--- libuser/apps/luserdel.c 2008-02-26 18:10:51.000000000 +0100
|
||||
+++ libuser-0.56.10/apps/luserdel.c 2009-06-23 16:24:31.417040103 +0200
|
||||
@@ -96,7 +96,7 @@
|
||||
return 3;
|
||||
}
|
||||
|
||||
- lu_hup_nscd();
|
||||
+ lu_nscd_flush_cache("passwd");
|
||||
|
||||
if (!dont_remove_group) {
|
||||
values = lu_ent_get(ent, LU_GIDNUMBER);
|
||||
@@ -134,11 +134,10 @@
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
+ lu_nscd_flush_cache("group");
|
||||
}
|
||||
}
|
||||
|
||||
- lu_hup_nscd();
|
||||
-
|
||||
if (remove_home) {
|
||||
values = lu_ent_get(ent, LU_HOMEDIRECTORY);
|
||||
if (values == NULL) {
|
||||
diff -ur libuser/apps/lusermod.c libuser-0.56.10/apps/lusermod.c
|
||||
--- libuser/apps/lusermod.c 2008-02-28 00:03:42.000000000 +0100
|
||||
+++ libuser-0.56.10/apps/lusermod.c 2009-06-23 16:24:31.417040103 +0200
|
||||
@@ -276,7 +276,7 @@
|
||||
user, lu_strerror(error));
|
||||
return 9;
|
||||
}
|
||||
- lu_hup_nscd();
|
||||
+ lu_nscd_flush_cache("passwd");
|
||||
|
||||
/* If the user's name changed, we need to update supplemental
|
||||
* group membership information. */
|
||||
@@ -336,7 +336,7 @@
|
||||
groupname, lu_strerror(error));
|
||||
lu_ent_free(group);
|
||||
}
|
||||
- lu_hup_nscd();
|
||||
+ lu_nscd_flush_cache("group");
|
||||
}
|
||||
|
||||
/* If we need to move the user's directory, we do that now. */
|
||||
diff -ur libuser/configure.in libuser-0.56.10/configure.in
|
||||
--- libuser/configure.in 2009-04-14 13:04:23.000000000 +0200
|
||||
+++ libuser-0.56.10/configure.in 2009-06-23 16:25:09.528264894 +0200
|
||||
@@ -8,6 +8,9 @@
|
||||
AM_PROG_CC_C_O
|
||||
AC_CHECK_PROG([YACC], [bison -y], [bison -y], [:])
|
||||
AC_ISC_POSIX
|
||||
+AC_PATH_PROG([NSCD], [nscd], [/usr/sbin/nscd],
|
||||
+ [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin])
|
||||
+AC_ARG_VAR([NSCD], [Path to nscd])
|
||||
|
||||
AC_DISABLE_STATIC
|
||||
AC_PROG_LIBTOOL
|
||||
diff -ur libuser/ChangeLog libuser-0.56.10/ChangeLog
|
||||
--- libuser/ChangeLog 2009-04-14 13:04:19.000000000 +0200
|
||||
+++ libuser-0.56.10/ChangeLog 2009-06-23 16:27:49.363265232 +0200
|
||||
@@ -1,3 +1,33 @@
|
||||
+2009-06-23 Miloslav Trmač <mitr@redhat.com>
|
||||
+
|
||||
+ * apps/lgroupmod.c (main): Remove unnecessary nscd refreshes. Refresh
|
||||
+ the "passwd" nscd cache only once after modifying all affected users.
|
||||
+ * apps/lnewusers.c (main): Refresh the "group" nscd cache after adding
|
||||
+ a group. Refresh the "passwd" nscd cache only after changing the user's
|
||||
+ password.
|
||||
+ * apps/lpasswd.c (main): Refresh the relevant nscd cache after changing
|
||||
+ the password.
|
||||
+ * apps/luseradd.c (main): Refresh the "passwd" nscd cache only after
|
||||
+ changing the user's password.
|
||||
+ * apps/luserdel.c (main): Only refresh the "group" cache if a group was
|
||||
+ deleted.
|
||||
+
|
||||
+ * Makefile.am (apps_libapputil_la_CPPFLAGS): New variable.
|
||||
+ * apps/apputil.c (lu_nscd_flush_cache): New function.
|
||||
+ (lu_signal_nscd, lu_hup_nscd): Remove.
|
||||
+ * apps/apputil.h: Update prototypes.
|
||||
+ * apps/lchage.c (main)
|
||||
+ * apps/lchfn.c (main)
|
||||
+ * apps/lchsh.c (main)
|
||||
+ * apps/lgroupadd.c (main)
|
||||
+ * apps/lgroupdel.c (main)
|
||||
+ * apps/lgroupmod.c (main):
|
||||
+ * apps/lnewusers.c (main):
|
||||
+ * apps/luseradd.c (main)
|
||||
+ * apps/luserdel.c (main): Use lu_nscd_flush_cache () instead of
|
||||
+ lu_hup_nscd ().
|
||||
+ Based on a patch by Masahiro Matsuya <mmatsuya@redhat.com>.
|
||||
+
|
||||
2009-04-14 Miloslav Trmač <mitr@redhat.com>
|
||||
|
||||
* configure.in: Version 0.56.10.
|
||||
diff -ur libuser/Makefile.am libuser-0.56.10/Makefile.am
|
||||
--- libuser/Makefile.am 2008-02-26 18:10:51.000000000 +0100
|
||||
+++ libuser-0.56.10/Makefile.am 2009-06-23 16:24:31.413046399 +0200
|
||||
@@ -92,6 +92,7 @@
|
||||
|
||||
|
||||
## Dependency data
|
||||
+apps_libapputil_la_CPPFLAGS = $(AM_CPPFLAGS) -DNSCD='"$(NSCD)"'
|
||||
apps_libapputil_la_SOURCES = apps/apputil.c apps/apputil.h
|
||||
apps_libapputil_la_LDFLAGS = $(GOBJECT_LIBS) -lpam -lpam_misc $(SELINUX_LIBS)
|
||||
|
22
libuser.spec
22
libuser.spec
@ -2,14 +2,19 @@
|
||||
|
||||
Name: libuser
|
||||
Version: 0.56.10
|
||||
Release: 2
|
||||
Release: 3
|
||||
Group: System Environment/Base
|
||||
License: LGPLv2+
|
||||
URL: https://fedorahosted.org/libuser/
|
||||
Source: https://fedorahosted.org/releases/l/i/libuser/libuser-%{version}.tar.bz2
|
||||
Patch0: libuser-0.56.10-nscd.patch
|
||||
BuildRoot: %{_tmppath}/%{name}-root
|
||||
BuildRequires: glib2-devel, linuxdoc-tools, pam-devel, popt-devel, python-devel
|
||||
BuildRequires: cyrus-sasl-devel, libselinux-devel, openldap-devel
|
||||
# To make sure the configure script can find it
|
||||
BuildRequires: nscd
|
||||
# For Patch0
|
||||
BuildRequires: autoconf, automake, cvs, gettext-devel, gtk-doc, libtool
|
||||
Summary: A user and group account administration library
|
||||
|
||||
%description
|
||||
@ -42,6 +47,14 @@ administering user and group accounts.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1 -b .nscd
|
||||
gtkdocize --docdir docs/reference
|
||||
libtoolize --force
|
||||
autopoint
|
||||
aclocal -I m4
|
||||
autoconf -Wall
|
||||
autoheader -Wall
|
||||
automake -Wall --add-missing
|
||||
|
||||
%build
|
||||
%configure --with-selinux --with-ldap --with-html-dir=%{_datadir}/gtk-doc/html
|
||||
@ -52,7 +65,7 @@ rm -fr $RPM_BUILD_ROOT
|
||||
|
||||
%install
|
||||
rm -fr $RPM_BUILD_ROOT
|
||||
make install DESTDIR=$RPM_BUILD_ROOT
|
||||
make install DESTDIR=$RPM_BUILD_ROOT INSTALL='install -p'
|
||||
|
||||
%find_lang %{name}
|
||||
|
||||
@ -98,6 +111,11 @@ python -c "import libuser"
|
||||
%{_datadir}/gtk-doc/html/*
|
||||
|
||||
%changelog
|
||||
* Thu Jul 30 2009 Miloslav Trmač <mitr@redhat.com> - 0.56.10-3
|
||||
- Fix nscd cache invalidation
|
||||
Resolves: #506628
|
||||
- Preserve timestamps during (make install)
|
||||
|
||||
* Sat Jul 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.56.10-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user