Changeset 192


Ignore:
Timestamp:
Nov 12, 2008, 12:37:00 AM (16 years ago)
Author:
katerina
Message:

Fixes for cygwin, and improved error diagnostics (tickets #126, #127, #128).

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/aclocal.m4

    r191 r192  
    11421142      if test $ssp_cv_cc = yes; then
    11431143        CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector"
     1144        LDFLAGS="$LDFLAGS -fstack-protector"
    11441145        AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
    11451146      fi
     
    11471148      if test $ssp_cv_cc = yes; then
    11481149        CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all"
     1150        LDFLAGS="$LDFLAGS -fstack-protector-all"
    11491151        AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
    11501152      fi
  • trunk/configure.ac

    r191 r192  
    1212dnl start
    1313dnl
    14 AM_INIT_AUTOMAKE(samhain, 2.5.0)
     14AM_INIT_AUTOMAKE(samhain, 2.5.1)
    1515AC_DEFINE([SAMHAIN], 1, [Application is samhain])
    1616AC_CANONICAL_HOST
     
    8888        *cygwin*)
    8989        AC_DEFINE(HOST_IS_CYGWIN)
    90         AC_MSG_RESULT(CYGWIN do not check for trusted paths)
     90        dnmalloc_ok=no
     91        AC_MSG_RESULT(CYGWIN no trusted paths and no dnmalloc)
    9192        ;;
    9293
  • trunk/docs/Changelog

    r191 r192  
    112.5.1:
     2        * add -fstack-protector flags to LDFLAGS
     3        * cygwin fix: don't use dnmalloc, doesn't work with pthreads
     4        * cygwin fix: make trust check in samhain-install.sh return zero
     5        * improved diagnostics for file read errors
     6        * fixed script permissions (754 -> 755), reported by Christoph
    27        * constness patch by Joe MacDonald
    38        * GnuPG key ID patch by Jim Dutton
     9        * sh_kern.c: more error checking for reads from kernel
    410       
    5112.5.0 (01-11-2008):
  • trunk/include/sh_cat.h

    r185 r192  
    187187 MSG_FI_NOGRP,   
    188188 MSG_FI_NOUSR,   
    189  MSG_FI_LSTAT,   
     189 MSG_FI_STAT,   
    190190 MSG_FI_OBSC,     
    191191 MSG_FI_OBSC2,   
  • trunk/include/slib.h

    r190 r192  
    108108#define SL_EBADNAME  -1040     /* Invalid name.                        */
    109109#define SL_ESTAT     -1041     /* stat of file failed. Check errno.    */
     110#define SL_EFSTAT    -1042     /* fstat of file failed. Check errno.   */
    110111
    111112#define SL_EBADUID   -1050      /* Owner not trustworthy.              */
     
    115116#define SL_TOOMANY   -1053      /* Too many open files                 */
    116117#define SL_TIMEOUT   -1054      /* Timeout in read                     */
     118
     119#define SL_EISDIR    -1055      /* Is a directory                      */
    117120/*
    118121 * All int functions return SL_NONE on success.
  • trunk/src/sh_cat.c

    r185 r192  
    183183  { MSG_FI_NOGRP,    SH_ERR_ERR,     FIL,   N_("interface=\"getgrgid\" msg=\"No such group\" group=\"%ld\" path=\"%s\"")},
    184184  { MSG_FI_NOUSR,    SH_ERR_ERR,     FIL,   N_("interface=\"getpwuid\" msg=\"No such user\" userid=\"%ld\" path=\"%s\"")},
    185   { MSG_FI_LSTAT,    SH_ERR_ERR,     FIL,   N_("interface=\"lstat\" msg=\"%s\" path=\"%s\"")},
     185  { MSG_FI_STAT,     SH_ERR_ERR,     FIL,   N_("interface=\"%s\" msg=\"%s\" userid=\"%ld\" path=\"%s\"")},
    186186  { MSG_FI_OBSC,     SH_ERR_ERR,     FIL,   N_("msg=\"Weird filename\" path=\"%s\"")},
    187187  { MSG_FI_OBSC2,    SH_ERR_ERR,     FIL,   N_("msg=\"Weird filename\" path=\"%s/%s\"")},
     
    271271  { MSG_E_HASH,      SH_ERR_ERR,     ERR,   N_("msg=\"Incorrect checksum\" path=\"%s\"")},
    272272  { MSG_E_ACCESS,    SH_ERR_ERR,     ERR,   N_("msg=\"File not accessible\" userid=\"%ld\" path=\"%s\"")},
    273   { MSG_E_READ,      SH_ERR_ERR,     ERR,   N_("msg=\"Not accessible or not a regular file\" path=\"%s\"")},
     273  { MSG_E_READ,      SH_ERR_ERR,     ERR,   N_("msg=\"Not accessible or not a regular file (%s / %s)\" path=\"%s\"")},
    274274  { MSG_E_NOTREG,    SH_ERR_ERR,     ERR,   N_("msg=\"Not a regular file\" path=\"%s\"")},
    275275  { MSG_E_TIMEOUT,   SH_ERR_ERR,     ERR,   N_("msg=\"Timeout (%d sec) while checksumming file\" path=\"%s\"")},
     
    512512  { MSG_FI_NOGRP,    SH_ERR_ERR,     FIL,   N_("msg=<No such group>, interface=<getgrgid>, group=<%ld>, path=<%s>")},
    513513  { MSG_FI_NOUSR,    SH_ERR_ERR,     FIL,   N_("msg=<No such user>, interface=<getpwuid>, userid=<%ld>, path=<%s>")},
    514   { MSG_FI_LSTAT,    SH_ERR_ERR,     FIL,   N_("msg=<%s>, interface=<lstat>, path=<%s>")},
     514  { MSG_FI_STAT,     SH_ERR_ERR,     FIL,   N_("interface=<%s>, msg=<%s>, userid=<%ld>, path=<%s>")},
    515515  { MSG_FI_OBSC,     SH_ERR_ERR,     FIL,   N_("msg=<Weird filename>, path=<%s>")},
    516516  { MSG_FI_OBSC2,    SH_ERR_ERR,     FIL,   N_("msg=<Weird filename>, path=<%s/%s>")},
     
    599599  { MSG_E_HASH,      SH_ERR_ERR,     ERR,   N_("msg=<Incorrect checksum>, path=<%s>")},
    600600  { MSG_E_ACCESS,    SH_ERR_ERR,     ERR,   N_("msg=<File not accessible>, userid=<%ld>, path=<%s>")},
    601   { MSG_E_READ,      SH_ERR_ERR,     ERR,   N_("msg=<Not accessible or not a regular file>, path=<%s>")},
     601  { MSG_E_READ,      SH_ERR_ERR,     ERR,   N_("msg=<Not accessible or not a regular file (%s / %s)>, path=<%s>")},
    602602  { MSG_E_NOTREG,    SH_ERR_ERR,     ERR,   N_("msg=<Not a regular file>, path=<%s>")},
    603603  { MSG_E_TIMEOUT,   SH_ERR_ERR,     ERR,   N_("msg=<Timeout (%d sec) while checksumming file>, path=<%s>")},
  • trunk/src/sh_kern.c

    r167 r192  
    487487  if (kmap == MAP_FAILED)
    488488    {
     489      memset(buf, '\0', len);
    489490      return -1;
    490491    }
     
    593594              (sh.flag.update == S_TRUE))
    594595            {
    595               sh_kern_read_data (kd, kmem_call_table[j],
    596                                  (unsigned char *) &(kmem_code_table[j][0]),
    597                                  2 * sizeof(unsigned int));
     596              if (sh_kern_read_data (kd, kmem_call_table[j],
     597                                     (unsigned char *) &(kmem_code_table[j][0]),
     598                                     2 * sizeof(unsigned int)))
     599                status = -3;
    598600            }
    599601          else
    600602            {
    601               sh_kern_read_data (kd, sh_syscalls[j].addr,
    602                                  (unsigned char *) &(kmem_code_table[j][0]),
    603                                  2 * sizeof(unsigned int));
     603              if (sh_kern_read_data (kd, sh_syscalls[j].addr,
     604                                     (unsigned char *) &(kmem_code_table[j][0]),
     605                                     2 * sizeof(unsigned int)))
     606                status = -4;
    604607            }
    605608        }
     
    621624     
    622625      memset(sh_idt_table, '\0', SH_MAXIDT*8);
    623       sh_kern_read_data (kd, idt_addr,
    624                          (unsigned char *) sh_idt_table, idt_size*8);
     626      if (sh_kern_read_data (kd, idt_addr,
     627                             (unsigned char *) sh_idt_table, idt_size*8))
     628        status = -5;
    625629    }
    626630
     
    633637  if(status == 0)
    634638    {
    635       sh_kern_read_data (kd, system_call_addr,
    636                          (unsigned char *) new_system_call_code, SH_KERN_SCC);
     639      if (sh_kern_read_data (kd, system_call_addr,
     640                             (unsigned char *) new_system_call_code,
     641                             SH_KERN_SCC))
     642        status = -6;
    637643    }
    638644 
     
    643649  if(status == 0)
    644650    {
    645       sh_kern_read_data (kd, proc_root,
    646                          (unsigned char *) &proc_root_dir,
    647                          sizeof(proc_root_dir));
    648       sh_kern_read_data (kd, proc_root_iops,
    649                          (unsigned char *) &proc_root_inode,
    650                          sizeof(proc_root_inode));
     651      if (sh_kern_read_data (kd, proc_root,
     652                             (unsigned char *) &proc_root_dir,
     653                             sizeof(proc_root_dir)))
     654        status = -7;
     655      if (sh_kern_read_data (kd, proc_root_iops,
     656                             (unsigned char *) &proc_root_inode,
     657                             sizeof(proc_root_inode)))
     658        status = -8;
    651659    }
    652660 
     
    654662   * Write out data to the pipe
    655663   */
    656   if(status == 0)
    657     {
    658       status = write(mpipe[1], &kmem_call_table, sizeof(kmem_call_table));
    659 
    660       if(status > 0)
    661         status = write(mpipe[1], &kmem_code_table, sizeof(kmem_code_table));
    662 
    663       if(status > 0)
    664         status = write(mpipe[1], &sh_idt_table, sizeof(sh_idt_table));
    665 
    666       if(status > 0)
    667         status = write(mpipe[1], new_system_call_code, SH_KERN_SCC);
    668 
    669       if(status > 0)
    670         status = write(mpipe[1], &proc_root_dir, sizeof(proc_root_dir));
    671 
    672       if(status > 0)
    673         status = write(mpipe[1], &proc_root_inode, sizeof(proc_root_inode));
    674     }
     664  status = write(mpipe[1], &status, sizeof(int));
     665
     666  if (status > 0)
     667    status = write(mpipe[1], &kmem_call_table, sizeof(kmem_call_table));
     668 
     669  if(status > 0)
     670    status = write(mpipe[1], &kmem_code_table, sizeof(kmem_code_table));
     671 
     672  if(status > 0)
     673    status = write(mpipe[1], &sh_idt_table, sizeof(sh_idt_table));
     674 
     675  if(status > 0)
     676    status = write(mpipe[1], new_system_call_code, SH_KERN_SCC);
     677 
     678  if(status > 0)
     679    status = write(mpipe[1], &proc_root_dir, sizeof(proc_root_dir));
     680 
     681  if(status > 0)
     682    status = write(mpipe[1], &proc_root_inode, sizeof(proc_root_inode));
     683
    675684  _exit( (status >= 0) ? 0 : status);
    676685}
    677 
    678686
    679687struct sh_kernel_info {
     
    693701  int  status;
    694702  long size;
     703  int  errcode;
    695704
    696705  /* Close reading side of pipe, and wait some milliseconds
     
    699708  retry_msleep (0, ShKernDelay); /* milliseconds */
    700709
    701   size = SH_KERN_SIZ * sizeof(unsigned long);
    702 
    703   if (size != read(mpipe[0], &(kinfo->kmem_call_table), size))
    704     status = -4;
     710  if (sizeof(int) != read(mpipe[0], &errcode, sizeof(int)))
     711    status = -3;
    705712  else
    706713    status = 0;
     714
     715  if (errcode)
     716    status = errcode - 100;
     717
     718  if(status == 0)
     719    {
     720      size = SH_KERN_SIZ * sizeof(unsigned long);
     721
     722      if (size != read(mpipe[0], &(kinfo->kmem_call_table), size))
     723        status = -4;
     724      else
     725        status = 0;
     726    }
    707727
    708728  if(status == 0)
     
    13551375  if ( status < 0)
    13561376    {
     1377      char errmsg[SH_ERRBUF_SIZE];
     1378      sl_snprintf(errmsg, SH_ERRBUF_SIZE,
     1379                  _("error reading from /dev/kmem: %d"), status);
    13571380      sh_error_handle ((-1), FIL__, __LINE__, status, MSG_E_SUBGEN,
    1358                        _("error reading from /dev/kmem"),
     1381                       errmsg,
    13591382                       _("kern_check_internal") );
    13601383      SL_RETURN( (-1), _("sh_kern_check_internal"));
  • trunk/src/sh_prelink.c

    r160 r192  
    124124  if (SL_ISERROR(ticket))
    125125    {
     126      char errbuf[SH_ERRBUF_SIZE];
     127      char errbuf2[SH_ERRBUF_SIZE];
     128      sh_error_message(errno, errbuf2, sizeof(errbuf2));
     129      sl_strlcpy(errbuf, sl_error_string(ticket), sizeof(errbuf));
    126130      tmp = sh_util_safe_name (task->command);
    127       sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, ticket, MSG_E_READ, tmp);
     131      sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, ticket, MSG_E_READ, errbuf, errbuf2, tmp);
    128132      SH_FREE(tmp);
    129133      return;
  • trunk/src/sh_tiger0.c

    r171 r192  
    223223        if (SL_ISERROR (count))
    224224          {
     225            int error = errno;
     226
    225227            if (sig_termfast == 1) {
    226228              sh_unix_munlock((char *)buffer, (PRIV_MAX)*sizeof(sh_byte));
     
    239241              }
    240242            else
    241               sh_error_handle (ShDFLevel[SH_ERR_T_FILE], FIL__, __LINE__,
    242                                count, MSG_E_READ, tmp);
     243              {
     244                char errbuf[SH_ERRBUF_SIZE];
     245                char errbuf2[SH_ERRBUF_SIZE];
     246                sl_strlcpy(errbuf, sl_error_string(count), sizeof(errbuf));
     247                sh_error_message(error, errbuf2, sizeof(errbuf2));
     248                sh_error_handle (ShDFLevel[SH_ERR_T_FILE], FIL__, __LINE__,
     249                                 count, MSG_E_READ, errbuf, errbuf2, tmp);
     250              }
    243251            SH_FREE(tmp);
    244252            memset (bbuf,   0, 64);
     
    894902      if (SL_ISERROR (n))
    895903        {
     904          int error = errno;
     905
    896906          if (sig_termfast == 1)
    897907            {
     
    909919            }
    910920          else
    911             sh_error_handle (ShDFLevel[SH_ERR_T_FILE], FIL__, __LINE__, n,
    912                              MSG_E_READ, tmp);
     921            {
     922              char errbuf[SH_ERRBUF_SIZE];
     923              char errbuf2[SH_ERRBUF_SIZE];
     924              sl_strlcpy(errbuf, sl_error_string(n), sizeof(errbuf));
     925              sh_error_message(error, errbuf2, sizeof(errbuf2));
     926              sh_error_handle (ShDFLevel[SH_ERR_T_FILE], FIL__, __LINE__, n,
     927                               MSG_E_READ, errbuf, errbuf2, tmp);
     928            }
    913929          SH_FREE(tmp);
    914930          *Length = 0;
     
    14241440      if (SL_ISERROR (n))
    14251441        {
     1442          int error = errno;
     1443
    14261444          if (sig_termfast == 1)
    14271445            {
     
    14411459          else
    14421460            {
     1461              char errbuf[SH_ERRBUF_SIZE];
     1462              char errbuf2[SH_ERRBUF_SIZE];
     1463              sl_strlcpy(errbuf, sl_error_string(n), sizeof(errbuf));
     1464              sh_error_message(error, errbuf2, sizeof(errbuf2));
    14431465              sh_error_handle (ShDFLevel[SH_ERR_T_FILE], FIL__, __LINE__, n,
    1444                                MSG_E_READ, tmp);
     1466                               MSG_E_READ, errbuf, errbuf2, tmp);
    14451467            }
    14461468          SH_FREE(tmp);
  • trunk/src/sh_unix.c

    r185 r192  
    32813281  struct stat   fbuf;
    32823282  int           stat_return;
     3283  int           stat_errno = 0;
    32833284
    32843285  ShFileType    type;
     
    32933294
    32943295  SL_TICKET     rval_open;
     3296  int           err_open = 0;
     3297
    32953298  int           fd;
    32963299  int           fstat_return;
     3300  int           fstat_errno = 0;
     3301
    32973302  sh_string   * content = NULL;
    32983303     
     
    33163321                             path /* theFile->fullpath */, &buf);
    33173322
     3323  if (stat_return)
     3324    stat_errno = errno;
     3325
    33183326  fd           = -1;
    33193327  fstat_return = -1;
     
    33253333    {
    33263334      rval_open = sl_open_fastread (path /* theFile->fullpath */, SL_YESPRIV);
     3335      if (SL_ISERROR(rval_open))
     3336        err_open = errno;
    33273337
    33283338      alert_timeout = 120; /* this is per 8K block now ! */
     
    33523362
    33533363  if (fd >= 0)
    3354     fstat_return = retry_fstat (FIL__, __LINE__, fd, &fbuf);
     3364    {
     3365      fstat_return = retry_fstat (FIL__, __LINE__, fd, &fbuf);
     3366      if (fstat_return)
     3367        fstat_errno = errno;
     3368    }
    33553369  else
    3356     fd = -1;
     3370    {
     3371      fd = -1;
     3372    }
    33573373     
    33583374
     
    33703386          if (S_FALSE == sh_ignore_chk_del(theFile->fullpath)) {
    33713387            char errbuf[SH_ERRBUF_SIZE];
     3388            uid_t euid;
     3389            (void) sl_get_euid(&euid);
    33723390            tmp2 = sh_util_safe_name (theFile->fullpath);
    3373             sh_error_handle (level, FIL__, __LINE__, stat_return, MSG_FI_LSTAT,
    3374                              sh_error_message (stat_return, errbuf, sizeof(errbuf)),
     3391            sh_error_handle (level, FIL__, __LINE__, stat_return, MSG_FI_STAT,
     3392                             _("lstat"),
     3393                             sh_error_message (stat_errno, errbuf, sizeof(errbuf)),
     3394                             (long) euid,
    33753395                             tmp2);
    33763396            SH_FREE(tmp2);
     
    35003520   */
    35013521
    3502   else    /* fstat_return != 0 or !S_ISREG(fbuf.st_mode) */
     3522  else    /* fstat_return != 0 or !S_ISREG(fbuf.st_mode) or open() failed */
    35033523    {
    35043524      uid_t   euid;
    3505       int fstat_errval = errno;
     3525
    35063526      if (fileHash != NULL)
    35073527        sl_strlcpy(fileHash, SH_KEY_NULL, KEY_LEN+1);
     
    35133533          if (fstat_return != 0)
    35143534            {
     3535              char errbuf[SH_ERRBUF_SIZE];
    35153536              (void) sl_get_euid(&euid);
    3516               sh_error_handle (level, FIL__, __LINE__, fstat_errval,
    3517                                MSG_E_ACCESS, (long) euid, tmp2);
     3537
     3538              sh_error_handle (level, FIL__, __LINE__, stat_return, MSG_FI_STAT,
     3539                               _("fstat"),
     3540                               sh_error_message (fstat_errno, errbuf, sizeof(errbuf)),
     3541                               (long) euid,
     3542                               tmp2);
    35183543            }
    35193544          else if (!S_ISREG(fbuf.st_mode))
    35203545            {
    3521               sh_error_handle (level, FIL__, __LINE__, fstat_errval,
     3546              sh_error_handle (level, FIL__, __LINE__, fstat_errno,
    35223547                               MSG_E_NOTREG, tmp2);
    35233548            }
    35243549          else
    35253550            {
    3526               sh_error_handle (level, FIL__, __LINE__, fstat_errval,
    3527                                MSG_E_READ, tmp2);
     3551              char errbuf[SH_ERRBUF_SIZE];
     3552              char errbuf2[SH_ERRBUF_SIZE];
     3553              sl_strlcpy(errbuf, sl_error_string(rval_open), sizeof(errbuf));
     3554              sh_error_message(err_open, errbuf2, sizeof(errbuf2));
     3555              sh_error_handle (level, FIL__, __LINE__, err_open,
     3556                               MSG_E_READ, errbuf, errbuf2, tmp2);
    35283557            }
    35293558          SH_FREE(tmp2);
     
    37373766          if (stat_return != ENOENT)
    37383767            {
     3768              uid_t euid;
    37393769              char errbuf[SH_ERRBUF_SIZE];
     3770
     3771              (void) sl_get_euid(&euid);
    37403772              sh_error_handle (level, FIL__, __LINE__, stat_return,
    3741                                MSG_FI_LSTAT,
     3773                               MSG_FI_STAT,
     3774                               _("lstat"),
    37423775                               sh_error_message (stat_return,errbuf, sizeof(errbuf)),
     3776                               (long) euid,
    37433777                               tmp2);
    37443778            }
  • trunk/src/slib.c

    r190 r192  
    17001700  struct stat   lbuf;
    17011701  struct stat   buf;
     1702  int           errval = 0;
    17021703  int           lstat_return;
    17031704  int           stat_return;
     
    17501751  else
    17511752    lstat_return = retry_lstat(FIL__, __LINE__, filename, &lbuf);
     1753  errval = errno;
    17521754#ifdef USE_SUID
    17531755  if (priv == SL_YESPRIV)
     
    17591761      lstat_return = ENOENT;
    17601762      if ( (mode == SL_OPEN_FOR_READ && lstat_return == ENOENT) ||
    1761            (errno != ENOENT))
     1763           (errval != ENOENT))
    17621764        {
    17631765          TPT(( 0, FIL__, __LINE__, _("msg=<lstat: %s> errno=<%d>\n"),
    1764             filename, errno));
    1765           SL_IRETURN(SL_EBADFILE, _("sl_open_file"));
     1766            filename, errval));
     1767          errno = errval;
     1768          SL_IRETURN(SL_ESTAT, _("sl_open_file"));
    17661769        }
    17671770    }
     
    17701773       ( S_ISDIR(lbuf.st_mode) || (S_IWOTH & lbuf.st_mode) )
    17711774      )
    1772     SL_IRETURN(SL_EBADFILE, _("sl_open_file"));
    1773 
     1775    {
     1776      int retval = S_ISDIR(lbuf.st_mode) ? SL_EISDIR : SL_EBADOTH;
     1777      errno = 0;
     1778      SL_IRETURN(retval, _("sl_open_file"));
     1779    }
    17741780   
    17751781  /* O_NOATIME has an effect for read(). But write() ?.
     
    17801786      fd = aud_open_noatime (FIL__, __LINE__, priv, filename,
    17811787                             O_RDONLY|O_NONBLOCK, 0, &o_noatime);
     1788      errval = errno;
    17821789      if (fd >= 0) {
    17831790        sflags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0);
     
    17921799        fd = aud_open (FIL__, __LINE__, priv, filename,
    17931800                       O_WRONLY,                   open_mode);
     1801      errval = errno;
    17941802      break;
    17951803    case SL_OPEN_SAFE_RDWR:
    17961804      if (lstat_return == ENOENT)
    1797         fd = aud_open (FIL__, __LINE__, priv, filename,
    1798                        O_RDWR|O_CREAT|O_EXCL,      open_mode);
     1805        {
     1806          fd = aud_open (FIL__, __LINE__, priv, filename,
     1807                         O_RDWR|O_CREAT|O_EXCL,      open_mode);
     1808          errval = errno;
     1809        }
    17991810      else
    1800         SL_IRETURN(SL_EBADFILE, _("sl_open_file"));
     1811        {
     1812          errno = errval;
     1813          SL_IRETURN(SL_EBADFILE, _("sl_open_file"));
     1814        }
    18011815      break;
    18021816    case SL_OPEN_FOR_RDWR:
    18031817      if (lstat_return == ENOENT)
    1804         fd = aud_open (FIL__, __LINE__, priv, filename,
    1805                       O_RDWR|O_CREAT|O_EXCL,      open_mode);
     1818        fd = aud_open (FIL__, __LINE__, priv, filename,
     1819                        O_RDWR|O_CREAT|O_EXCL,      open_mode);
    18061820      else
    18071821        fd = aud_open (FIL__, __LINE__, priv, filename,
    18081822                       O_RDWR,                     open_mode);
     1823      errval = errno;
    18091824      break;
    18101825    case SL_OPEN_FOR_WTRUNC:
     
    18151830        fd = aud_open (FIL__, __LINE__, priv, filename,
    18161831                       O_WRONLY|O_TRUNC,           open_mode);
     1832      errval = errno;
    18171833      break;
    18181834    case SL_OPEN_FOR_RWTRUNC:
     
    18231839        fd = aud_open (FIL__, __LINE__, priv, filename,
    18241840                       O_RDWR|O_TRUNC,             open_mode);
     1841      errval = errno;
    18251842      break;
    18261843    default:
     1844      errno = 0;
    18271845      SL_IRETURN(SL_EINTERNAL, _("sl_open_file"));
    18281846    }
     
    18311849    {
    18321850      TPT(( 0, FIL__, __LINE__, _("msg=<Error opening: %s> errno=<%d>\n"),
    1833             filename, errno));
     1851            filename, errval));
     1852      errno = errval;
    18341853      SL_IRETURN(SL_EBADFILE, _("sl_open_file"));
    18351854    }
     
    18401859#endif
    18411860  stat_return = retry_fstat(FIL__, __LINE__, fd, &buf);
     1861  errval = errno;
    18421862#ifdef USE_SUID
    18431863  if (priv == SL_YESPRIV)
     
    18481868    {
    18491869      close (fd);
    1850       SL_IRETURN(SL_EBADFILE, _("sl_open_file"));
    1851     }
     1870      errno = errval;
     1871      SL_IRETURN(SL_EFSTAT, _("sl_open_file"));
     1872    }
     1873
     1874  errno = 0;
    18521875
    18531876  if (lstat_return != ENOENT && buf.st_ino != lbuf.st_ino)
     
    22212244  /* int sflags; */
    22222245  int retval;
     2246  int error;
    22232247
    22242248  int    byteread = 0;
     
    22802304              else
    22812305                {
     2306                  error = errno;
    22822307                  if (is_nonblocking == SL_FALSE)
    22832308                      retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
    22842309                  TPT(( 0, FIL__, __LINE__, _("msg=<read error>")));
     2310                  errno = error;
    22852311                  return (SL_EREAD);
    22862312                }
     
    22992325              retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
    23002326          TPT(( 0, FIL__, __LINE__, _("msg=<timeout>")));
     2327          errno = 0;
    23012328          return (SL_TIMEOUT);
    23022329        }
    23032330      else
    23042331        {
     2332          error = errno;
    23052333          if (is_nonblocking == SL_FALSE)
    23062334              retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
    23072335          TPT(( 0, FIL__, __LINE__, _("msg=<timeout>")));
     2336          errno = error;
    23082337          return (SL_EREAD);
    23092338        }
     
    23142343              retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
    23152344          TPT(( 0, FIL__, __LINE__, _("msg=<terminated>")));
     2345          errno = 0;
    23162346          return (SL_EREAD);
    23172347        }
     
    23252355              retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags);
    23262356          TPT(( 0, FIL__, __LINE__, _("msg=<timeout>")));
     2357          errno = 0;
    23272358          return (SL_TIMEOUT);
    23282359        }
     
    25442575char * sl_error_string(int errorcode)
    25452576{
     2577
    25462578  switch (errorcode)
    25472579    {
     
    25792611    case SL_EBADOTH:
    25802612      return _("World writeable.");
     2613    case SL_EISDIR:
     2614      return _("Is a directory.");
    25812615    case SL_EBADFILE:
    25822616      return _("File access error.");
     
    25882622    case SL_ESTAT:
    25892623      return _("stat() failed.");
     2624    case SL_EFSTAT:
     2625      return _("fstat() failed.");
    25902626    default:
    25912627      return _("Unknown error.");
  • trunk/src/trustfile.c

    r183 r192  
    10081008
    10091009#ifdef TRUST_MAIN
     1010
     1011#if defined(HOST_IS_CYGWIN) || defined(__cygwin__) || defined(__CYGWIN32__) || defined(__CYGWIN__)
     1012int main()
     1013{
     1014  return 0;
     1015}
     1016#else
    10101017int main (int argc, char * argv[])
    10111018{
     
    10451052}
    10461053#endif
    1047 
    1048 
    1049 
     1054#endif
     1055
     1056
     1057
Note: See TracChangeset for help on using the changeset viewer.