Changeset 481 for trunk/src/slib.c
- Timestamp:
- Jul 18, 2015, 5:06:52 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/slib.c
r476 r481 587 587 588 588 589 #if !defined (VA_COPY) 590 #if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32)) 591 #define VA_COPY(ap1, ap2) (*(ap1) = *(ap2)) 592 #elif defined (VA_COPY_AS_ARRAY) 593 #define VA_COPY(ap1, ap2) memmove ((ap1), (ap2), sizeof (va_list)) 594 #else /* va_list is a pointer */ 595 #define VA_COPY(ap1, ap2) ((ap1) = (ap2)) 596 #endif 597 #endif 598 589 599 #if !defined(HAVE_VSNPRINTF) || defined(HAVE_BROKEN_VSNPRINTF) 590 600 static … … 774 784 str[n-1] = '\0'; 775 785 #else 776 va_copy(vl2, vl);/* save the argument list */786 VA_COPY (vl2, vl); /* save the argument list */ 777 787 total = sl_printf_count (format, vl); 778 788 len = (int) total; … … 820 830 str[n-1] = '\0'; 821 831 #else 822 va_copy(vl2, vl);/* save the argument list */832 VA_COPY (vl2, vl); /* save the argument list */ 823 833 total = sl_printf_count (format, vl); 824 834 if (total < n) … … 1141 1151 static gid_t rgid_orig; 1142 1152 1143 static int uids_are_stored = S L_FALSE;1144 static int suid_is_set = S L_TRUE;1153 static int uids_are_stored = S_FALSE; 1154 static int suid_is_set = S_TRUE; 1145 1155 1146 1156 #ifdef HAVE_SETRESUID … … 1156 1166 int sl_is_suid() 1157 1167 { 1158 if (uids_are_stored == S L_FALSE)1168 if (uids_are_stored == S_FALSE) 1159 1169 { 1160 1170 if (getuid() == geteuid() && getgid() == getegid()) … … 1179 1189 { 1180 1190 SL_ENTER(_("sl_get_euid")); 1181 /* SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));*/1182 if (uids_are_stored == S L_TRUE)1191 /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/ 1192 if (uids_are_stored == S_TRUE) 1183 1193 *ret = euid; 1184 1194 else … … 1189 1199 uid_t sl_ret_euid() 1190 1200 { 1191 /* SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));*/1192 if (uids_are_stored == S L_TRUE)1201 /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/ 1202 if (uids_are_stored == S_TRUE) 1193 1203 return (euid); 1194 1204 else … … 1203 1213 { 1204 1214 SL_ENTER(_("sl_get_egid")); 1205 /* SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));*/1206 if (uids_are_stored == S L_TRUE)1215 /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/ 1216 if (uids_are_stored == S_TRUE) 1207 1217 *ret = egid; 1208 1218 else … … 1218 1228 { 1219 1229 SL_ENTER(_("sl_get_ruid")); 1220 /* SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));*/1221 if (uids_are_stored == S L_TRUE)1230 /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/ 1231 if (uids_are_stored == S_TRUE) 1222 1232 *ret = ruid; 1223 1233 else … … 1233 1243 { 1234 1244 SL_ENTER(_("sl_get_rgid")); 1235 /* SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));*/1236 if (uids_are_stored == S L_TRUE)1245 /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/ 1246 if (uids_are_stored == S_TRUE) 1237 1247 *ret = rgid; 1238 1248 else … … 1248 1258 { 1249 1259 SL_ENTER(_("sl_get_ruid_orig")); 1250 /* SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));*/1251 if (uids_are_stored == S L_TRUE)1260 /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/ 1261 if (uids_are_stored == S_TRUE) 1252 1262 *ret = ruid_orig; 1253 1263 else … … 1263 1273 { 1264 1274 SL_ENTER(_("sl_get_rgid_orig")); 1265 /* SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));*/1266 if (uids_are_stored == S L_TRUE)1275 /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/ 1276 if (uids_are_stored == S_TRUE) 1267 1277 *ret = rgid_orig; 1268 1278 else … … 1289 1299 SL_ENTER(_("sl_set_suid")); 1290 1300 1291 if (uids_are_stored == S L_FALSE)1301 if (uids_are_stored == S_FALSE) 1292 1302 { 1293 1303 SL_IRETURN(SL_ENONE, _("sl_set_suid")); 1294 1304 } 1295 1305 1296 SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));1306 SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE")); 1297 1307 1298 1308 if (ruid == euid && rgid == egid) 1299 1309 { 1300 suid_is_set = S L_TRUE;1310 suid_is_set = S_TRUE; 1301 1311 SL_IRETURN(SL_ENONE, _("sl_set_suid")); 1302 1312 } 1303 SL_REQUIRE(suid_is_set == S L_FALSE, _("suid_is_set == SL_FALSE"));1313 SL_REQUIRE(suid_is_set == S_FALSE, _("suid_is_set == S_FALSE")); 1304 1314 1305 1315 #if defined(HAVE_SETRESUID) … … 1330 1340 1331 1341 SL_REQUIRE(retval == 0, _("retval == 0")); 1332 suid_is_set = S L_TRUE;1342 suid_is_set = S_TRUE; 1333 1343 SL_IRETURN(SL_ENONE, _("sl_set_suid")); 1334 1344 } … … 1344 1354 SL_ENTER(_("sl_unset_suid")); 1345 1355 1346 if (uids_are_stored == S L_FALSE)1356 if (uids_are_stored == S_FALSE) 1347 1357 { 1348 1358 SL_IRETURN(SL_ENONE, _("sl_unset_suid")); 1349 1359 } 1350 1360 1351 SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));1361 SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE")); 1352 1362 1353 1363 if (ruid == euid && rgid == egid) 1354 1364 { 1355 suid_is_set = S L_FALSE;1365 suid_is_set = S_FALSE; 1356 1366 SL_IRETURN(SL_ENONE, _("sl_unset_suid")); 1357 1367 } 1358 SL_REQUIRE(suid_is_set == S L_TRUE, _("suid_is_set == SL_TRUE"));1368 SL_REQUIRE(suid_is_set == S_TRUE, _("suid_is_set == S_TRUE")); 1359 1369 1360 1370 #if defined(HAVE_SETRESUID) … … 1384 1394 1385 1395 SL_REQUIRE(retval == 0, _("retval == 0")); 1386 suid_is_set = S L_FALSE;1396 suid_is_set = S_FALSE; 1387 1397 SL_IRETURN(SL_ENONE, _("sl_unset_suid")); 1388 1398 } … … 1395 1405 { 1396 1406 SL_ENTER(_("sl_save_uids")); 1397 if (uids_are_stored == S L_TRUE)1407 if (uids_are_stored == S_TRUE) 1398 1408 SL_IRETURN(SL_EREPEAT, _("sl_save_uids")); 1399 1409 … … 1404 1414 ruid = ruid_orig; 1405 1415 rgid = rgid_orig; 1406 uids_are_stored = S L_TRUE;1416 uids_are_stored = S_TRUE; 1407 1417 1408 1418 SL_IRETURN(SL_ENONE, _("sl_save_uids")); … … 1417 1427 { 1418 1428 SL_ENTER(_("sl_drop_privileges")); 1419 SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));1429 SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE")); 1420 1430 1421 1431 SL_REQUIRE(setgid(rgid_orig) == 0, _("setgid(rgid_orig) == 0")); … … 1442 1452 { 1443 1453 SL_ENTER(_("sl_policy_get_root")); 1444 SL_REQUIRE(uids_are_stored == S L_FALSE, _("uids_are_stored == SL_FALSE"));1454 SL_REQUIRE(uids_are_stored == S_FALSE, _("uids_are_stored == S_FALSE")); 1445 1455 1446 1456 SL_REQUIRE (sl_save_uids() == SL_ENONE, _("sl_save_uids() == SL_ENONE")); … … 1455 1465 rgid = egid; 1456 1466 } 1457 suid_is_set = S L_TRUE;1467 suid_is_set = S_TRUE; 1458 1468 if (euid == 0) 1459 1469 { … … 1474 1484 { 1475 1485 SL_ENTER(_("sl_policy_get_real")); 1476 SL_REQUIRE(uids_are_stored == S L_FALSE, _("uids_are_stored == SL_FALSE"));1486 SL_REQUIRE(uids_are_stored == S_FALSE, _("uids_are_stored == S_FALSE")); 1477 1487 SL_REQUIRE (sl_save_uids() == SL_ENONE, _("sl_save_uids() == SL_ENONE")); 1478 1488 … … 1507 1517 _("sl_drop_privileges() == SL_ENONE")); 1508 1518 1509 suid_is_set = S L_TRUE;1519 suid_is_set = S_TRUE; 1510 1520 SL_IRETURN(SL_ENONE, _("sl_policy_get_real")); 1511 1521 } … … 1522 1532 1523 1533 SL_REQUIRE(user != NULL, _("user != NULL")); 1524 SL_REQUIRE(uids_are_stored == S L_FALSE, _("uids_are_stored == SL_FALSE"));1534 SL_REQUIRE(uids_are_stored == S_FALSE, _("uids_are_stored == S_FALSE")); 1525 1535 SL_REQUIRE (sl_save_uids() == SL_ENONE, _("sl_save_uids() == SL_ENONE")); 1526 1536 … … 1778 1788 ofiles[fd]->content = NULL; 1779 1789 ofiles[fd]->stream = stream; 1780 ofiles[fd]->flush = S L_FALSE;1790 ofiles[fd]->flush = S_FALSE; 1781 1791 1782 1792 sl_strlcpy(ofiles[fd]->ofile, ofile, SL_OFILE_SIZE); … … 2058 2068 ofiles[fd]->content = NULL; 2059 2069 ofiles[fd]->stream = NULL; 2060 ofiles[fd]->flush = S L_FALSE;2070 ofiles[fd]->flush = S_FALSE; 2061 2071 2062 2072 sl_strlcpy(ofiles[fd]->ofile, ofile, SL_OFILE_SIZE); … … 2182 2192 #endif 2183 2193 2184 static int sl_drop_cache = S L_FALSE;2194 static int sl_drop_cache = S_FALSE; 2185 2195 2186 2196 int sl_set_drop_cache(const char * str) … … 2203 2213 #if defined(HAVE_POSIX_FADVISE) && defined(HAVE_MINCORE) && defined(POSIX_FADV_DONTNEED) 2204 2214 2205 if (S L_FALSE != sl_drop_cache && !SL_ISERROR(status))2215 if (S_FALSE != sl_drop_cache && !SL_ISERROR(status)) 2206 2216 { 2207 2217 int fd = get_the_fd(status); … … 2209 2219 { 2210 2220 if (0 == sl_check_mincore(fd)) 2211 ofiles[fd]->flush = S L_TRUE;2221 ofiles[fd]->flush = S_TRUE; 2212 2222 } 2213 2223 } … … 2345 2355 { 2346 2356 #if defined(HAVE_POSIX_FADVISE) && defined(HAVE_MINCORE) && defined(POSIX_FADV_DONTNEED) 2347 if (ofiles[fd]->flush == S L_TRUE)2357 if (ofiles[fd]->flush == S_TRUE) 2348 2358 { 2349 2359 posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); … … 2569 2579 extern volatile int sig_termfast; 2570 2580 2571 if (is_nonblocking == S L_FALSE)2581 if (is_nonblocking == S_FALSE) 2572 2582 { 2573 2583 /* set to non-blocking mode … … 2620 2630 { 2621 2631 error = errno; 2622 if (is_nonblocking == S L_FALSE)2632 if (is_nonblocking == S_FALSE) 2623 2633 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2624 2634 TPT(( 0, FIL__, __LINE__, _("msg=<read error>"))); … … 2637 2647 else if (retval == 0) 2638 2648 { 2639 if (is_nonblocking == S L_FALSE)2649 if (is_nonblocking == S_FALSE) 2640 2650 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2641 2651 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); … … 2648 2658 { 2649 2659 error = errno; 2650 if (is_nonblocking == S L_FALSE)2660 if (is_nonblocking == S_FALSE) 2651 2661 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2652 2662 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); … … 2657 2667 if (sig_termfast == 1) 2658 2668 { 2659 if (is_nonblocking == S L_FALSE)2669 if (is_nonblocking == S_FALSE) 2660 2670 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2661 2671 TPT(( 0, FIL__, __LINE__, _("msg=<terminated>"))); … … 2669 2679 if (tdiff > timeout) 2670 2680 { 2671 if (is_nonblocking == S L_FALSE)2681 if (is_nonblocking == S_FALSE) 2672 2682 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2673 2683 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); … … 2679 2689 } 2680 2690 2681 if (is_nonblocking == S L_FALSE)2691 if (is_nonblocking == S_FALSE) 2682 2692 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2683 2693 return ((int) bytes); … … 2888 2898 2889 2899 extern uid_t rootonly[]; 2890 extern int EUIDSLOT;2891 extern int ORIG_EUIDSLOT;2900 extern unsigned int EUIDSLOT; 2901 extern unsigned int ORIG_EUIDSLOT; 2892 2902 2893 2903 extern char tf_path[MAXFILENAME]; /* Error path for trust function. */ … … 2998 3008 int sl_trust_purge_user (void) 2999 3009 { 3000 int i;3010 unsigned int i; 3001 3011 3002 3012 EUIDSLOT = ORIG_EUIDSLOT; … … 3074 3084 { 3075 3085 long status; 3076 static time_t old = 0;3077 static time_t now;3086 static size_t old = 0; 3087 static size_t now; 3078 3088 3079 3089 SL_ENTER(_("sl_trustfile_euid")); … … 3084 3094 3085 3095 now = time(NULL); 3096 3086 3097 if (now < (old + 300)) 3087 3098 { … … 3119 3130 { 3120 3131 if ((b == 0) || (a >= (INT_MIN / b) && a <= (INT_MAX / b))) 3121 return S L_TRUE; /* no overflow */3122 return S L_FALSE;3132 return S_TRUE; /* no overflow */ 3133 return S_FALSE; 3123 3134 } 3124 3135 … … 3126 3137 { 3127 3138 if ((b == 0) || (a <= (SIZE_MAX / b))) 3128 return S L_TRUE; /* no overflow */3129 return S L_FALSE;3139 return S_TRUE; /* no overflow */ 3140 return S_FALSE; 3130 3141 } 3131 3142 … … 3134 3145 (void) a; 3135 3146 if (b != 0) 3136 return S L_TRUE; /* no overflow */3137 return S L_FALSE;3147 return S_TRUE; /* no overflow */ 3148 return S_FALSE; 3138 3149 } 3139 3150 … … 3143 3154 { 3144 3155 if (a <= (INT_MAX - b)) 3145 return S L_TRUE; /* no overflow */3156 return S_TRUE; /* no overflow */ 3146 3157 else 3147 return S L_FALSE;3158 return S_FALSE; 3148 3159 } 3149 3160 else if (a < 0 && b < 0) 3150 3161 { 3151 3162 if (a >= (INT_MIN - b)) 3152 return S L_TRUE; /* no overflow */3163 return S_TRUE; /* no overflow */ 3153 3164 else 3154 return S L_FALSE;3155 } 3156 return S L_TRUE;3165 return S_FALSE; 3166 } 3167 return S_TRUE; 3157 3168 } 3158 3169 … … 3160 3171 { 3161 3172 if (a <= (SIZE_MAX - b)) 3162 return S L_TRUE; /* no overflow */3173 return S_TRUE; /* no overflow */ 3163 3174 else 3164 return S L_FALSE;3175 return S_FALSE; 3165 3176 } 3166 3177 … … 3170 3181 { 3171 3182 if (a <= (INT_MAX + b)) 3172 return S L_TRUE; /* no overflow */3183 return S_TRUE; /* no overflow */ 3173 3184 else 3174 return S L_FALSE;3185 return S_FALSE; 3175 3186 } 3176 3187 else if (a < 0 && b >= 0) 3177 3188 { 3178 3189 if (a >= (INT_MIN + b)) 3179 return S L_TRUE; /* no overflow */3190 return S_TRUE; /* no overflow */ 3180 3191 else 3181 return S L_FALSE;3182 } 3183 return S L_TRUE;3184 } 3192 return S_FALSE; 3193 } 3194 return S_TRUE; 3195 }
Note:
See TracChangeset
for help on using the changeset viewer.