set_perms.c 552 B

1234567891011121314151617181920212223242526272829
  1. #include <unistd.h>
  2. #include <sys/stat.h>
  3. #include <sys/types.h>
  4. #include <grass/gis.h>
  5. #include "access.h"
  6. #include "local_proto.h"
  7. int set_perms(char *path, int perms, int group, int other)
  8. {
  9. char *explain_perms();
  10. perms |= OWNER_PERMS;
  11. perms &= ~GROUP_BITS;
  12. perms &= ~OTHER_BITS;
  13. if (group)
  14. perms |= GROUP_PERMS;
  15. if (other)
  16. perms |= OTHER_PERMS;
  17. if (chmod(path, perms) == 0)
  18. fprintf(stdout, "%s\n", explain_perms(group, other, 0));
  19. else
  20. G_fatal_error("unable to change mapset permissions");
  21. return 0;
  22. }