On Sat, 27 Apr 2002, Riku Meskanen wrote:
>
> I'm still thinking /etc/man.config.d/ support possibilities.
>
> As the /etc/man.config is just flat config with really no
> really need stacked options or anything and the /etc/man.config.d/
> could be achieved simply modifying read_config_file() to traverse
> the directory and include all configs. Will possibly look it further
> later, if someone else does not like to implement it.
>
> BTW The ready made RPMs with glob support for test can be found
> from http://people.jyu.fi/~mesrik/tmp/man/
>
Ok, spent some more time on it and it config directory is
now fully functional with relevant IMHO security checks etc.

RPM will add /etc/man.config.d (relative to your man config
ofcourse) directory were the another package can add easily
it's own foo.conf and declare required MANPATH there.

Check http://people.jyu.fi/~mesrik/tmp/man the 'release' 8 has
it built in and diffs follows, if you prefer those.

I was first thinking making these better configurable options,
but the package does not use recent autoconfigure, so I simply
made patches active by default. NOCONFIGD and NOGLOB can
consequtively disable the features if not desired.

I would appreciate if Bero and Aeb give glimpse to these
patches, please. They sure are worth that :)

HTH,

:-) riku

ps.     anybody knows why this man package still uses internal
        glob package that RMS wrote ages ago? It shouldn't be
        much work rewriting that one function to use system wide
        glob ...

--- man-1.5j/src/man-config.c.dist      Fri Apr 26 20:23:21 2002
+++ man-1.5j/src/man-config.c   Fri Apr 26 23:06:48 2002
@@ -19,6 +19,14 @@
 #include <string.h>
 #include <stdlib.h>

+#ifndef NOGLOB
+/* Can't refer to system <glob.h> as long as there is local glob.h
+   on this same directory. Is that really needed any more or would
+   it be better replace glob_filename() with few lines of code and
+   call to glob from libc ? -- [EMAIL PROTECTED] */
+#include "/usr/include/glob.h"
+#endif
+
 #include "defs.h"
 #include "man-config.h"
 #include "man.h"
@@ -201,7 +209,10 @@
      char *p;
      char buf[BUFSIZE];
      FILE *config = NULL;
