added support for wildcards in path
- resolves: #693458
  fixed error with .so links
This commit is contained in:
Peter Schiffer 2012-04-24 15:32:21 +02:00
parent ce87928fd7
commit b2bffc6b83
3 changed files with 243 additions and 1 deletions

View File

@ -0,0 +1,16 @@
diff -up man-db-2.6.1/src/ult_src.c.better_so man-db-2.6.1/src/ult_src.c
--- man-db-2.6.1/src/ult_src.c.better_so 2012-02-05 14:21:24.000000000 +0100
+++ man-db-2.6.1/src/ult_src.c 2012-04-24 13:55:03.770469147 +0200
@@ -345,6 +345,12 @@ const char *ult_src (const char *name, c
NULL);
free (include);
+ if (access (base, F_OK) != 0) {
+ debug ("ult_src: original path of .so link: %s doesn't exist\n",
+ base);
+ return NULL;
+ }
+
debug ("ult_src: points to %s\n", base);
recurse++;

View File

@ -0,0 +1,215 @@
diff -upr man-db-2.6.1.orig/src/globbing.c man-db-2.6.1/src/globbing.c
--- man-db-2.6.1.orig/src/globbing.c 2010-09-26 23:08:14.000000000 +0200
+++ man-db-2.6.1/src/globbing.c 2012-04-24 14:30:30.113882075 +0200
@@ -427,3 +427,30 @@ char **look_for_file (const char *hier,
else
return gbuf.gl_pathv;
}
+
+char **expand_path (const char *path)
+{
+ int res = 0;
+ char **result = NULL;
+ glob_t globbuf;
+
+ res = glob (path, 0, NULL, &globbuf);
+ /* if glob failed, return the given path */
+ if (res != 0) {
+ result = (char **) xmalloc (2 * sizeof(char **));
+ result[0] = xstrndup (path, strlen(path));
+ result[1] = NULL;
+ return result;
+ }
+
+ result = (char **) xmalloc ((globbuf.gl_pathc + 1) * sizeof(char **));
+ size_t i;
+ for (i = 0; i < globbuf.gl_pathc; i++) {
+ result[i] = xstrndup (globbuf.gl_pathv[i], strlen (globbuf.gl_pathv[i]));
+ }
+ result[globbuf.gl_pathc] = NULL;
+
+ globfree (&globbuf);
+
+ return result;
+}
diff -upr man-db-2.6.1.orig/src/globbing.h man-db-2.6.1/src/globbing.h
--- man-db-2.6.1.orig/src/globbing.h 2008-12-11 00:06:18.000000000 +0100
+++ man-db-2.6.1/src/globbing.h 2012-03-26 20:35:49.580882731 +0200
@@ -29,3 +29,6 @@ enum look_for_file_opts {
/* globbing.c */
extern char **look_for_file (const char *hier, const char *sec,
const char *unesc_name, int cat, int opts);
+
+/* Expand path with wildcards into list of all existing directories. */
+extern char **expand_path (const char *path);
diff -upr man-db-2.6.1.orig/src/Makefile.am man-db-2.6.1/src/Makefile.am
--- man-db-2.6.1.orig/src/Makefile.am 2012-02-05 14:25:20.000000000 +0100
+++ man-db-2.6.1/src/Makefile.am 2012-03-26 20:35:49.581882637 +0200
@@ -72,6 +72,8 @@ zsoelim_LDADD = $(LIBMAN) $(libpipeline_
accessdb_SOURCES = \
accessdb.c
catman_SOURCES = \
+ globbing.c \
+ globbing.h \
catman.c \
manp.c \
manp.h
@@ -140,10 +142,14 @@ mandb_SOURCES = \
ult_src.c \
ult_src.h
manpath_SOURCES = \
+ globbing.c \
+ globbing.h \
manp.c \
manp.h \
manpath.c
whatis_SOURCES = \
+ globbing.c \
+ globbing.h \
manconv.c \
manconv.h \
manp.c \
diff -upr man-db-2.6.1.orig/src/manp.c man-db-2.6.1/src/manp.c
--- man-db-2.6.1.orig/src/manp.c 2012-02-05 14:18:59.000000000 +0100
+++ man-db-2.6.1/src/manp.c 2012-03-26 20:35:49.617879267 +0200
@@ -75,6 +75,7 @@
#endif
#include "manp.h"
+#include "globbing.h"
struct list {
char *key;
@@ -1035,32 +1036,45 @@ char *get_manpath_from_path (const char
static void add_dir_to_list (char **lp, const char *dir)
{
int status;
- int pos = 0;
-
- while (*lp != NULL) {
- if (pos > MAXDIRS - 1)
- gripe_overlong_list ();
- if (!strcmp (*lp, dir)) {
- debug ("%s is already in the manpath\n", dir);
- return;
+ int pos = 0, i = 0;
+ char *d = NULL;
+ char **expanded_dirs = NULL;
+
+ expanded_dirs = expand_path (dir);
+ for (i = 0; expanded_dirs[i] != NULL; i++) {
+ d = expanded_dirs[i];
+
+ while (*lp != NULL) {
+ if (pos > MAXDIRS - 1)
+ gripe_overlong_list ();
+ if (!strcmp (*lp, d)) {
+ debug ("%s is already in the manpath\n", d);
+ return;
+ }
+ lp++;
+ pos++;
}
- lp++;
- pos++;
- }
- /* Not found -- add it. */
+ /* Not found -- add it. */
+
+ status = is_directory (d);
- status = is_directory (dir);
+ if (status < 0)
+ gripe_stat_file (d);
+ else if (status == 0)
+ gripe_not_directory (d);
+ else if (status == 1) {
+ debug ("adding %s to manpath\n", d);
- if (status < 0)
- gripe_stat_file (dir);
- else if (status == 0)
- gripe_not_directory (dir);
- else if (status == 1) {
- debug ("adding %s to manpath\n", dir);
+ *lp = xstrdup (d);
+ }
- *lp = xstrdup (dir);
+ free (d);
}
+
+ /* free also the last NULL pointer */
+ free (expanded_dirs[i]);
+ free (expanded_dirs);
}
/* path does not exist in config file: check to see if path/../man,
@@ -1104,33 +1118,47 @@ static inline char *has_mandir (const ch
static char **add_dir_to_path_list (char **mphead, char **mp, const char *p)
{
- int status;
+ int status, i = 0;
char *cwd;
+ char *d = NULL;
+ char **expanded_dirs = NULL;
if (mp - mphead > MAXDIRS - 1)
gripe_overlong_list ();
- status = is_directory (p);
-
- if (status < 0)
- gripe_stat_file (p);
- else if (status == 0)
- gripe_not_directory (p);
- else {
- /* deal with relative paths */
+ expanded_dirs = expand_path (p);
+ for (i = 0; expanded_dirs[i] != NULL; i++) {
+ d = expanded_dirs[i];
+
+ status = is_directory (d);
+
+ if (status < 0)
+ gripe_stat_file (d);
+ else if (status == 0)
+ gripe_not_directory (d);
+ else {
+ /* deal with relative paths */
+
+ if (*d != '/') {
+ cwd = xgetcwd ();
+ if (!cwd)
+ error (FATAL, errno,
+ _("can't determine current directory"));
+ *mp = appendstr (cwd, "/", d, NULL);
+ } else
+ *mp = xstrdup (d);
- if (*p != '/') {
- cwd = xgetcwd ();
- if (!cwd)
- error (FATAL, errno,
- _("can't determine current directory"));
- *mp = appendstr (cwd, "/", p, NULL);
- } else
- *mp = xstrdup (p);
+ debug ("adding %s to manpathlist\n", *mp);
+ mp++;
+ }
- debug ("adding %s to manpathlist\n", *mp);
- mp++;
+ free (d);
}
+
+ /* free also the last NULL pointer */
+ free (expanded_dirs[i]);
+ free (expanded_dirs);
+
return mp;
}

View File

@ -3,7 +3,7 @@
Summary: Tools for searching and reading man pages Summary: Tools for searching and reading man pages
Name: man-db Name: man-db
Version: 2.6.1 Version: 2.6.1
Release: 1%{?dist} Release: 2%{?dist}
# project man-db GPLv2+ # project man-db GPLv2+
# Gnulib part GPLv3+ # Gnulib part GPLv3+
License: GPLv2+ and GPLv3+ License: GPLv2+ and GPLv3+
@ -14,6 +14,8 @@ Source1: man-db.crondaily
Source2: man-db.sysconfig Source2: man-db.sysconfig
# Resolves: #655385 - use old format of nroff output # Resolves: #655385 - use old format of nroff output
Patch1: man-db-2.5.9-sgr.patch Patch1: man-db-2.5.9-sgr.patch
Patch2: man-db-2.6.1-wildcards.patch
Patch3: man-db-2.6.1-so-links.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Obsoletes: man < 2.0 Obsoletes: man < 2.0
Provides: man-pages-reader = %{version} Provides: man-pages-reader = %{version}
@ -34,8 +36,11 @@ manual pages.
%prep %prep
%setup -q %setup -q
%patch1 -p1 -b .sgr %patch1 -p1 -b .sgr
%patch2 -p1 -b .wildcards
%patch3 -p1 -b .so-links
%build %build
./autogen.sh
%configure\ %configure\
--with-sections="1 1p 8 2 3 3p 4 5 6 7 9 0p n l p o 1x 2x 3x 4x 5x 6x 7x 8x" \ --with-sections="1 1p 8 2 3 3p 4 5 6 7 9 0p n l p o 1x 2x 3x 4x 5x 6x 7x 8x" \
--disable-setuid --with-browser=elinks --disable-setuid --with-browser=elinks
@ -111,6 +116,12 @@ rm -rf $RPM_BUILD_ROOT
%lang(it) %{_datadir}/man/it/man*/* %lang(it) %{_datadir}/man/it/man*/*
%changelog %changelog
* Tue Apr 24 2012 Peter Schiffer <pschiffe@redhat.com> - 2.6.1-2
- resolves: #677669
added support for wildcards in path
- resolves: #693458
fixed error with .so links
* Thu Apr 05 2012 Peter Schiffer <pschiffe@redhat.com> - 2.6.1-1 * Thu Apr 05 2012 Peter Schiffer <pschiffe@redhat.com> - 2.6.1-1
- resolves: #790771 - resolves: #790771
update to 2.6.1 update to 2.6.1