2
0

access.c 499 B

1234567891011121314151617
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <stdlib.h>
  4. #include "test_helpers.h"
  5. int main(void) {
  6. if (access("example_dir/1-never-gonna-give-you-up", R_OK | W_OK)) {
  7. perror("access");
  8. exit(EXIT_FAILURE);
  9. }
  10. if (!access("example_dir/1-never-gonna-give-you-up", X_OK)) {
  11. puts("Accessing a file with X_OK worked even though it... probably... shouldn't?");
  12. puts("Please run `chmod 644 example_dir/*` and try again.");
  13. exit(EXIT_FAILURE);
  14. }
  15. }