Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.1 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h>
  3. #include <signal.h>
  4. #include <errno.h>
  5. #include <sys/wait.h>
  6. #include <unistd.h>
  7. #include <sys/stat.h>
  8. #include <fcntl.h>
  9. #include <stdio.h>
  10. #include "tsttmp.h" // defines DbgPrint as printf
  11. extern int errno;
  12. VOID umask0(void);
  13. //
  14. // 'tstumask'
  15. //
  16. int
  17. __cdecl
  18. main(int argc, char *argv[])
  19. {
  20. if (argc != 1) {
  21. DbgPrint("Usage: '%s'\n", argv[0]);
  22. return 1;
  23. }
  24. umask0();
  25. return 1;
  26. }
  27. VOID
  28. umask0(void)
  29. {
  30. mode_t oldmask, savemask;
  31. DbgPrint("umask0:++\n");
  32. oldmask = umask(S_IRWXU);
  33. savemask = oldmask;
  34. oldmask = umask(S_IRWXG);
  35. if ((oldmask & S_IRWXU) != S_IRWXU) {
  36. DbgPrint("FAIL on S_IRWXU\n");
  37. return;
  38. }
  39. oldmask = umask(S_IRWXO);
  40. if ((oldmask & S_IRWXG) != S_IRWXG) {
  41. DbgPrint("FAIL on S_IRWXG\n");
  42. return;
  43. }
  44. oldmask = umask((mode_t) 0L);
  45. if ((oldmask & S_IRWXO) != S_IRWXO) {
  46. DbgPrint("FAIL on S_IRWXO\n");
  47. return;
  48. }
  49. oldmask = umask(savemask);
  50. if ( (oldmask & _S_PROT) != (mode_t) 0L) {
  51. DbgPrint("FAIL on 0 perm\n");
  52. return;
  53. }
  54. DbgPrint("PASSED\n");
  55. DbgPrint("umask0:--\n");
  56. }