Changeset 40 for trunk


Ignore:
Timestamp:
May 31, 2006, 9:38:30 PM (18 years ago)
Author:
rainer
Message:

Fix for tickets #13, #14, #15, #16, #17

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.in

    r34 r40  
    484484            echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`"; \
    485485            $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`; \
     486            chmod 0700 $(DESTDIR)$(sbindir)/`echo $$p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`; \
    486487            echo " ./sstrip $(DESTDIR)$(sbindir)/`echo $$p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`"; \
    487488            ./sstrip $(DESTDIR)$(sbindir)/`echo $$p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`; \
     
    623624          exit 1; \
    624625        fi; \
    625         make DESTDIR=$$STAGE install-light; \
     626        $(MAKE) DESTDIR=$$STAGE install-light; \
    626627        rm -f $$STAGE/@sbindir@/@install_name@_stealth; \
    627628        echo "#! /bin/sh"                        > $$STAGE/setup.sh; \
     
    926927          exit 1; \
    927928        fi; \
    928         make DESTDIR=$$STAGE install-light;
     929        $(MAKE) DESTDIR=$$STAGE install-light;
    929930        $(MAKE) solaris-pkg-finish
    930931
     
    936937          exit 1; \
    937938        fi; \
    938         make DESTDIR=$$STAGE install;
     939        $(MAKE) DESTDIR=$$STAGE install;
    939940        $(MAKE) solaris-pkg-finish
    940941
     
    946947        user=`id | sed s,uid=[0123456789]*\(,, | sed s,\).*,,`; \
    947948        group=`id | sed s,.*gid=[0123456789]*\(,, | sed s,\).*,,`; \
    948         cat prototype | grep -v 'none / ' | grep -v 'none /usr ' | \
    949         grep -v 'none /usr/local ' | grep -v 'none /usr/bin ' | \
    950         grep -v 'none /usr/local/bin ' | grep -v 'none /usr/local/sbin ' | \
    951         grep -v 'none /var ' | grep -v 'none /usr/sbin ' | \
     949        cat prototype | grep -v 'none / ' | \
     950        sed 's,none /etc .*,none /etc ? ? ?,' | \
     951        sed 's,none /etc/init.d .*,none /etc/init.d ? ? ?,' | \
     952        sed 's,none /usr .*,none /usr ? ? ?,' | \
     953        sed 's,none /usr/bin .*,none /usr/bin ? ? ?,' | \
     954        sed 's,none /var .*,none /var ? ? ?,' | \
     955        sed 's,none /var/lib .*,none /var/lib ? ? ?,' | \
     956        sed 's,none /var/log .*,none /var/log ? ? ?,' | \
     957        sed 's,none /var/run .*,none /var/run ? ? ?,' | \
     958        sed 's,none /usr/sbin .*,none /usr/sbin ? ? ?,' | \
    952959        sed s,$$user\ $$group,root\ sys,g > prototype.1; \
    953960        rm -f prototype && mv prototype.1 prototype; \
    954         echo "d none /var ? ? ?" >> prototype; \
     961        if test -d /usr/local; then \
     962                cat prototype | \
     963                sed 's,none /usr/local .*,none /usr/local ? ? ?,' >prototype.1;\
     964                rm -f prototype && mv prototype.1 prototype; \
     965        fi; \
     966        if test -d /usr/local/bin; then \
     967                cat prototype | \
     968                sed 's,none /usr/local/bin .*,none /usr/local/bin ? ? ?,' >prototype.1;\
     969                rm -f prototype && mv prototype.1 prototype; \
     970        fi; \
     971        if test -d /usr/local/sbin; then \
     972                cat prototype | \
     973                sed 's,none /usr/local/sbin .*,none /usr/local/sbin ? ? ?,' >prototype.1;\
     974                rm -f prototype && mv prototype.1 prototype; \
     975        fi; \
     976        if test -d /usr/local/man; then \
     977                cat prototype | \
     978                sed 's,none /usr/local/man .*,none /usr/local/man ? ? ?,' >prototype.1;\
     979                rm -f prototype && mv prototype.1 prototype; \
     980        fi; \
     981        if test -d /usr/local/man/man5; then \
     982                cat prototype | \
     983                sed 's,none /usr/local/man/man5 .*,none /usr/local/man/man5 ? ? ?,' >prototype.1;\
     984                rm -f prototype && mv prototype.1 prototype; \
     985        fi; \
     986        if test -d /usr/local/man/man8; then \
     987                cat prototype | \
     988                sed 's,none /usr/local/man/man8 .*,none /usr/local/man/man8 ? ? ?,' >prototype.1;\
     989                rm -f prototype && mv prototype.1 prototype; \
     990        fi; \
    955991        echo "d none /etc/rc0.d ? ? ?" >> prototype; \
    956992        echo "d none /etc/rc1.d ? ? ?" >> prototype; \
     
    9751011          echo; \
    9761012          cp /tmp/samhain-pkg-staging/@install_name@.pkg $(PACKAGE)-$(VERSION).pkg; \
    977           echo "Package @install_name@.pkg is ready for installation"; \
     1013          echo "Package $(PACKAGE)-$(VERSION).pkg is ready for installation"; \
    9781014          echo; \
    979           rm -r /var/spool/pkg/@install_name@ /tmp/samhain-pkg-staging; \
     1015          rm -rf /var/spool/pkg/@install_name@ /tmp/samhain-pkg-staging; \
    9801016        else \
    9811017          echo; \
     
    9931029          exit 1; \
    9941030        fi; \
    995         make DESTDIR=$$STAGE install; \
    996         make DESTDIR=$$STAGE install-boot; \
     1031        $(MAKE) DESTDIR=$$STAGE install; \
     1032        $(MAKE) DESTDIR=$$STAGE install-boot; \
    9971033        cp hp_ux.psf $$STAGE; \
    9981034        mkdir $$STAGE/sc; \
     
    11411177        cp config.h m_comp/; \
    11421178        cp $(srcsrc)/samhain_hide.c m_comp/; \
    1143         cd m_comp && make modules
     1179        cd m_comp && $(MAKE) modules
    11441180        @if test -f m_comp/samhain_hide.ko; then \
    11451181          cp -p m_comp/samhain_hide.ko samhain_hide.ko; \
  • trunk/aclocal.m4

    r18 r40  
    11791179    ssp_old_cflags="$CFLAGS"
    11801180    CFLAGS="$CFLAGS -fstack-protector"
    1181     AC_TRY_COMPILE(,,, ssp_cc=no)
     1181    AC_TRY_LINK(,,, ssp_cc=no)
    11821182    # echo $ssp_cc
    11831183    if test "X$ssp_cc" = "Xno"; then
  • trunk/configure.ac

    r39 r40  
    3737dnl start
    3838dnl
    39 AM_INIT_AUTOMAKE(samhain, 2.2.0)
     39AM_INIT_AUTOMAKE(samhain, 2.2.1)
    4040AC_CANONICAL_HOST
    4141
  • trunk/docs/Changelog

    r38 r40  
     12.2.1:
     2        * fix Solaris package creation
     3        * recognize Solaris doors and event ports
     4        * fix the idmef_inode_t patch: provide required info to avoid stat()
     5        * fix bug on database update: fill in dev and rdev fields
     6        * fix get_file_infos() in sh_prelude.c: avoid premature return 
     7        * GCC_STACK_PROTECT_CC: AC_TRY_COMPILE -> AC_TRY_LINK
    18        * deploy.sh: allow to set a group for hosts upon installation
    29        * patch by Yoann: fix an issue when setting the idmef_inode_t object
  • trunk/dsys/comINSTALL

    r27 r40  
    255255            printINFO "ssh -x -l root ${host} /bin/sh -c '(cd ${tmpdir} && eval ${is_command} ${tmpdir}/samhain-${src_version}.${realformat} ${tmp_iname})'"
    256256        fi
     257    elif test "x$format" = "xsolaris-pkg"
     258    then
     259        if test x"$simulate" = x0
     260        then
     261            ssh -x -l "root" "${host}" /bin/sh -c \''(cd "'${tmpdir}'" && PATH="'/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH'" && export PATH && eval "'${is_command}'" "'samhain-${src_version}.${realformat} all'") >/dev/null '\'
     262        else
     263            printINFO "ssh -x -l root ${host} /bin/sh -c '(cd ${tmpdir} && eval ${is_command} samhain-${src_version}.${realformat}) all'"
     264        fi
    257265    elif test "x$format" = "xtbz2"
    258266    then
  • trunk/include/samhain.h

    r34 r40  
    4545/* Sizes for arrays (user, group, timestamp).
    4646 */
     47#define SOCKPASS_MAX 14
    4748#define USER_MAX  20
    4849#define GROUP_MAX 20
    4950#define TIM_MAX   32
     51
    5052
    5153/* The number of bytes in a key, 
     
    262264
    263265typedef struct {
    264   char   sh_sockpass[32];
     266  char   sh_sockpass[2*SOCKPASS_MAX+2];
    265267  char   sigkey_old[KEY_LEN+1];
    266268  char   sigkey_new[KEY_LEN+1];
  • trunk/include/sh_unix.h

    r27 r40  
    4949  SH_FILE_FIFO,
    5050  SH_FILE_SOCKET,
     51  SH_FILE_DOOR,
     52  SH_FILE_PORT,
    5153  SH_FILE_UNKNOWN
    5254} ShFileType;
     
    7779/* hardlinks    */
    7880#define MODI_HLN (1 << 10)
    79 /* device num   */
     81/* device type   */
    8082#define MODI_RDEV (1 << 11)
    8183/* size may grow   */
  • trunk/src/sh_database.c

    r35 r40  
    14921492}
    14931493
    1494 static int is_escaped(char * p) {
     1494static int is_escaped(unsigned char * p) {
    14951495
    14961496  int    escp = 0;
     
    15041504        }
    15051505      else if ((*p == '\'' || *p == '\"') && escp == 0)
     1506        {
     1507          retv = S_FALSE;
     1508        }
     1509      else if (*p > 0x7F)
    15061510        {
    15071511          retv = S_FALSE;
     
    15811585      p[2] == 'o' && p[3] == 'g')
    15821586    {
     1587      /*
     1588       * recursive call
     1589       */
    15831590      new       = SH_ALLOC(sizeof(dbins));
    15841591      init_db_entry(new);
  • trunk/src/sh_files.c

    r34 r40  
    102102  long    NumCDev;
    103103  long    NumBDev;
     104  long    NumDoor;
     105  long    NumPort;
    104106  long    NumAll;
    105107  long    TotalBytes;
     
    16071609  theDir.NumCDev     = 0;
    16081610  theDir.NumBDev     = 0;
     1611  theDir.NumDoor     = 0;
     1612  theDir.NumPort     = 0;
    16091613  theDir.NumAll      = 0;
    16101614  theDir.TotalBytes  = 0;
     
    18311835    else if (checkit == SH_FILE_CDEV)      ++theDir.NumCDev;
    18321836    else if (checkit == SH_FILE_BDEV)      ++theDir.NumBDev;
     1837    else if (checkit == SH_FILE_DOOR)      ++theDir.NumDoor;
     1838    else if (checkit == SH_FILE_PORT)      ++theDir.NumPort;
    18331839   
    18341840    SH_FREE(tmpcat);
     
    20792085    case 'b': SL_RETURN(SH_FILE_BDEV, _("sh_files_filecheck"));     
    20802086    case '|': SL_RETURN(SH_FILE_FIFO, _("sh_files_filecheck"));     
     2087    case 'D': SL_RETURN(SH_FILE_DOOR, _("sh_files_filecheck"));   
     2088    case 'P': SL_RETURN(SH_FILE_PORT, _("sh_files_filecheck"));   
    20812089    case 's': SL_RETURN(SH_FILE_SOCKET, _("sh_files_filecheck"));   
    20822090    default:  SL_RETURN(SH_FILE_UNKNOWN, _("sh_files_filecheck"));   
  • trunk/src/sh_hash.c

    r34 r40  
    19981998  p.linkmode    = (UINT32) buf->linkmode;
    19991999  p.hardlinks   = (UINT32) buf->hardlinks;
     2000  p.dev   = (UINT64) buf->dev;
     2001  p.rdev  = (UINT64) buf->rdev;
    20002002  p.mode  = (UINT32) buf->mode;
    20012003  p.ino   = (UINT32) buf->ino;
     
    20592061#endif
    20602062
    2061 #ifndef PRIi64
    2062 #define PRIi64 "lld"
     2063#ifndef PRIu64
     2064#ifdef  HAVE_LONG_32
     2065#define PRIu64 "llu"
     2066#else
     2067#define PRIu64 "lu"
     2068#endif
    20632069#endif
    20642070
     
    20722078#ifdef SH_USE_XML
    20732079  sl_snprintf(form_rval, 80, _("%s%s%s%s%s"),
    2074               _("size_old=\"%"), PRIi64, _("\" size_new=\"%"), PRIi64, "\" ");
     2080              _("size_old=\"%"), PRIu64, _("\" size_new=\"%"), PRIu64, "\" ");
    20752081#else
    20762082  sl_snprintf(form_rval, 80, _("%s%s%s%s%s"),
    2077               _("size_old=<%"), PRIi64, _(">, size_new=<%"), PRIi64, ">, ");
     2083              _("size_old=<%"), PRIu64, _(">, size_new=<%"), PRIu64, ">, ");
    20782084#endif
    20792085
     
    21242130
    21252131  if (is_new)
    2126     format = _("hardlinks_new=\"%ld\" ");
    2127   else
    2128     format = _("hardlinks_old=\"%ld\" ");
     2132    format = _("hardlinks_new=\"%lu\" ");
     2133  else
     2134    format = _("hardlinks_old=\"%lu\" ");
    21292135  sl_snprintf(tmp, SH_BUFSIZE, format,
    21302136              (unsigned long) theFile->hardlinks);
     
    21332139
    21342140  if (is_new)
    2135     format = _("idevice_new=\"%ld\" ");
    2136   else
    2137     format = _("idevice_old=\"%ld\" ");
     2141    format = _("idevice_new=\"%lu\" ");
     2142  else
     2143    format = _("idevice_old=\"%lu\" ");
    21382144  sl_snprintf(tmp, SH_BUFSIZE, format, (unsigned long) theFile->rdev);
    21392145  sl_strlcat(msg, tmp, SH_BUFSIZE);
     
    21412147
    21422148  if (is_new)
    2143     format = _("inode_new=\"%ld\" ");
    2144   else
    2145     format = _("inode_old=\"%ld\" ");
     2149    format = _("inode_new=\"%lu\" ");
     2150  else
     2151    format = _("inode_old=\"%lu\" ");
    21462152  sl_snprintf(tmp, SH_BUFSIZE, format, (unsigned long) theFile->ino);
    21472153  sl_strlcat(msg, tmp, SH_BUFSIZE);
     2154
     2155  /*
     2156   * also report device for prelude
     2157   */
     2158#if defined(HAVE_LIBPRELUDE) && defined(HAVE_LIBPRELUDE_9)
     2159  if (is_new)
     2160    format = _("dev_new=\"%lu,%lu\" ");
     2161  else
     2162    format = _("dev_old=\"%lu,%lu\" ");
     2163  sl_snprintf(tmp, SH_BUFSIZE, format,               
     2164              (unsigned long) major(theFile->dev),
     2165              (unsigned long) minor(theFile->dev));
     2166  sl_strlcat(msg, tmp, SH_BUFSIZE);
     2167#endif
    21482168
    21492169
     
    22612281
    22622282  if (is_new)
    2263     format = _("hardlinks_new=<%ld>, ");
    2264   else
    2265     format = _("hardlinks_old=<%ld>, ");
     2283    format = _("hardlinks_new=<%lu>, ");
     2284  else
     2285    format = _("hardlinks_old=<%lu>, ");
    22662286  sl_snprintf(tmp, SH_BUFSIZE, format,
    22672287              (unsigned long) theFile->hardlinks);
     
    22702290
    22712291  if (is_new)
    2272     format = _("idevice_new=<%ld>, ");
    2273   else
    2274     format = _("idevice_old=<%ld>, ");
     2292    format = _("idevice_new=<%lu>, ");
     2293  else
     2294    format = _("idevice_old=<%lu>, ");
    22752295  sl_snprintf(tmp, SH_BUFSIZE, format, (unsigned long) theFile->rdev);
    22762296  sl_strlcat(msg, tmp, SH_BUFSIZE);
     
    22782298
    22792299  if (is_new)
    2280     format = _("inode_new=<%ld>, ");
    2281   else
    2282     format = _("inode_old=<%ld>, ");
     2300    format = _("inode_new=<%lu>, ");
     2301  else
     2302    format = _("inode_old=<%lu>, ");
    22832303  sl_snprintf(tmp, SH_BUFSIZE, format, (unsigned long) theFile->ino);
    22842304  sl_strlcat(msg, tmp, SH_BUFSIZE);
    22852305
     2306
     2307  /*
     2308   * also report device for prelude
     2309   */
     2310#if defined(HAVE_LIBPRELUDE) && defined(HAVE_LIBPRELUDE_9)
     2311  if (is_new)
     2312    format = _("dev_new=<%lu,%lu>, ");
     2313  else
     2314    format = _("dev_old=<%lu,%lu>, ");
     2315  sl_snprintf(tmp, SH_BUFSIZE, format,               
     2316              (unsigned long) major(theFile->dev),
     2317              (unsigned long) minor(theFile->dev));
     2318  sl_strlcat(msg, tmp, SH_BUFSIZE);
     2319#endif
    22862320
    22872321  if (is_new)
     
    27292763          sl_snprintf(tmp, SH_BUFSIZE,
    27302764#ifdef SH_USE_XML
    2731                       _("hardlinks_old=\"%ld\" hardlinks_new=\"%ld\" "),
    2732 #else
    2733                       _("hardlinks_old=<%ld>, hardlinks_new=<%ld>, "),
     2765                      _("hardlinks_old=\"%lu\" hardlinks_new=\"%lu\" "),
     2766#else
     2767                      _("hardlinks_old=<%lu>, hardlinks_new=<%lu>, "),
    27342768#endif
    27352769                      (unsigned long) p->theFile.hardlinks,
     
    27462780          sl_snprintf(tmp, SH_BUFSIZE,
    27472781#ifdef SH_USE_XML
    2748                       _("device_old=\"%ld,%ld\" device_new=\"%ld,%ld\" idevice_old=\"%ld\" idevice_new=\"%ld\" "),
    2749 #else
    2750                       _("device_old=<%ld,%ld>, device_new=<%ld,%ld>, "),
     2782                      _("device_old=\"%lu,%lu\" device_new=\"%lu,%lu\" idevice_old=\"%lu\" idevice_new=\"%lu\" "),
     2783#else
     2784                      _("device_old=<%lu,%lu>, device_new=<%lu,%lu>, "),
    27512785#endif
    27522786                      (unsigned long) major(p->theFile.rdev),
     
    27702804          sl_snprintf(tmp, SH_BUFSIZE,
    27712805#ifdef SH_USE_XML
    2772                       _("inode_old=\"%ld\" inode_new=\"%ld\" "),
    2773 #else
    2774                       _("inode_old=<%ld>, inode_new=<%ld>, "),
     2806                      _("inode_old=\"%lu\" inode_new=\"%lu\" "),
     2807#else
     2808                      _("inode_old=<%lu>, inode_new=<%lu>, "),
    27752809#endif
    27762810                      (unsigned long) p->theFile.ino,
     
    27792813#ifdef REPLACE_OLD
    27802814          if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE)
    2781             p->theFile.ino = theFile->ino;
    2782 #endif
    2783         }
     2815            {
     2816              p->theFile.ino = theFile->ino;
     2817              p->theFile.dev = theFile->dev;
     2818            }
     2819#endif
     2820        }
     2821
     2822
     2823      /*
     2824       * also report device for prelude
     2825       */
     2826#if defined(HAVE_LIBPRELUDE) && defined(HAVE_LIBPRELUDE_9)
     2827      if ((modi_mask & MODI_INO) != 0)
     2828        {
     2829          sl_snprintf(tmp, SH_BUFSIZE,
     2830#ifdef SH_USE_XML
     2831                      _("dev_old=\"%lu,%lu\" dev_new=\"%lu,%lu\" "),
     2832#else
     2833                      _("dev_old=<%lu,%lu>, dev_new=<%lu,%lu>, "),
     2834#endif
     2835                      (unsigned long) major(p->theFile.dev),
     2836                      (unsigned long) minor(p->theFile.dev),
     2837                      (unsigned long) major(theFile->dev),
     2838                      (unsigned long) minor(theFile->dev)
     2839                      );
     2840          sl_strlcat(msg, tmp, SH_BUFSIZE);
     2841#ifdef REPLACE_OLD
     2842          if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE)
     2843            p->theFile.dev = theFile->dev;
     2844#endif
     2845        }
     2846#endif
    27842847
    27852848      if (   ((modi_mask & MODI_USR) != 0)
     
    27902853        {
    27912854#ifdef SH_USE_XML
    2792           sl_snprintf(tmp, SH_BUFSIZE, _("owner_old=\"%s\" owner_new=\"%s\" iowner_old=\"%ld\" iowner_new=\"%ld\" "),
    2793 #else
    2794           sl_snprintf(tmp, SH_BUFSIZE, _("owner_old=<%s>, owner_new=<%s>, "),
    2795 #endif
    2796                       p->theFile.c_owner, theFile->c_owner
    2797 #ifdef SH_USE_XML
    2798                       , (long) p->theFile.owner, (long) theFile->owner
    2799 #endif
     2855          sl_snprintf(tmp, SH_BUFSIZE,
     2856                      _("owner_old=\"%s\" owner_new=\"%s\" iowner_old=\"%ld\" iowner_new=\"%ld\" "),
     2857#else
     2858          sl_snprintf(tmp, SH_BUFSIZE,
     2859                      _("owner_old=<%s>, owner_new=<%s>, iowner_old=<%ld>, iowner_new=<%ld>, "),
     2860#endif
     2861                      p->theFile.c_owner, theFile->c_owner,
     2862                      (long) p->theFile.owner, (long) theFile->owner
    28002863                      );
    28012864          sl_strlcat(msg, tmp, SH_BUFSIZE);
     
    28182881        {
    28192882#ifdef SH_USE_XML
    2820           sl_snprintf(tmp, SH_BUFSIZE, _("group_old=\"%s\" group_new=\"%s\" igroup_old=\"%ld\" igroup_new=\"%ld\" "),
     2883          sl_snprintf(tmp, SH_BUFSIZE,
     2884                      _("group_old=\"%s\" group_new=\"%s\" igroup_old=\"%ld\" igroup_new=\"%ld\" "),
    28212885                      p->theFile.c_group, theFile->c_group,
    28222886                      (long) p->theFile.group, (long) theFile->group);
    28232887#else
    2824           sl_snprintf(tmp, SH_BUFSIZE, _("group_old=<%s>, group_new=<%s>, "),
    2825                       p->theFile.c_group, theFile->c_group);
     2888          sl_snprintf(tmp, SH_BUFSIZE,
     2889                      _("group_old=<%s>, group_new=<%s>, igroup_old=<%ld>, igroup_new=<%ld>, "),
     2890                      p->theFile.c_group, theFile->c_group,
     2891                      (long) p->theFile.group, (long) theFile->group);
    28262892#endif
    28272893
     
    31533219  if (ListWithDelimiter == S_TRUE)
    31543220    {
    3155       printf(_("%7ld, %10s, %5d, %12s, %5d, %3d, %-8s, %5d, %-8s, %5d, "),
    3156              (unsigned long) p->theFile.ino,
     3221      printf(_("%7ld, %7ld, %10s, %5d, %12s, %5d, %3d, %-8s, %5d, %-8s, %5d, "),
     3222             (unsigned long) p->theFile.ino, (unsigned long) p->theFile.dev,
    31573223             p->theFile.c_mode, (int) p->theFile.mode,
    31583224             p->theFile.c_attributes, (int) p->theFile.attributes,
     
    31633229  else
    31643230    {
    3165       printf(_("%7ld %10s %5d %12s %5d %3d %-8s %5d %-8s %5d "),
    3166              (unsigned long) p->theFile.ino,
     3231      printf(_("%7ld %7ld %10s %5d %12s %5d %3d %-8s %5d %-8s %5d "),
     3232             (unsigned long) p->theFile.ino, (unsigned long) p->theFile.dev,
    31673233             p->theFile.c_mode, (int) p->theFile.mode,
    31683234             p->theFile.c_attributes, (int) p->theFile.attributes,
     
    31733239
    31743240  if ('c' == p->theFile.c_mode[0] || 'b' == p->theFile.c_mode[0])
    3175     sl_snprintf(str, 80, "%"PRIi64, p->theFile.rdev);
    3176   else
    3177     sl_snprintf(str, 80, "%"PRIi64, p->theFile.size);
     3241    sl_snprintf(str, 80, "%"PRIu64, p->theFile.rdev);
     3242  else
     3243    sl_snprintf(str, 80, "%"PRIu64, p->theFile.size);
    31783244
    31793245  printf( _(" %8s"), str);
  • trunk/src/sh_prelude.c

    r37 r40  
    3939#include <string.h>
    4040#include <sys/types.h>
    41 #include <sys/stat.h>
    4241
    4342#if TIME_WITH_SYS_TIME
     
    5655#endif
    5756
    58 #ifdef MAJOR_IN_MKDEV
    59 # include <sys/mkdev.h>
    60 #else
    61 # ifdef MAJOR_IN_SYSMACROS
    62 #  include <sys/sysmacros.h>
    63 # endif
    64 #endif
    65 
    6657#include <unistd.h>
    6758#include <syslog.h>
    6859#include <pwd.h>
    69 #include <grp.h>
    7060
    7161int     sh_argc_store;
     
    412402                if ( ptr ) {
    413403                        ret = idmef_file_new_name(file, &str);
    414                         if ( ret < 0 )
    415                                 return;
    416                        
    417                         prelude_string_set_dup(str, ptr + 1);
     404                        if ( ret == 0 ) {
     405                                prelude_string_set_dup(str, ptr + 1);
     406                        }
    418407                }
    419408        }
     
    428417        if ( ptr ) {
    429418                ret = idmef_time_from_samhain(&time, ptr);
    430                 if ( ret < 0 ) {
    431                         free(ptr);
    432                         return;
    433                 }
    434                
    435                 idmef_file_set_modify_time(file, time);
     419                if ( ret == 0 ) {
     420                        idmef_file_set_modify_time(file, time);
     421                }
    436422                free(ptr);
    437423        }
     
    440426        if ( ptr ) {
    441427                ret = idmef_time_from_samhain(&time, ptr);
    442                 if ( ret < 0 ) {
    443                         free(ptr);
    444                         return;
    445                 }
    446 
    447                 idmef_file_set_create_time(file, time);
     428                if ( ret == 0 ) {
     429                        idmef_file_set_create_time(file, time);
     430                }
    448431                free(ptr);
    449432        }
     
    451434        ptr = get_value(msg, _("inode"), suffix);
    452435        if ( ptr ) {
    453                 struct stat st;
    454 
    455                 ret = lstat(prelude_string_get_string(idmef_file_get_path(file)), &st);
    456                 if ( ret < 0 ) {
    457                         free(ptr);
    458                         return;
    459                 }
    460 
    461436                ret = idmef_file_new_inode(file, &inode);
    462                 if ( ret < 0 ) {
    463                         free(ptr);
    464                         return;
    465                 }
    466                
    467                 idmef_inode_set_major_device(inode, major(st.st_dev));
    468                 idmef_inode_set_minor_device(inode, minor(st.st_dev));
    469                 idmef_inode_set_number(inode, strtoul(ptr, NULL, 10));
     437                if ( ret == 0 ) {
     438                        char * dev = get_value(msg, _("dev"), suffix);
     439                        if (dev) {
     440                                char * q = strchr(dev, ',');
     441                                if (*q) {
     442                                         *q = '\0'; ++q;
     443                                         idmef_inode_set_major_device(inode, strtoul(dev, NULL, 0));
     444                                         idmef_inode_set_minor_device(inode, strtoul(  q, NULL, 0));
     445                                }
     446                                free(dev);
     447                        }
     448                        idmef_inode_set_number(inode, strtoul(ptr, NULL, 10));
     449                }
    470450                free(ptr);
    471451        }
     
    475455                ret = idmef_file_new_checksum(file, &checksum, IDMEF_LIST_APPEND);
    476456                if ( ret < 0 ) {
    477                         free(ptr);
    478                         return;
     457                        free(ptr);
     458                        goto get_mode;
    479459                }
    480460
     
    482462
    483463                if (hashtype == 0)
    484                         idmef_checksum_set_algorithm(checksum, IDMEF_CHECKSUM_ALGORITHM_TIGER);
    485 
    486                 else if (hashtype == 1)
    487                         idmef_checksum_set_algorithm(checksum, IDMEF_CHECKSUM_ALGORITHM_SHA1);
    488 
    489                 else if (hashtype == 2)
    490                         idmef_checksum_set_algorithm(checksum, IDMEF_CHECKSUM_ALGORITHM_MD5);
    491 
    492                 else
    493                         idmef_checksum_set_algorithm(checksum, IDMEF_CHECKSUM_ALGORITHM_TIGER);
    494 
    495 
    496                 ret = idmef_checksum_new_value(checksum, &str);
    497                 if ( ret < 0 ) {
    498                         free(ptr);
    499                         return;
     464                        idmef_checksum_set_algorithm(checksum, IDMEF_CHECKSUM_ALGORITHM_TIGER);
     465
     466                else if (hashtype == 1)
     467                        idmef_checksum_set_algorithm(checksum, IDMEF_CHECKSUM_ALGORITHM_SHA1);
     468               
     469                else if (hashtype == 2)
     470                        idmef_checksum_set_algorithm(checksum, IDMEF_CHECKSUM_ALGORITHM_MD5);
     471               
     472                else
     473                        idmef_checksum_set_algorithm(checksum, IDMEF_CHECKSUM_ALGORITHM_TIGER);
     474
     475
     476                ret = idmef_checksum_new_value(checksum, &str);
     477                if ( ret < 0 ) {
     478                        free(ptr);
     479                        goto get_mode;
    500480                }
    501481
    502482                /* will be freed on destroy()
    503483                 */
    504                 prelude_string_set_nodup(str, ptr);
    505         }
     484                prelude_string_set_nodup(str, ptr);
     485        }
     486
     487 get_mode:
    506488
    507489        mode = get_value(msg, _("mode"), suffix);
     
    510492                ret = idmef_file_new_file_access(file, &access, IDMEF_LIST_APPEND);
    511493                if ( ret < 0 )
    512                         goto mode_free;
     494                        goto get_owner;
    513495
    514496                /* flawfinder: ignore *//* is part of name, not access() */
    515497                ret = idmef_file_access_new_user_id(access, &userid);
    516498                if ( ret < 0 )
    517                         goto mode_free;
     499                        goto get_owner;
    518500                idmef_user_id_set_type(userid, IDMEF_USER_ID_TYPE_OTHER_PRIVS);
    519501
     
    521503                get_access_info ( access, mode, 7, 9 );
    522504        }
     505
     506 get_owner:
    523507 
    524508        ptr = get_value(msg, _("owner"), suffix);
    525509        if ( ptr ) {
    526                 struct passwd *pw;
     510                char * uid;
    527511               
    528512                /* flawfinder: ignore *//* is part of name, not access() */
     
    530514                if ( ret < 0 ) {
    531515                        free(ptr);
    532                         goto mode_free;
     516                        goto get_group;
    533517                }
    534518
     
    537521                if ( ret < 0 ) {
    538522                        free(ptr);
    539                         goto mode_free;
     523                        goto get_group;
    540524                }
    541525                idmef_user_id_set_type(userid, IDMEF_USER_ID_TYPE_USER_PRIVS);
     
    544528                if ( ret < 0 ) {
    545529                        free(ptr);
    546                         goto mode_free;
     530                        goto get_group;
    547531                }
    548532                prelude_string_set_nodup(str, ptr);
    549533               
    550                 pw = getpwnam(ptr);
    551                 if ( ! pw )
    552                         goto mode_free;
    553                
    554                 idmef_user_id_set_number(userid, pw->pw_uid);
     534                uid = get_value(msg, _("iowner"), suffix);
     535                if ( ! uid )
     536                        goto get_group;
     537               
     538                idmef_user_id_set_number(userid, strtoul(uid, NULL, 0));
    555539
    556540                if ( mode ) {
     
    558542                        get_access_info ( access, mode, 1, 3 );
    559543                }
    560         }
     544
     545                free(uid);
     546        }
     547
     548 get_group:
    561549
    562550        ptr = get_value(msg, _("group"), suffix);
    563551        if ( ptr ) {
    564                 struct group *gr;
     552                char *gid;
    565553               
    566554                /* flawfinder: ignore *//* is part of name, not access() */
     
    587575                prelude_string_set_nodup(str, ptr);
    588576
    589                 gr = getgrnam(ptr);
    590                 if ( ! gr )
     577                gid = get_value(msg, _("igroup"), suffix);
     578                if ( ! gid )
    591579                        goto mode_free;
    592580
    593                 idmef_user_id_set_number(userid, gr->gr_gid);
     581                idmef_user_id_set_number(userid, strtoul(gid, NULL, 0));
    594582
    595583                if ( mode ) {
    596584                        get_access_info ( access, mode, 4, 6 ); /* flawfinder: ignore */
    597585                }
     586
     587                free(gid);
    598588        }
    599589
  • trunk/src/sh_socket.c

    r34 r40  
    111111int    pf_unix_fd  = -1;
    112112static char * sh_sockname = NULL;
    113 /* static char   sh_sockpass[29]; */
    114 static char   sh_sockpass_real[15];
     113static char   sh_sockpass_real[SOCKPASS_MAX+1];
    115114
    116115struct socket_cmd {
     
    226225{
    227226  int j = 0;
    228   while (skey->sh_sockpass[2*j] != '\0')
     227  while (skey->sh_sockpass[2*j] != '\0' && j < sizeof(sh_sockpass_real))
    229228    {
    230229      sh_sockpass_real[j] = skey->sh_sockpass[2*j];
     
    309308
    310309  i = sl_strlen(c);
    311   if (i > 14) {
     310  if (i > SOCKPASS_MAX) {
    312311    return -1;
    313312  }
    314   for (j = 0; j < 29; ++j)
     313  for (j = 0; j < (2*SOCKPASS_MAX+1); ++j)
    315314    {
    316315      skey->sh_sockpass[j] = '\0';
     
    556555
    557556  iov.iov_base = (char *) &message;
    558   iov.iov_len  = SH_MAXMSG;
     557  iov.iov_len  = sizeof(message);
    559558
    560559  memset (&msg, 0, sizeof (msg));
     
    626625#endif
    627626
    628   /* nbytes = recv (talkfd, message, SH_MAXMSG, 0); */
    629 
    630   message[SH_MAXMSG-1] = '\0';
     627  /* msg.msg_iov.iov_base, filled by recvmsg
     628   */
     629  message[sizeof(message)-1] = '\0';
    631630
    632631  if (nbytes < 0)
     
    684683  if (eopw)
    685684    *eopw = '\0';
    686   if (0 == strcmp(goodpassword, message))
     685  /*
     686   * message is null-terminated and >> goodpassword
     687   */
     688  if (0 == strcmp(goodpassword, message) &&
     689      strlen(goodpassword) < (sizeof(message)/2))
    687690    {
    688691      client_uid = sh_socket_flaguid;
     
    808811      while (list_cmd)
    809812        {
    810           sl_snprintf(message, SH_MAXMSG, _("SENT  %8s  %32s  %s"),
     813          sl_snprintf(message, sizeof(message), _("SENT  %8s  %32s  %s"),
    811814                      list_cmd->cmd, list_cmd->clt, list_cmd->cti);
    812815          /*
     
    835838  while (list_cmd)
    836839    {
    837       sl_snprintf(message, SH_MAXMSG, _(">>>>  %8s  %32s  %s"),
     840      sl_snprintf(message, sizeof(message), _(">>>>  %8s  %32s  %s"),
    838841                  list_cmd->cmd, list_cmd->clt, list_cmd->cti);
    839842      /*
     
    964967    }
    965968
    966   sl_strlcpy(cancel_cmd, _("CANCEL"), SH_MAXMSGLEN);
     969  sl_strlcpy(cancel_cmd, _("CANCEL"), sizeof(cancel_cmd));
    967970
    968971  while (sh_socket_read (&cmd) > 0)
     
    994997      if (0 == sl_strcmp(new->clt, client_name))
    995998        {
    996           sl_strlcpy(out, new->cmd, SH_MAXMSGLEN);
     999          sl_strlcpy(out, new->cmd, sizeof(out));
    9971000          sh_socket_add2run (new);
    9981001          sh_socket_rm2list  (client_name);
  • trunk/src/sh_unix.c

    r34 r40  
    120120#endif
    121121#endif
     122
     123#if defined(S_IFDOOR) && !defined(S_ISDOOR)
     124#define S_ISDOOR(mode) (((mode) & S_IFMT) == S_IFDOOR)
     125#else
     126#if !defined(S_ISDOOR)
     127#define S_ISDOOR(mode) (0)
     128#endif
     129#endif
     130
     131#if defined(S_IFPORT) && !defined(S_ISPORT)
     132#define S_ISPORT(mode) (((mode) & S_IFMT) == S_IFPORT)
     133#else
     134#if !defined(S_ISPORT)
     135#define S_ISPORT(mode) (0)
     136#endif
     137#endif
     138
    122139
    123140#undef  FIL__
     
    26742691    c_mode[0] = 's';
    26752692  }
     2693  else if ( S_ISDOOR(buf->st_mode) ) {
     2694    (*type)   = SH_FILE_DOOR;
     2695    c_mode[0] = 'D';
     2696  }
     2697  else if ( S_ISPORT(buf->st_mode) ) {
     2698    (*type)   = SH_FILE_PORT;
     2699    c_mode[0] = 'P';
     2700  }
    26762701  else                              {
    26772702    (*type)   = SH_FILE_UNKNOWN;
Note: See TracChangeset for help on using the changeset viewer.