policycoreutils: make ignore_enoent do something

We have dumb code in setfiles which will set a static variable called
ignore_enoent.  Thing is, nothing uses it.  So move the setting to where
it is useful and use it!

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
This commit is contained in:
Eric Paris 2011-07-10 16:38:41 +02:00
parent 84ea17b5f3
commit 30ad11feb9
3 changed files with 4 additions and 2 deletions

View File

@ -374,6 +374,8 @@ int process_one_realpath(char *name, int recurse)
} else {
rc = lstat(name, &sb);
if (rc < 0) {
if (r_opts->ignore_enoent && errno == ENOENT)
return 0;
fprintf(stderr, "%s: lstat(%s) failed: %s\n",
r_opts->progname, name, strerror(errno));
return -1;

View File

@ -27,6 +27,7 @@ struct restore_opts {
int hard_links;
int verbose;
int logging;
int ignore_enoent;
char *rootpath;
int rootpathlen;
char *progname;

View File

@ -25,7 +25,6 @@ static char *policyfile = NULL;
static int warn_no_match = 0;
static int null_terminated = 0;
static int errors;
static int ignore_enoent;
static struct restore_opts r_opts;
#define STAT_BLOCK_SIZE 1
@ -335,7 +334,7 @@ int main(int argc, char **argv)
r_opts.debug = 1;
break;
case 'i':
ignore_enoent = 1;
r_opts.ignore_enoent = 1;
break;
case 'l':
r_opts.logging = 1;