Dirty patch for slocate v1.5

From: matt (mattat_private)
Date: Sun May 23 1999 - 06:30:36 PDT

  • Next message: acpizer: "Re: Solaris libc exploit"

    Well, I'm sure some people will want to use Secure Locate  on FreeBSD. I
    know I certaintly did, so I made a quick and dirty patch for it which will
    make it run nicely on FreeBSD. Tested on FreeBSD 3.1-RELEASE, patch sent
    to author to be fixed up (I hope =) and included in the 1.6 release of
    slocate. I cannot say it too many times that this is a DIRTY HACK. It's
    been running perfectly fine on my FreeBSD machine ever since I did it
    though, so at least I know it works.. Patch follows. This will make a
    link in /usr/libexec/ to updatedb which basically just calls slocate with
    the -u option.. I personally run it from crontab as /usr/libexec/updatedb.
    
    Oh yeah, don't forget to get rid of your old "normal" locate databases,
    and if you wish, chmod 000 the normal locate binaries in /usr/libexec
    like I did, or you could make links to updatedb from them, depending
    if you call them alot from scripts.. Anyhow, be creative!
    
    --- START DIFF ---
    
    diff -urb slocate-1.5-original/install slocate-1.5/install
    --- slocate-1.5-original/install        Wed May  5 21:51:29 1999
    +++ slocate-1.5/install Thu May 13 02:15:03 1999
    @@ -1,52 +1,79 @@
     #!/bin/sh
    
    -groupadd >/dev/null 2>&1
    +SYSTEM=`uname -s`
    +echo "Finding your system type....."
    
    -if [ $? -eq 127 ] ; then
    +case ${SYSTEM} in
    +
    +    "Linux")
    +
    +        GPATH="/usr/sbin/groupadd"
    +        GOPTS="slocate"
    +
    +        DBPATH="/var/lib/slocate"
    +       UPREFIX="/usr/bin"
    +
    +       echo "We have a winner! SYSTEM=Linux"
    +    ;;
    +    "FreeBSD")
    +
    +        GPATH="/usr/sbin/pw"
    +        GOPTS="groupadd slocate"
    +
    +        DBPATH="/var/db/slocate"
    +       UPREFIX="/usr/libexec"
    +
    +       echo "We have a winner! SYSTEM=FreeBSD"
    +    ;;
    +    *)
        echo
    -   echo "Could not find groupadd utility."
    +   echo "Could not find system type for groupadd."
        echo
        echo "Read the README.DOC file to install Secure Locate manually."
        echo
        exit 1
    -fi
    +esac
    
     user=`id -un`
    -
     instdir="/usr/bin"
     echo
     echo "Copying slocate to $instdir"
     install -m 0755 slocate /usr/bin
    -groupadd slocate
    +$GPATH $GOPTS
    
     CWD="`pwd`"
    
     cd $instdir
     echo
     echo "Changing permisions on slocate"
    +
     chown $user:slocate slocate
     chmod g+s ./slocate
    +
     cd $CWD
    +
     echo "Making Database Directory"
    -install -d -m 0750 /var/lib/slocate
    -chown $user:slocate /var/lib/slocate
    -echo "Creating Symlinks"
    +install -d -m 0750 $DBPATH
    +chown $user:slocate $DBPATH
    
    +echo "Creating Symlinks"
     if [ -f /usr/bin/locate ] ; then
        rm -f /usr/bin/locate.old
        mv /usr/bin/locate /usr/bin/locate.old
    +   chmod 700 /usr/bin/locate.old
     fi
    
     ln -s /usr/bin/slocate /usr/bin/locate
    
    -if [ -f /usr/bin/updatedb ] ; then
    -   rm -f /usr/bin/updatedb.old
    -   mv /usr/bin/locate /usr/bin/locate.old
    +if [ -f $UPREFIX/updatedb ] ; then
    +   rm -f $UPREFIX/updatedb.old
    +   mv $UPREFIX/updatedb $UPREFIX/updatedb.old
     fi
    
    -ln -s /usr/bin/slocate /usr/bin/updatedb
    +ln -s /usr/bin/slocate $UPREFIX/updatedb
    
     echo "Installing man page"
    +
     if [ -d /usr/man ] ; then
       mandir="/usr/man"
     elif [ -d /usr/share/man ] ; then
    diff -urb slocate-1.5-original/link.c slocate-1.5/link.c
    --- slocate-1.5-original/link.c Wed May  5 14:21:05 1999
    +++ slocate-1.5/link.c  Thu May 13 02:12:50 1999
    @@ -6,7 +6,9 @@
    
     #include <stdio.h>
     #include <stdlib.h>
    -
    +#ifdef __FreeBSD__
    +  #include <unistd.h> /* make it work on FreeBSD -matt */
    +#endif
     #include "link.h"
    
     /* Initialize 2D List */
    diff -urb slocate-1.5-original/main.c slocate-1.5/main.c
    --- slocate-1.5-original/main.c Wed May  5 14:52:52 1999
    +++ slocate-1.5/main.c  Thu May 13 02:12:50 1999
    @@ -85,9 +85,18 @@
     #define WARN_MESSAGE "8 days"
    
     char **SLOCATE_PATH = NULL;
    +
    +/* More fitting paths for FreeBSD -matt */
    +#ifdef __FreeBSD__
    +char *SLOCATEDB = "/var/db/slocate/slocate.db";
    +char *TMPSLOCATEDB = "/var/db/slocate/slocate.tmp";
    +char *SLOCATEDB_DIR = "/var/db/slocate/";
    +#else
    +/* Leave the normal paths for non-FreeBSD machines -matt */
     char *SLOCATEDB = "/var/lib/slocate/slocate.db";
     char *TMPSLOCATEDB = "/var/lib/slocate/slocate.tmp";
     char *SLOCATEDB_DIR = "/var/lib/slocate/";
    +#endif
     char *EXCLUDE_DIR;
     int EXCLUDE=0;
     int VERBOSE=0;
    
    --- END DIFF ---
    
    --
    Mail: mattat_private && mattat_private
    @IRC: irc.idirect.ca && mlink.ca.relic.net
    



    This archive was generated by hypermail 2b30 : Fri Apr 13 2001 - 14:46:35 PDT