mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-03 09:00:21 +00:00
style(9) cleanups mostly consisting of:
o explicitly check return values and variables against a value o return x; -> return (x); o fix inconsistent sysexits usage by nuking it (partially suggested by bde) Obtained from: TrustedBSD Project
This commit is contained in:
parent
05da5209f6
commit
a043a09da7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=87254
@ -32,43 +32,44 @@
|
|||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sysexits.h>
|
|
||||||
|
|
||||||
#include "setfacl.h"
|
#include "setfacl.h"
|
||||||
|
|
||||||
/* read acl text from a file and return the corresponding acl */
|
/*
|
||||||
|
* read acl text from a file and return the corresponding acl
|
||||||
|
*/
|
||||||
acl_t
|
acl_t
|
||||||
get_acl_from_file(const char *filename)
|
get_acl_from_file(const char *filename)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
|
|
||||||
if (!filename)
|
if (filename == NULL)
|
||||||
err(EX_USAGE, "(null) filename in get_acl_from_file()");
|
err(1, "(null) filename in get_acl_from_file()");
|
||||||
|
|
||||||
bzero(&buf, sizeof(buf));
|
bzero(&buf, sizeof(buf));
|
||||||
|
|
||||||
if (!strcmp(filename, "-")) {
|
if (strcmp(filename, "-") == 0) {
|
||||||
if (have_stdin)
|
if (have_stdin != 0)
|
||||||
err(EX_USAGE, "cannot specify more than one stdin");
|
err(1, "cannot specify more than one stdin");
|
||||||
file = stdin;
|
file = stdin;
|
||||||
have_stdin = 1;
|
have_stdin = 1;
|
||||||
} else {
|
} else {
|
||||||
file = fopen(filename, "r");
|
file = fopen(filename, "r");
|
||||||
if (!file)
|
if (file == NULL)
|
||||||
err(EX_OSERR, "fopen() %s failed", filename);
|
err(1, "fopen() %s failed", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
fread(buf, sizeof(buf), (size_t)1, file);
|
fread(buf, sizeof(buf), (size_t)1, file);
|
||||||
if (ferror(file)) {
|
if (ferror(file) != 0) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
err(EX_USAGE, "error reading from %s", filename);
|
err(1, "error reading from %s", filename);
|
||||||
} else if (!feof(file)) {
|
} else if (feof(file) == 0) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
errx(EX_USAGE, "line too long in %s", filename);
|
errx(1, "line too long in %s", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
return acl_from_text(buf);
|
return (acl_from_text(buf));
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sysexits.h>
|
|
||||||
|
|
||||||
#include "setfacl.h"
|
#include "setfacl.h"
|
||||||
|
|
||||||
@ -55,13 +54,13 @@ set_acl_mask(acl_t *prev_acl)
|
|||||||
* specified ACL mask entry.
|
* specified ACL mask entry.
|
||||||
*/
|
*/
|
||||||
if (have_mask)
|
if (have_mask)
|
||||||
return 0;
|
return (0);
|
||||||
|
|
||||||
acl = acl_dup(*prev_acl);
|
acl = acl_dup(*prev_acl);
|
||||||
if (!acl)
|
if (acl == NULL)
|
||||||
err(EX_OSERR, "acl_dup() failed");
|
err(1, "acl_dup() failed");
|
||||||
|
|
||||||
if (!n_flag) {
|
if (n_flag == 0) {
|
||||||
/*
|
/*
|
||||||
* If no mask entry is specified and the -n option is not
|
* If no mask entry is specified and the -n option is not
|
||||||
* specified, then the permissions of the resulting ACL mask
|
* specified, then the permissions of the resulting ACL mask
|
||||||
@ -72,7 +71,7 @@ set_acl_mask(acl_t *prev_acl)
|
|||||||
if (acl_calc_mask(&acl)) {
|
if (acl_calc_mask(&acl)) {
|
||||||
warn("acl_calc_mask() failed");
|
warn("acl_calc_mask() failed");
|
||||||
acl_free(acl);
|
acl_free(acl);
|
||||||
return -1;
|
return (-1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@ -90,7 +89,7 @@ set_acl_mask(acl_t *prev_acl)
|
|||||||
|
|
||||||
if (tag == ACL_MASK) {
|
if (tag == ACL_MASK) {
|
||||||
acl_free(acl);
|
acl_free(acl);
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,11 +101,11 @@ set_acl_mask(acl_t *prev_acl)
|
|||||||
*/
|
*/
|
||||||
warnx("warning: no mask entry");
|
warnx("warning: no mask entry");
|
||||||
acl_free(acl);
|
acl_free(acl);
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
**prev_acl = *acl;
|
**prev_acl = *acl;
|
||||||
acl_free(acl);
|
acl_free(acl);
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,12 @@
|
|||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sysexits.h>
|
|
||||||
|
|
||||||
#include "setfacl.h"
|
#include "setfacl.h"
|
||||||
|
|
||||||
/* merge acl into existing file's ACL */
|
/*
|
||||||
|
* merge an ACL into existing file's ACL
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
merge_acl(acl_t acl, acl_t *prev_acl)
|
merge_acl(acl_t acl, acl_t *prev_acl)
|
||||||
{
|
{
|
||||||
@ -51,8 +52,8 @@ merge_acl(acl_t acl, acl_t *prev_acl)
|
|||||||
acl_new = acl_dup(prev_acl[0]);
|
acl_new = acl_dup(prev_acl[0]);
|
||||||
else
|
else
|
||||||
acl_new = acl_dup(prev_acl[1]);
|
acl_new = acl_dup(prev_acl[1]);
|
||||||
if (!acl_new)
|
if (acl_new == NULL)
|
||||||
err(EX_OSERR, "acl_dup() failed");
|
err(1, "acl_dup() failed");
|
||||||
|
|
||||||
entry_id = ACL_FIRST_ENTRY;
|
entry_id = ACL_FIRST_ENTRY;
|
||||||
|
|
||||||
@ -62,21 +63,20 @@ merge_acl(acl_t acl, acl_t *prev_acl)
|
|||||||
|
|
||||||
/* keep track of existing ACL_MASK entries */
|
/* keep track of existing ACL_MASK entries */
|
||||||
if (acl_get_tag_type(entry, &tag) == -1)
|
if (acl_get_tag_type(entry, &tag) == -1)
|
||||||
err(EX_OSERR,
|
err(1, "acl_get_tag_type() failed - invalid ACL entry");
|
||||||
"acl_get_tag_type() failed - invalid ACL entry");
|
|
||||||
if (tag == ACL_MASK)
|
if (tag == ACL_MASK)
|
||||||
have_mask = 1;
|
have_mask = 1;
|
||||||
|
|
||||||
/* check against the existing ACL entries */
|
/* check against the existing ACL entries */
|
||||||
entry_id_new = ACL_FIRST_ENTRY;
|
entry_id_new = ACL_FIRST_ENTRY;
|
||||||
while (!have_entry &&
|
while (have_entry == 0 &&
|
||||||
acl_get_entry(acl_new, entry_id_new, &entry_new) == 1) {
|
acl_get_entry(acl_new, entry_id_new, &entry_new) == 1) {
|
||||||
entry_id_new = ACL_NEXT_ENTRY;
|
entry_id_new = ACL_NEXT_ENTRY;
|
||||||
|
|
||||||
if (acl_get_tag_type(entry, &tag) == -1)
|
if (acl_get_tag_type(entry, &tag) == -1)
|
||||||
err(EX_OSERR, "acl_get_tag_type() failed");
|
err(1, "acl_get_tag_type() failed");
|
||||||
if (acl_get_tag_type(entry_new, &tag_new) == -1)
|
if (acl_get_tag_type(entry_new, &tag_new) == -1)
|
||||||
err(EX_OSERR, "acl_get_tag_type() failed");
|
err(1, "acl_get_tag_type() failed");
|
||||||
if (tag != tag_new)
|
if (tag != tag_new)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -85,27 +85,25 @@ merge_acl(acl_t acl, acl_t *prev_acl)
|
|||||||
case ACL_GROUP:
|
case ACL_GROUP:
|
||||||
id = acl_get_qualifier(entry);
|
id = acl_get_qualifier(entry);
|
||||||
if (id == NULL)
|
if (id == NULL)
|
||||||
err(EX_OSERR,
|
err(1, "acl_get_qualifier() failed");
|
||||||
"acl_get_qualifier() failed");
|
|
||||||
id_new = acl_get_qualifier(entry_new);
|
id_new = acl_get_qualifier(entry_new);
|
||||||
if (id_new == NULL)
|
if (id_new == NULL)
|
||||||
err(EX_OSERR,
|
err(1, "acl_get_qualifier() failed");
|
||||||
"acl_get_qualifier() failed");
|
|
||||||
if (*id == *id_new) {
|
if (*id == *id_new) {
|
||||||
/* any other matches */
|
/* any other matches */
|
||||||
if (acl_get_permset(entry, &permset)
|
if (acl_get_permset(entry, &permset)
|
||||||
== -1)
|
== -1)
|
||||||
err(EX_OSERR,
|
err(1,
|
||||||
"acl_get_permset() failed");
|
"acl_get_permset() failed");
|
||||||
if (acl_set_permset(entry_new, permset)
|
if (acl_set_permset(entry_new, permset)
|
||||||
== -1)
|
== -1)
|
||||||
err(EX_OSERR,
|
err(1,
|
||||||
"acl_set_permset() failed");
|
"acl_set_permset() failed");
|
||||||
have_entry = 1;
|
have_entry = 1;
|
||||||
}
|
}
|
||||||
acl_free(id);
|
acl_free(id);
|
||||||
acl_free(id_new);
|
acl_free(id_new);
|
||||||
if (!have_entry)
|
if (have_entry == 0)
|
||||||
break;
|
break;
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case ACL_USER_OBJ:
|
case ACL_USER_OBJ:
|
||||||
@ -113,28 +111,26 @@ merge_acl(acl_t acl, acl_t *prev_acl)
|
|||||||
case ACL_OTHER:
|
case ACL_OTHER:
|
||||||
case ACL_MASK:
|
case ACL_MASK:
|
||||||
if (acl_get_permset(entry, &permset) == -1)
|
if (acl_get_permset(entry, &permset) == -1)
|
||||||
err(EX_OSERR,
|
err(1, "acl_get_permset() failed");
|
||||||
"acl_get_permset() failed");
|
|
||||||
if (acl_set_permset(entry_new, permset) == -1)
|
if (acl_set_permset(entry_new, permset) == -1)
|
||||||
err(EX_OSERR,
|
err(1, "acl_set_permset() failed");
|
||||||
"acl_set_permset() failed");
|
|
||||||
have_entry = 1;
|
have_entry = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* should never be here */
|
/* should never be here */
|
||||||
errx(EX_OSERR, "Invalid tag type: %i", tag);
|
errx(1, "Invalid tag type: %i", tag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if this entry has not been found, it must be new */
|
/* if this entry has not been found, it must be new */
|
||||||
if (!have_entry) {
|
if (have_entry == 0) {
|
||||||
if (acl_create_entry(&acl_new, &entry_new) == -1) {
|
if (acl_create_entry(&acl_new, &entry_new) == -1) {
|
||||||
acl_free(acl_new);
|
acl_free(acl_new);
|
||||||
return -1;
|
return (-1);
|
||||||
}
|
}
|
||||||
if (acl_copy_entry(entry_new, entry) == -1)
|
if (acl_copy_entry(entry_new, entry) == -1)
|
||||||
err(EX_OSERR, "acl_copy_entry() failed");
|
err(1, "acl_copy_entry() failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,5 +144,5 @@ merge_acl(acl_t acl, acl_t *prev_acl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -33,11 +33,12 @@
|
|||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sysexits.h>
|
|
||||||
|
|
||||||
#include "setfacl.h"
|
#include "setfacl.h"
|
||||||
|
|
||||||
/* remove ACL entries from an ACL */
|
/*
|
||||||
|
* remove ACL entries from an ACL
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
remove_acl(acl_t acl, acl_t *prev_acl)
|
remove_acl(acl_t acl, acl_t *prev_acl)
|
||||||
{
|
{
|
||||||
@ -52,8 +53,8 @@ remove_acl(acl_t acl, acl_t *prev_acl)
|
|||||||
acl_new = acl_dup(prev_acl[0]);
|
acl_new = acl_dup(prev_acl[0]);
|
||||||
else
|
else
|
||||||
acl_new = acl_dup(prev_acl[1]);
|
acl_new = acl_dup(prev_acl[1]);
|
||||||
if (!acl_new)
|
if (acl_new == NULL)
|
||||||
err(EX_OSERR, "acl_dup() failed");
|
err(1, "acl_dup() failed");
|
||||||
|
|
||||||
tag = ACL_UNDEFINED_TAG;
|
tag = ACL_UNDEFINED_TAG;
|
||||||
|
|
||||||
@ -80,12 +81,14 @@ remove_acl(acl_t acl, acl_t *prev_acl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (carried_error)
|
if (carried_error)
|
||||||
return -1;
|
return (-1);
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove default entries */
|
/*
|
||||||
|
* remove default entries
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
remove_default(acl_t *prev_acl)
|
remove_default(acl_t *prev_acl)
|
||||||
{
|
{
|
||||||
@ -93,16 +96,18 @@ remove_default(acl_t *prev_acl)
|
|||||||
if (prev_acl[1]) {
|
if (prev_acl[1]) {
|
||||||
acl_free(prev_acl[1]);
|
acl_free(prev_acl[1]);
|
||||||
prev_acl[1] = acl_init(ACL_MAX_ENTRIES);
|
prev_acl[1] = acl_init(ACL_MAX_ENTRIES);
|
||||||
if (!prev_acl[1])
|
if (prev_acl[1] == NULL)
|
||||||
err(1, "acl_init() failed");
|
err(1, "acl_init() failed");
|
||||||
} else {
|
} else {
|
||||||
warn("cannot remove default ACL");
|
warn("cannot remove default ACL");
|
||||||
return -1;
|
return (-1);
|
||||||
}
|
}
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove extended entries */
|
/*
|
||||||
|
* remove extended entries
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
remove_ext(acl_t *prev_acl)
|
remove_ext(acl_t *prev_acl)
|
||||||
{
|
{
|
||||||
@ -116,13 +121,13 @@ remove_ext(acl_t *prev_acl)
|
|||||||
acl_old = acl_dup(prev_acl[0]);
|
acl_old = acl_dup(prev_acl[0]);
|
||||||
else
|
else
|
||||||
acl_old = acl_dup(prev_acl[1]);
|
acl_old = acl_dup(prev_acl[1]);
|
||||||
if (!acl_old)
|
if (acl_old == NULL)
|
||||||
err(EX_OSERR, "acl_dup() failed");
|
err(1, "acl_dup() failed");
|
||||||
|
|
||||||
have_mask_entry = 0;
|
have_mask_entry = 0;
|
||||||
acl_new = acl_init(ACL_MAX_ENTRIES);
|
acl_new = acl_init(ACL_MAX_ENTRIES);
|
||||||
if (!acl_new)
|
if (acl_new == NULL)
|
||||||
err(EX_OSERR, "%s", "acl_init() failed");
|
err(1, "acl_init() failed");
|
||||||
tag = ACL_UNDEFINED_TAG;
|
tag = ACL_UNDEFINED_TAG;
|
||||||
|
|
||||||
/* only save the default user/group/other entries */
|
/* only save the default user/group/other entries */
|
||||||
@ -157,7 +162,7 @@ remove_ext(acl_t *prev_acl)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (have_mask_entry && !n_flag) {
|
if (have_mask_entry && n_flag == 0) {
|
||||||
if (acl_calc_mask(&acl_new) == -1)
|
if (acl_calc_mask(&acl_new) == -1)
|
||||||
err(1, "acl_calc_mask() failed");
|
err(1, "acl_calc_mask() failed");
|
||||||
} else {
|
} else {
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sysexits.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "setfacl.h"
|
#include "setfacl.h"
|
||||||
@ -67,21 +66,21 @@ get_file_acls(const char *filename)
|
|||||||
|
|
||||||
if (stat(filename, &sb) == -1) {
|
if (stat(filename, &sb) == -1) {
|
||||||
warn("stat() of %s failed", filename);
|
warn("stat() of %s failed", filename);
|
||||||
return NULL;
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
acl = zmalloc(sizeof(acl_t) * 2);
|
acl = zmalloc(sizeof(acl_t) * 2);
|
||||||
acl[0] = acl_get_file(filename, ACL_TYPE_ACCESS);
|
acl[0] = acl_get_file(filename, ACL_TYPE_ACCESS);
|
||||||
if (!acl[0])
|
if (acl[0] == NULL)
|
||||||
err(EX_OSERR, "acl_get_file() failed");
|
err(1, "acl_get_file() failed");
|
||||||
if (S_ISDIR(sb.st_mode)) {
|
if (S_ISDIR(sb.st_mode)) {
|
||||||
acl[1] = acl_get_file(filename, ACL_TYPE_DEFAULT);
|
acl[1] = acl_get_file(filename, ACL_TYPE_DEFAULT);
|
||||||
if (!acl[1])
|
if (acl[1] == NULL)
|
||||||
err(EX_OSERR, "acl_get_file() failed");
|
err(1, "acl_get_file() failed");
|
||||||
} else
|
} else
|
||||||
acl[1] = NULL;
|
acl[1] = NULL;
|
||||||
|
|
||||||
return acl;
|
return (acl);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -90,7 +89,7 @@ usage(void)
|
|||||||
|
|
||||||
fprintf(stderr, "usage: setfacl [-bdknv] [-m entries] [-M file1] "
|
fprintf(stderr, "usage: setfacl [-bdknv] [-m entries] [-M file1] "
|
||||||
"[-x entries] [-X file2] [file ...]\n");
|
"[-x entries] [-X file2] [file ...]\n");
|
||||||
exit(EX_USAGE);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -114,8 +113,8 @@ main(int argc, char *argv[])
|
|||||||
case 'M':
|
case 'M':
|
||||||
entry = zmalloc(sizeof(struct sf_entry));
|
entry = zmalloc(sizeof(struct sf_entry));
|
||||||
entry->acl = get_acl_from_file(optarg);
|
entry->acl = get_acl_from_file(optarg);
|
||||||
if (!entry->acl)
|
if (entry->acl == NULL)
|
||||||
err(EX_OSERR, "get_acl_from_file() failed");
|
err(1, "get_acl_from_file() failed");
|
||||||
entry->op = OP_MERGE_ACL;
|
entry->op = OP_MERGE_ACL;
|
||||||
TAILQ_INSERT_TAIL(&entrylist, entry, next);
|
TAILQ_INSERT_TAIL(&entrylist, entry, next);
|
||||||
break;
|
break;
|
||||||
@ -141,8 +140,8 @@ main(int argc, char *argv[])
|
|||||||
case 'm':
|
case 'm':
|
||||||
entry = zmalloc(sizeof(struct sf_entry));
|
entry = zmalloc(sizeof(struct sf_entry));
|
||||||
entry->acl = acl_from_text(optarg);
|
entry->acl = acl_from_text(optarg);
|
||||||
if (!entry->acl)
|
if (entry->acl == NULL)
|
||||||
err(EX_USAGE, "acl_from_text() failed");
|
err(1, "acl_from_text() failed");
|
||||||
entry->op = OP_MERGE_ACL;
|
entry->op = OP_MERGE_ACL;
|
||||||
TAILQ_INSERT_TAIL(&entrylist, entry, next);
|
TAILQ_INSERT_TAIL(&entrylist, entry, next);
|
||||||
break;
|
break;
|
||||||
@ -152,8 +151,8 @@ main(int argc, char *argv[])
|
|||||||
case 'x':
|
case 'x':
|
||||||
entry = zmalloc(sizeof(struct sf_entry));
|
entry = zmalloc(sizeof(struct sf_entry));
|
||||||
entry->acl = acl_from_text(optarg);
|
entry->acl = acl_from_text(optarg);
|
||||||
if (!entry->acl)
|
if (entry->acl == NULL)
|
||||||
err(EX_USAGE, "acl_from_text() failed");
|
err(1, "acl_from_text() failed");
|
||||||
entry->op = OP_REMOVE_ACL;
|
entry->op = OP_REMOVE_ACL;
|
||||||
TAILQ_INSERT_TAIL(&entrylist, entry, next);
|
TAILQ_INSERT_TAIL(&entrylist, entry, next);
|
||||||
break;
|
break;
|
||||||
@ -164,13 +163,13 @@ main(int argc, char *argv[])
|
|||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
if (!n_flag && TAILQ_EMPTY(&entrylist))
|
if (n_flag == 0 && TAILQ_EMPTY(&entrylist))
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
/* take list of files from stdin */
|
/* take list of files from stdin */
|
||||||
if (argc == 0 || !strcmp(argv[0], "-")) {
|
if (argc == 0 || strcmp(argv[0], "-") == 0) {
|
||||||
if (have_stdin)
|
if (have_stdin)
|
||||||
err(EX_USAGE, "cannot have more than one stdin");
|
err(1, "cannot have more than one stdin");
|
||||||
have_stdin = 1;
|
have_stdin = 1;
|
||||||
bzero(&filename, sizeof(filename));
|
bzero(&filename, sizeof(filename));
|
||||||
while (fgets(filename, (int)sizeof(filename), stdin)) {
|
while (fgets(filename, (int)sizeof(filename), stdin)) {
|
||||||
@ -186,7 +185,7 @@ main(int argc, char *argv[])
|
|||||||
TAILQ_FOREACH(file, &filelist, next) {
|
TAILQ_FOREACH(file, &filelist, next) {
|
||||||
/* get our initial access and default ACL's */
|
/* get our initial access and default ACL's */
|
||||||
acl = get_file_acls(file->filename);
|
acl = get_file_acls(file->filename);
|
||||||
if (!acl)
|
if (acl == NULL)
|
||||||
continue;
|
continue;
|
||||||
if ((acl_type == ACL_TYPE_DEFAULT) && !acl[1]) {
|
if ((acl_type == ACL_TYPE_DEFAULT) && !acl[1]) {
|
||||||
warnx("Default ACL not valid for %s", file->filename);
|
warnx("Default ACL not valid for %s", file->filename);
|
||||||
@ -221,7 +220,6 @@ main(int argc, char *argv[])
|
|||||||
local_error += remove_acl(entry->acl, acl);
|
local_error += remove_acl(entry->acl, acl);
|
||||||
need_mask = 1;
|
need_mask = 1;
|
||||||
break;
|
break;
|
||||||
/* NOTREACHED */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,5 +248,5 @@ main(int argc, char *argv[])
|
|||||||
free(acl);
|
free(acl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return carried_error;
|
return (carried_error);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sysexits.h>
|
|
||||||
|
|
||||||
#include "setfacl.h"
|
#include "setfacl.h"
|
||||||
|
|
||||||
@ -40,6 +39,6 @@ zmalloc(size_t size)
|
|||||||
|
|
||||||
ptr = calloc(1, size);
|
ptr = calloc(1, size);
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
err(EX_OSERR, "calloc() failed");
|
err(1, "calloc() failed");
|
||||||
return ptr;
|
return (ptr);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user