Changeset 248 for trunk


Ignore:
Timestamp:
Sep 21, 2009, 8:23:56 PM (15 years ago)
Author:
katerina
Message:

Code to track down originating site for ticket #163.

Location:
trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r247 r248  
    1212dnl start
    1313dnl
    14 AM_INIT_AUTOMAKE(samhain, 2.5.9a)
     14AM_INIT_AUTOMAKE(samhain, 2.5.9b)
    1515AC_DEFINE([SAMHAIN], 1, [Application is samhain])
    1616AC_CANONICAL_HOST
  • trunk/docs/Changelog

    r247 r248  
     12.5.9b:
     2        * remove stale file record when creating handle, and raise diagnostic
     3          error to find origin of stale record
     4
    152.5.9a:
    26        * fixed a race condition in closing of file handles
  • trunk/include/slib.h

    r243 r248  
    327327   * ---------------------------------------------------------------- */
    328328
    329   SL_TICKET sl_make_ticket (int fd, const char * path);
    330 
     329#define SL_OFILE_SIZE 32
     330
     331  char * sl_check_stale();
     332
     333  SL_TICKET sl_make_ticket (const char * ofile, int oline,
     334                            int fd, const char * filename);
     335 
    331336  /* Open for writing.
    332337   */
    333   SL_TICKET  sl_open_write       (const char * fname, int priviledge_mode);
     338  SL_TICKET  sl_open_write       (const char * ofile, int oline,
     339                                  const char * fname, int priviledge_mode);
    334340
    335341  /* Open for reading.
    336342   */
    337   SL_TICKET  sl_open_read        (const char * fname, int priviledge_mode);
     343  SL_TICKET  sl_open_read        (const char * ofile, int oline,
     344                                  const char * fname, int priviledge_mode);
    338345
    339346  /* Drop from cach when closing
     
    343350  /* Open for reading w/minimum checking.
    344351   */
    345   SL_TICKET  sl_open_fastread    (const char * fname, int priviledge_mode);
     352  SL_TICKET  sl_open_fastread    (const char * ofile, int oline,
     353                                  const char * fname, int priviledge_mode);
    346354
    347355  /* Open for read and write.
    348356   */
    349   SL_TICKET  sl_open_rdwr        (const char * fname, int priviledge_mode);
     357  SL_TICKET  sl_open_rdwr        (const char * ofile, int oline,
     358                                  const char * fname, int priviledge_mode);
    350359
    351360  /* Open for read and write, fail if file exists.
    352361   */
    353   SL_TICKET sl_open_safe_rdwr    (const char * fname, int priv);
     362  SL_TICKET sl_open_safe_rdwr    (const char * ofile, int oline,
     363                                  const char * fname, int priv);
    354364
    355365  /* Open for write, truncate.
    356366   */
    357   SL_TICKET  sl_open_write_trunc (const char * fname, int priviledge_mode);
     367  SL_TICKET  sl_open_write_trunc (const char * ofile, int oline,
     368                                  const char * fname, int priviledge_mode);
    358369
    359370  /* Open for read and write, truncate.
    360371   */
    361   SL_TICKET  sl_open_rdwr_trunc  (const char * fname, int priviledge_mode);
     372  SL_TICKET  sl_open_rdwr_trunc  (const char * ofile, int oline,
     373                                  const char * fname, int priviledge_mode);
    362374
    363375  /* Initialize the content sh_string.
  • trunk/src/bignum.c

    r1 r248  
    926926    if (a->sign == BIG_SIGN_MINUS)
    927927    {
    928         *n = -*n;;
     928      *n = -*n;;
    929929    }
    930930    return FALSE;
  • trunk/src/cutest_sh_tiger0.c

    r170 r248  
    159159  CuAssertStrEquals(tc, expected, actual);
    160160
    161   rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV);
     161  rval_open = sl_open_fastread (__FILE__, __LINE__, "cutest_foo", SL_YESPRIV);
    162162  CuAssertTrue(tc, rval_open >= 0);
    163163
     
    173173  CuAssertTrue(tc, result == 0);
    174174
    175   rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV);
     175  rval_open = sl_open_fastread (__FILE__, __LINE__, "cutest_foo", SL_YESPRIV);
    176176  CuAssertTrue(tc, rval_open >= 0);
    177177
     
    189189  CuAssertTrue(tc, result == 0);
    190190
    191   rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV);
     191  rval_open = sl_open_fastread (__FILE__, __LINE__, "cutest_foo", SL_YESPRIV);
    192192  CuAssertTrue(tc, rval_open >= 0);
    193193
     
    354354  CuAssertTrue(tc, result == 0);
    355355
    356   rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV);
     356  rval_open = sl_open_fastread (__FILE__, __LINE__, "cutest_foo", SL_YESPRIV);
    357357  CuAssertTrue(tc, rval_open >= 0);
    358358
  • trunk/src/cutest_slib.c

    r169 r248  
    55#include "CuTest.h"
    66#include "samhain.h"
     7
     8void Test_sl_stale (CuTest *tc) {
     9
     10  extern int get_the_fd (SL_TICKET ticket);
     11
     12  int       fd1, fd2, ret, line, val;
     13  SL_TICKET tfd1, tfd2;
     14  char *    err1;
     15  char      err2[128];
     16
     17  line = __LINE__; tfd1 = sl_open_read(__FILE__, __LINE__, "/etc/group", SL_NOPRIV);
     18  CuAssertTrue(tc, tfd1 > 0);
     19
     20  fd1 = get_the_fd(tfd1);
     21  CuAssertTrue(tc, fd1 >= 0);
     22
     23  ret = close(fd1);
     24  CuAssertTrue(tc, ret == 0);
     25
     26  tfd2 = sl_open_read(__FILE__, __LINE__, "/etc/group", SL_NOPRIV);
     27  CuAssertTrue(tc, tfd2 > 0);
     28  CuAssertTrue(tc, tfd2 != tfd1);
     29
     30  fd2 = get_the_fd(tfd2);
     31  CuAssertIntEquals(tc, fd1, fd2);
     32
     33  err1 = sl_check_stale();
     34  CuAssertTrue(tc, err1 != NULL);
     35
     36  sl_snprintf(err2, sizeof(err2),
     37              "stale handle, %s, %d", __FILE__, line);
     38  val = strcmp(err1, err2);
     39  CuAssertIntEquals(tc, 0, val);
     40}
    741
    842void Test_sl_snprintf (CuTest *tc) {
  • trunk/src/samhain.c

    r215 r248  
    20992099#endif
    21002100
     2101      {
     2102        char * stale = sl_check_stale();
     2103
     2104        if (stale)
     2105          {
     2106            sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, 0, MSG_E_SUBGEN,
     2107                            stale, _("sl_check_stale"));
     2108          }
     2109      }
     2110
    21012111      /* no loop if not daemon
    21022112       */
  • trunk/src/sh_err_log.c

    r212 r248  
    6969  /* open the file, then check it
    7070   */
    71   if ( SL_ISERROR(fd = sl_open_read (path, SL_NOPRIV)))
     71  if ( SL_ISERROR(fd = sl_open_read (FIL__, __LINE__, path, SL_NOPRIV)))
    7272    {
    7373      fprintf(stderr, _("Could not open file <%s>\n"), path);
     
    163163    }
    164164
    165   if ( SL_ISERROR(fd = sl_open_read (s, SL_NOPRIV)) )
     165  if ( SL_ISERROR(fd = sl_open_read (FIL__, __LINE__, s, SL_NOPRIV)) )
    166166    {
    167167      fprintf(stderr,
     
    540540  if (status == 0)
    541541    {
    542       fd = sl_open_write (logfile, SL_YESPRIV);
     542      fd = sl_open_write (FIL__, __LINE__, logfile, SL_YESPRIV);
    543543      if (SL_ISERROR(fd))
    544544        {
     
    761761  if (!sl_ok_adds(status, (2*KEY_LEN)) || !sl_ok_adds((2*KEY_LEN + status),32))
    762762    {
     763      sl_close(fd);
    763764      SL_RETURN ((-1), _("sh_log_file"));
    764765    }
  • trunk/src/sh_extern.c

    r247 r248  
    381381
    382382                  fd =
    383                     sl_open_read(task->command,
     383                    sl_open_read(FIL__, __LINE__, task->command,
    384384                                 task->privileged==0 ? SL_NOPRIV : SL_YESPRIV);
    385385
     
    389389                    {
    390390                      PDBGC_S("fexecve: checksum mismatch");
     391                      sl_close(fd);
    391392                      _exit(EXIT_FAILURE);
    392393                    }
     
    398399                  } while (val_return < 0 && errno == EINTR);
    399400                  pfd = val_return;
     401
     402                  sl_close(fd);
     403                  fd = -1;
     404
    400405                  if (pfd < 0)
    401406                    {
     
    403408                      _exit(EXIT_FAILURE);
    404409                    }
    405                   sl_close(fd);
    406                   fd = -1;
    407410                }
    408411#endif
     
    538541  PDBG_D(task->pipeFD);
    539542
    540   task->pipeTI = sl_make_ticket(task->pipeFD, _("pipe"));
     543  task->pipeTI = sl_make_ticket(FIL__, __LINE__, task->pipeFD, _("pipe"));
    541544
    542545  flags = (int) retry_fcntl (FIL__, __LINE__, task->pipeFD, F_GETFL, 0);
  • trunk/src/sh_forward.c

    r225 r248  
    31333133              if (conn != NULL && conn->FileName != NULL)
    31343134                {
    3135                   sfd = sl_open_read(conn->FileName, SL_YESPRIV);
     3135                  sfd = sl_open_read(FIL__, __LINE__,
     3136                                     conn->FileName, SL_YESPRIV);
    31363137                  if (!SL_ISERROR(sfd))
    31373138                    {
     
    32293230                {
    32303231                  bytes = -1;
    3231                   sfd = sl_open_read(conn->FileName, SL_YESPRIV);
     3232                  sfd = sl_open_read(FIL__, __LINE__,
     3233                                     conn->FileName, SL_YESPRIV);
    32323234                  if (!SL_ISERROR(sfd))
    32333235                    {
  • trunk/src/sh_gpg.c

    r247 r248  
    270270  char        pname[128];
    271271  int         pfd;
     272  int         val_return;
    272273#endif
    273274#endif
     
    534535       */
    535536#if defined(WITH_PGP)
    536       checkfd = sl_open_read(DEFAULT_PGP_PATH, SL_NOPRIV);
    537 #else
    538       checkfd = sl_open_read(DEFAULT_GPG_PATH, SL_NOPRIV);
     537      checkfd = sl_open_read(FIL__, __LINE__, DEFAULT_PGP_PATH, SL_NOPRIV);
     538#else
     539      checkfd = sl_open_read(FIL__, __LINE__, DEFAULT_GPG_PATH, SL_NOPRIV);
    539540#endif
    540541
    541542      if (0 != sh_gpg_checksum(checkfd, 0))
    542         aud__exit(FIL__, __LINE__, EXIT_FAILURE);
     543        {
     544          sl_close(checkfd);
     545          aud__exit(FIL__, __LINE__, EXIT_FAILURE);
     546        }
    543547
    544548      pfd = get_the_fd(checkfd);
     549      do {
     550        val_return = dup (pfd);
     551      } while (val_return < 0 && errno == EINTR);
     552      pfd = val_return;
     553      sl_close(checkfd);
     554      checkfd = -1;
     555
    545556      sl_snprintf(pname, sizeof(pname), _("/proc/self/fd/%d"), pfd);
    546557      if (0 == access(pname, R_OK|X_OK))               /* flawfinder: ignore */
     
    559570      /* procfs not working, go ahead
    560571       */
    561       sl_close(checkfd);
    562       checkfd = -1;
    563572#endif
    564573
     
    576585        {
    577586#if defined(WITH_PGP)
    578           checkfd = sl_open_fastread(DEFAULT_PGP_PATH, SL_NOPRIV);
    579 #else
    580           checkfd = sl_open_fastread(DEFAULT_GPG_PATH, SL_NOPRIV);
     587          checkfd = sl_open_fastread(FIL__, __LINE__, DEFAULT_PGP_PATH, SL_NOPRIV);
     588#else
     589          checkfd = sl_open_fastread(FIL__, __LINE__, DEFAULT_GPG_PATH, SL_NOPRIV);
    581590#endif
    582591          if (0 != sh_gpg_checksum(checkfd, 0)) {
     
    685694
    686695#ifdef HAVE_GPG_CHECKSUM
    687   checkfd = sl_open_read(DEFAULT_GPG_PATH, SL_YESPRIV);
     696  checkfd = sl_open_read(FIL__, __LINE__, DEFAULT_GPG_PATH, SL_YESPRIV);
    688697
    689698  if (0 != sh_gpg_checksum(checkfd, 1))
     
    716725
    717726#ifdef HAVE_GPG_CHECKSUM
    718   checkfd = sl_open_read(DEFAULT_PGP_PATH, SL_YESPRIV);
     727  checkfd = sl_open_read(FIL__, __LINE__, DEFAULT_PGP_PATH, SL_YESPRIV);
    719728
    720729  if (0 != sh_gpg_checksum(checkfd, 1))
  • trunk/src/sh_hash.c

    r247 r248  
    11911191    if (fd == (-1))
    11921192      {
    1193         if ( SL_ISERROR(fd = sl_open_read(file_path('D', 'R'), SL_YESPRIV)))
     1193        if ( SL_ISERROR(fd = sl_open_read(FIL__, __LINE__,
     1194                                          file_path('D', 'R'), SL_YESPRIV)))
    11941195          {
    11951196            TPT(( 0, FIL__, __LINE__, _("msg=<Error opening: %s>\n"),
     
    15481549      if (pushdata_stdout == S_FALSE && pushdata_fd == -1)
    15491550        {
    1550           if ( SL_ISERROR(pushdata_fd = sl_open_write(file_path('D', 'W'), SL_YESPRIV)))
     1551          if ( SL_ISERROR(pushdata_fd = sl_open_write(FIL__, __LINE__,
     1552                                                      file_path('D', 'W'),
     1553                                                      SL_YESPRIV)))
    15511554            {
    15521555              SH_FREE(fullpath);
     
    15721575              SH_FREE(linkpath);
    15731576              sh_error_handle((-1), FIL__, __LINE__, status, MSG_E_SUBGPATH,
    1574                               _("Failed to seek to end of baseline database"), _("sh_hash_pushdata_int"),
     1577                              _("Failed to seek to end of baseline database"),
     1578                              _("sh_hash_pushdata_int"),
    15751579                              file_path('D', 'W'));
    15761580              aud_exit(FIL__, __LINE__, EXIT_FAILURE);
     
    15831587        {
    15841588          TPT((0, FIL__, __LINE__, _("msg=<Update.>\n")))
    1585             if ( SL_ISERROR(pushdata_fd = sl_open_rdwr(file_path('D', 'W'), SL_YESPRIV))){
     1589            if ( SL_ISERROR(pushdata_fd = sl_open_rdwr(FIL__, __LINE__,
     1590                                                       file_path('D', 'W'),
     1591                                                       SL_YESPRIV))){
    15861592              SH_FREE(fullpath);
    15871593              SH_FREE(linkpath);
     
    40324038  line = SH_ALLOC(MAX_PATH_STORE+2);
    40334039
    4034   if ( SL_ISERROR(fd = sl_open_read(db_file, SL_YESPRIV)))
     4040  if ( SL_ISERROR(fd = sl_open_read(FIL__, __LINE__, db_file, SL_YESPRIV)))
    40354041    {
    40364042      fprintf(stderr, _("ERROR: can't open %s for read (errnum = %ld)\n"),
  • trunk/src/sh_html.c

    r170 r248  
    106106  if (p)
    107107    {
    108       fd = sl_open_read (p, SL_YESPRIV);
     108      fd = sl_open_read (FIL__, __LINE__, p, SL_YESPRIV);
    109109      SH_FREE(p);
    110110    }
     
    227227  if (p)
    228228    {
    229       fd = sl_open_read (p, SL_YESPRIV);
     229      fd = sl_open_read (FIL__, __LINE__, p, SL_YESPRIV);
    230230      SH_FREE(p);
    231231    }
     
    300300  if (p)
    301301    {
    302       fd = sl_open_read (p, SL_YESPRIV);
     302      fd = sl_open_read (FIL__, __LINE__, p, SL_YESPRIV);
    303303      SH_FREE(p);
    304304    }
     
    481481
    482482
    483   fd = sl_open_write_trunc (DEFAULT_HTML_FILE, SL_YESPRIV);
     483  fd = sl_open_write_trunc (FIL__, __LINE__, DEFAULT_HTML_FILE, SL_YESPRIV);
    484484
    485485  if (SL_ISERROR(fd))
  • trunk/src/sh_mail.c

    r240 r248  
    115115      _exit (EXIT_FAILURE);
    116116    }
    117   if ( SL_ISERROR(fd = sl_open_read (s, SL_NOPRIV)))
     117  if ( SL_ISERROR(fd = sl_open_read (FIL__, __LINE__, s, SL_NOPRIV)))
    118118    {
    119119      fprintf(stderr, _("Could not open file %s\n"), s);
  • trunk/src/sh_prelink.c

    r192 r248  
    120120      task->com_ti = -1;
    121121    }
    122   ticket = sl_open_read(task->command,
     122  ticket = sl_open_read(FIL__, __LINE__, task->command,
    123123                        task->privileged == 0 ? SL_NOPRIV : SL_YESPRIV);
    124124  if (SL_ISERROR(ticket))
  • trunk/src/sh_readconf.c

    r219 r248  
    407407          aud_exit (FIL__, __LINE__, EXIT_FAILURE);
    408408        }
    409       if (SL_ISERROR(fd = sl_open_read(file_path('C',local_flag),SL_YESPRIV)))
     409      if (SL_ISERROR(fd = sl_open_read(FIL__, __LINE__,
     410                                       file_path('C',local_flag),SL_YESPRIV)))
    410411        {
    411412          sl_get_euid(&euid);
     
    425426   */
    426427  sl_strlcpy(sh.conf.hash,
    427              sh_tiger_hash(file_path('C',local_flag), fd, TIGER_NOLIM, hashbuf, sizeof(hashbuf)),
     428             sh_tiger_hash(file_path('C',local_flag), fd, TIGER_NOLIM,
     429                           hashbuf, sizeof(hashbuf)),
    428430             KEY_LEN+1);
    429431  sl_rewind (fd);
  • trunk/src/sh_tiger0.c

    r192 r248  
    169169          TPT((0,FIL__, __LINE__, _("msg=<TIGER_FILE>, path=<%s>\n"),
    170170               (filename == NULL ? _("(null)") : filename) ));
    171           fd = sl_open_read (filename, SL_YESPRIV);
     171          fd = sl_open_read (FIL__, __LINE__, filename, SL_YESPRIV);
    172172        }
    173173
  • trunk/src/sh_tools.c

    r197 r248  
    17371737  } while (status == BAD);
    17381738
    1739   fd = sl_open_safe_rdwr (file, SL_YESPRIV);
     1739  fd = sl_open_safe_rdwr (FIL__, __LINE__, file, SL_YESPRIV);
    17401740  if (SL_ISERROR(fd))
    17411741    {
  • trunk/src/sh_unix.c

    r247 r248  
    34723472  if (stat_return == 0 && S_ISREG(buf.st_mode))
    34733473    {
    3474       rval_open = sl_open_fastread (path /* theFile->fullpath */, SL_YESPRIV);
     3474      rval_open = sl_open_fastread (FIL__, __LINE__,
     3475                                    path /* theFile->fullpath */, SL_YESPRIV);
    34753476      if (SL_ISERROR(rval_open))
    34763477        err_open = errno;
     
    41094110    }
    41104111
    4111   fd = sl_open_safe_rdwr (lockfile, SL_YESPRIV);       /* fails if file exists */
     4112  fd = sl_open_safe_rdwr (FIL__, __LINE__,
     4113                          lockfile, SL_YESPRIV);      /* fails if file exists */
    41124114
    41134115  if (!SL_ISERROR(fd))
     
    41984200  if (status >= 0)
    41994201    {
    4200        fd = sl_open_read (lockfile, SL_YESPRIV);
     4202       fd = sl_open_read (FIL__, __LINE__, lockfile, SL_YESPRIV);
    42014203       if (SL_ISERROR(fd))
    42024204         sh_error_handle ((-1), FIL__, __LINE__, fd,
  • trunk/src/sh_utils.c

    r226 r248  
    11701170  sl_snprintf (outpath, len, _("%s.out"), path);
    11711171
    1172   fp = sl_open_read(path, SL_NOPRIV);
     1172  fp = sl_open_read(FIL__, __LINE__, path, SL_NOPRIV);
    11731173  if (SL_ISERROR(fp))
    11741174    {
     
    11811181    }
    11821182 
    1183   fout = sl_open_write(outpath, SL_NOPRIV);
     1183  fout = sl_open_write(FIL__, __LINE__, outpath, SL_NOPRIV);
    11841184  if (SL_ISERROR(fout))
    11851185    {
  • trunk/src/slib.c

    r247 r248  
    15571557
    15581558typedef struct openfiles {
    1559   SL_TICKET ticket;     /* The unique  ID.      */
    1560   int fd;               /* The file descriptor. */
    1561   char * path;          /* The file path.       */
    1562   int flush;            /* Whether we want to flush the cache */
    1563   sh_string * content;  /* The file content     */
     1559  SL_TICKET ticket;          /* The unique  ID.      */
     1560  int fd;                    /* The file descriptor. */
     1561  char * path;               /* The file path.       */
     1562  int flush;                 /* Whether we want to flush the cache */
     1563  char ofile[SL_OFILE_SIZE]; /* origin file */
     1564  int  oline;                /* origin line */
     1565  sh_string * content;       /* The file content     */
    15641566} SL_OFILE;
    15651567
    15661568static SL_OFILE * ofiles[MAXFD];
    15671569
     1570static char stale_orig_file[64] = { '\0' };
     1571static int  stale_orig_line = -1;
     1572static char stale_orig_mesg[128];
     1573
    15681574SH_MUTEX_STATIC(mutex_ticket, PTHREAD_MUTEX_INITIALIZER);
    15691575
    15701576static unsigned int nonce_counter = TOFFSET;
     1577
     1578char * sl_check_stale()
     1579{
     1580  if (stale_orig_line == -1)
     1581    return NULL;
     1582  sl_snprintf(stale_orig_mesg, sizeof(stale_orig_mesg),
     1583              _("stale handle, %s, %d"), stale_orig_file, stale_orig_line);
     1584  stale_orig_file[0] = '\0';
     1585  stale_orig_line    = -1;
     1586  return stale_orig_mesg;
     1587}
    15711588
    15721589static
     
    16481665}
    16491666
    1650 SL_TICKET sl_make_ticket (int fd, const char * filename)
     1667SL_TICKET sl_make_ticket (const char * ofile, int oline,
     1668                          int fd, const char * filename)
    16511669{
    16521670  size_t    len;
     
    16601678     }
    16611679
    1662    if (ofiles[fd] != NULL)
    1663     {
    1664       SL_IRETURN(SL_EINTERNAL06, _("sl_make_ticket"));
     1680  if (ofiles[fd] != NULL) /* stale entry */
     1681    {
     1682      /* SL_IRETURN(SL_EINTERNAL06, _("sl_make_ticket")); */
     1683      sl_strlcpy(stale_orig_file, ofiles[fd]->ofile, sizeof(stale_orig_file));
     1684      stale_orig_line = ofiles[fd]->oline;
     1685
     1686      if (ofiles[fd]->content)
     1687        sh_string_destroy(&(ofiles[fd]->content));
     1688      (void) free (ofiles[fd]->path);
     1689      (void) free (ofiles[fd]);
     1690      ofiles[fd] = NULL;
    16651691    }
    16661692
     
    16961722  ofiles[fd]->content = NULL;
    16971723  ofiles[fd]->flush   = SL_FALSE;
     1724
     1725  sl_strlcpy(ofiles[fd]->ofile, ofile, SL_OFILE_SIZE);
     1726  ofiles[fd]->oline = oline;
    16981727
    16991728  SL_IRETURN(ticket, _("sl_make_ticket"));
     
    17261755
    17271756static
    1728 int sl_open_file (const char *filename, int mode, int priv)
     1757int sl_open_file (const char * ofile, int oline,
     1758                  const char *filename, int mode, int priv)
    17291759{
    17301760  struct stat   lbuf;
     
    19201950     }
    19211951
    1922    if (ofiles[fd] != NULL)
    1923     {
     1952  if (ofiles[fd] != NULL) /* stale entry */
     1953    {
     1954      /*
    19241955      close(fd);
    19251956      SL_IRETURN(SL_EINTERNAL09, _("sl_open_file"));
     1957      */
     1958      sl_strlcpy(stale_orig_file, ofiles[fd]->ofile, sizeof(stale_orig_file));
     1959      stale_orig_line = ofiles[fd]->oline;
     1960
     1961      if (ofiles[fd]->content)
     1962        sh_string_destroy(&(ofiles[fd]->content));
     1963      (void) free (ofiles[fd]->path);
     1964      (void) free (ofiles[fd]);
     1965      ofiles[fd] = NULL;
    19261966    }
    19271967
     
    19612001  ofiles[fd]->flush   = SL_FALSE;
    19622002
     2003  sl_strlcpy(ofiles[fd]->ofile, ofile, SL_OFILE_SIZE);
     2004  ofiles[fd]->oline = oline;
     2005
    19632006  SL_IRETURN(ticket, _("sl_open_file"));
    19642007}
     
    19712014    return (fd);
    19722015
    1973   if (ofiles[fd] == NULL || fd != ofiles[fd]->fd || fd < 0)
     2016  if (ofiles[fd] == NULL || fd != ofiles[fd]->fd ||
     2017      ticket != ofiles[fd]->ticket || fd < 0)
    19742018    return (SL_EINTERNAL10);
     2019
    19752020  return (fd);
    19762021}
     
    19872032}
    19882033 
    1989 SL_TICKET sl_open_write (const char * fname, int priv)
     2034SL_TICKET sl_open_write (const char * ofile, int oline,
     2035                         const char * fname, int priv)
    19902036{
    19912037  long status;
     
    19952041    SL_IRETURN(status, _("sl_open_write"));
    19962042
    1997   status = sl_open_file(fname, SL_OPEN_FOR_WRITE, priv);
     2043  status = sl_open_file(ofile, oline, fname, SL_OPEN_FOR_WRITE, priv);
    19982044  SL_IRETURN(status, _("sl_open_write"));
    19992045}
    20002046
    2001 SL_TICKET sl_open_read (const char * fname, int priv)
     2047SL_TICKET sl_open_read (const char * ofile, int oline,
     2048                        const char * fname, int priv)
    20022049{
    20032050  long status;
     
    20122059    }
    20132060
    2014   status = sl_open_file(fname, SL_OPEN_FOR_READ, priv);
     2061  status = sl_open_file(ofile, oline, fname, SL_OPEN_FOR_READ, priv);
    20152062  SL_IRETURN(status, _("sl_open_read"));
    20162063}
     
    20672114}
    20682115
    2069 SL_TICKET sl_open_fastread (const char * fname, int priv)
     2116SL_TICKET sl_open_fastread (const char * ofile, int oline,
     2117                            const char * fname, int priv)
    20702118{
    20712119  long status;
     
    20752123    SL_IRETURN(status, _("sl_open_read"));
    20762124
    2077   status = sl_open_file(fname, SL_OPEN_FOR_FASTREAD, priv);
     2125  status = sl_open_file(ofile, oline, fname, SL_OPEN_FOR_FASTREAD, priv);
    20782126
    20792127#if defined(HAVE_POSIX_FADVISE) && defined(HAVE_MINCORE) && defined(POSIX_FADV_DONTNEED)
     
    20942142}
    20952143
    2096 SL_TICKET sl_open_rdwr (const char * fname, int priv)
     2144SL_TICKET sl_open_rdwr (const char * ofile, int oline,
     2145                        const char * fname, int priv)
    20972146{
    20982147  long status;
     
    21022151    SL_IRETURN(status, _("sl_open_rdwr"));
    21032152
    2104   status = sl_open_file(fname, SL_OPEN_FOR_RDWR, priv);
     2153  status = sl_open_file(ofile, oline, fname, SL_OPEN_FOR_RDWR, priv);
    21052154  SL_IRETURN(status, _("sl_open_rdwr"));
    21062155}
    21072156
    2108 SL_TICKET sl_open_safe_rdwr (const char * fname, int priv)
     2157SL_TICKET sl_open_safe_rdwr (const char * ofile, int oline,
     2158                             const char * fname, int priv)
    21092159{
    21102160  long status;
     
    21142164    SL_IRETURN(status, _("sl_open_safe_rdwr"));
    21152165
    2116   status = sl_open_file(fname, SL_OPEN_SAFE_RDWR, priv);
     2166  status = sl_open_file(ofile, oline, fname, SL_OPEN_SAFE_RDWR, priv);
    21172167  SL_IRETURN(status, _("sl_open_safe_rdwr"));
    21182168}
    21192169
    2120 SL_TICKET sl_open_write_trunc (const char * fname, int priv)
     2170SL_TICKET sl_open_write_trunc (const char * ofile, int oline,
     2171                               const char * fname, int priv)
    21212172{
    21222173  long status;
     
    21262177    SL_IRETURN(status, _("sl_open_write_trunc"));
    21272178
    2128   status = sl_open_file(fname, SL_OPEN_FOR_WTRUNC, priv);
     2179  status = sl_open_file(ofile, oline, fname, SL_OPEN_FOR_WTRUNC, priv);
    21292180  SL_IRETURN(status, _("sl_open_write_trunc"));
    21302181}
    21312182
    2132 SL_TICKET sl_open_rdwr_trunc (const char * fname, int priv)
     2183SL_TICKET sl_open_rdwr_trunc (const char * ofile, int oline,
     2184                              const char * fname, int priv)
    21332185{
    21342186  long status;
     
    21382190    SL_IRETURN(status, _("sl_open_rdwr_trunc"));
    21392191
    2140   status = sl_open_file(fname, SL_OPEN_FOR_RWTRUNC, priv);
     2192  status = sl_open_file(ofile, oline, fname, SL_OPEN_FOR_RWTRUNC, priv);
    21412193  SL_IRETURN(status, _("sl_open_rdwr_trunc"));
    21422194}
     
    21502202    return (fd);
    21512203
    2152   if (ofiles[fd] == NULL || fd != ofiles[fd]->fd || fd < 0)
     2204  if (ofiles[fd] == NULL || fd != ofiles[fd]->fd ||
     2205      ticket != ofiles[fd]->ticket || fd < 0)
    21532206    return (SL_EINTERNAL12);
    21542207
     
    21672220    return (NULL);
    21682221
    2169   if (ofiles[fd] == NULL || fd != ofiles[fd]->fd || fd < 0)
     2222  if (ofiles[fd] == NULL || fd != ofiles[fd]->fd ||
     2223      ticket != ofiles[fd]->ticket || fd < 0)
    21702224    return (NULL);
    21712225
Note: See TracChangeset for help on using the changeset viewer.