Changeset 192
- Timestamp:
- Nov 12, 2008, 12:37:00 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/aclocal.m4
r191 r192 1142 1142 if test $ssp_cv_cc = yes; then 1143 1143 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector" 1144 LDFLAGS="$LDFLAGS -fstack-protector" 1144 1145 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.]) 1145 1146 fi … … 1147 1148 if test $ssp_cv_cc = yes; then 1148 1149 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all" 1150 LDFLAGS="$LDFLAGS -fstack-protector-all" 1149 1151 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.]) 1150 1152 fi -
trunk/configure.ac
r191 r192 12 12 dnl start 13 13 dnl 14 AM_INIT_AUTOMAKE(samhain, 2.5. 0)14 AM_INIT_AUTOMAKE(samhain, 2.5.1) 15 15 AC_DEFINE([SAMHAIN], 1, [Application is samhain]) 16 16 AC_CANONICAL_HOST … … 88 88 *cygwin*) 89 89 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) 91 92 ;; 92 93 -
trunk/docs/Changelog
r191 r192 1 1 2.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 2 7 * constness patch by Joe MacDonald 3 8 * GnuPG key ID patch by Jim Dutton 9 * sh_kern.c: more error checking for reads from kernel 4 10 5 11 2.5.0 (01-11-2008): -
trunk/include/sh_cat.h
r185 r192 187 187 MSG_FI_NOGRP, 188 188 MSG_FI_NOUSR, 189 MSG_FI_ LSTAT,189 MSG_FI_STAT, 190 190 MSG_FI_OBSC, 191 191 MSG_FI_OBSC2, -
trunk/include/slib.h
r190 r192 108 108 #define SL_EBADNAME -1040 /* Invalid name. */ 109 109 #define SL_ESTAT -1041 /* stat of file failed. Check errno. */ 110 #define SL_EFSTAT -1042 /* fstat of file failed. Check errno. */ 110 111 111 112 #define SL_EBADUID -1050 /* Owner not trustworthy. */ … … 115 116 #define SL_TOOMANY -1053 /* Too many open files */ 116 117 #define SL_TIMEOUT -1054 /* Timeout in read */ 118 119 #define SL_EISDIR -1055 /* Is a directory */ 117 120 /* 118 121 * All int functions return SL_NONE on success. -
trunk/src/sh_cat.c
r185 r192 183 183 { MSG_FI_NOGRP, SH_ERR_ERR, FIL, N_("interface=\"getgrgid\" msg=\"No such group\" group=\"%ld\" path=\"%s\"")}, 184 184 { 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\"")}, 186 186 { MSG_FI_OBSC, SH_ERR_ERR, FIL, N_("msg=\"Weird filename\" path=\"%s\"")}, 187 187 { MSG_FI_OBSC2, SH_ERR_ERR, FIL, N_("msg=\"Weird filename\" path=\"%s/%s\"")}, … … 271 271 { MSG_E_HASH, SH_ERR_ERR, ERR, N_("msg=\"Incorrect checksum\" path=\"%s\"")}, 272 272 { 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\"")}, 274 274 { MSG_E_NOTREG, SH_ERR_ERR, ERR, N_("msg=\"Not a regular file\" path=\"%s\"")}, 275 275 { MSG_E_TIMEOUT, SH_ERR_ERR, ERR, N_("msg=\"Timeout (%d sec) while checksumming file\" path=\"%s\"")}, … … 512 512 { MSG_FI_NOGRP, SH_ERR_ERR, FIL, N_("msg=<No such group>, interface=<getgrgid>, group=<%ld>, path=<%s>")}, 513 513 { 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>")}, 515 515 { MSG_FI_OBSC, SH_ERR_ERR, FIL, N_("msg=<Weird filename>, path=<%s>")}, 516 516 { MSG_FI_OBSC2, SH_ERR_ERR, FIL, N_("msg=<Weird filename>, path=<%s/%s>")}, … … 599 599 { MSG_E_HASH, SH_ERR_ERR, ERR, N_("msg=<Incorrect checksum>, path=<%s>")}, 600 600 { 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>")}, 602 602 { MSG_E_NOTREG, SH_ERR_ERR, ERR, N_("msg=<Not a regular file>, path=<%s>")}, 603 603 { MSG_E_TIMEOUT, SH_ERR_ERR, ERR, N_("msg=<Timeout (%d sec) while checksumming file>, path=<%s>")}, -
trunk/src/sh_kern.c
r167 r192 487 487 if (kmap == MAP_FAILED) 488 488 { 489 memset(buf, '\0', len); 489 490 return -1; 490 491 } … … 593 594 (sh.flag.update == S_TRUE)) 594 595 { 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; 598 600 } 599 601 else 600 602 { 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; 604 607 } 605 608 } … … 621 624 622 625 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; 625 629 } 626 630 … … 633 637 if(status == 0) 634 638 { 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; 637 643 } 638 644 … … 643 649 if(status == 0) 644 650 { 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; 651 659 } 652 660 … … 654 662 * Write out data to the pipe 655 663 */ 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 675 684 _exit( (status >= 0) ? 0 : status); 676 685 } 677 678 686 679 687 struct sh_kernel_info { … … 693 701 int status; 694 702 long size; 703 int errcode; 695 704 696 705 /* Close reading side of pipe, and wait some milliseconds … … 699 708 retry_msleep (0, ShKernDelay); /* milliseconds */ 700 709 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; 705 712 else 706 713 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 } 707 727 708 728 if(status == 0) … … 1355 1375 if ( status < 0) 1356 1376 { 1377 char errmsg[SH_ERRBUF_SIZE]; 1378 sl_snprintf(errmsg, SH_ERRBUF_SIZE, 1379 _("error reading from /dev/kmem: %d"), status); 1357 1380 sh_error_handle ((-1), FIL__, __LINE__, status, MSG_E_SUBGEN, 1358 _("error reading from /dev/kmem"),1381 errmsg, 1359 1382 _("kern_check_internal") ); 1360 1383 SL_RETURN( (-1), _("sh_kern_check_internal")); -
trunk/src/sh_prelink.c
r160 r192 124 124 if (SL_ISERROR(ticket)) 125 125 { 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)); 126 130 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); 128 132 SH_FREE(tmp); 129 133 return; -
trunk/src/sh_tiger0.c
r171 r192 223 223 if (SL_ISERROR (count)) 224 224 { 225 int error = errno; 226 225 227 if (sig_termfast == 1) { 226 228 sh_unix_munlock((char *)buffer, (PRIV_MAX)*sizeof(sh_byte)); … … 239 241 } 240 242 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 } 243 251 SH_FREE(tmp); 244 252 memset (bbuf, 0, 64); … … 894 902 if (SL_ISERROR (n)) 895 903 { 904 int error = errno; 905 896 906 if (sig_termfast == 1) 897 907 { … … 909 919 } 910 920 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 } 913 929 SH_FREE(tmp); 914 930 *Length = 0; … … 1424 1440 if (SL_ISERROR (n)) 1425 1441 { 1442 int error = errno; 1443 1426 1444 if (sig_termfast == 1) 1427 1445 { … … 1441 1459 else 1442 1460 { 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)); 1443 1465 sh_error_handle (ShDFLevel[SH_ERR_T_FILE], FIL__, __LINE__, n, 1444 MSG_E_READ, tmp);1466 MSG_E_READ, errbuf, errbuf2, tmp); 1445 1467 } 1446 1468 SH_FREE(tmp); -
trunk/src/sh_unix.c
r185 r192 3281 3281 struct stat fbuf; 3282 3282 int stat_return; 3283 int stat_errno = 0; 3283 3284 3284 3285 ShFileType type; … … 3293 3294 3294 3295 SL_TICKET rval_open; 3296 int err_open = 0; 3297 3295 3298 int fd; 3296 3299 int fstat_return; 3300 int fstat_errno = 0; 3301 3297 3302 sh_string * content = NULL; 3298 3303 … … 3316 3321 path /* theFile->fullpath */, &buf); 3317 3322 3323 if (stat_return) 3324 stat_errno = errno; 3325 3318 3326 fd = -1; 3319 3327 fstat_return = -1; … … 3325 3333 { 3326 3334 rval_open = sl_open_fastread (path /* theFile->fullpath */, SL_YESPRIV); 3335 if (SL_ISERROR(rval_open)) 3336 err_open = errno; 3327 3337 3328 3338 alert_timeout = 120; /* this is per 8K block now ! */ … … 3352 3362 3353 3363 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 } 3355 3369 else 3356 fd = -1; 3370 { 3371 fd = -1; 3372 } 3357 3373 3358 3374 … … 3370 3386 if (S_FALSE == sh_ignore_chk_del(theFile->fullpath)) { 3371 3387 char errbuf[SH_ERRBUF_SIZE]; 3388 uid_t euid; 3389 (void) sl_get_euid(&euid); 3372 3390 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, 3375 3395 tmp2); 3376 3396 SH_FREE(tmp2); … … 3500 3520 */ 3501 3521 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 */ 3503 3523 { 3504 3524 uid_t euid; 3505 int fstat_errval = errno; 3525 3506 3526 if (fileHash != NULL) 3507 3527 sl_strlcpy(fileHash, SH_KEY_NULL, KEY_LEN+1); … … 3513 3533 if (fstat_return != 0) 3514 3534 { 3535 char errbuf[SH_ERRBUF_SIZE]; 3515 3536 (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); 3518 3543 } 3519 3544 else if (!S_ISREG(fbuf.st_mode)) 3520 3545 { 3521 sh_error_handle (level, FIL__, __LINE__, fstat_err val,3546 sh_error_handle (level, FIL__, __LINE__, fstat_errno, 3522 3547 MSG_E_NOTREG, tmp2); 3523 3548 } 3524 3549 else 3525 3550 { 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); 3528 3557 } 3529 3558 SH_FREE(tmp2); … … 3737 3766 if (stat_return != ENOENT) 3738 3767 { 3768 uid_t euid; 3739 3769 char errbuf[SH_ERRBUF_SIZE]; 3770 3771 (void) sl_get_euid(&euid); 3740 3772 sh_error_handle (level, FIL__, __LINE__, stat_return, 3741 MSG_FI_LSTAT, 3773 MSG_FI_STAT, 3774 _("lstat"), 3742 3775 sh_error_message (stat_return,errbuf, sizeof(errbuf)), 3776 (long) euid, 3743 3777 tmp2); 3744 3778 } -
trunk/src/slib.c
r190 r192 1700 1700 struct stat lbuf; 1701 1701 struct stat buf; 1702 int errval = 0; 1702 1703 int lstat_return; 1703 1704 int stat_return; … … 1750 1751 else 1751 1752 lstat_return = retry_lstat(FIL__, __LINE__, filename, &lbuf); 1753 errval = errno; 1752 1754 #ifdef USE_SUID 1753 1755 if (priv == SL_YESPRIV) … … 1759 1761 lstat_return = ENOENT; 1760 1762 if ( (mode == SL_OPEN_FOR_READ && lstat_return == ENOENT) || 1761 (err no!= ENOENT))1763 (errval != ENOENT)) 1762 1764 { 1763 1765 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")); 1766 1769 } 1767 1770 } … … 1770 1773 ( S_ISDIR(lbuf.st_mode) || (S_IWOTH & lbuf.st_mode) ) 1771 1774 ) 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 } 1774 1780 1775 1781 /* O_NOATIME has an effect for read(). But write() ?. … … 1780 1786 fd = aud_open_noatime (FIL__, __LINE__, priv, filename, 1781 1787 O_RDONLY|O_NONBLOCK, 0, &o_noatime); 1788 errval = errno; 1782 1789 if (fd >= 0) { 1783 1790 sflags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0); … … 1792 1799 fd = aud_open (FIL__, __LINE__, priv, filename, 1793 1800 O_WRONLY, open_mode); 1801 errval = errno; 1794 1802 break; 1795 1803 case SL_OPEN_SAFE_RDWR: 1796 1804 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 } 1799 1810 else 1800 SL_IRETURN(SL_EBADFILE, _("sl_open_file")); 1811 { 1812 errno = errval; 1813 SL_IRETURN(SL_EBADFILE, _("sl_open_file")); 1814 } 1801 1815 break; 1802 1816 case SL_OPEN_FOR_RDWR: 1803 1817 if (lstat_return == ENOENT) 1804 1805 1818 fd = aud_open (FIL__, __LINE__, priv, filename, 1819 O_RDWR|O_CREAT|O_EXCL, open_mode); 1806 1820 else 1807 1821 fd = aud_open (FIL__, __LINE__, priv, filename, 1808 1822 O_RDWR, open_mode); 1823 errval = errno; 1809 1824 break; 1810 1825 case SL_OPEN_FOR_WTRUNC: … … 1815 1830 fd = aud_open (FIL__, __LINE__, priv, filename, 1816 1831 O_WRONLY|O_TRUNC, open_mode); 1832 errval = errno; 1817 1833 break; 1818 1834 case SL_OPEN_FOR_RWTRUNC: … … 1823 1839 fd = aud_open (FIL__, __LINE__, priv, filename, 1824 1840 O_RDWR|O_TRUNC, open_mode); 1841 errval = errno; 1825 1842 break; 1826 1843 default: 1844 errno = 0; 1827 1845 SL_IRETURN(SL_EINTERNAL, _("sl_open_file")); 1828 1846 } … … 1831 1849 { 1832 1850 TPT(( 0, FIL__, __LINE__, _("msg=<Error opening: %s> errno=<%d>\n"), 1833 filename, errno)); 1851 filename, errval)); 1852 errno = errval; 1834 1853 SL_IRETURN(SL_EBADFILE, _("sl_open_file")); 1835 1854 } … … 1840 1859 #endif 1841 1860 stat_return = retry_fstat(FIL__, __LINE__, fd, &buf); 1861 errval = errno; 1842 1862 #ifdef USE_SUID 1843 1863 if (priv == SL_YESPRIV) … … 1848 1868 { 1849 1869 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; 1852 1875 1853 1876 if (lstat_return != ENOENT && buf.st_ino != lbuf.st_ino) … … 2221 2244 /* int sflags; */ 2222 2245 int retval; 2246 int error; 2223 2247 2224 2248 int byteread = 0; … … 2280 2304 else 2281 2305 { 2306 error = errno; 2282 2307 if (is_nonblocking == SL_FALSE) 2283 2308 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2284 2309 TPT(( 0, FIL__, __LINE__, _("msg=<read error>"))); 2310 errno = error; 2285 2311 return (SL_EREAD); 2286 2312 } … … 2299 2325 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2300 2326 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); 2327 errno = 0; 2301 2328 return (SL_TIMEOUT); 2302 2329 } 2303 2330 else 2304 2331 { 2332 error = errno; 2305 2333 if (is_nonblocking == SL_FALSE) 2306 2334 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2307 2335 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); 2336 errno = error; 2308 2337 return (SL_EREAD); 2309 2338 } … … 2314 2343 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2315 2344 TPT(( 0, FIL__, __LINE__, _("msg=<terminated>"))); 2345 errno = 0; 2316 2346 return (SL_EREAD); 2317 2347 } … … 2325 2355 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2326 2356 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); 2357 errno = 0; 2327 2358 return (SL_TIMEOUT); 2328 2359 } … … 2544 2575 char * sl_error_string(int errorcode) 2545 2576 { 2577 2546 2578 switch (errorcode) 2547 2579 { … … 2579 2611 case SL_EBADOTH: 2580 2612 return _("World writeable."); 2613 case SL_EISDIR: 2614 return _("Is a directory."); 2581 2615 case SL_EBADFILE: 2582 2616 return _("File access error."); … … 2588 2622 case SL_ESTAT: 2589 2623 return _("stat() failed."); 2624 case SL_EFSTAT: 2625 return _("fstat() failed."); 2590 2626 default: 2591 2627 return _("Unknown error."); -
trunk/src/trustfile.c
r183 r192 1008 1008 1009 1009 #ifdef TRUST_MAIN 1010 1011 #if defined(HOST_IS_CYGWIN) || defined(__cygwin__) || defined(__CYGWIN32__) || defined(__CYGWIN__) 1012 int main() 1013 { 1014 return 0; 1015 } 1016 #else 1010 1017 int main (int argc, char * argv[]) 1011 1018 { … … 1045 1052 } 1046 1053 #endif 1047 1048 1049 1054 #endif 1055 1056 1057
Note:
See TracChangeset
for help on using the changeset viewer.