-
+#ifndef NOGLOB
+     glob_t  gs;
+     char    **gp;
+#endif
      if (cf) {
          /* User explicitly specified a config file */
          if ((config = fopen (cf, "r")) == NULL) {
@@ -249,9 +260,24 @@

          if (!strncmp ("MANPATH_MAP", bp, 11))
               adddir (bp+11, 0);
-         else if (!strncmp ("MANPATH", bp, 7))
+         else if (!strncmp ("MANPATH", bp, 7)) {
+#ifndef NOGLOB
+              /* config glob manpath support - [EMAIL PROTECTED] */
+              p = bp+7;
+              while (whitespace(*p))
+                    p++;
+              if (!glob(p,0,NULL,&gs)) {
+                    for (gp = gs.gl_pathv; *gp; gp++) {
+                         adddir (*gp, 1);
+                    }
+              } else {
+                    adddir(bp+7,1);
+              }
+              globfree(&gs);
+#else
               adddir (bp+7, 1);
-         else if(!strncmp ("MANDATORY_MANPATH", bp, 17))/* backwards compatible */
+#endif
+          } else if(!strncmp ("MANDATORY_MANPATH", bp, 17))/* backwards compatible */
               adddir (bp+17, 1);
          else if (!strncmp ("FHS", bp, 3))
               fhs = 1;
--- man-1.5j/src/man.conf.in.diff       Fri Apr 26 23:33:46 2002
+++ man-1.5j/src/man.conf.in    Fri Apr 26 23:34:13 2002
@@ -40,6 +40,7 @@
 MANPATH        /usr/X11R6/man
 MANPATH        /usr/local/man
 MANPATH /usr/kerberos/man
+MANPATH /opt/*/man
 MANPATH        /usr/man
 #
 # Uncomment if you want to include one of these by default

--- man-1.5j/src/man-config.c.dist      Sat Apr 27 15:56:34 2002
+++ man-1.5j/src/man-config.c   Sat Apr 27 15:57:43 2002
@@ -26,6 +26,13 @@
    call to glob from libc ? -- [EMAIL PROTECTED] */
 #include "/usr/include/glob.h"
 #endif
+#ifndef NOCONFIGD
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <libgen.h>
+char  *manconfigd = NULL; /* global used to pass possible config include dir */
+#endif

 #include "defs.h"
 #include "man-config.h"
@@ -213,6 +220,11 @@
      glob_t  gs;
      char    **gp;
 #endif
+#ifndef NOCONFIGD
+     char    *dn = NULL;
+     char    *fn = NULL;
+     struct  stat ds;
+#endif
      if (cf) {
          /* User explicitly specified a config file */
          if ((config = fopen (cf, "r")) == NULL) {
@@ -235,6 +247,31 @@
               gripe (CONFIG_OPEN_ERROR, CONFIG_FILE);
               return;
          }
+#ifndef NOCONFIGD
+         /* build config dir and check that it us owned by root, in
+            root group and group and others must not have write perms
+            -- [EMAIL PROTECTED] */
+         dn = dirname(strdup(cf));
+         fn = basename(strdup(cf));
+         realloc(dn,strlen(dn)+strlen(fn)+5);
+         strcat(dn,"/");
+         strcat(dn,fn);
+         strcat(dn,".d");
+         if (!stat(dn,&ds) &&
+             S_ISDIR(ds.st_mode) &&
+             (ds.st_uid == 0) &&
+             (ds.st_gid == 0) &&
+             ((ds.st_mode & S_IWGRP) == 0) &&
+             ((ds.st_mode & S_IWOTH) == 0)) {
+                 if (debug)
+                         fprintf(stderr, "found config dir %s\n", dn);
+                 /* confing dir name is passed back to caller with
+                    manconfigd global pointer */
+                 manconfigd = dn;
+          } else
+                 /* didn't find better gripe, for _a directory_ */
+                 gripe (BAD_CONFIG_FILE, dn);
+#endif
      }

      if (debug)
--- man-1.5j/src/man-getopt.c.dist      Sat Apr 27 10:06:57 2002
+++ man-1.5j/src/man-getopt.c   Sat Apr 27 15:48:46 2002
@@ -2,6 +2,13 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#ifndef NOCONFIGD
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+/* sigh - for local glob.h which we can't use ... :( */
+#include "/usr/include/glob.h"
+#endif

 #include "defs.h"
 #include "gripes.h"
@@ -216,16 +223,51 @@
  * Also reads the configuration file.
  */

+#ifndef NOCONFIGD
+#define CONFSUFFIX "/*.conf"
+extern char *manconfigd;
+#endif
+
 void
 man_getopt (int argc, char **argv) {
      char *config_file = NULL;
      char *manp = NULL;
      int optct = 0;
+#ifndef NOCONFIGD
+     glob_t gs;
+     struct stat ss;
+     char   **gp, mcm[80];
+#endif

      optct = get_options_from_argvec(argc, argv, &config_file, &manp);

      read_config_file (config_file);

+#ifndef NOCONFIGD
+     if (manconfigd != NULL) {
+            /* append glob suffix and traverse directory, read config
+               if file permissions are sane enough --  [EMAIL PROTECTED] */
+            strncpy(mcm,manconfigd,sizeof(mcm) - strlen(CONFSUFFIX) -1);
+            strcat(mcm,CONFSUFFIX);
+            if (!glob(mcm,0,NULL,&gs)) {
+                    for (gp = gs.gl_pathv; *gp; gp++) {
+                            if (!stat(*gp,&ss) &&
+                                S_ISREG(ss.st_mode) &&
+                                !S_ISLNK(ss.st_mode) &&
+                                (ss.st_uid == 0) &&
+                                (ss.st_gid == 0) &&
+                                ((ss.st_mode & S_IWGRP) == 0) &&
+                                ((ss.st_mode & S_IWOTH) == 0)) {
+                                    read_config_file(*gp);
+                            } else
+                                    /* not really descriptive :/ */
+                                    gripe(BAD_CONFIG_FILE,*gp);
+                    }
+            }
+            globfree(&gs);
+     }
+#endif
+
      /* If no options were given and MANDEFOPTIONS is set, use that */
      if (optct == 0) {
             char *defopts = getval ("MANDEFOPTIONS");

--- man.spec.dist       Fri Apr 26 23:51:42 2002
+++ man.spec    Sat Apr 27 16:28:08 2002
@@ -5,7 +5,7 @@
 Summary: A set of documentation tools:  man, apropos and whatis.
 Name: man
 Version: 1.5j
-Release: 6
+Release: 8
 License: GPL
 Group: System Environment/Base
 Source0: ftp://ftp.win.tue.nl/pub/linux-local/utils/man/man-%{version}.tar.bz2
@@ -32,6 +32,8 @@
 Patch24: man-1.5i2-initial.patch
 Patch25: man-1.5i2-legacy.patch
 Patch26: man-1.5j-sanitycheck.patch
+Patch27: man-1.5j-globfeat.patch
+Patch28: man-1.5j-manconfigd.patch

 # Japanese patches
 Patch51: man-1.5h1-gencat.patch
@@ -84,7 +86,8 @@
 %endif

 %patch26 -p1 -b .sanitycheck
-
+%patch27 -p1 -b .globfeat
+%patch28 -p1 -b .manconfigd
 #rm -f $RPM_BUILD_DIR/man-%{version}/man/en/man.conf.man

 find $RPM_BUILD_DIR/man-%{version} -type f|xargs perl -pi -e 
's,man\.conf\(5\),man.config(5),g'
@@ -104,27 +107,28 @@

 %install
 rm -rf $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT/etc/cron.{daily,weekly}
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/cron.{daily,weekly}
 mkdir -p $RPM_BUILD_ROOT%{_bindir} $RPM_BUILD_ROOT%{_sbindir}
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/man.config.d
 make install PREFIX=$RPM_BUILD_ROOT

 mkdir -p $RPM_BUILD_ROOT%{_mandir}/man1
 mkdir -p $RPM_BUILD_ROOT%{_mandir}/man5
 mkdir -p $RPM_BUILD_ROOT%{_mandir}/man8
-mkdir -p $RPM_BUILD_ROOT/etc
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}
 install -m 644 man/en/apropos.1 $RPM_BUILD_ROOT%{_mandir}/man1
 install -m 644 man/en/man.1 $RPM_BUILD_ROOT%{_mandir}/man1
 install -m 644 man/en/whatis.1 $RPM_BUILD_ROOT%{_mandir}/man1
 install -m 644 man/en/man.conf.man $RPM_BUILD_ROOT%{_mandir}/man5/man.config.5
 install -m 644 man/en/makewhatis.8 $RPM_BUILD_ROOT%{_mandir}/man8
-install -m 644 src/man.conf $RPM_BUILD_ROOT/etc/man.config
+install -m 644 src/man.conf $RPM_BUILD_ROOT%{_sysconfdir}/man.config

-install -m755 $RPM_SOURCE_DIR/makewhatis.cronweekly 
$RPM_BUILD_ROOT/etc/cron.weekly/makewhatis.cron
-install -m755 $RPM_SOURCE_DIR/makewhatis.crondaily 
$RPM_BUILD_ROOT/etc/cron.daily/makewhatis.cron
+install -m755 $RPM_SOURCE_DIR/makewhatis.cronweekly 
+$RPM_BUILD_ROOT%{_sysconfdir}/cron.weekly/makewhatis.cron
+install -m755 $RPM_SOURCE_DIR/makewhatis.crondaily 
+$RPM_BUILD_ROOT%{_sysconfdir}/cron.daily/makewhatis.cron

 %if %{legacypaths}
 perl -pi -e "s,/usr/share/man,/usr/man,g" src/man.conf
-install -m 644 src/man.conf $RPM_BUILD_ROOT/etc/man.config
+install -m 644 src/man.conf $RPM_BUILD_ROOT%{_sysconfdir}/man.config
 %endif

 mkdir -p $RPM_BUILD_ROOT/%{cache}
@@ -137,17 +141,17 @@
        mkdir -p $RPM_BUILD_ROOT/%{cache}/X11R6/cat$i
 done

-strip $RPM_BUILD_ROOT/usr/bin/man
+strip $RPM_BUILD_ROOT%{_bindir}/man

 # added man2html stuff
 cd man2html
 make install DESTDIR=$RPM_BUILD_ROOT
-strip -R .comment $RPM_BUILD_ROOT/usr/bin/man2html
+strip -R .comment $RPM_BUILD_ROOT%{_bindir}/man2html
 gzip -9f $RPM_BUILD_ROOT%{_mandir}/*/*

 # symlinks for manpath
 ( cd $RPM_BUILD_ROOT
-  ln -s man ./usr/bin/manpath
+  ln -s man .%{_bindir}/manpath
   ln -s man.1.gz .%{_mandir}/man1/manpath.1.gz
 )

@@ -172,25 +176,26 @@

 %files
 %defattr(-,root,root)
-%config /etc/cron.weekly/makewhatis.cron
-%config /etc/cron.daily/makewhatis.cron
+%config %{_sysconfdir}/cron.weekly/makewhatis.cron
+%config %{_sysconfdir}/cron.daily/makewhatis.cron
 %if %{usecache}
-%attr(2755,root,man)   /usr/bin/man
+%attr(2755,root,man)   %{_bindir}/man
 %else
-%attr(0755,root,root)   /usr/bin/man
+%attr(0755,root,root)   %{_bindir}/man
 %endif
-/usr/bin/manpath
-/usr/bin/apropos
-/usr/bin/whatis
-/usr/sbin/makewhatis
-%config /etc/man.config
+%{_bindir}/manpath
+%{_bindir}/apropos
+%{_bindir}/whatis
+%{_sbindir}/makewhatis
+%config %{_sysconfdir}/man.config
+%attr(0755,root,root) %dir %{_sysconfdir}/man.config.d
 %{_mandir}/man5/man.config.5*
 %{_mandir}/man1/whatis.1*
 %{_mandir}/man1/man.1*
 %{_mandir}/man1/manpath.1*
 %{_mandir}/man1/apropos.1*
 %{_mandir}/man1/man2html.1*
-/usr/bin/man2html
+%{_bindir}/man2html
 %lang(cs) %dir /usr/share/locale/cs
 %lang(cs) /usr/share/locale/cs/man
 %lang(da) %dir /usr/share/locale/da
@@ -227,6 +232,19 @@
 %attr(0775,root,man)   %dir %{cache}/X11R6/cat[123456789n]

 %changelog
+* Sat Apr 27 2002 Riku Meskanen <[EMAIL PROTECTED]>
+- Wrote config-directory (usually %{_sysconfdir}/man.config.d) support
+  which will help greatly packagers task of getting right MANPATH, just
+  add your %{_sysconfdir}/man.config.d/foo.conf and it will be included
+  if the file and directory permissionas are worth trusting.
+- for spec cleanup starters did query-replace /etc -> %{_sysconfdir},
+  /usr/bin -> %{_bindir} and /usr/sbin -> %{_sbindir}, did not touch
+  locale stuff as I'm not quite sure if it had some side effects...
+
+* Fri Apr 26 2002 Riku Meskanen <[EMAIL PROTECTED]>
+- Added glob() to man.config MANPATH for supporting easier /opt
+  deployment, feature simplifies setting MANPATH /opt/*/man
+
 * Mon Mar 25 2002 Bernhard Rosenkraenzer <[EMAIL PROTECTED]> 1.5j-6
 - Fix bugs #60676 and #61105
 - Add /usr/local/man and /usr/X11R6/man to makewhatis default paths
-- 
    [ This .signature intentionally left blank ]



_______________________________________________
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-devel-list

Reply via email to