1--TEST-- 2Test umask() function: usage variations - perms from 0351 to 0777 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) == 'WIN') { 6 die('skip.. only on Linux'); 7} 8?> 9--FILE-- 10<?php 11/* Prototype: int umask ( [int $mask] ); 12 Description: Changes the current umask 13*/ 14 15$file_path = dirname(__FILE__); 16 17/* Check umask() on file/dir */ 18 19echo "*** Testing umask() on file and directory ***\n"; 20// temp filename used 21$filename = "$file_path/umask_variation2.tmp"; 22// temp dir used 23$dirname = "$file_path/umask_variation2"; 24 25for($mask = 0351; $mask <= 0777; $mask++) { 26 echo "-- Setting umask to "; 27 echo sprintf('%03o', $mask); 28 echo " --\n"; 29 // setting umask 30 umask($mask); 31 32 /* umasking file */ 33 // creating temp file 34 $fp = fopen($filename, "w"); 35 fclose($fp); 36 echo "File permission : "; 37 // check file permission 38 echo substr(sprintf('%o', fileperms($filename)), -3); 39 echo "\n"; 40 // chmod file to 0777 to enable deletion 41 chmod($filename, 0777); 42 // delete temp file created here 43 unlink($filename); 44 45 /* umasking directory */ 46 // create temp dir 47 mkdir($dirname); 48 echo "Directory permission : "; 49 // check $dirname permission 50 echo substr(sprintf('%o', fileperms($dirname)), -3); 51 echo "\n"; 52 // chmod 0777 to enable deletion 53 chmod($dirname, 0777); 54 // delete temp dir created 55 rmdir($dirname); 56} 57 58echo "Done\n"; 59?> 60--EXPECTF-- 61*** Testing umask() on file and directory *** 62-- Setting umask to 351 -- 63File permission : 426 64Directory permission : 426 65-- Setting umask to 352 -- 66File permission : 424 67Directory permission : 425 68-- Setting umask to 353 -- 69File permission : 424 70Directory permission : 424 71-- Setting umask to 354 -- 72File permission : 422 73Directory permission : 423 74-- Setting umask to 355 -- 75File permission : 422 76Directory permission : 422 77-- Setting umask to 356 -- 78File permission : 420 79Directory permission : 421 80-- Setting umask to 357 -- 81File permission : 420 82Directory permission : 420 83-- Setting umask to 360 -- 84File permission : 406 85Directory permission : 417 86-- Setting umask to 361 -- 87File permission : 406 88Directory permission : 416 89-- Setting umask to 362 -- 90File permission : 404 91Directory permission : 415 92-- Setting umask to 363 -- 93File permission : 404 94Directory permission : 414 95-- Setting umask to 364 -- 96File permission : 402 97Directory permission : 413 98-- Setting umask to 365 -- 99File permission : 402 100Directory permission : 412 101-- Setting umask to 366 -- 102File permission : 400 103Directory permission : 411 104-- Setting umask to 367 -- 105File permission : 400 106Directory permission : 410 107-- Setting umask to 370 -- 108File permission : 406 109Directory permission : 407 110-- Setting umask to 371 -- 111File permission : 406 112Directory permission : 406 113-- Setting umask to 372 -- 114File permission : 404 115Directory permission : 405 116-- Setting umask to 373 -- 117File permission : 404 118Directory permission : 404 119-- Setting umask to 374 -- 120File permission : 402 121Directory permission : 403 122-- Setting umask to 375 -- 123File permission : 402 124Directory permission : 402 125-- Setting umask to 376 -- 126File permission : 400 127Directory permission : 401 128-- Setting umask to 377 -- 129File permission : 400 130Directory permission : 400 131-- Setting umask to 400 -- 132File permission : 266 133Directory permission : 377 134-- Setting umask to 401 -- 135File permission : 266 136Directory permission : 376 137-- Setting umask to 402 -- 138File permission : 264 139Directory permission : 375 140-- Setting umask to 403 -- 141File permission : 264 142Directory permission : 374 143-- Setting umask to 404 -- 144File permission : 262 145Directory permission : 373 146-- Setting umask to 405 -- 147File permission : 262 148Directory permission : 372 149-- Setting umask to 406 -- 150File permission : 260 151Directory permission : 371 152-- Setting umask to 407 -- 153File permission : 260 154Directory permission : 370 155-- Setting umask to 410 -- 156File permission : 266 157Directory permission : 367 158-- Setting umask to 411 -- 159File permission : 266 160Directory permission : 366 161-- Setting umask to 412 -- 162File permission : 264 163Directory permission : 365 164-- Setting umask to 413 -- 165File permission : 264 166Directory permission : 364 167-- Setting umask to 414 -- 168File permission : 262 169Directory permission : 363 170-- Setting umask to 415 -- 171File permission : 262 172Directory permission : 362 173-- Setting umask to 416 -- 174File permission : 260 175Directory permission : 361 176-- Setting umask to 417 -- 177File permission : 260 178Directory permission : 360 179-- Setting umask to 420 -- 180File permission : 246 181Directory permission : 357 182-- Setting umask to 421 -- 183File permission : 246 184Directory permission : 356 185-- Setting umask to 422 -- 186File permission : 244 187Directory permission : 355 188-- Setting umask to 423 -- 189File permission : 244 190Directory permission : 354 191-- Setting umask to 424 -- 192File permission : 242 193Directory permission : 353 194-- Setting umask to 425 -- 195File permission : 242 196Directory permission : 352 197-- Setting umask to 426 -- 198File permission : 240 199Directory permission : 351 200-- Setting umask to 427 -- 201File permission : 240 202Directory permission : 350 203-- Setting umask to 430 -- 204File permission : 246 205Directory permission : 347 206-- Setting umask to 431 -- 207File permission : 246 208Directory permission : 346 209-- Setting umask to 432 -- 210File permission : 244 211Directory permission : 345 212-- Setting umask to 433 -- 213File permission : 244 214Directory permission : 344 215-- Setting umask to 434 -- 216File permission : 242 217Directory permission : 343 218-- Setting umask to 435 -- 219File permission : 242 220Directory permission : 342 221-- Setting umask to 436 -- 222File permission : 240 223Directory permission : 341 224-- Setting umask to 437 -- 225File permission : 240 226Directory permission : 340 227-- Setting umask to 440 -- 228File permission : 226 229Directory permission : 337 230-- Setting umask to 441 -- 231File permission : 226 232Directory permission : 336 233-- Setting umask to 442 -- 234File permission : 224 235Directory permission : 335 236-- Setting umask to 443 -- 237File permission : 224 238Directory permission : 334 239-- Setting umask to 444 -- 240File permission : 222 241Directory permission : 333 242-- Setting umask to 445 -- 243File permission : 222 244Directory permission : 332 245-- Setting umask to 446 -- 246File permission : 220 247Directory permission : 331 248-- Setting umask to 447 -- 249File permission : 220 250Directory permission : 330 251-- Setting umask to 450 -- 252File permission : 226 253Directory permission : 327 254-- Setting umask to 451 -- 255File permission : 226 256Directory permission : 326 257-- Setting umask to 452 -- 258File permission : 224 259Directory permission : 325 260-- Setting umask to 453 -- 261File permission : 224 262Directory permission : 324 263-- Setting umask to 454 -- 264File permission : 222 265Directory permission : 323 266-- Setting umask to 455 -- 267File permission : 222 268Directory permission : 322 269-- Setting umask to 456 -- 270File permission : 220 271Directory permission : 321 272-- Setting umask to 457 -- 273File permission : 220 274Directory permission : 320 275-- Setting umask to 460 -- 276File permission : 206 277Directory permission : 317 278-- Setting umask to 461 -- 279File permission : 206 280Directory permission : 316 281-- Setting umask to 462 -- 282File permission : 204 283Directory permission : 315 284-- Setting umask to 463 -- 285File permission : 204 286Directory permission : 314 287-- Setting umask to 464 -- 288File permission : 202 289Directory permission : 313 290-- Setting umask to 465 -- 291File permission : 202 292Directory permission : 312 293-- Setting umask to 466 -- 294File permission : 200 295Directory permission : 311 296-- Setting umask to 467 -- 297File permission : 200 298Directory permission : 310 299-- Setting umask to 470 -- 300File permission : 206 301Directory permission : 307 302-- Setting umask to 471 -- 303File permission : 206 304Directory permission : 306 305-- Setting umask to 472 -- 306File permission : 204 307Directory permission : 305 308-- Setting umask to 473 -- 309File permission : 204 310Directory permission : 304 311-- Setting umask to 474 -- 312File permission : 202 313Directory permission : 303 314-- Setting umask to 475 -- 315File permission : 202 316Directory permission : 302 317-- Setting umask to 476 -- 318File permission : 200 319Directory permission : 301 320-- Setting umask to 477 -- 321File permission : 200 322Directory permission : 300 323-- Setting umask to 500 -- 324File permission : 266 325Directory permission : 277 326-- Setting umask to 501 -- 327File permission : 266 328Directory permission : 276 329-- Setting umask to 502 -- 330File permission : 264 331Directory permission : 275 332-- Setting umask to 503 -- 333File permission : 264 334Directory permission : 274 335-- Setting umask to 504 -- 336File permission : 262 337Directory permission : 273 338-- Setting umask to 505 -- 339File permission : 262 340Directory permission : 272 341-- Setting umask to 506 -- 342File permission : 260 343Directory permission : 271 344-- Setting umask to 507 -- 345File permission : 260 346Directory permission : 270 347-- Setting umask to 510 -- 348File permission : 266 349Directory permission : 267 350-- Setting umask to 511 -- 351File permission : 266 352Directory permission : 266 353-- Setting umask to 512 -- 354File permission : 264 355Directory permission : 265 356-- Setting umask to 513 -- 357File permission : 264 358Directory permission : 264 359-- Setting umask to 514 -- 360File permission : 262 361Directory permission : 263 362-- Setting umask to 515 -- 363File permission : 262 364Directory permission : 262 365-- Setting umask to 516 -- 366File permission : 260 367Directory permission : 261 368-- Setting umask to 517 -- 369File permission : 260 370Directory permission : 260 371-- Setting umask to 520 -- 372File permission : 246 373Directory permission : 257 374-- Setting umask to 521 -- 375File permission : 246 376Directory permission : 256 377-- Setting umask to 522 -- 378File permission : 244 379Directory permission : 255 380-- Setting umask to 523 -- 381File permission : 244 382Directory permission : 254 383-- Setting umask to 524 -- 384File permission : 242 385Directory permission : 253 386-- Setting umask to 525 -- 387File permission : 242 388Directory permission : 252 389-- Setting umask to 526 -- 390File permission : 240 391Directory permission : 251 392-- Setting umask to 527 -- 393File permission : 240 394Directory permission : 250 395-- Setting umask to 530 -- 396File permission : 246 397Directory permission : 247 398-- Setting umask to 531 -- 399File permission : 246 400Directory permission : 246 401-- Setting umask to 532 -- 402File permission : 244 403Directory permission : 245 404-- Setting umask to 533 -- 405File permission : 244 406Directory permission : 244 407-- Setting umask to 534 -- 408File permission : 242 409Directory permission : 243 410-- Setting umask to 535 -- 411File permission : 242 412Directory permission : 242 413-- Setting umask to 536 -- 414File permission : 240 415Directory permission : 241 416-- Setting umask to 537 -- 417File permission : 240 418Directory permission : 240 419-- Setting umask to 540 -- 420File permission : 226 421Directory permission : 237 422-- Setting umask to 541 -- 423File permission : 226 424Directory permission : 236 425-- Setting umask to 542 -- 426File permission : 224 427Directory permission : 235 428-- Setting umask to 543 -- 429File permission : 224 430Directory permission : 234 431-- Setting umask to 544 -- 432File permission : 222 433Directory permission : 233 434-- Setting umask to 545 -- 435File permission : 222 436Directory permission : 232 437-- Setting umask to 546 -- 438File permission : 220 439Directory permission : 231 440-- Setting umask to 547 -- 441File permission : 220 442Directory permission : 230 443-- Setting umask to 550 -- 444File permission : 226 445Directory permission : 227 446-- Setting umask to 551 -- 447File permission : 226 448Directory permission : 226 449-- Setting umask to 552 -- 450File permission : 224 451Directory permission : 225 452-- Setting umask to 553 -- 453File permission : 224 454Directory permission : 224 455-- Setting umask to 554 -- 456File permission : 222 457Directory permission : 223 458-- Setting umask to 555 -- 459File permission : 222 460Directory permission : 222 461-- Setting umask to 556 -- 462File permission : 220 463Directory permission : 221 464-- Setting umask to 557 -- 465File permission : 220 466Directory permission : 220 467-- Setting umask to 560 -- 468File permission : 206 469Directory permission : 217 470-- Setting umask to 561 -- 471File permission : 206 472Directory permission : 216 473-- Setting umask to 562 -- 474File permission : 204 475Directory permission : 215 476-- Setting umask to 563 -- 477File permission : 204 478Directory permission : 214 479-- Setting umask to 564 -- 480File permission : 202 481Directory permission : 213 482-- Setting umask to 565 -- 483File permission : 202 484Directory permission : 212 485-- Setting umask to 566 -- 486File permission : 200 487Directory permission : 211 488-- Setting umask to 567 -- 489File permission : 200 490Directory permission : 210 491-- Setting umask to 570 -- 492File permission : 206 493Directory permission : 207 494-- Setting umask to 571 -- 495File permission : 206 496Directory permission : 206 497-- Setting umask to 572 -- 498File permission : 204 499Directory permission : 205 500-- Setting umask to 573 -- 501File permission : 204 502Directory permission : 204 503-- Setting umask to 574 -- 504File permission : 202 505Directory permission : 203 506-- Setting umask to 575 -- 507File permission : 202 508Directory permission : 202 509-- Setting umask to 576 -- 510File permission : 200 511Directory permission : 201 512-- Setting umask to 577 -- 513File permission : 200 514Directory permission : 200 515-- Setting umask to 600 -- 516File permission : 066 517Directory permission : 177 518-- Setting umask to 601 -- 519File permission : 066 520Directory permission : 176 521-- Setting umask to 602 -- 522File permission : 064 523Directory permission : 175 524-- Setting umask to 603 -- 525File permission : 064 526Directory permission : 174 527-- Setting umask to 604 -- 528File permission : 062 529Directory permission : 173 530-- Setting umask to 605 -- 531File permission : 062 532Directory permission : 172 533-- Setting umask to 606 -- 534File permission : 060 535Directory permission : 171 536-- Setting umask to 607 -- 537File permission : 060 538Directory permission : 170 539-- Setting umask to 610 -- 540File permission : 066 541Directory permission : 167 542-- Setting umask to 611 -- 543File permission : 066 544Directory permission : 166 545-- Setting umask to 612 -- 546File permission : 064 547Directory permission : 165 548-- Setting umask to 613 -- 549File permission : 064 550Directory permission : 164 551-- Setting umask to 614 -- 552File permission : 062 553Directory permission : 163 554-- Setting umask to 615 -- 555File permission : 062 556Directory permission : 162 557-- Setting umask to 616 -- 558File permission : 060 559Directory permission : 161 560-- Setting umask to 617 -- 561File permission : 060 562Directory permission : 160 563-- Setting umask to 620 -- 564File permission : 046 565Directory permission : 157 566-- Setting umask to 621 -- 567File permission : 046 568Directory permission : 156 569-- Setting umask to 622 -- 570File permission : 044 571Directory permission : 155 572-- Setting umask to 623 -- 573File permission : 044 574Directory permission : 154 575-- Setting umask to 624 -- 576File permission : 042 577Directory permission : 153 578-- Setting umask to 625 -- 579File permission : 042 580Directory permission : 152 581-- Setting umask to 626 -- 582File permission : 040 583Directory permission : 151 584-- Setting umask to 627 -- 585File permission : 040 586Directory permission : 150 587-- Setting umask to 630 -- 588File permission : 046 589Directory permission : 147 590-- Setting umask to 631 -- 591File permission : 046 592Directory permission : 146 593-- Setting umask to 632 -- 594File permission : 044 595Directory permission : 145 596-- Setting umask to 633 -- 597File permission : 044 598Directory permission : 144 599-- Setting umask to 634 -- 600File permission : 042 601Directory permission : 143 602-- Setting umask to 635 -- 603File permission : 042 604Directory permission : 142 605-- Setting umask to 636 -- 606File permission : 040 607Directory permission : 141 608-- Setting umask to 637 -- 609File permission : 040 610Directory permission : 140 611-- Setting umask to 640 -- 612File permission : 026 613Directory permission : 137 614-- Setting umask to 641 -- 615File permission : 026 616Directory permission : 136 617-- Setting umask to 642 -- 618File permission : 024 619Directory permission : 135 620-- Setting umask to 643 -- 621File permission : 024 622Directory permission : 134 623-- Setting umask to 644 -- 624File permission : 022 625Directory permission : 133 626-- Setting umask to 645 -- 627File permission : 022 628Directory permission : 132 629-- Setting umask to 646 -- 630File permission : 020 631Directory permission : 131 632-- Setting umask to 647 -- 633File permission : 020 634Directory permission : 130 635-- Setting umask to 650 -- 636File permission : 026 637Directory permission : 127 638-- Setting umask to 651 -- 639File permission : 026 640Directory permission : 126 641-- Setting umask to 652 -- 642File permission : 024 643Directory permission : 125 644-- Setting umask to 653 -- 645File permission : 024 646Directory permission : 124 647-- Setting umask to 654 -- 648File permission : 022 649Directory permission : 123 650-- Setting umask to 655 -- 651File permission : 022 652Directory permission : 122 653-- Setting umask to 656 -- 654File permission : 020 655Directory permission : 121 656-- Setting umask to 657 -- 657File permission : 020 658Directory permission : 120 659-- Setting umask to 660 -- 660File permission : 006 661Directory permission : 117 662-- Setting umask to 661 -- 663File permission : 006 664Directory permission : 116 665-- Setting umask to 662 -- 666File permission : 004 667Directory permission : 115 668-- Setting umask to 663 -- 669File permission : 004 670Directory permission : 114 671-- Setting umask to 664 -- 672File permission : 002 673Directory permission : 113 674-- Setting umask to 665 -- 675File permission : 002 676Directory permission : 112 677-- Setting umask to 666 -- 678File permission : 000 679Directory permission : 111 680-- Setting umask to 667 -- 681File permission : 000 682Directory permission : 110 683-- Setting umask to 670 -- 684File permission : 006 685Directory permission : 107 686-- Setting umask to 671 -- 687File permission : 006 688Directory permission : 106 689-- Setting umask to 672 -- 690File permission : 004 691Directory permission : 105 692-- Setting umask to 673 -- 693File permission : 004 694Directory permission : 104 695-- Setting umask to 674 -- 696File permission : 002 697Directory permission : 103 698-- Setting umask to 675 -- 699File permission : 002 700Directory permission : 102 701-- Setting umask to 676 -- 702File permission : 000 703Directory permission : 101 704-- Setting umask to 677 -- 705File permission : 000 706Directory permission : 100 707-- Setting umask to 700 -- 708File permission : 066 709Directory permission : 077 710-- Setting umask to 701 -- 711File permission : 066 712Directory permission : 076 713-- Setting umask to 702 -- 714File permission : 064 715Directory permission : 075 716-- Setting umask to 703 -- 717File permission : 064 718Directory permission : 074 719-- Setting umask to 704 -- 720File permission : 062 721Directory permission : 073 722-- Setting umask to 705 -- 723File permission : 062 724Directory permission : 072 725-- Setting umask to 706 -- 726File permission : 060 727Directory permission : 071 728-- Setting umask to 707 -- 729File permission : 060 730Directory permission : 070 731-- Setting umask to 710 -- 732File permission : 066 733Directory permission : 067 734-- Setting umask to 711 -- 735File permission : 066 736Directory permission : 066 737-- Setting umask to 712 -- 738File permission : 064 739Directory permission : 065 740-- Setting umask to 713 -- 741File permission : 064 742Directory permission : 064 743-- Setting umask to 714 -- 744File permission : 062 745Directory permission : 063 746-- Setting umask to 715 -- 747File permission : 062 748Directory permission : 062 749-- Setting umask to 716 -- 750File permission : 060 751Directory permission : 061 752-- Setting umask to 717 -- 753File permission : 060 754Directory permission : 060 755-- Setting umask to 720 -- 756File permission : 046 757Directory permission : 057 758-- Setting umask to 721 -- 759File permission : 046 760Directory permission : 056 761-- Setting umask to 722 -- 762File permission : 044 763Directory permission : 055 764-- Setting umask to 723 -- 765File permission : 044 766Directory permission : 054 767-- Setting umask to 724 -- 768File permission : 042 769Directory permission : 053 770-- Setting umask to 725 -- 771File permission : 042 772Directory permission : 052 773-- Setting umask to 726 -- 774File permission : 040 775Directory permission : 051 776-- Setting umask to 727 -- 777File permission : 040 778Directory permission : 050 779-- Setting umask to 730 -- 780File permission : 046 781Directory permission : 047 782-- Setting umask to 731 -- 783File permission : 046 784Directory permission : 046 785-- Setting umask to 732 -- 786File permission : 044 787Directory permission : 045 788-- Setting umask to 733 -- 789File permission : 044 790Directory permission : 044 791-- Setting umask to 734 -- 792File permission : 042 793Directory permission : 043 794-- Setting umask to 735 -- 795File permission : 042 796Directory permission : 042 797-- Setting umask to 736 -- 798File permission : 040 799Directory permission : 041 800-- Setting umask to 737 -- 801File permission : 040 802Directory permission : 040 803-- Setting umask to 740 -- 804File permission : 026 805Directory permission : 037 806-- Setting umask to 741 -- 807File permission : 026 808Directory permission : 036 809-- Setting umask to 742 -- 810File permission : 024 811Directory permission : 035 812-- Setting umask to 743 -- 813File permission : 024 814Directory permission : 034 815-- Setting umask to 744 -- 816File permission : 022 817Directory permission : 033 818-- Setting umask to 745 -- 819File permission : 022 820Directory permission : 032 821-- Setting umask to 746 -- 822File permission : 020 823Directory permission : 031 824-- Setting umask to 747 -- 825File permission : 020 826Directory permission : 030 827-- Setting umask to 750 -- 828File permission : 026 829Directory permission : 027 830-- Setting umask to 751 -- 831File permission : 026 832Directory permission : 026 833-- Setting umask to 752 -- 834File permission : 024 835Directory permission : 025 836-- Setting umask to 753 -- 837File permission : 024 838Directory permission : 024 839-- Setting umask to 754 -- 840File permission : 022 841Directory permission : 023 842-- Setting umask to 755 -- 843File permission : 022 844Directory permission : 022 845-- Setting umask to 756 -- 846File permission : 020 847Directory permission : 021 848-- Setting umask to 757 -- 849File permission : 020 850Directory permission : 020 851-- Setting umask to 760 -- 852File permission : 006 853Directory permission : 017 854-- Setting umask to 761 -- 855File permission : 006 856Directory permission : 016 857-- Setting umask to 762 -- 858File permission : 004 859Directory permission : 015 860-- Setting umask to 763 -- 861File permission : 004 862Directory permission : 014 863-- Setting umask to 764 -- 864File permission : 002 865Directory permission : 013 866-- Setting umask to 765 -- 867File permission : 002 868Directory permission : 012 869-- Setting umask to 766 -- 870File permission : 000 871Directory permission : 011 872-- Setting umask to 767 -- 873File permission : 000 874Directory permission : 010 875-- Setting umask to 770 -- 876File permission : 006 877Directory permission : 007 878-- Setting umask to 771 -- 879File permission : 006 880Directory permission : 006 881-- Setting umask to 772 -- 882File permission : 004 883Directory permission : 005 884-- Setting umask to 773 -- 885File permission : 004 886Directory permission : 004 887-- Setting umask to 774 -- 888File permission : 002 889Directory permission : 003 890-- Setting umask to 775 -- 891File permission : 002 892Directory permission : 002 893-- Setting umask to 776 -- 894File permission : 000 895Directory permission : 001 896-- Setting umask to 777 -- 897File permission : 000 898Directory permission : 000 899Done 900