rpms/shadow-utils/devel shadow-4.0.14-symlinks.patch, NONE, 1.1 shadow-utils.spec, 1.67, 1.68
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Mon Mar 6 14:58:00 UTC 2006
- Previous message (by thread): rpms/policycoreutils/devel policycoreutils-rhat.patch, 1.166, 1.167 policycoreutils.spec, 1.239, 1.240
- Next message (by thread): rpms/NetworkManager/devel .cvsignore, 1.33, 1.34 NetworkManager.spec, 1.98, 1.99 sources, 1.49, 1.50
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: pvrabec
Update of /cvs/dist/rpms/shadow-utils/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv4951
Modified Files:
shadow-utils.spec
Added Files:
shadow-4.0.14-symlinks.patch
Log Message:
use lrename() function, which follow a destination symbolic link(#181977)
shadow-4.0.14-symlinks.patch:
commonio.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 72 insertions(+), 1 deletion(-)
--- NEW FILE shadow-4.0.14-symlinks.patch ---
--- shadow-4.0.12/lib/commonio.c.symlinks 2006-03-06 11:13:18.000000000 -0500
+++ shadow-4.0.12/lib/commonio.c 2006-03-06 11:18:05.000000000 -0500
@@ -5,6 +5,8 @@
RCSID ("$Id: commonio.c,v 1.28 2005/03/31 05:14:49 kloczek Exp $")
#include "defines.h"
#include <sys/stat.h>
+#include <unistd.h>
+#include <limits.h>
#include <utime.h>
#include <fcntl.h>
#include <errno.h>
@@ -22,6 +24,7 @@
#include "commonio.h"
/* local function prototypes */
+static int lrename(const char *, const char *);
static int check_link_count (const char *);
static int do_lock_file (const char *, const char *);
static FILE *fopen_set_perms (const char *, const char *, const struct stat *);
@@ -36,6 +39,74 @@
static int lock_count = 0;
static int nscd_need_reload = 0;
+/*
+ * Simple rename(P) alternative that attempts to rename to symlink
+ * target. If symlink target is on different device, or resolving target
+ * fails for any reason, then falls back to POSIX rename().
+ *
+ * This function helps preserve symbolic link structures when
+ * attempting to do atomic file replacement.
+ */
+int
+lrename(const char *old, const char *new)
+{
+ const char *new0 = new;
+ char *target = NULL;
+ size_t targetlen = 0;
+ int res;
+#if defined(S_ISLNK)
+ struct stat sb = {0};
+#if defined(_POSIX_SYMLOOP_MAX)
+ int maxloops = _POSIX_SYMLOOP_MAX;
+#elif defined(_SYMLOOP_MAX)
+ int maxloops = _SYMLOOP_MAX;
+#else
+ int maxloops = sysconf(_SC_SYMLOOP_MAX);
+ if (maxloops <= 0)
+ maxloops = 8;
+#endif
+ while (maxloops-- > 0 && lstat(new, &sb) == 0 && S_ISLNK(sb.st_mode))
+ {
+ size_t len;
+ size_t bufflen = sb.st_size + 1;
+ char *buff = malloc(bufflen);
+ if (!buff)
+ {
+ new = new0;
+ break;
+ }
+ len = readlink(new, buff, bufflen - 1);
+ if (target) // aka new
+ {
+ free(target);
+ target = NULL;
+ }
+ target = buff;
+ targetlen = bufflen;
+ if (len == -1)
+ {
+ // could be a dangling link
+ new = new0;
+ break;
+ }
+ else
+ {
+ target[len] = '\0';
+ new = target;
+ }
+ }
+#endif
+ res = rename(old, new);
+ if (res != 0 && new == target)
+ res = rename(old, new0);
+ if (target)
+ {
+ free(target);
+ target = NULL;
+ }
+ return res;
+}
+
static int check_link_count (const char *file)
{
struct stat sb;
@@ -705,7 +776,7 @@
goto fail;
}
- if (rename (buf, db->filename))
+ if (lrename (buf, db->filename))
goto fail;
nscd_need_reload = 1;
Index: shadow-utils.spec
===================================================================
RCS file: /cvs/dist/rpms/shadow-utils/devel/shadow-utils.spec,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- shadow-utils.spec 11 Feb 2006 05:41:44 -0000 1.67
+++ shadow-utils.spec 6 Mar 2006 14:57:57 -0000 1.68
@@ -5,7 +5,7 @@
Summary: Utilities for managing accounts and shadow password files.
Name: shadow-utils
Version: 4.0.14
-Release: 1.2
+Release: 2
Epoch: 2
URL: http://shadow.pld.org.pl/
Source0: ftp://ftp.pld.org.pl/software/shadow/shadow-%{version}.tar.bz2
@@ -17,6 +17,8 @@
Patch3: shadow-4.0.14-goodname.patch
Patch4: shadow-4.0.13-newgrpPwd.patch
Patch5: shadow-4.0.12-lOption.patch
+Patch6: shadow-4.0.14-symlinks.patch
+
License: BSD
Group: System Environment/Base
BuildRequires: autoconf, automake, libtool, gettext-devel
@@ -47,12 +49,13 @@
%patch3 -p1 -b .goodname
%patch4 -p1 -b .newgrpPwd
%patch5 -p1 -b .lOption
+%patch6 -p1 -b .symlinks
rm po/*.gmo
rm po/stamp-po
-libtoolize --force
aclocal
+libtoolize --force
automake -a
autoconf
@@ -197,6 +200,9 @@
%{_mandir}/*/man8/faillog.8*
%changelog
+* Mon Mar 06 2006 Peter Vrabec <pvrabec at redhat.com> 2:4.0.14-2
+- use lrename() function, which follow a destination symbolic link(#181977)
+
* Fri Feb 10 2006 Jesse Keating <jkeating at redhat.com> - 2:4.0.14-1.2
- bump again for double-long bug on ppc(64)
- Previous message (by thread): rpms/policycoreutils/devel policycoreutils-rhat.patch, 1.166, 1.167 policycoreutils.spec, 1.239, 1.240
- Next message (by thread): rpms/NetworkManager/devel .cvsignore, 1.33, 1.34 NetworkManager.spec, 1.98, 1.99 sources, 1.49, 1.50
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-cvs-commits
mailing list