diff options
author | Christopher Faylor <me@cgf.cx> | 2011-12-17 23:39:47 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2011-12-17 23:39:47 +0000 |
commit | 1b23b30b29eebbe7c9953f2a7470f31a0feb8702 (patch) | |
tree | 10592e165f5e31aac70913190d50d700f6fec96c /winsup/utils/setfacl.c | |
parent | 988d896c0a3b60fab9cd323e52eefd4af98be323 (diff) | |
download | cygnal-1b23b30b29eebbe7c9953f2a7470f31a0feb8702.tar.gz cygnal-1b23b30b29eebbe7c9953f2a7470f31a0feb8702.tar.bz2 cygnal-1b23b30b29eebbe7c9953f2a7470f31a0feb8702.zip |
Clean up whitespace.
Diffstat (limited to 'winsup/utils/setfacl.c')
-rw-r--r-- | winsup/utils/setfacl.c | 468 |
1 files changed, 234 insertions, 234 deletions
diff --git a/winsup/utils/setfacl.c b/winsup/utils/setfacl.c index 857be7971..66739c043 100644 --- a/winsup/utils/setfacl.c +++ b/winsup/utils/setfacl.c @@ -56,7 +56,7 @@ mode_t getperm (char *in) { int i = atoi (in); if (i < 0 || i > 7) - return ILLEGAL_MODE; + return ILLEGAL_MODE; return i << 6 | i << 3 | i; } if (strlen (in) > 3 && strchr (" \t\n\r#", in[3])) @@ -68,8 +68,8 @@ mode_t getperm (char *in) || !strchr ("x-", in[2])) return ILLEGAL_MODE; return (in[0] == 'r' ? S_IROTH : 0) - | (in[1] == 'w' ? S_IWOTH : 0) - | (in[2] == 'x' ? S_IXOTH : 0); + | (in[1] == 'w' ? S_IWOTH : 0) + | (in[2] == 'x' ? S_IXOTH : 0); } BOOL @@ -127,34 +127,34 @@ getaclentry (action_t action, char *c, aclent_t *ace) can't be deleted. */ c2 = strchrnul (c + 1, ':'); if (*c2 == ':') - *c2++ = '\0'; + *c2++ = '\0'; else if (action != Delete) return FALSE; else if (!(ace->a_type & ACL_DEFAULT)) return FALSE; /* Fetch user/group id. */ if (isdigit ((unsigned char) *c)) - { - char *c3; + { + char *c3; - ace->a_id = strtol (c, &c3, 10); - if (*c3) - return FALSE; - } + ace->a_id = strtol (c, &c3, 10); + if (*c3) + return FALSE; + } else if (ace->a_type & USER_OBJ) - { - struct passwd *pw = getpwnam (c); - if (!pw) - return FALSE; - ace->a_id = pw->pw_uid; - } + { + struct passwd *pw = getpwnam (c); + if (!pw) + return FALSE; + ace->a_id = pw->pw_uid; + } else - { - struct group *gr = getgrnam (c); - if (!gr) - return FALSE; - ace->a_id = gr->gr_gid; - } + { + struct group *gr = getgrnam (c); + if (!gr) + return FALSE; + ace->a_id = gr->gr_gid; + } if (ace->a_type & USER_OBJ) { ace->a_type &= ~USER_OBJ; @@ -194,28 +194,28 @@ getaclentries (action_t action, char *buf, aclent_t *acls, int *idx) char fbuf[256], *fb; if (!strcmp (buf, "-")) - fp = stdin; + fp = stdin; else if (! (fp = fopen (buf, "r"))) - return FALSE; + return FALSE; while ((fb = fgets (fbuf, 256, fp))) - { + { while (strchr (" \t", *fb)) ++fb; if (strchr ("\n\r#", *fb)) continue; - if (!getaclentry (action, fb, acls + (*idx)++)) - { - fclose (fp); - return FALSE; - } - } + if (!getaclentry (action, fb, acls + (*idx)++)) + { + fclose (fp); + return FALSE; + } + } if (fp != stdin) fclose (fp); } else for (c = strtok (buf, ","); c; c = strtok (NULL, ",")) if (!getaclentry (action, c, acls + (*idx)++)) - return FALSE; + return FALSE; return TRUE; } @@ -226,7 +226,7 @@ searchace (aclent_t *aclp, int nentries, int type, int id) for (i = 0; i < nentries; ++i) if ((aclp[i].a_type == type && (id < 0 || aclp[i].a_id == id)) - || !aclp[i].a_type) + || !aclp[i].a_type) return i; return -1; } @@ -239,24 +239,24 @@ modacl (aclent_t *tgt, int tcnt, aclent_t *src, int scnt) for (s = 0; s < scnt; ++s) { t = searchace (tgt, MAX_ACL_ENTRIES, src[s].a_type, - (src[s].a_type & (USER | GROUP)) ? src[s].a_id : -1); + (src[s].a_type & (USER | GROUP)) ? src[s].a_id : -1); if (t < 0) - return -1; + return -1; if (src[s].a_perm == ILLEGAL_MODE) - { - if (t < tcnt) - { - for (i = t + 1; i < tcnt; ++i) - tgt[i - 1] = tgt[i]; - --tcnt; - } - } + { + if (t < tcnt) + { + for (i = t + 1; i < tcnt; ++i) + tgt[i - 1] = tgt[i]; + --tcnt; + } + } else - { - tgt[t] = src[s]; - if (t >= tcnt) - ++tcnt; - } + { + tgt[t] = src[s]; + if (t >= tcnt) + ++tcnt; + } } return tcnt; } @@ -290,105 +290,105 @@ static void usage (FILE * stream) { fprintf (stream, "" - "Usage: %s [-r] (-f ACL_FILE | -s acl_entries) FILE...\n" - " %s [-r] ([-d acl_entries] [-m acl_entries]) FILE...\n" - "\n" - "Modify file and directory access control lists (ACLs)\n" - "\n" - " -d, --delete delete one or more specified ACL entries\n" - " -f, --file set ACL entries for FILE to ACL entries read\n" - " from a ACL_FILE\n" - " -m, --modify modify one or more specified ACL entries\n" - " -r, --replace replace mask entry with maximum permissions\n" - " needed for the file group class\n" - " -s, --substitute substitute specified ACL entries for the\n" - " ACL of FILE\n" - " -h, --help output usage information and exit\n" - " -V, --version output version information and exit\n" - "\n" - "At least one of (-d, -f, -m, -s) must be specified\n" - "\n", prog_name, prog_name); - if (stream == stdout) + "Usage: %s [-r] (-f ACL_FILE | -s acl_entries) FILE...\n" + " %s [-r] ([-d acl_entries] [-m acl_entries]) FILE...\n" + "\n" + "Modify file and directory access control lists (ACLs)\n" + "\n" + " -d, --delete delete one or more specified ACL entries\n" + " -f, --file set ACL entries for FILE to ACL entries read\n" + " from a ACL_FILE\n" + " -m, --modify modify one or more specified ACL entries\n" + " -r, --replace replace mask entry with maximum permissions\n" + " needed for the file group class\n" + " -s, --substitute substitute specified ACL entries for the\n" + " ACL of FILE\n" + " -h, --help output usage information and exit\n" + " -V, --version output version information and exit\n" + "\n" + "At least one of (-d, -f, -m, -s) must be specified\n" + "\n", prog_name, prog_name); + if (stream == stdout) { printf("" - " Acl_entries are one or more comma-separated ACL entries \n" - " from the following list:\n" - "\n" - " u[ser]::perm\n" - " u[ser]:uid:perm\n" - " g[roup]::perm\n" - " g[roup]:gid:perm\n" - " m[ask]:perm\n" - " o[ther]:perm\n" - "\n" - " Default entries are like the above with the additional\n" - " default identifier. For example: \n" - "\n" - " d[efault]:u[ser]:uid:perm\n" - "\n" - " 'perm' is either a 3-char permissions string in the form\n" - " \"rwx\" with the character - for no permission\n" - " or it is the octal representation of the permissions, a\n" - " value from 0 (equivalent to \"---\") to 7 (\"rwx\").\n" - " 'uid' is a user name or a numerical uid.\n" - " 'gid' is a group name or a numerical gid.\n" - "\n" - "\n" - "For each file given as parameter, %s will either replace its\n" - "complete ACL (-s, -f), or it will add, modify, or delete ACL\n" - "entries.\n" - "\n" - "The following options are supported:\n" - "\n" - "-d Delete one or more specified entries from the file's ACL.\n" - " The owner, group and others entries must not be deleted.\n" - " Acl_entries to be deleted should be specified without\n" - " permissions, as in the following list:\n" - "\n" - " u[ser]:uid\n" - " g[roup]:gid\n" - " d[efault]:u[ser]:uid\n" - " d[efault]:g[roup]:gid\n" - " d[efault]:m[ask]:\n" - " d[efault]:o[ther]:\n" - "\n" - "-f Take the Acl_entries from ACL_FILE one per line. Whitespace\n" - " characters are ignored, and the character \"#\" may be used\n" - " to start a comment. The special filename \"-\" indicates\n" - " reading from stdin.\n" - " Required entries are\n" - " - One user entry for the owner of the file.\n" - " - One group entry for the group of the file.\n" - " - One other entry.\n" - " If additional user and group entries are given:\n" - " - A mask entry for the file group class of the file.\n" - " - No duplicate user or group entries with the same uid/gid.\n" - " If it is a directory:\n" - " - One default user entry for the owner of the file.\n" - " - One default group entry for the group of the file.\n" - " - One default mask entry for the file group class.\n" - " - One default other entry.\n" - "\n" - "-m Add or modify one or more specified ACL entries.\n" - " Acl_entries is a comma-separated list of entries from the \n" - " same list as above.\n" - "\n" - "-r Causes the permissions specified in the mask entry to be\n" - " ignored and replaced by the maximum permissions needed for\n" - " the file group class.\n" - "\n" - "-s Like -f, but substitute the file's ACL with Acl_entries\n" - " specified in a comma-separated list on the command line.\n" - "\n" - "While the -d and -m options may be used in the same command, the\n" - "-f and -s options may be used only exclusively.\n" - "\n" - "Directories may contain default ACL entries. Files created\n" - "in a directory that contains default ACL entries will have\n" - "permissions according to the combination of the current umask,\n" - "the explicit permissions requested and the default ACL entries\n" - "Note: Under Cygwin, the default ACL entries are not taken into\n" - "account currently.\n\n", prog_name); + " Acl_entries are one or more comma-separated ACL entries \n" + " from the following list:\n" + "\n" + " u[ser]::perm\n" + " u[ser]:uid:perm\n" + " g[roup]::perm\n" + " g[roup]:gid:perm\n" + " m[ask]:perm\n" + " o[ther]:perm\n" + "\n" + " Default entries are like the above with the additional\n" + " default identifier. For example: \n" + "\n" + " d[efault]:u[ser]:uid:perm\n" + "\n" + " 'perm' is either a 3-char permissions string in the form\n" + " \"rwx\" with the character - for no permission\n" + " or it is the octal representation of the permissions, a\n" + " value from 0 (equivalent to \"---\") to 7 (\"rwx\").\n" + " 'uid' is a user name or a numerical uid.\n" + " 'gid' is a group name or a numerical gid.\n" + "\n" + "\n" + "For each file given as parameter, %s will either replace its\n" + "complete ACL (-s, -f), or it will add, modify, or delete ACL\n" + "entries.\n" + "\n" + "The following options are supported:\n" + "\n" + "-d Delete one or more specified entries from the file's ACL.\n" + " The owner, group and others entries must not be deleted.\n" + " Acl_entries to be deleted should be specified without\n" + " permissions, as in the following list:\n" + "\n" + " u[ser]:uid\n" + " g[roup]:gid\n" + " d[efault]:u[ser]:uid\n" + " d[efault]:g[roup]:gid\n" + " d[efault]:m[ask]:\n" + " d[efault]:o[ther]:\n" + "\n" + "-f Take the Acl_entries from ACL_FILE one per line. Whitespace\n" + " characters are ignored, and the character \"#\" may be used\n" + " to start a comment. The special filename \"-\" indicates\n" + " reading from stdin.\n" + " Required entries are\n" + " - One user entry for the owner of the file.\n" + " - One group entry for the group of the file.\n" + " - One other entry.\n" + " If additional user and group entries are given:\n" + " - A mask entry for the file group class of the file.\n" + " - No duplicate user or group entries with the same uid/gid.\n" + " If it is a directory:\n" + " - One default user entry for the owner of the file.\n" + " - One default group entry for the group of the file.\n" + " - One default mask entry for the file group class.\n" + " - One default other entry.\n" + "\n" + "-m Add or modify one or more specified ACL entries.\n" + " Acl_entries is a comma-separated list of entries from the \n" + " same list as above.\n" + "\n" + "-r Causes the permissions specified in the mask entry to be\n" + " ignored and replaced by the maximum permissions needed for\n" + " the file group class.\n" + "\n" + "-s Like -f, but substitute the file's ACL with Acl_entries\n" + " specified in a comma-separated list on the command line.\n" + "\n" + "While the -d and -m options may be used in the same command, the\n" + "-f and -s options may be used only exclusively.\n" + "\n" + "Directories may contain default ACL entries. Files created\n" + "in a directory that contains default ACL entries will have\n" + "permissions according to the combination of the current umask,\n" + "the explicit permissions requested and the default ACL entries\n" + "Note: Under Cygwin, the default ACL entries are not taken into\n" + "account currently.\n\n", prog_name); } else fprintf(stream, "Try '%s --help' for more information.\n", prog_name); @@ -410,14 +410,14 @@ static void print_version () { printf ("setfacl (cygwin) %d.%d.%d\n" - "POSIX ACL modification utility\n" - "Copyright (C) 2000 - %s Red Hat, Inc.\n" - "This is free software; see the source for copying conditions. There is NO\n" + "POSIX ACL modification utility\n" + "Copyright (C) 2000 - %s Red Hat, Inc.\n" + "This is free software; see the source for copying conditions. There is NO\n" "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n", - CYGWIN_VERSION_DLL_MAJOR / 1000, - CYGWIN_VERSION_DLL_MAJOR % 1000, - CYGWIN_VERSION_DLL_MINOR, - strrchr (__DATE__, ' ') + 1); + CYGWIN_VERSION_DLL_MAJOR / 1000, + CYGWIN_VERSION_DLL_MAJOR % 1000, + CYGWIN_VERSION_DLL_MINOR, + strrchr (__DATE__, ' ') + 1); } int @@ -437,83 +437,83 @@ main (int argc, char **argv) switch (c) { case 'd': - if (action == NoAction) - action = Delete; - else if (action == Modify) - action = ModNDel; - else - { - usage (stderr); - return 1; + if (action == NoAction) + action = Delete; + else if (action == Modify) + action = ModNDel; + else + { + usage (stderr); + return 1; } - if (! getaclentries (Delete, optarg, acls, &aclidx)) - { - fprintf (stderr, "%s: illegal acl entries\n", prog_name); - return 2; - } - break; + if (! getaclentries (Delete, optarg, acls, &aclidx)) + { + fprintf (stderr, "%s: illegal acl entries\n", prog_name); + return 2; + } + break; case 'f': - if (action == NoAction) - action = Set; - else - { - usage (stderr); - return 1; + if (action == NoAction) + action = Set; + else + { + usage (stderr); + return 1; + } + if (! getaclentries (SetFromFile, optarg, acls, &aclidx)) + { + fprintf (stderr, "%s: illegal acl entries\n", prog_name); + return 2; } - if (! getaclentries (SetFromFile, optarg, acls, &aclidx)) - { - fprintf (stderr, "%s: illegal acl entries\n", prog_name); - return 2; - } - break; + break; case 'h': - usage (stdout); - return 0; + usage (stdout); + return 0; case 'm': - if (action == NoAction) - action = Modify; - else if (action == Delete) - action = ModNDel; - else - { - usage (stderr); - return 1; + if (action == NoAction) + action = Modify; + else if (action == Delete) + action = ModNDel; + else + { + usage (stderr); + return 1; } - if (! getaclentries (Modify, optarg, acls, &aclidx)) - { - fprintf (stderr, "%s: illegal acl entries\n", prog_name); - return 2; - } - break; + if (! getaclentries (Modify, optarg, acls, &aclidx)) + { + fprintf (stderr, "%s: illegal acl entries\n", prog_name); + return 2; + } + break; case 'r': - if (!ropt) - ropt = 1; - else - { - usage (stderr); - return 1; + if (!ropt) + ropt = 1; + else + { + usage (stderr); + return 1; } - break; + break; case 's': - if (action == NoAction) - action = Set; - else - { - usage (stderr); - return 1; + if (action == NoAction) + action = Set; + else + { + usage (stderr); + return 1; + } + if (! getaclentries (Set, optarg, acls, &aclidx)) + { + fprintf (stderr, "%s: illegal acl entries\n", prog_name); + return 2; } - if (! getaclentries (Set, optarg, acls, &aclidx)) - { - fprintf (stderr, "%s: illegal acl entries\n", prog_name); - return 2; - } - break; + break; case 'V': - print_version (); - return 0; + print_version (); + return 0; default: - fprintf (stderr, "Try `%s --help' for more information.\n", prog_name); - return 1; + fprintf (stderr, "Try `%s --help' for more information.\n", prog_name); + return 1; } if (action == NoAction) { @@ -529,31 +529,31 @@ main (int argc, char **argv) switch (aclcheck (acls, aclidx, NULL)) { case GRP_ERROR: - fprintf (stderr, "%s: more than one group entry.\n", prog_name); - return 2; + fprintf (stderr, "%s: more than one group entry.\n", prog_name); + return 2; case USER_ERROR: - fprintf (stderr, "%s: more than one user entry.\n", prog_name); - return 2; + fprintf (stderr, "%s: more than one user entry.\n", prog_name); + return 2; case CLASS_ERROR: - fprintf (stderr, "%s: more than one mask entry.\n", prog_name); - return 2; + fprintf (stderr, "%s: more than one mask entry.\n", prog_name); + return 2; case OTHER_ERROR: - fprintf (stderr, "%s: more than one other entry.\n", prog_name); - return 2; + fprintf (stderr, "%s: more than one other entry.\n", prog_name); + return 2; case DUPLICATE_ERROR: - fprintf (stderr, "%s: duplicate additional user or group.\n", prog_name); - return 2; + fprintf (stderr, "%s: duplicate additional user or group.\n", prog_name); + return 2; case ENTRY_ERROR: - fprintf (stderr, "%s: invalid entry type.\n", prog_name); - return 2; + fprintf (stderr, "%s: invalid entry type.\n", prog_name); + return 2; case MISS_ERROR: - fprintf (stderr, "%s: missing entries.\n", prog_name); - return 2; + fprintf (stderr, "%s: missing entries.\n", prog_name); + return 2; case MEM_ERROR: - fprintf (stderr, "%s: out of memory.\n", prog_name); - return 2; + fprintf (stderr, "%s: out of memory.\n", prog_name); + return 2; default: - break; + break; } for (c = optind; c < argc; ++c) ret |= setfacl (action, argv[c], acls, aclidx); |