- Timestamp:
- Mar 12, 2013, 9:42:07 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docs/Changelog
r427 r428 1 1 3.0.11: 2 * Propagate ERANGE error from getgrxxx_r (issue raised by C. Feikes) 2 3 * Fix reconnecting do database for Oracle 3 4 * Add better logrotate handling for the GrowingLogs policy (search -
trunk/include/slib.h
r412 r428 63 63 #define SL_FALSE 0 64 64 65 #define SH_GRBUF_SIZE 409666 #define SH_PWBUF_SIZE 409665 #define SH_GRBUF_SIZE 4096 66 #define SH_PWBUF_SIZE 32768 67 67 68 68 -
trunk/src/sh_static.c
r252 r428 76 76 77 77 #define PWD_BUFFER_SIZE 256 78 #define GRP_BUFFER_SIZE 256 78 #define GRP_BUFFER_SIZE 3584 79 #define GRP_BUFFER_SIZE_MALLOC 32768 79 80 80 81 /**********************************************************************/ … … 467 468 char **m; 468 469 struct group group; 469 char buff[PWD_BUFFER_SIZE]; 470 471 char * buff = malloc(GRP_BUFFER_SIZE_MALLOC); 470 472 471 473 rv = -1; … … 481 483 num_groups = 1; 482 484 483 while (!__pgsreader(__parsegrent, &group, buff, sizeof(buff), grf)) {485 while (!__pgsreader(__parsegrent, &group, buff, GRP_BUFFER_SIZE_MALLOC, grf)) { 484 486 assert(group.gr_mem); /* Must have at least a NULL terminator. */ 485 487 if (group.gr_gid != gid) { … … 511 513 * warnings from various malloc debuggers. */ 512 514 free(group_list); 515 free(buff); 513 516 return rv; 514 517 } … … 699 702 line_buff[line_len] = 0; 700 703 } else if (line_len + 2 == buflen) { /* line too long */ 704 rv = ERANGE; 705 break; 706 /* 701 707 ++skip; 702 708 continue; 709 */ 703 710 } 704 711 -
trunk/src/sh_unix.c
r425 r428 1007 1007 struct group * w; 1008 1008 gid_t gid = 0; 1009 int status = 0; 1009 1010 1010 1011 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) … … 1035 1036 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1036 1037 buffer = SH_ALLOC(SH_GRBUF_SIZE); 1037 s h_getgrnam_r(g, &grp, buffer, SH_GRBUF_SIZE, &w);1038 status = sh_getgrnam_r(g, &grp, buffer, SH_GRBUF_SIZE, &w); 1038 1039 #else 1040 errno = 0; 1039 1041 w = sh_getgrnam(g); 1040 #endif 1041 1042 if (w == NULL) 1042 status = errno; 1043 #endif 1044 1045 if ((status == ERANGE) && (w == NULL)) 1046 { 1047 static int seen = 0; 1048 1049 if (seen == 0) 1050 { 1051 char errbuf[SH_ERRBUF_SIZE]; 1052 1053 sh_error_handle (SH_ERR_ERR, FIL__, __LINE__, EINVAL, MSG_E_GRNULL, 1054 sh_error_message(status, errbuf, sizeof(errbuf)), 1055 _("sh_group_to_gid"), (long) -1, _("line too long in group entry")); 1056 ++seen; 1057 } 1058 *fail = -1; 1059 } 1060 else if (w == NULL) 1043 1061 { 1044 1062 char * tmp = sh_util_strdup(g); … … 2881 2899 #endif 2882 2900 2901 if (status == ERANGE) 2902 { 2903 static int seen = 0; 2904 2905 if (seen == 0) 2906 { 2907 sh_error_handle (SH_ERR_ERR, FIL__, __LINE__, EINVAL, MSG_E_GRNULL, 2908 sh_error_message(status, errbuf, sizeof(errbuf)), 2909 _("getgrgid"), (long) gid, _("line too long in group entry")); 2910 ++seen; 2911 } 2912 2913 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2914 SH_FREE(buffer); 2915 #endif 2916 2917 sh_userid_add(gid, NULL, CACHE_GID); 2918 SL_RETURN( NULL, _("sh_unix_getGIDname")); 2919 } 2920 2883 2921 if (tempres == NULL) 2884 2922 { -
trunk/src/trustfile.c
r230 r428 414 414 */ 415 415 /* not static to circumvent stupid gcc 4 bug */ 416 int isingrp(gid_t grp, uid_t *ulist )416 int isingrp(gid_t grp, uid_t *ulist, int * errval) 417 417 { 418 418 struct passwd *w; /* info about group member */ … … 420 420 register char **p; /* points to current group member */ 421 421 struct group *g; /* pointer to group information */ 422 423 int status; 422 424 423 425 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) … … 430 432 SL_ENTER(_("isingrp")); 431 433 434 *errval = 0; 435 432 436 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 433 437 buffer = malloc(SH_GRBUF_SIZE); 434 sh_getgrgid_r(grp, &gr, buffer, SH_GRBUF_SIZE, &g); 435 #else 438 status = sh_getgrgid_r(grp, &gr, buffer, SH_GRBUF_SIZE, &g); 439 #else 440 errno = 0; 436 441 g = sh_getgrgid(grp); 442 status = errno; 437 443 #endif 438 444 439 445 if (g == NULL) 440 446 { 447 if (status == ERANGE) 448 *errval = status; 449 441 450 goto end_false; 442 451 } … … 510 519 */ 511 520 /* not static to circumvent stupid gcc 4 bug */ 512 int onlytrustedingrp(gid_t grp, uid_t *ulist )521 int onlytrustedingrp(gid_t grp, uid_t *ulist, int * errval) 513 522 { 514 523 struct passwd *w; /* info about group member */ … … 518 527 register int flag = -1; /* group member found */ 519 528 529 int status; 530 520 531 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 521 532 struct group gr; … … 529 540 SL_ENTER(_("onlytrustedingrp")); 530 541 542 *errval = 0; 543 531 544 #ifdef TRUST_DEBUG 532 545 fprintf(stderr, "trustfile: group writeable, group_gid: %ld\n", … … 536 549 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 537 550 buffer = malloc(SH_GRBUF_SIZE); 538 sh_getgrgid_r(grp, &gr, buffer, SH_GRBUF_SIZE, &g); 539 #else 551 status = sh_getgrgid_r(grp, &gr, buffer, SH_GRBUF_SIZE, &g); 552 #else 553 errno = 0; 540 554 g = sh_getgrgid(grp); 555 status = errno; 541 556 #endif 542 557 543 558 if (g == NULL) 544 559 { 560 if (status == ERANGE) 561 *errval = status; 562 545 563 #ifdef TRUST_DEBUG 546 564 fprintf(stderr, … … 722 740 char c; /* used to hold temp char */ 723 741 742 int errgrp = 0; 743 724 744 SL_ENTER(_("sl_trustfile")); 725 745 if (fname == NULL) … … 1010 1030 */ 1011 1031 if (((stbuf.st_mode & S_IWGRP) == S_IWGRP) && 1012 ((okusers != NULL && !onlytrustedingrp((gid_t)stbuf.st_gid,okusers ))||1013 (badusers != NULL && isingrp((gid_t)stbuf.st_gid, badusers )))1032 ((okusers != NULL && !onlytrustedingrp((gid_t)stbuf.st_gid,okusers,&errgrp))|| 1033 (badusers != NULL && isingrp((gid_t)stbuf.st_gid, badusers,&errgrp))) 1014 1034 #ifdef STICKY 1015 1035 && ((stbuf.st_mode&S_IFDIR) != S_IFDIR || … … 1035 1055 tf_badgid = (gid_t) stbuf.st_gid; 1036 1056 free(fexp); 1037 SL_IRETURN( SL_EBADGID, _("sl_trustfile"));1057 SL_IRETURN((errgrp == ERANGE) ? SL_ERANGE : SL_EBADGID, _("sl_trustfile")); 1038 1058 } 1039 1059 /*
Note:
See TracChangeset
for help on using the changeset viewer.