set_perms.c 582 B

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