Changeset 169 for trunk/src


Ignore:
Timestamp:
Apr 13, 2008, 9:59:55 PM (17 years ago)
Author:
katerina
Message:

Fixes for tickes #93 to #104 (yes, big commit, bad, bad,...).

Location:
trunk/src
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cutest_slib.c

    r21 r169  
    2424}
    2525
     26void Test_sl_strcasecmp (CuTest *tc) {
     27  char one[64], two[64];
     28  int  res;
    2629
     30  strcpy(one, "foo");
     31  strcpy(two, "foo");
     32  res = sl_strcasecmp(one, two);
     33  CuAssertIntEquals(tc, 0, res);
     34
     35  strcpy(one, "fo");
     36  strcpy(two, "foo");
     37  res = sl_strcasecmp(one, two);
     38  CuAssertIntEquals(tc, -1, res);
     39
     40  strcpy(one, "foo");
     41  strcpy(two, "fo");
     42  res = sl_strcasecmp(one, two);
     43  CuAssertIntEquals(tc, 1, res);
     44
     45  strcpy(one, "1234");
     46  strcpy(two, "2345");
     47  res = sl_strcasecmp(one, two);
     48  CuAssertIntEquals(tc, -1, res);
     49
     50  strcpy(one, "234");
     51  strcpy(two, "123");
     52  res = sl_strcasecmp(one, two);
     53  CuAssertIntEquals(tc, 1, res);
     54
     55  strcpy(one, "");
     56  strcpy(two, "123");
     57  res = sl_strcasecmp(one, two);
     58  CuAssertIntEquals(tc, -1, res);
     59
     60  strcpy(one, "234");
     61  strcpy(two, "");
     62  res = sl_strcasecmp(one, two);
     63  CuAssertIntEquals(tc, 1, res);
     64
     65  strcpy(one, "");
     66  strcpy(two, "");
     67  res = sl_strcasecmp(one, two);
     68  CuAssertTrue(tc, res == 0);
     69
     70#ifndef SL_FAIL_ON_ERROR
     71  res = sl_strcasecmp(NULL, two);
     72  CuAssertIntEquals(tc, -1, res);
     73
     74  res = sl_strcasecmp(one, NULL);
     75  CuAssertIntEquals(tc, 1, res);
     76
     77  res = sl_strcasecmp(NULL, NULL);
     78  CuAssertTrue(tc, res != 0);
     79#endif
     80}
  • trunk/src/samhain.c

    r162 r169  
    775775   */
    776776  (void) sh_unix_rm_lock_file (sh.srvlog.name);
    777   (void) sh_unix_rm_pid_file ();
     777  if (sh.flag.isdaemon == S_TRUE)
     778    (void) sh_unix_rm_pid_file ();
    778779  if (skey != NULL)
    779780    memset (skey, (int) '\0', sizeof(sh_key_t));
  • trunk/src/sh_calls.c

    r137 r169  
    341341#endif
    342342
    343   SL_ENTER(_("retry_fcntl"));
     343  SL_ENTER(_("retry_msleep"));
    344344
    345345  errno  = 0;
  • trunk/src/sh_cat.c

    r144 r169  
    134134
    135135#ifdef SH_USE_PORTCHECK
    136   { MSG_PORT_REPORT, SH_ERR_SEVERE,  EVENT, N_("msg=\"%s\"")},
     136  { MSG_PORT_MISS,   SH_ERR_SEVERE,  EVENT, N_("msg=\"POLICY [ServiceMissing] %s\"")},
     137  { MSG_PORT_NEW,    SH_ERR_SEVERE,  EVENT, N_("msg=\"POLICY [ServiceNew] %s\"")},
     138  { MSG_PORT_RESTART,SH_ERR_SEVERE,  EVENT, N_("msg=\"POLICY [ServiceRestarted] %s\"")},
     139  { MSG_PORT_NEWPORT,SH_ERR_SEVERE,  EVENT, N_("msg=\"POLICY [ServicePortSwitch] %s\"")},
    137140#endif
    138141
     
    449452
    450453#ifdef SH_USE_PORTCHECK
    451   { MSG_PORT_REPORT, SH_ERR_SEVERE,  EVENT, N_("msg=<%s>")},
     454  { MSG_PORT_MISS,   SH_ERR_SEVERE,  EVENT, N_("msg=<POLICY [ServiceMissing] %s>")},
     455  { MSG_PORT_NEW,    SH_ERR_SEVERE,  EVENT, N_("msg=<POLICY [ServiceNew] %s>")},
     456  { MSG_PORT_RESTART,SH_ERR_SEVERE,  EVENT, N_("msg=<POLICY [ServiceRestarted] %s>")},
     457  { MSG_PORT_NEWPORT,SH_ERR_SEVERE,  EVENT, N_("msg=<POLICY [ServicePortSwitch] %s>")},
    452458#endif
    453459
  • trunk/src/sh_extern.c

    r164 r169  
    143143   * --  check whether path is trustworthy
    144144   */
     145  status = sl_trustfile(task->command, NULL, NULL);
     146#if 0
    145147  if ((uid_t) -1 != task->trusted_users[0])
    146148    {
    147149      status = sl_trustfile(task->command, task->trusted_users, NULL);
    148150    }
     151#endif
    149152
    150153  PDBG_OPEN;
     
    647650      tas->argv[i]          = NULL;
    648651      tas->envv[i]          = NULL;
     652#if 0
    649653      tas->trusted_users[i] = (uid_t) -1;
     654#endif
    650655    }
    651656
     
    826831
    827832  (void) sl_get_euid(&ff_euid);
     833#if 0
    828834  ext_com->tas.trusted_users[0] = (uid_t) 0;
    829835  ext_com->tas.trusted_users[1] = (uid_t) (ff_euid);
     836#endif
    830837
    831838  /* ------------------------------------------------- */
  • trunk/src/sh_getopt.c

    r161 r169  
    225225    HAS_ARG_NO,
    226226    sh_getopt_forever},
     227  { N_("list-file"), 
     228    '-',
     229    N_("Modify -d to list content of a single file"), 
     230    HAS_ARG_YES,
     231    set_list_file},
    227232  { N_("full-detail"), 
    228233    'a',
     
    417422#if defined(SL_DEBUG)
    418423  if (num > 0) fputc ('\n', stdout);
    419   fputs (_(" debug build"), stdout); ++num;
     424  fputs (_(" debug build (don't use for production)"), stdout); ++num;
    420425#endif
    421426#if defined(SCREW_IT_UP)
     
    433438
    434439#if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE)
     440#if defined(HAVE_LIBZ)
     441  if (num > 0) fputc ('\n', stdout);
     442  fputs (_(" optionally store full text for files"), stdout); ++num;
     443#endif
    435444#if defined(USE_XATTR)
    436445  if (num > 0) fputc ('\n', stdout);
  • trunk/src/sh_hash.c

    r167 r169  
    24972497  sl_strlcat(msg, tmp, SH_BUFSIZE);
    24982498
    2499   if (theFile->c_mode[0] == 'l' || theFile->link_path != NULL)
     2499  if (theFile->c_mode[0] == 'l' ||
     2500      (theFile->link_path != NULL && theFile->link_path[0] != '-'))
    25002501    {
    25012502      tmp_lnk     = sh_util_safe_name(theFile->link_path);
     
    26632664  sl_strlcat(msg, tmp, SH_BUFSIZE);
    26642665
    2665   if (theFile->c_mode[0] == 'l' || theFile->link_path != NULL)
     2666  if (theFile->c_mode[0] == 'l' ||
     2667      (theFile->link_path != NULL && theFile->link_path[0] != '-'))
    26662668    {
    26672669      tmp_lnk     = sh_util_safe_name(theFile->link_path);
     
    27392741  char timstr2m[32];
    27402742  char linkHash[KEY_LEN+1];
     2743  char * linkComp;
    27412744  int  maxcomp;
    27422745
     
    28692872  if (p->theFile.c_mode[0] == 'l')
    28702873    {
    2871       if (sl_strlen(theFile->link_path) >= MAX_PATH_STORE)
    2872         {
    2873           sl_strlcpy(linkHash,
    2874                      sh_tiger_hash(theFile->link_path,
    2875                                    TIGER_DATA,
    2876                                    sl_strlen(theFile->link_path),
    2877                                    hashbuf, sizeof(hashbuf)),
    2878                      MAX_PATH_STORE+1);
    2879           maxcomp = MAX_PATH_STORE;
    2880         }
    2881       else
    2882         {
    2883           sl_strlcpy(linkHash, theFile->link_path, KEY_LEN + 1);
    2884           maxcomp = KEY_LEN;
    2885         }
    2886      
    2887 
    2888       if ( sl_strncmp (linkHash, p->linkpath, maxcomp) != 0 &&
    2889            (theFile->check_mask & MODI_LNK) != 0)
    2890         {
     2874      if (!(theFile->link_path) &&
     2875          (theFile->check_mask & MODI_LNK) != 0)
     2876        {
     2877          linkComp = NULL;
    28912878          modi_mask |= MODI_LNK;
    28922879          change_code[1] = 'L';
    28932880          TPT ((0, FIL__, __LINE__, _("mod=<link>")));
    2894         }
     2881        }
     2882      else
     2883        {
     2884          if (sl_strlen(theFile->link_path) >= MAX_PATH_STORE)
     2885            {
     2886              sl_strlcpy(linkHash,
     2887                         sh_tiger_hash(theFile->link_path,
     2888                                       TIGER_DATA,
     2889                                       sl_strlen(theFile->link_path),
     2890                                       hashbuf, sizeof(hashbuf)),
     2891                         MAX_PATH_STORE+1);
     2892              linkComp = linkHash;
     2893              maxcomp  = KEY_LEN;
     2894            }
     2895          else
     2896            {
     2897              linkComp = theFile->link_path;
     2898              maxcomp  = MAX_PATH_STORE;
     2899            }
     2900         
     2901          if ( sl_strncmp (linkComp, p->linkpath, maxcomp) != 0 &&
     2902               (theFile->check_mask & MODI_LNK) != 0)
     2903            {
     2904              modi_mask |= MODI_LNK;
     2905              change_code[1] = 'L';
     2906              TPT ((0, FIL__, __LINE__, _("mod=<link>")));
     2907            }
     2908        }
    28952909    }
    28962910
     
    33493363            }
    33503364#endif
    3351         }
    3352 
    3353 
    3354       if ((modi_mask & MODI_LNK) != 0 && theFile->c_mode[0] == 'l')
    3355         {
    3356           tmp_lnk     = sh_util_safe_name(theFile->link_path);
    3357           tmp_lnk_old = sh_util_safe_name(p->linkpath);
     3365          /* FIXME is this correct? */
     3366          if (theFile->c_mode[0] != 'l' && theFile->link_path &&
     3367              strlen(theFile->link_path) > 2)
     3368            modi_mask |= MODI_LNK;
     3369        }
     3370
     3371
     3372      if ((modi_mask & MODI_LNK) != 0 /* && theFile->c_mode[0] == 'l' */)
     3373        {
     3374          if (theFile->link_path)
     3375            tmp_lnk     = sh_util_safe_name(theFile->link_path);
     3376          else
     3377            tmp_lnk     = sh_util_strdup("-");
     3378          if (p->linkpath)
     3379            tmp_lnk_old = sh_util_safe_name(p->linkpath);
     3380          else
     3381            tmp_lnk_old = sh_util_strdup("-");
    33583382#ifdef SH_USE_XML
    33593383          sl_snprintf(tmp, SH_BUFSIZE, _("link_old=\"%s\" link_new=\"%s\" "),
     
    35993623#endif
    36003624
    3601 static int ListFullDetail = S_FALSE;
     3625static int ListFullDetail    = S_FALSE;
    36023626static int ListWithDelimiter = S_FALSE;
     3627static char * ListFile       = NULL;
     3628
     3629int set_list_file (const char * c)
     3630{
     3631  ListFile = sh_util_strdup(c);
     3632  return 0;
     3633}
    36033634
    36043635int set_full_detail (const char * c)
     
    38583889}
    38593890
     3891#ifdef HAVE_LIBZ
     3892#include <zlib.h>
     3893#endif   
     3894
     3895int sh_hash_printcontent(char * linkpath)
     3896{
     3897#ifdef HAVE_LIBZ
     3898  unsigned char * decoded;
     3899  unsigned char * decompressed = NULL;
     3900  size_t dlen;
     3901  unsigned long clen;
     3902  unsigned long clen_o;
     3903  int    res;
     3904
     3905  if (linkpath && *linkpath != '-')
     3906    {
     3907      dlen = sh_util_base64_dec_alloc (&decoded,
     3908                                       (unsigned char *)linkpath,
     3909                                       strlen(linkpath));
     3910      clen = dlen * 2 + 1;
     3911      do {
     3912        if (decompressed)
     3913          SH_FREE(decompressed);
     3914        clen += dlen; clen_o = clen;
     3915        decompressed = SH_ALLOC(clen);
     3916        res = uncompress(decompressed, &clen, decoded, dlen);
     3917        if (res == Z_MEM_ERROR)
     3918          { fprintf(stderr, _("Error: Not enough memory\n")); return -1; }
     3919        if (res == Z_DATA_ERROR)
     3920          { fprintf(stderr, _("Error: Data corrupt or incomplete\n")); return -1; }
     3921      } while (res == Z_BUF_ERROR || clen == clen_o);
     3922      decompressed[clen] = '\0';
     3923      fputs( (char*) decompressed, stdout);
     3924      return 0;
     3925    }
     3926#else
     3927  (void) linkpath;
     3928#endif
     3929  fprintf(stderr, _("Error: No data available\n"));
     3930  return -1;
     3931}
     3932
    38603933int sh_hash_list_db (const char * db_file)
    38613934{
     
    38633936  SL_TICKET fd;
    38643937  char * line;
     3938  int  flag = 0;
    38653939
    38663940  if (!db_file)
     
    39003974    {
    39013975      p = sh_hash_getdataent (fd, line, MAX_PATH_STORE);
    3902       if ((p != NULL) && (p->fullpath[0] != 'K'))
    3903         {
    3904           if (ListFullDetail == S_FALSE)
    3905             sh_hash_list_db_entry (p);
     3976      if ((p != NULL) && (p->fullpath[0] == '/'))
     3977        {
     3978          if (!ListFile)
     3979            {
     3980              flag = 1;
     3981              if (ListFullDetail == S_FALSE)
     3982                sh_hash_list_db_entry (p);
     3983              else
     3984                sh_hash_list_db_entry_full_detail (p);
     3985            }
    39063986          else
    3907             sh_hash_list_db_entry_full_detail (p);
     3987            {
     3988              if (0 != sl_strcmp(ListFile, p->fullpath))
     3989                {
     3990                  continue;
     3991                }
     3992              flag = 1;
     3993              if ('l' != p->theFile.c_mode[0])
     3994                {
     3995                  if (sh_hash_printcontent(p->linkpath) < 0)
     3996                    {
     3997                      _exit(EXIT_FAILURE);
     3998                      return -1;
     3999                    }
     4000                }
     4001              else
     4002                {
     4003                  fprintf(stderr, _("File is a link\n"));
     4004                  _exit(EXIT_FAILURE);
     4005                  return -1;
     4006                }
     4007              break;
     4008            }
    39084009        }
    39094010      else if (p == NULL)
     
    39194020  fflush(NULL);
    39204021
     4022  if (flag == 0)
     4023    {
     4024      fprintf(stderr, _("No file found\n"));
     4025      _exit(EXIT_FAILURE);
     4026    }
    39214027  _exit(EXIT_SUCCESS);
    39224028  return 0;
  • trunk/src/sh_mounts.c

    r149 r169  
    180180  }
    181181
    182   lastcheck = time(NULL);
    183 
    184182  SL_RETURN(0, _("sh_mounts_init"));
    185183}
     
    197195    SL_RETURN(-1, _("sh_mounts_timer"));
    198196  }
    199   
     197 
    200198  SL_RETURN(0, _("sh_mounts_timer"));
    201199}
     
    400398
    401399/* FreeBSD includes */
    402 #ifdef HOST_IS_FREEBSD
     400#if defined(HOST_IS_FREEBSD) || defined(HOST_IS_OPENBSD)
    403401#include <sys/param.h>
    404402#include <sys/ucred.h>
     
    577575#endif
    578576
    579 #if defined(HOST_IS_FREEBSD)
     577#if defined(HOST_IS_FREEBSD) || defined(HOST_IS_OPENBSD)
    580578
    581579/* FreeBSD returns flags instead of strings as mount options, so we'll convert
     
    595593                {"local",       MNT_LOCAL},
    596594                {"quota",       MNT_QUOTA},
     595#ifdef MNT_NOATIME
     596                {"noatime",     MNT_NOATIME},
     597#endif
    597598                {"bound",       -1}
    598599        };
     
    665666        list = m;
    666667
    667 /* The FreeBSD way */
    668 #ifdef HOST_IS_FREEBSD
     668/* The Open/FreeBSD way */
     669#if defined(HOST_IS_FREEBSD) || defined(HOST_IS_OPENBSD)
    669670{
    670671        struct statfs *fsp;
  • trunk/src/sh_portcheck.c

    r162 r169  
    384384          if (ptr->flag != SH_PORT_OPT && ptr->flag != SH_PORT_IGN)
    385385            {
    386               snprintf (errbuf, sizeof(errbuf), _("POLICY [ServiceMissing] port %s:%d/%s (%s)"),
     386              snprintf (errbuf, sizeof(errbuf), _("port: %s:%d/%s (%s)"),
    387387                        ptr->interface, ptr->port, SH_PROTO_STR(proto),
    388388                        ptr->service ? ptr->service : check_services(ptr->port, proto));
     
    395395                  SH_MUTEX_LOCK(mutex_thread_nolog);
    396396                  sh_error_handle(sh_portchk_severity, FIL__, __LINE__, 0,
    397                                   MSG_PORT_REPORT, errbuf);
     397                                  MSG_PORT_MISS, errbuf);
    398398                  SH_MUTEX_UNLOCK(mutex_thread_nolog);
    399399                }
     
    497497      if (!portent)
    498498        {
    499           snprintf (errbuf, sizeof(errbuf), _("POLICY [ServiceNew] port %s:%d/%s (%s)"),
     499          snprintf (errbuf, sizeof(errbuf), _("port: %s:%d/%s (%s)"),
    500500                    inet_ntoa(haddr), port, SH_PROTO_STR(proto), service);
    501501#ifdef TEST_ONLY
     
    505505          SH_MUTEX_LOCK(mutex_thread_nolog);
    506506          sh_error_handle(sh_portchk_severity, FIL__, __LINE__, 0,
    507                           MSG_PORT_REPORT, errbuf);
     507                          MSG_PORT_NEW, errbuf);
    508508          SH_MUTEX_UNLOCK(mutex_thread_nolog);
    509509#endif
     
    515515      else if (portent->status == SH_PORT_MISS && portent->flag != SH_PORT_IGN)
    516516        {
    517           snprintf (errbuf, sizeof(errbuf), _("POLICY [ServiceRestarted] port %s:%d/%s to %d/%s (%s)"),
    518                     inet_ntoa(haddr), portent->port, SH_PROTO_STR(proto), port, SH_PROTO_STR(proto), service);
     517          snprintf (errbuf, sizeof(errbuf), _("port: %s:%d/%s (%s), was %d/%s"),
     518                    inet_ntoa(haddr), port, SH_PROTO_STR(proto), service, portent->port, SH_PROTO_STR(proto));
    519519#ifdef TEST_ONLY
    520520          fprintf(stderr, _("service: %s\n"), errbuf);
     
    522522          SH_MUTEX_LOCK(mutex_thread_nolog);
    523523          sh_error_handle(sh_portchk_severity, FIL__, __LINE__, 0,
    524                           MSG_PORT_REPORT, errbuf);
     524                          MSG_PORT_RESTART, errbuf);
    525525          SH_MUTEX_UNLOCK(mutex_thread_nolog);
    526526#endif
     
    530530      else if (port != portent->port && (-1) != portent->port)
    531531        {
    532           snprintf (errbuf, sizeof(errbuf), _("POLICY [ServicePortSwitch] port %s:%d/%s to %d/%s (%s)"),
    533                     inet_ntoa(haddr), portent->port, SH_PROTO_STR(proto), port, SH_PROTO_STR(proto), service);
     532          snprintf (errbuf, sizeof(errbuf), _("port: %s:%d/%s (%s), was %d/%s"),
     533                    inet_ntoa(haddr), port, SH_PROTO_STR(proto), service, portent->port, SH_PROTO_STR(proto));
    534534#ifdef TEST_ONLY
    535535          fprintf(stderr, _("service: %s\n"), errbuf);
     
    537537          SH_MUTEX_LOCK(mutex_thread_nolog);
    538538          sh_error_handle(sh_portchk_severity, FIL__, __LINE__, 0,
    539                           MSG_PORT_REPORT, errbuf);
     539                          MSG_PORT_NEWPORT, errbuf);
    540540          SH_MUTEX_UNLOCK(mutex_thread_nolog);
    541541#endif
     
    552552      if (!portent)
    553553        {
    554           snprintf (errbuf, sizeof(errbuf), _("POLICY [ServiceNew] port %s:%d/%s (%s)"),
     554          snprintf (errbuf, sizeof(errbuf), _("port: %s:%d/%s (%s)"),
    555555                    inet_ntoa(haddr), port, SH_PROTO_STR(proto), check_services(port, proto));
    556556#ifdef TEST_ONLY
     
    560560          SH_MUTEX_LOCK(mutex_thread_nolog);
    561561          sh_error_handle(sh_portchk_severity, FIL__, __LINE__, 0,
    562                           MSG_PORT_REPORT, errbuf);
     562                          MSG_PORT_NEW, errbuf);
    563563          SH_MUTEX_UNLOCK(mutex_thread_nolog);
    564564#endif
     
    570570      else if (portent->status == SH_PORT_MISS && portent->flag != SH_PORT_IGN)
    571571        {
    572           snprintf (errbuf, sizeof(errbuf), _("POLICY [ServiceRestarted] port %s:%d/%s (%s)"),
     572          snprintf (errbuf, sizeof(errbuf), _("port: %s:%d/%s (%s)"),
    573573                    inet_ntoa(haddr), port, SH_PROTO_STR(proto), check_services(port, proto));
    574574#ifdef TEST_ONLY
     
    577577          SH_MUTEX_LOCK(mutex_thread_nolog);
    578578          sh_error_handle(sh_portchk_severity, FIL__, __LINE__, 0,
    579                           MSG_PORT_REPORT, errbuf);
     579                          MSG_PORT_RESTART, errbuf);
    580580          SH_MUTEX_UNLOCK(mutex_thread_nolog);
    581581#endif
  • trunk/src/sh_prelude.c

    r131 r169  
    8585#define SH_NEED_PWD_GRP 1
    8686#include "sh_static.h"
    87 
     87char * sh_util_strdup (const char * str) SH_GNUC_MALLOC;
    8888/*
    8989 * When SH_USE_XML is set, value are formated using name="value".
     
    651651#endif
    652652
     653#ifdef SH_USE_PORTCHECK
     654                { MSG_PORT_MISS, N_("Service closed"), IDMEF_IMPACT_TYPE_OTHER },
     655                { MSG_PORT_NEW, N_("Service opened"), IDMEF_IMPACT_TYPE_OTHER },
     656                { MSG_PORT_RESTART, N_("Service restarted"), IDMEF_IMPACT_TYPE_OTHER },
     657                { MSG_PORT_NEWPORT, N_("Service restarted"), IDMEF_IMPACT_TYPE_OTHER },
     658#endif
     659
    653660#ifdef SH_USE_SUIDCHK
    654661                { MSG_SUID_POLICY, N_("SUID/SGID File Detected"), IDMEF_IMPACT_TYPE_FILE },
     
    684691
    685692
     693#ifdef SH_USE_PORTCHECK
     694static int get_service_info(char *msg, idmef_alert_t *alert)
     695{
     696        int ret;
     697        long port;
     698        char *ptr, *new, *tmp, *ip, *srv, *end;
     699        prelude_string_t *str;
     700        idmef_address_t *address;
     701        idmef_node_t *node;
     702        idmef_service_t *service;
     703        idmef_source_t *source = idmef_alert_get_next_source(alert, NULL);
     704
     705        new = sh_util_strdup(msg);
     706 
     707        ptr = strstr(new, _("port: "));
     708        if ( ! ptr ) {
     709                sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
     710                                _("malformed Samhain port check message"), _("get_service_info"));
     711                SH_FREE( new );
     712                return -1;
     713        }
     714
     715        ptr += 6; /* skip 'port: ', position on first byte of interface */
     716        tmp = strchr(ptr, ':');
     717        if ( ! tmp ) {
     718                sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
     719                                _("malformed Samhain port check message (no port)"), _("get_service_info"));
     720                SH_FREE( new );
     721                return -1;
     722        }
     723        *tmp = '\0';
     724
     725        ip = strdup(ptr);
     726        if ( ip ) {
     727                if ( ! source ) {
     728                        ret = idmef_alert_new_source(alert, &source, IDMEF_LIST_APPEND);
     729                        if ( ret < 0 ) {
     730                                free(ip);
     731                                SH_FREE( new );
     732                                return ret;
     733                        }
     734                }
     735
     736                ret = idmef_source_new_node(source, &node);
     737                if ( ret < 0 ) {
     738                        free(ip);
     739                        SH_FREE( new );
     740                        return ret;
     741                }
     742               
     743                ret = idmef_node_new_address(node, &address, IDMEF_LIST_APPEND);
     744                if ( ret < 0 ) {
     745                        free(ip);
     746                        SH_FREE( new );
     747                        return ret;
     748                }
     749               
     750                ret = idmef_address_new_address(address, &str);
     751                if ( ret < 0 ) {
     752                        free(ip);
     753                        SH_FREE( new );
     754                        return ret;
     755                }
     756               
     757                prelude_string_set_nodup(str, ip);
     758        }
     759
     760        ptr = tmp;
     761        ++ptr;
     762        tmp = strchr(ptr, '/');
     763        if ( ! tmp ) {
     764                sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
     765                                _("malformed Samhain port check message (no protocol)"), _("get_service_info"));
     766                SH_FREE( new );
     767                return -1;
     768        }
     769        *tmp = '\0';
     770
     771        port = strtol(ptr, &end, 0);
     772        if ( *ptr && *end == '\0' && port >= 0 && port < 65536) {
     773
     774                if ( ! source ) {
     775                        ret = idmef_alert_new_source(alert, &source, IDMEF_LIST_APPEND);
     776                        if ( ret < 0 ) {
     777                                free(srv);
     778                                SH_FREE( new );
     779                                return ret;
     780                        }
     781                }
     782
     783                ret = idmef_source_new_service(source, &service);
     784                if ( ret < 0 ) {
     785                        free(srv);
     786                        SH_FREE( new );
     787                        return ret;
     788                }
     789
     790                idmef_service_set_port(service, port);
     791        }
     792
     793        ptr = tmp;
     794        ++ptr;
     795        ptr = strchr(ptr, '(');
     796        if ( ! ptr ) {
     797                sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
     798                                _("malformed Samhain port check message (no service)"), _("get_service_info"));
     799                SH_FREE( new );
     800                return -1;
     801        }
     802        ++ptr;
     803        tmp = strchr(ptr, ')');
     804        if ( ! tmp ) {
     805                sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
     806                                _("malformed Samhain port check message (service not closed)"), _("get_service_info"));
     807                SH_FREE( new );
     808                return -1;
     809        }
     810        *tmp = '\0';
     811
     812        srv = strdup(ptr);
     813        if ( srv ) {
     814                if ( ! source ) {
     815                        ret = idmef_alert_new_source(alert, &source, IDMEF_LIST_APPEND);
     816                        if ( ret < 0 ) {
     817                                free(srv);
     818                                SH_FREE( new );
     819                                return ret;
     820                        }
     821                }
     822
     823                if ( ! service ) {
     824                        ret = idmef_source_new_service(source, &service);
     825                        if ( ret < 0 ) {
     826                                free(srv);
     827                                SH_FREE( new );
     828                                return ret;
     829                        }
     830                }
     831
     832                ret = idmef_service_new_ident(service, &str);
     833                if ( ret < 0 ) {
     834                        free(srv);
     835                        SH_FREE( new );
     836                        return ret;
     837                }
     838               
     839                prelude_string_set_nodup(str, srv);
     840        }
     841
     842        SH_FREE( new );
     843
     844        return 0;
     845}
     846#endif
    686847
    687848static int get_login_info(char *msg, idmef_alert_t *alert)
     
    9021063                goto err;
    9031064       
     1065#ifdef SH_USE_PORTCHECK
     1066        if (msgid == MSG_PORT_MISS || msgid == MSG_PORT_NEW || msgid == MSG_PORT_RESTART || msgid == MSG_PORT_NEWPORT) {
     1067                ret = get_service_info(message, alert);
     1068                if ( ret < 0 )
     1069                        goto err;
     1070        }
     1071#endif
     1072   
    9041073        map_policy_to_class(message, msgid, impact, str);
    9051074
  • trunk/src/sh_processcheck.c

    r144 r169  
    837837          else if (errno == EAGAIN)
    838838            {
     839              clearerr(in);
    839840              continue;
    840841            }
     842#ifdef HOST_IS_OPENBSD
     843          else if (errno == ENODEV)
     844            {
     845              clearerr(in);
     846              continue;
     847            }
     848#endif
    841849          else
    842850            {
     
    10491057  size_t i, j;
    10501058  char  tests[512];
     1059  int   retval;
    10511060
    10521061  pid_t this_pid;
     
    10601069      SH_MUTEX_LOCK(mutex_thread_nolog);
    10611070      sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
    1062                       _("Internal error: NULL argument"),
     1071                      _("Internal error: NULL argument, switching off"),
    10631072                      _("sh_process_check_int"));
    10641073      SH_MUTEX_UNLOCK(mutex_thread_nolog);
     
    10671076
    10681077  SH_MUTEX_LOCK(mutex_thread_nolog);
    1069   sh_processes_runps (res, NULL, 0, SH_PR_PS, 0);
     1078  retval = sh_processes_runps (res, NULL, 0, SH_PR_PS, 0);
    10701079  SH_MUTEX_UNLOCK(mutex_thread_nolog);
    10711080  for (i = sh_prochk_minpid; i != sh_prochk_maxpid; ++i)
     
    10751084    }
    10761085  SH_MUTEX_LOCK(mutex_thread_nolog);
    1077   sh_processes_runps (res, NULL, 0, SH_PR_PS2, 0);
     1086  retval += sh_processes_runps (res, NULL, 0, SH_PR_PS2, 0);
    10781087  SH_MUTEX_UNLOCK(mutex_thread_nolog);
     1088
     1089  if (retval != 0)
     1090    {
     1091      SH_MUTEX_LOCK(mutex_thread_nolog);
     1092      sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
     1093                      _("Failed to run ps, switching off"),
     1094                      _("sh_process_check_int"));
     1095      SH_MUTEX_UNLOCK(mutex_thread_nolog);
     1096      SL_RETURN ((-1), _("sh_process_check_int"));
     1097    }
    10791098
    10801099  /* Evaluate results
  • trunk/src/sh_readconf.c

    r164 r169  
    573573   */
    574574  sl_rewind (fd);
    575   sh_error_only_stderr (S_FALSE);
    576575  if (0 != sh_gpg_check_sign (fd, 0, 1))
    577576    aud_exit (FIL__, __LINE__, EXIT_FAILURE);
  • trunk/src/sh_tools.c

    r161 r169  
    582582                      *errnum = 0;
    583583                      if (sl_strlen(host_entry->h_name) == 0 ||
    584                           (*errnum = sl_strcmp(host_name,host_entry->h_name)) != 0)
     584                          (*errnum = sl_strcasecmp(host_name,host_entry->h_name)) != 0)
    585585                        {
    586586                          if (*errnum)
     
    16631663        SH_FREE (file);
    16641664        SH_FREE(my_tmp_dir);
     1665        sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, status, MSG_E_SUBGEN,
     1666                        _("Error (lstat) while opening temporary file"), _("open_tmp"));
    16651667        TPT(( 0, FIL__, __LINE__, _("msg=<Unexpected error %d>\n"), error));
    16661668        SL_RETURN((-1), _("open_tmp"));
  • trunk/src/sh_unix.c

    r167 r169  
    4343#include <fcntl.h>
    4444#include <unistd.h>
     45/* need to undef these, since the #define's may be picked up from
     46 * linux/wait.h, and will clash with a typedef in sys/wait.h
     47 */
     48#undef P_ALL
     49#undef P_PID
     50#undef P_PGID
    4551#include <sys/wait.h>
    4652
     
    29932999              someval *= 1000;  /* milliseconds in a second */
    29943000              sometime = (unsigned long) someval;
    2995               /* fprintf(stderr, "FIXME PAUSE %ld\n", sometime); */
    29963001              retry_msleep(0, sometime);
    29973002            }
     
    29993004            {
    30003005              sometime = (unsigned long) someval;
    3001               /* fprintf(stderr, "FIXME PAUSE %ld sec\n", sometime); */
    30023006              retry_msleep (sometime, 0);
    30033007            }
     
    30373041
    30383042  SL_ENTER(_("sh_unix_checksum_size"));
     3043
     3044  tmpFile.link_path = NULL;
    30393045
    30403046  if (sh.flag.checkSum != SH_CHECK_INIT)
     
    32563262}
    32573263#endif
    3258    
     3264
     3265#ifdef HAVE_LIBZ
     3266#include <zlib.h>
     3267#endif   
    32593268
    32603269int sh_unix_getinfo (int level, char * filename, file_type * theFile,
     
    34023411              UINT64 length_nolim = TIGER_NOLIM;
    34033412
    3404               if ((theFile->check_mask & MODI_TXT) != 0 && fbuf.st_size < SH_TXT_MAX)
     3413              if ((theFile->check_mask & MODI_TXT) != 0 && fbuf.st_size < (10 * SH_TXT_MAX))
    34053414                {
    34063415                  sl_init_content (rval_open, fbuf.st_size);
     
    34153424
    34163425              content = sl_get_content(rval_open);
     3426              content = sh_string_copy(content);
    34173427
    34183428              if ((theFile->check_mask & MODI_SGROW) != 0)
     
    34543464              UINT64 length_nolim = TIGER_NOLIM;
    34553465
    3456               if ((theFile->check_mask & MODI_TXT) != 0 && fbuf.st_size < SH_TXT_MAX)
     3466              if ((theFile->check_mask & MODI_TXT) != 0 && fbuf.st_size < (10 * SH_TXT_MAX))
    34573467                {
    34583468                  sl_init_content (rval_open, fbuf.st_size);
     
    34673477
    34683478              content = sl_get_content(rval_open);
     3479              content = sh_string_copy(content);
    34693480
    34703481              if ((theFile->check_mask & MODI_SGROW) != 0)
     
    37593770      if (content)
    37603771        {
    3761           sh_util_base64_enc_alloc (&(theFile->link_path),
    3762                                     sh_string_str(content),
    3763                                     sh_string_len(content));
     3772#ifdef HAVE_LIBZ
     3773          unsigned long   clen = compressBound(sh_string_len(content));
     3774          unsigned char * compressed = SH_ALLOC(clen);
     3775          if (Z_OK == compress(compressed, &clen,
     3776                               (unsigned char *) sh_string_str(content),
     3777                               sh_string_len(content)))
     3778              {
     3779                if (clen < SH_TXT_MAX)
     3780                  {
     3781                    sh_util_base64_enc_alloc (&(theFile->link_path),
     3782                                              (char *) compressed, clen);
     3783                  }
     3784                else
     3785                  {
     3786                    char tmsg[128];
     3787                    char * tpath = sh_util_safe_name (theFile->fullpath);
     3788                    sl_snprintf(tmsg, sizeof(tmsg),
     3789                                _("compressed file too large (%lu bytes)"),
     3790                                clen);
     3791                    sh_error_handle (SH_ERR_WARN, FIL__, __LINE__, -1,
     3792                                     MSG_E_SUBGPATH, tmsg,
     3793                                     _("sh_unix_getinfo"), tpath);
     3794                    SH_FREE(tpath);
     3795                  }
     3796              }
     3797          SH_FREE(compressed);
     3798#endif
     3799          sh_string_destroy(&content);
    37643800        }
    37653801    }
     
    37703806#endif
    37713807
    3772 int sh_unix_unlock (char * lockfile, char * flag);
    3773 int sh_unix_lock   (char * lockfile, char * flag);
     3808int sh_unix_unlock(char * lockfile, char * flag)
     3809{
     3810  int         error = 0;
     3811 
     3812  SL_ENTER(_("sh_unix_unlock"));
     3813
     3814  if (sh.flag.isdaemon == S_FALSE && flag == NULL)
     3815    SL_RETURN((0),_("sh_unix_unlock"));
     3816
     3817  /* --- Logfile is not locked to us. ---
     3818   */
     3819  if (sh.flag.islocked == BAD && flag != NULL)
     3820    SL_RETURN((-1),_("sh_unix_unlock"));
     3821
     3822  /* --- Check whether the directory is secure. ---
     3823   */
     3824  if (0 != tf_trust_check (lockfile, SL_YESPRIV))
     3825    SL_RETURN((-1),_("sh_unix_unlock"));
     3826
     3827  /* --- Delete the lock file. ---
     3828   */
     3829  error = retry_aud_unlink (FIL__, __LINE__, lockfile);
     3830 
     3831  if (error == 0)
     3832    {
     3833      if (flag != NULL)
     3834        sh.flag.islocked = BAD; /* not locked anymore */
     3835    }
     3836  else if (flag != NULL)
     3837    {
     3838      char errbuf[SH_ERRBUF_SIZE];
     3839      error = errno;
     3840      sh_error_handle ((-1), FIL__, __LINE__, error, MSG_E_UNLNK,
     3841                       sh_error_message(error, errbuf, sizeof(errbuf)),
     3842                       lockfile);
     3843      SL_RETURN((-1),_("sh_unix_unlock"));
     3844    }
     3845  SL_RETURN((0),_("sh_unix_unlock"));
     3846}
     3847
     3848int sh_unix_lock (char * lockfile, char * flag)
     3849{
     3850  int filed;
     3851  int errnum;
     3852  char myPid[64];
     3853  SL_TICKET  fd;
     3854  extern int get_the_fd (SL_TICKET ticket);
     3855
     3856  SL_ENTER(_("sh_unix_lock"));
     3857
     3858  sprintf (myPid, "%ld\n", (long) sh.pid);             /* known to fit  */
     3859
     3860  fd = sl_open_safe_rdwr (lockfile, SL_YESPRIV);       /* fails if file exists */
     3861
     3862  if (!SL_ISERROR(fd))
     3863    {
     3864      errnum = sl_write (fd, myPid, sl_strlen(myPid));
     3865      filed = get_the_fd(fd);
     3866      fchmod (filed, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
     3867      sl_close (fd);
     3868
     3869      if (!SL_ISERROR(errnum))
     3870        {
     3871          if (flag != NULL)
     3872            sh.flag.islocked = GOOD;
     3873          SL_RETURN((0),_("sh_unix_lock"));
     3874        }
     3875    }
     3876
     3877  TPT((0, FIL__, __LINE__, _("msg=<open pid file failed>\n")));
     3878  if (flag != NULL)
     3879    sh.flag.islocked       = BAD;
     3880  SL_RETURN((-1),_("sh_unix_lock"));
     3881
     3882  /* notreached */
     3883}
     3884
    37743885
    37753886/* check whether file is locked
     
    39644075}
    39654076
    3966 int sh_unix_unlock(char * lockfile, char * flag)
    3967 {
    3968   int         error = 0;
    3969  
    3970   SL_ENTER(_("sh_unix_unlock"));
    3971 
    3972   /* --- Logfile is not locked to us. ---
    3973    */
    3974   if (sh.flag.islocked == BAD && flag != NULL)
    3975     SL_RETURN((-1),_("sh_unix_unlock"));
    3976 
    3977   /* --- Check whether the directory is secure. ---
    3978    */
    3979   if (0 != tf_trust_check (lockfile, SL_YESPRIV))
    3980     SL_RETURN((-1),_("sh_unix_unlock"));
    3981 
    3982   /* --- Delete the lock file. ---
    3983    */
    3984   error = retry_aud_unlink (FIL__, __LINE__, lockfile);
    3985  
    3986   if (error == 0)
    3987     {
    3988       if (flag != NULL)
    3989         sh.flag.islocked = BAD; /* not locked anymore */
    3990     }
    3991   else if (flag != NULL)
    3992     {
    3993       char errbuf[SH_ERRBUF_SIZE];
    3994       error = errno;
    3995       sh_error_handle ((-1), FIL__, __LINE__, error, MSG_E_UNLNK,
    3996                        sh_error_message(error, errbuf, sizeof(errbuf)),
    3997                        lockfile);
    3998       SL_RETURN((-1),_("sh_unix_unlock"));
    3999     }
    4000   SL_RETURN((0),_("sh_unix_unlock"));
    4001 }
    4002 
    40034077/* rm lock for filename
    40044078 */
     
    40294103{
    40304104  return sh_unix_unlock(sh.srvlog.alt, NULL);
    4031 }
    4032 
    4033 int sh_unix_lock (char * lockfile, char * flag)
    4034 {
    4035   int filed;
    4036   int errnum;
    4037   char myPid[64];
    4038   SL_TICKET  fd;
    4039   extern int get_the_fd (SL_TICKET ticket);
    4040 
    4041   SL_ENTER(_("sh_unix_lock"));
    4042 
    4043   sprintf (myPid, "%ld\n", (long) sh.pid);             /* known to fit  */
    4044 
    4045   fd = sl_open_safe_rdwr (lockfile, SL_YESPRIV);       /* fails if file exists */
    4046 
    4047   if (!SL_ISERROR(fd))
    4048     {
    4049       errnum = sl_write (fd, myPid, sl_strlen(myPid));
    4050       filed = get_the_fd(fd);
    4051       fchmod (filed, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
    4052       sl_close (fd);
    4053 
    4054       if (!SL_ISERROR(errnum))
    4055         {
    4056           if (flag != NULL)
    4057             sh.flag.islocked = GOOD;
    4058           SL_RETURN((0),_("sh_unix_lock"));
    4059         }
    4060     }
    4061 
    4062   TPT((0, FIL__, __LINE__, _("msg=<open pid file failed>\n")));
    4063   if (flag != NULL)
    4064     sh.flag.islocked       = BAD;
    4065   SL_RETURN((-1),_("sh_unix_lock"));
    4066 
    4067   /* notreached */
    40684105}
    40694106
  • trunk/src/slib.c

    r167 r169  
    108108int  sl_trace_use (const char * dummy)
    109109{
    110   if (dummy)
    111     slib_do_trace = 1;
    112   else
    113     slib_do_trace = 1;
     110  (void) dummy;
     111  slib_do_trace = 1;
    114112  return 0;
    115113}
     
    156154          fprintf(trace_fp, "[%2d] %s \t - File %c%s%c at line %d\n",
    157155                 trace_level, str, 0x22, file, 0x22, line);
     156          fflush(trace_fp);
    158157        }
    159158      else
     
    191190          fprintf(trace_fp, _("[%2d] %s \t - File %c%s%c at line %d\n"),
    192191                 trace_level, str, 0x22, file, 0x22, line);
     192          fflush(trace_fp);
    193193        }
    194194      else
     
    10071007}
    10081008
     1009#include <ctype.h>
     1010int sl_strcasecmp(const char * one, const char * two)
     1011{
     1012#ifdef SL_FAIL_ON_ERROR
     1013  SL_REQUIRE (one != NULL, _("one != NULL"));
     1014  SL_REQUIRE (two != NULL, _("two != NULL"));
     1015#endif
     1016
     1017  if (one && two)
     1018    {
     1019      do {
     1020        if (*one && *two)
     1021          {
     1022            if (tolower(*one) == tolower(*two))
     1023              {
     1024                ++one; ++two;
     1025              }
     1026            else if (tolower(*one) < tolower(*two))
     1027              return -1;
     1028            else
     1029              return 1;
     1030          }
     1031        else if (*one == '\0' && *two == '\0')
     1032          return 0;
     1033        else if (*one == '\0')
     1034          return -1;
     1035        else
     1036          return 1;
     1037      } while (1 == 1);
     1038    }
     1039  else if (one == NULL && two != NULL)
     1040    return -1;
     1041  else if (one != NULL && two == NULL)
     1042    return 1;
     1043  else
     1044    return -7; /* default to not equal */
     1045}
    10091046
    10101047int sl_strcmp(const char * a, const char * b)
     
    10221059    return (1);
    10231060  else
    1024     return (-7); /* arbitrary */
     1061    return (-7); /* default to not equal */
    10251062}
    10261063
     
    10401077    return (1);
    10411078  else
    1042     return (-7); /* arbitrary */
     1079    return (-7); /* default to not equal */
    10431080}
    10441081
     
    22322269                  if (is_nonblocking == SL_FALSE)
    22332270                      retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
     2271                  TPT(( 0, FIL__, __LINE__, _("msg=<read error>")));
    22342272                  return (SL_EREAD);
    22352273                }
     
    22472285          if (is_nonblocking == SL_FALSE)
    22482286              retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
     2287          TPT(( 0, FIL__, __LINE__, _("msg=<timeout>")));
    22492288          return (SL_TIMEOUT);
    22502289        }
     
    22532292          if (is_nonblocking == SL_FALSE)
    22542293              retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
     2294          TPT(( 0, FIL__, __LINE__, _("msg=<timeout>")));
    22552295          return (SL_EREAD);
    22562296        }
     
    22602300          if (is_nonblocking == SL_FALSE)
    22612301              retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
     2302          TPT(( 0, FIL__, __LINE__, _("msg=<terminated>")));
    22622303          return (SL_EREAD);
    22632304        }
     
    22702311          if (is_nonblocking == SL_FALSE)
    22712312              retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
     2313          TPT(( 0, FIL__, __LINE__, _("msg=<timeout>")));
    22722314          return (SL_TIMEOUT);
    22732315        }
     
    22822324                     int timeout, int is_nonblocking)
    22832325{
    2284   int    fd;
     2326  int    fd, retval;
    22852327 
     2328  SL_ENTER(_("sl_read_timeout"));
     2329
    22862330  if (buf_in == NULL || SL_ISERROR(fd = get_the_fd(ticket)))
    22872331    {
     
    22892333        {
    22902334          TPT(( 0, FIL__, __LINE__, _("msg=<null buffer>")));
    2291           return (SL_ENULL);
     2335          SL_IRETURN((SL_ENULL), _("sl_read_timeout"));
    22922336        }
    22932337      if (SL_ISERROR(fd = get_the_fd(ticket)))
    22942338        {
    22952339          TPT(( 0, FIL__, __LINE__, _("msg=<ticket error> errno=<%d>"), fd));
    2296           return (fd);
     2340          SL_IRETURN((fd),  _("sl_read_timeout"));
    22972341        }
    22982342    }
    22992343
    2300   return sl_read_timeout_fd (fd, buf_in, count, timeout, is_nonblocking);
     2344  retval = sl_read_timeout_fd (fd, buf_in, count, timeout, is_nonblocking);
     2345  SL_IRETURN((retval), _("sl_read_timeout"));
    23012346}
    23022347
     
    23102355  char * buf;
    23112356
     2357  SL_ENTER(_("sl_read"));
     2358
    23122359  if (count < 1)
    23132360    {
    23142361      TPT(( 0, FIL__, __LINE__, _("msg=<range error>")));
    2315       return(SL_ERANGE);
     2362      SL_IRETURN((SL_ERANGE), _("sl_read"));
    23162363    }
    23172364  if (buf_in == NULL)
    23182365    {
    23192366      TPT(( 0, FIL__, __LINE__, _("msg=<null buffer>")));
    2320       return (SL_ENULL);
     2367      SL_IRETURN((SL_ENULL), _("sl_read"));
    23212368    }
    23222369
     
    23242371    {
    23252372      TPT(( 0, FIL__, __LINE__, _("msg=<ticket error> errno=<%d>"), fd));
    2326       return (fd);
     2373      SL_IRETURN((fd), _("sl_read"));
    23272374    }
    23282375
     
    23452392    {
    23462393      TPT(( 0, FIL__, __LINE__, _("msg=<read error> errno=<%d>\n"), errno));
    2347       return (SL_EREAD);
    2348     }
    2349   return (bytes);
     2394      SL_IRETURN((SL_EREAD), _("sl_read"));
     2395    }
     2396  SL_IRETURN((bytes), _("sl_read"));
    23502397}
    23512398
     
    23572404  char * buf;
    23582405
     2406  SL_ENTER(_("sl_read_fast"));
     2407
    23592408  if (count < 1)
    23602409    {
    23612410      TPT(( 0, FIL__, __LINE__, _("msg=<range error>")));
    2362       return(SL_ERANGE);
     2411      SL_IRETURN((SL_ERANGE), _("sl_read_fast"));
    23632412    }
    23642413  if (buf_in == NULL)
    23652414    {
    23662415      TPT(( 0, FIL__, __LINE__, _("msg=<null buffer>")));
    2367       return (SL_ENULL);
     2416      SL_IRETURN((SL_ENULL), _("sl_read_fast"));
    23682417    }
    23692418
     
    23712420    {
    23722421      TPT(( 0, FIL__, __LINE__, _("msg=<ticket error> errno=<%d>"), fd));
    2373       return (fd);
     2422      SL_IRETURN((fd), _("sl_read_fast"));
    23742423    }
    23752424
     
    23812430      if (byteread >= 0)
    23822431        {
    2383           return (byteread);
     2432          SL_IRETURN((byteread), _("sl_read_fast"));
    23842433        } 
    23852434    } while ( byteread == -1 && (errno == EINTR || errno == EAGAIN));
     
    23892438    {
    23902439      TPT(( 0, FIL__, __LINE__, _("msg=<read error> errno=<%d>\n"), errno));
    2391       return (SL_EREAD);
    2392     }
    2393   return (0);
     2440      SL_IRETURN((SL_EREAD), _("sl_read_fast"));
     2441    }
     2442  SL_IRETURN((0), _("sl_read_fast"));
    23942443}
    23952444
Note: See TracChangeset for help on using the changeset viewer.