- Timestamp:
- Oct 26, 2007, 12:20:10 AM (17 years ago)
- Location:
- trunk/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/samhain.c
r133 r134 138 138 #endif 139 139 140 #ifdef HAVE_PTHREAD 141 typedef struct gt { 142 size_t g_count; 143 char * g_glob; 144 }; 145 146 pthread_key_t g_key; 147 148 int sh_g_thread() 149 { 150 struct gt * ptr = malloc(sizeof(struct gt)); 151 if (!gt) 152 return -1; 153 ptr->g_count = 0; 154 ptr->g_glob = calloc(1, SH_MAX_GLOBS * (GLOB_LEN+1)); 155 if (!(ptr->g_glob)) 156 return -1; 157 return pthread_setspecific(g_key, ptr); 158 } 159 160 void sh_g_destroy(void * data) 161 { 162 struct gt * ptr = (struct gt *) data; 163 free(ptr->g_glob); 164 free(ptr); 165 return; 166 } 167 168 static void sh_g_init() 169 { 170 if (0 != pthread_key_create(&g_key, sh_g_destroy)) 171 { 172 perror("1"); 173 exit(EXIT_FAILURE); 174 } 175 176 if (0 != sh_g_thread()) 177 { 178 perror("1"); 179 exit(EXIT_FAILURE); 180 } 181 return; 182 } 183 #define SH_G_INIT sh_g_init() 184 #else 185 #define SH_G_INIT ((void)0) 186 #endif 187 140 188 char * globber(const char * str) 141 189 { … … 143 191 size_t j; 144 192 145 static size_t items = 0; 193 #ifdef HAVE_PTHREAD 194 struct gt * ptr = pthread_getspecific(g_key); 195 size_t count = ptr->g_count; 196 char * glob = ptr->g_glob; 197 #else 146 198 static size_t count = 0; 147 199 static char glob[SH_MAX_GLOBS * (GLOB_LEN+1)]; 200 # 148 201 149 202 if (str == NULL) … … 152 205 j = strlen(str); 153 206 154 ++items;155 156 207 ASSERT((j <= GLOB_LEN), _("j <= GLOB_LEN")) 157 208 … … 164 215 { 165 216 count = 0; 166 items = 0;167 217 } 168 218 … … 177 227 178 228 i = count; 229 #ifdef HAVE_PTHREAD 230 ptr->count = count + j + 1; 231 #else 179 232 count = count + j + 1; 233 #endif 180 234 return &glob[i]; 181 235 } … … 1144 1198 char * my_argv[32]; 1145 1199 #endif 1200 1201 SH_G_INIT; /* Must precede any use of _() */ 1146 1202 1147 1203 SL_ENTER(_("main")); -
trunk/src/sh_calls.c
r132 r134 250 250 error = errno; 251 251 if (val_retry < 0) { 252 (void) s l_strlcpy(aud_err_message, sh_error_message(error, errbuf, sizeof(errbuf)), 64);252 (void) sh_error_message(error, aud_err_message, 64); 253 253 sh_error_handle ((-1), file, line, error, MSG_ERR_LSTAT, 254 254 sh_error_message(error, errbuf, sizeof(errbuf)), … … 273 273 error = errno; 274 274 if (val_retry < 0) { 275 (void) s l_strlcpy(aud_err_message, sh_error_message(error, errbuf, sizeof(errbuf)), 64);275 (void) sh_error_message(error, aud_err_message, 64); 276 276 sh_error_handle ((-1), file, line, error, MSG_ERR_STAT, 277 277 sh_error_message(error, errbuf, sizeof(errbuf)), … … 363 363 if (sec > 0) 364 364 { 365 sleep (sec); 365 sleep (sec); /* nanosleep not available */ 366 366 } 367 367 else … … 584 584 if (val_return < 0) 585 585 { 586 (void) s l_strlcpy(aud_err_message, sh_error_message(error, errbuf, sizeof(errbuf)), 64);586 (void) sh_error_message(error, aud_err_message, 64); 587 587 } 588 588 … … 618 618 if (val_return < 0) 619 619 { 620 (void) s l_strlcpy(aud_err_message, sh_error_message(error, errbuf, sizeof(errbuf)), 64);620 (void) sh_error_message(error, aud_err_message, 64); 621 621 } 622 622 -
trunk/src/sh_mail.c
r133 r134 2139 2139 #endif 2140 2140 } 2141 2142 SH_MUTEX_LOCK(mutex_resolv); 2141 2143 if (domain != NULL) 2142 2144 host = /*@-unrecog@*/sh_gethostbyname (domain)/*@+unrecog@*/; 2145 2146 if (host) 2147 { 2148 result = SH_ALLOC (sizeof (mx)); 2149 retval = SH_ALLOC (sizeof (dnsrep)); 2150 retval->reply = result; 2151 retval->count = 1; 2152 result->pref = 0; 2153 /*@-type@*/ 2154 len = strlen (host->h_name) + 1; 2155 result->address = SH_ALLOC (len); 2156 sl_strlcpy (result->address, host->h_name, len); 2157 /*@+type@*/ 2158 } 2159 SH_MUTEX_UNLOCK(mutex_resolv); 2160 2143 2161 if (!host) 2144 2162 { … … 2152 2170 SL_RETURN (NULL, _("return_mx")); 2153 2171 } 2154 result = SH_ALLOC (sizeof (mx)); 2155 retval = SH_ALLOC (sizeof (dnsrep)); 2156 retval->reply = result; 2157 retval->count = 1; 2158 result->pref = 0; 2159 /*@-type@*/ 2160 len = strlen (host->h_name) + 1; 2161 result->address = SH_ALLOC (len); 2162 sl_strlcpy (result->address, host->h_name, len); 2163 /*@+type@*/ 2172 2164 2173 SL_RETURN (retval, _("return_mx")); 2165 2174 } -
trunk/src/sh_mem.c
r22 r134 38 38 #include "sh_utils.h" 39 39 #include "sh_mem.h" 40 #include "sh_pthread.h" 40 41 41 42 extern int safe_logger (int signal, int method, char * details); … … 103 104 #endif 104 105 106 #ifdef HAVE_PTHREAD 107 static pthread_once_t mem_is_initialized = PTHREAD_ONCE_INIT; 108 static pthread_mutex_t mutex_mem; 109 110 static int initialize_mem(void) 111 { 112 pthread_mutexattr_t mta; 113 pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE); 114 pthread_mutex_init(&mutex_mem, &mta); 115 pthread_mutexattr_destroy(&mta); 116 return 0; 117 } 118 #define MEM_MUTEX_INIT (void) pthread_once(&mem_is_initialized, initialize_mem) 119 #else 120 #define MEM_MUTEX_INIT ((void)0) 121 #endif 122 105 123 #ifdef MEM_LOG 106 124 void sh_mem_dump () … … 109 127 110 128 111 FILE * fd = fopen(MEM_LOG, "w"); 129 FILE * fd; 130 131 MEM_MUTEX_INIT; 132 SH_MUTEX_LOCK(mutex_mem); 133 134 fd = fopen(MEM_LOG, "w"); 112 135 113 136 while (this != NULL) … … 117 140 } 118 141 fclose(fd); 142 SH_MUTEX_UNLOCK(mutex_mem); 119 143 return; 120 144 } … … 133 157 SL_ENTER(_("sh_mem_stat")); 134 158 159 MEM_MUTEX_INIT; 160 SH_MUTEX_LOCK(mutex_mem); 161 135 162 if (Alloc_Count == Free_Count) 136 163 { 137 164 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_MSTAMP, 138 165 Mem_Max, Mem_Current); 139 SL_RET0(_("sh_mem_stat"));166 goto out; 140 167 } 141 168 … … 167 194 this = this->next; 168 195 } 169 196 out: 197 SH_MUTEX_UNLOCK(mutex_mem); 170 198 SL_RET0(_("sh_mem_stat")); 171 199 } … … 178 206 SL_ENTER(_("sh_mem_check")); 179 207 208 MEM_MUTEX_INIT; 209 SH_MUTEX_LOCK(mutex_mem); 180 210 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_MSTAMP, 181 211 Mem_Max, Mem_Current); … … 210 240 /* if (nerr > 0) abort(); */ 211 241 242 SH_MUTEX_UNLOCK(mutex_mem); 212 243 SL_RET0(_("sh_mem_check")); 213 244 } … … 221 252 SL_ENTER(_("sh_mem_malloc")); 222 253 254 MEM_MUTEX_INIT; 255 SH_MUTEX_LOCK(mutex_mem); 223 256 the_realAddress = malloc(size + 2 * SH_MEMMULT); 224 257 … … 327 360 eblock = 0; 328 361 } 329 SL_RETURN( the_realAddress, _("sh_mem_malloc"));362 _exit(42); 330 363 } 331 364 … … 341 374 memlist = this; 342 375 376 SH_MUTEX_UNLOCK(mutex_mem); 343 377 SL_RETURN( theAddress, _("sh_mem_malloc")); 344 378 } … … 353 387 SL_ENTER(_("sh_mem_free")); 354 388 389 MEM_MUTEX_INIT; 390 SH_MUTEX_LOCK(mutex_mem); 355 391 if ( a == NULL ) 356 392 { 357 393 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MNULL, 358 394 file, line); 359 SL_RET0(_("sh_mem_free"));395 goto out; 360 396 } 361 397 … … 374 410 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MREC, 375 411 file, line); 376 SL_RET0(_("sh_mem_free"));412 goto out; 377 413 } 378 414 else … … 423 459 424 460 Mem_Current -= size; 461 out: 462 SH_MUTEX_UNLOCK(mutex_mem); 425 463 SL_RET0(_("sh_mem_free")); 426 464 } -
trunk/src/sh_portcheck.c
r132 r134 835 835 } 836 836 837 SH_MUTEX_LOCK(mutex_resolv); 837 838 hent = gethostbyname(portchk_hostname); 838 839 … … 840 841 { 841 842 memcpy (&(iface_list.iface[iface_list.used].s_addr), hent->h_addr_list[i], sizeof(in_addr_t)); 843 ++iface_list.used; 844 ++i; 845 } 846 SH_MUTEX_UNLOCK(mutex_resolv); 847 848 for (i = 0; i < iface_list.used; ++i) 849 { 842 850 sl_snprintf(errbuf, sizeof(errbuf), _("interface: %s"), 843 inet_ntoa(iface_list.iface[i face_list.used]));851 inet_ntoa(iface_list.iface[i])); 844 852 sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, 0, MSG_E_SUBGEN, 845 853 errbuf, _("sh_portchk_init")); 846 847 ++iface_list.used;848 ++i;849 854 } 850 855 … … 1442 1447 sh_portchk_check(); 1443 1448 1444 /*1445 sleep(10);1446 1447 sh_portchk_check();1448 */1449 1450 1449 return 0; 1451 1450 } -
trunk/src/sh_prelude_old.c
r1 r134 127 127 #define SH_NEED_GETHOSTBYXXX 128 128 #include "sh_static.h" 129 #include "sh_pthread.h" 129 130 130 131 static char programname[64]; … … 627 628 /* Get information about ip address */ 628 629 630 SH_MUTEX_LOCK(mutex_resolv); 629 631 myhost = sh_gethostbyname(hostname); 630 632 src_ip = xstrdup(inet_ntoa(*((struct in_addr *)myhost->h_addr_list[0]))); 633 SH_MUTEX_UNLOCK(mutex_resolv); 631 634 632 635 -
trunk/src/sh_static.c
r22 r134 51 51 #include <pwd.h> 52 52 #include <grp.h> 53 54 #include "sh_pthread.h" 53 55 54 56 #ifndef _PATH_PASSWD … … 312 314 } 313 315 314 #define LOCK ((void) 0) 315 #define UNLOCK ((void) 0) 316 SH_MUTEX_STATIC(pwf_lock, PTHREAD_MUTEX_INITIALIZER); 317 316 318 317 319 static FILE *pwf = NULL; … … 319 321 void sh_setpwent(void) 320 322 { 321 LOCK;323 SH_MUTEX_LOCK(pwf_lock); 322 324 if (pwf) { 323 325 rewind(pwf); 324 326 } 325 UNLOCK;327 SH_MUTEX_UNLOCK(pwf_lock); 326 328 } 327 329 328 330 void sh_endpwent(void) 329 331 { 330 LOCK;332 SH_MUTEX_LOCK(pwf_lock); 331 333 if (pwf) { 332 334 fclose(pwf); 333 335 pwf = NULL; 334 336 } 335 UNLOCK;337 SH_MUTEX_UNLOCK(pwf_lock); 336 338 } 337 339 … … 343 345 int rv; 344 346 345 LOCK;347 SH_MUTEX_LOCK(pwf_lock); 346 348 347 349 *result = NULL; /* In case of error... */ … … 361 363 362 364 ERR: 363 UNLOCK;365 SH_MUTEX_UNLOCK(pwf_lock); 364 366 365 367 return rv; 366 368 } 367 369 368 #define LOCK ((void) 0) 369 #define UNLOCK ((void) 0) 370 SH_MUTEX_STATIC(grf_lock, PTHREAD_MUTEX_INITIALIZER); 370 371 371 372 static FILE *grf = NULL; … … 373 374 void sh_setgrent(void) 374 375 { 375 LOCK;376 SH_MUTEX_LOCK(grf_lock); 376 377 if (grf) { 377 378 rewind(grf); 378 379 } 379 UNLOCK;380 SH_MUTEX_UNLOCK(grf_lock); 380 381 } 381 382 382 383 void sh_endgrent(void) 383 384 { 384 LOCK;385 SH_MUTEX_LOCK(grf_lock); 385 386 if (grf) { 386 387 fclose(grf); 387 388 grf = NULL; 388 389 } 389 UNLOCK;390 SH_MUTEX_UNLOCK(grf_lock); 390 391 } 391 392 … … 396 397 int rv; 397 398 398 LOCK;399 SH_MUTEX_LOCK(grf_lock); 399 400 400 401 *result = NULL; /* In case of error... */ … … 414 415 415 416 ERR: 416 UNLOCK;417 SH_MUTEX_UNLOCK(grf_lock); 417 418 418 419 return rv; … … 437 438 struct group *result; 438 439 439 440 sh_getgrent_r(&gr, line_buff, sizeof(line_buff), &result); 440 441 return result; 441 442 } … … 669 670 skip = 0; 670 671 do { 671 if (!fgets _unlocked(line_buff, buflen, f)) {672 if (feof _unlocked(f)) {672 if (!fgets(line_buff, buflen, f)) { 673 if (feof(f)) { 673 674 rv = ENOENT; 674 675 } … … 863 864 #include <arpa/nameser.h> 864 865 865 #define BIGLOCK 866 #define BIGUNLOCK 866 SH_MUTEX_STATIC(resolv_lock, PTHREAD_MUTEX_INITIALIZER); 867 867 868 868 #define __UCLIBC_HAS_IPV6__ … … 1198 1198 1199 1199 sl_strlcpy(lookup,name,MAXDNAME); 1200 BIGLOCK;1200 SH_MUTEX_LOCK_UNSAFE(resolv_lock); 1201 1201 if (variant < __searchdomains && strchr(lookup, '.') == NULL) 1202 1202 { … … 1204 1204 sl_strlcat(lookup,__searchdomain[variant], MAXDNAME); 1205 1205 } 1206 BIGUNLOCK;1206 SH_MUTEX_UNLOCK_UNSAFE(resolv_lock); 1207 1207 DPRINTF("lookup name: %s\n", lookup); 1208 1208 q.dotted = (char *)lookup; … … 1348 1348 int sdomains; 1349 1349 1350 BIGLOCK;1350 SH_MUTEX_LOCK_UNSAFE(resolv_lock); 1351 1351 sdomains=__searchdomains; 1352 BIGUNLOCK;1352 SH_MUTEX_UNLOCK_UNSAFE(resolv_lock); 1353 1353 variant = 0; 1354 1354 if (retries >= nscount*(sdomains+1)) … … 1360 1360 { 1361 1361 int sdomains; 1362 BIGLOCK;1362 SH_MUTEX_LOCK_UNSAFE(resolv_lock); 1363 1363 sdomains=__searchdomains; 1364 BIGUNLOCK;1364 SH_MUTEX_UNLOCK_UNSAFE(resolv_lock); 1365 1365 1366 1366 if (variant < sdomains) { … … 1566 1566 int argc; 1567 1567 1568 BIGLOCK; 1569 if (__nameservers > 0) { 1570 BIGUNLOCK; 1571 return 0; 1568 SH_MUTEX_LOCK(resolv_lock); 1569 if (__nameservers > 0) { 1570 goto the_end; 1572 1571 } 1573 1572 … … 1614 1613 } 1615 1614 DPRINTF("nameservers = %d\n", __nameservers); 1616 BIGUNLOCK; 1615 the_end: 1616 SH_MUTEX_UNLOCK(resolv_lock); 1617 1617 return 0; 1618 1618 } … … 1691 1691 for (;;) { 1692 1692 1693 BIGLOCK;1693 SH_MUTEX_LOCK_UNSAFE(resolv_lock); 1694 1694 __nameserversXX=__nameservers; 1695 1695 __nameserverXX=__nameserver; 1696 BIGUNLOCK;1696 SH_MUTEX_UNLOCK_UNSAFE(resolv_lock); 1697 1697 i = __dns_lookup(buf, T_A, __nameserversXX, __nameserverXX, &packet, &a); 1698 1698 … … 1911 1911 for (;;) { 1912 1912 1913 BIGLOCK;1913 SH_MUTEX_LOCK_UNSAFE(resolv_lock); 1914 1914 __nameserversXX=__nameservers; 1915 1915 __nameserverXX=__nameserver; 1916 BIGUNLOCK;1916 SH_MUTEX_UNLOCK_UNSAFE(resolv_lock); 1917 1917 i = __dns_lookup(buf, T_PTR, __nameserversXX, __nameserverXX, &packet, &a); 1918 1918 -
trunk/src/sh_tiger0.c
r133 r134 100 100 */ 101 101 102 static sh_byte buffer[PRIV_MAX + 72]; 102 /* static sh_byte buffer[PRIV_MAX + 72]; */ 103 103 104 104 #if defined(TIGER_64_BIT) … … 121 121 UINT64 bcount = 0; 122 122 123 static int lockflag = SL_FALSE;123 char * buffer = SH_ALLOC(PRIV_MAX + 72); 124 124 125 125 unsigned long pages_read; … … 176 176 MSG_E_ACCESS, (long) euid, tmp); 177 177 SH_FREE(tmp); 178 SH_FREE(buffer); 178 179 SL_RETURN( NULL, _("sh_tiger_hash_val")); 179 180 } 180 181 181 SH_MUTEX_LOCK(mutex_skey);182 182 #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK) 183 if ( (lockflag == SL_FALSE) && (skey->mlock_failed == SL_FALSE))183 if (skey->mlock_failed == SL_FALSE) 184 184 { 185 lockflag = SL_TRUE;186 185 if ( (-1) == sh_unix_mlock(FIL__, __LINE__, 187 186 (char *)buffer, 188 187 (PRIV_MAX)*sizeof(sh_byte))) 189 skey->mlock_failed = SL_TRUE; 188 { 189 SH_MUTEX_LOCK_UNSAFE(mutex_skey); 190 skey->mlock_failed = SL_TRUE; 191 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); 192 } 190 193 } 191 194 #else 192 if ( lockflag == SL_FALSE &&skey->mlock_failed == SL_FALSE)195 if (skey->mlock_failed == SL_FALSE) 193 196 { 194 lockflag = SL_TRUE;197 SH_MUTEX_LOCK_UNSAFE(mutex_skey); 195 198 skey->mlock_failed = SL_TRUE; 199 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); 196 200 } 197 201 #endif 198 SH_MUTEX_UNLOCK(mutex_skey);199 202 200 203 #ifdef TIGER_DBG … … 216 219 { 217 220 if (sig_termfast == 1) { 221 sh_unix_munlock((char *)buffer, (PRIV_MAX)*sizeof(sh_byte)); 222 SH_FREE(buffer); 218 223 SL_RETURN( NULL, _("sh_tiger_hash_val")); 219 224 } … … 234 239 memset (buffer, 0, PRIV_MAX); 235 240 241 sh_unix_munlock((char *)buffer, (PRIV_MAX)*sizeof(sh_byte)); 242 SH_FREE(buffer); 236 243 SL_RETURN( NULL, _("sh_tiger_hash_val")); 237 244 } … … 278 285 memset (bbuf, 0, 64); 279 286 memset (buffer, 0, PRIV_MAX); 280 287 sh_unix_munlock((char *)buffer, (PRIV_MAX)*sizeof(sh_byte)); 288 SH_FREE(buffer); 281 289 SL_RETURN( NULL, _("sh_tiger_hash_val")); 282 290 } … … 364 372 if (what == TIGER_FILE) 365 373 (void) sl_close (fd); 366 374 sh_unix_munlock((char *)buffer, (PRIV_MAX)*sizeof(sh_byte)); 375 SH_FREE(buffer); 367 376 SL_RETURN( res, _("sh_tiger_hash_val")); 368 377 } … … 370 379 if (what == TIGER_DATA && filename != NULL) 371 380 { 372 tiger(TIGER_CAST filename, (sh_word32) Length, res); 381 tiger(TIGER_CAST filename, (sh_word32) Length, res); 382 sh_unix_munlock((char *)buffer, (PRIV_MAX)*sizeof(sh_byte)); 383 SH_FREE(buffer); 373 384 SL_RETURN(res, _("sh_tiger_hash_val")); 374 385 } 386 sh_unix_munlock((char *)buffer, (PRIV_MAX)*sizeof(sh_byte)); 387 SH_FREE(buffer); 375 388 SL_RETURN( NULL, _("sh_tiger_hash_val")); 376 389 } -
trunk/src/sh_tools.c
r133 r134 521 521 #endif 522 522 { 523 523 SH_MUTEX_LOCK(mutex_resolv); 524 524 525 host_entry = sh_gethostbyname(address); 525 526 … … 598 599 } 599 600 } 601 SH_MUTEX_UNLOCK(mutex_resolv); 600 602 } 601 603 -
trunk/src/sh_unix.c
r133 r134 1583 1583 } 1584 1584 1585 SH_MUTEX_LOCK(mutex_resolv); 1585 1586 he1 = sh_gethostbyname(hostname); 1587 1588 if (he1 != NULL) 1589 { 1590 sl_strlcpy (sh.host.name, sh_unix_h_name(he1), SH_PATHBUF); 1591 } 1592 SH_MUTEX_UNLOCK(mutex_resolv); 1586 1593 1587 1594 if (he1 == NULL) … … 1591 1598 hostname); 1592 1599 sl_strlcpy (sh.host.name, hostname, SH_PATHBUF); 1593 }1594 else1595 {1596 sl_strlcpy (sh.host.name, sh_unix_h_name(he1), SH_PATHBUF);1597 1600 } 1598 1601 … … 1638 1641 (void) gethostname (hostname, 1024); 1639 1642 hostname[1023] = '\0'; 1643 1644 SH_MUTEX_LOCK(mutex_resolv); 1640 1645 he1 = sh_gethostbyname(hostname); 1641 1646 … … 1644 1649 sl_strlcpy (sh.host.name, sh_unix_h_name(he1), SH_PATHBUF); 1645 1650 } 1646 else 1651 SH_MUTEX_UNLOCK(mutex_resolv); 1652 1653 if (he1 == NULL) 1647 1654 { 1648 1655 dlog(1, FIL__, __LINE__, … … 1693 1700 (char *) skey, sizeof (sh_key_t)) ) 1694 1701 { 1702 SH_MUTEX_LOCK_UNSAFE(mutex_skey); 1695 1703 skey->mlock_failed = SL_TRUE; 1704 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); 1696 1705 } 1697 1706 } … … 1699 1708 if (skey->mlock_failed == SL_FALSE) 1700 1709 { 1710 SH_MUTEX_LOCK_UNSAFE(mutex_skey); 1701 1711 skey->mlock_failed = SL_TRUE; 1712 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); 1702 1713 } 1703 1714 #endif … … 4188 4199 4189 4200 #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK) 4201 4202 SH_MUTEX_STATIC(mutex_mlock,PTHREAD_MUTEX_INITIALIZER); 4203 4190 4204 int sh_unix_mlock (char * file, int line, void * in_addr, size_t len) 4191 4205 { … … 4201 4215 SL_ENTER(_("sh_unix_mlock")); 4202 4216 4217 /* There's no cancellation point here, except if tracing is on 4218 */ 4219 SH_MUTEX_LOCK_UNSAFE(mutex_mlock); 4220 4203 4221 if (0 != page_locking) 4204 4222 { 4205 4223 SL_RETURN((-1), _("sh_unix_mlock")); 4206 4224 } 4225 4207 4226 page_locking = 1; 4208 4227 … … 4218 4237 * addr is first page; num_pages is #(consecutive pages) to lock 4219 4238 */ 4239 4220 4240 while ((page_list != NULL) && (num_pages > 0)) 4221 4241 { … … 4271 4291 addr += pagesize; 4272 4292 } 4273 4274 4293 page_locking = 0; 4294 SH_MUTEX_UNLOCK_UNSAFE(mutex_mlock); 4295 4275 4296 SL_RETURN((status), _("sh_unix_mlock")); 4276 4297 } … … 4304 4325 4305 4326 SL_ENTER(_("sh_unix_munlock")); 4327 4328 /* There's no cancellation point here, except if tracing is on 4329 */ 4330 SH_MUTEX_LOCK_UNSAFE(mutex_mlock); 4306 4331 4307 4332 if (0 != page_locking) … … 4412 4437 4413 4438 page_locking = 0; 4439 SH_MUTEX_UNLOCK_UNSAFE(mutex_mlock); 4440 4414 4441 SL_RETURN((status), _("sh_unix_munlock")); 4415 4442 } -
trunk/src/sh_userfiles.c
r111 r134 267 267 /* We build a list in here because the samhain internals want to use 268 268 * getpwent() too */ 269 SH_MUTEX_LOCK(mutex_pwent); 269 270 /*@-unrecog@*/ 270 271 sh_setpwent(); … … 292 293 } 293 294 } 295 sh_endpwent(); 296 SH_MUTEX_UNLOCK(mutex_pwent); 294 297 295 298 for (homes = userHomes; homes != NULL; homes = homes->next ) { -
trunk/src/trustfile.c
r131 r134 507 507 #endif 508 508 509 int retval = SL_FALSE; 510 509 511 SL_ENTER(_("onlytrustedingrp")); 510 512 … … 603 605 /* now check ALL users for their GID !!! 604 606 */ 607 SH_MUTEX_LOCK(mutex_pwent); 608 605 609 while (NULL != (w = sh_getpwent())) 606 610 { … … 643 647 #endif 644 648 tf_baduid = w->pw_uid; 645 SL_IRETURN(SL_FALSE, _("onlytrustedingrp")); 649 retval = SL_FALSE; 650 goto out; 651 /* SL_IRETURN(SL_FALSE, _("onlytrustedingrp")); */ 646 652 } 647 653 } 648 654 } 655 retval = SL_TRUE; 656 657 out: 649 658 650 659 #ifdef HAVE_ENDPWENT 651 660 sh_endpwent(); 652 661 #endif 662 663 SH_MUTEX_UNLOCK(mutex_pwent); 664 653 665 /* TEST_ONLY */ 654 666 #endif 655 656 667 /* #ifdef HAVE_GETPWENT */ 657 668 #endif 658 669 659 670 #ifdef TRUST_DEBUG 660 fprintf(stderr, 661 "trustfile: group %ld: all members are trusted users --> OK\n", 662 (UID_CAST)grp); 671 if (retval == SL_TRUE) 672 fprintf(stderr, 673 "trustfile: group %ld: all members are trusted users --> OK\n", 674 (UID_CAST)grp); 663 675 #endif 664 676 /* all found 665 677 */ 666 SL_IRETURN( SL_TRUE, _("onlytrustedingrp"));678 SL_IRETURN(retval, _("onlytrustedingrp")); 667 679 } 668 680
Note:
See TracChangeset
for help on using the changeset viewer.