aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2012-10-28 04:52:56 +0000
committerMike Frysinger <vapier@gentoo.org>2012-10-28 04:52:56 +0000
commita4b0b822b8f82df5c1b57b58465c5d524a216c9e (patch)
tree9f7b7f9031e1e7055e71d8a416874e42ead760c3 /qcheck.c
parentshow matched pkgs even when DESCRIPTION could not be found #435636 by slawomi... (diff)
downloadportage-utils-a4b0b822b8f82df5c1b57b58465c5d524a216c9e.tar.gz
portage-utils-a4b0b822b8f82df5c1b57b58465c5d524a216c9e.tar.bz2
portage-utils-a4b0b822b8f82df5c1b57b58465c5d524a216c9e.zip
support skipping checking of CONFIG_PROTECT-ed files #330537 by Michał Górny
Diffstat (limited to 'qcheck.c')
-rw-r--r--qcheck.c55
1 files changed, 44 insertions, 11 deletions
diff --git a/qcheck.c b/qcheck.c
index 1dca35a..afff873 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2011 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qcheck.c,v 1.55 2011/12/19 04:23:18 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qcheck.c,v 1.56 2012/10/28 04:52:56 vapier Exp $
*
* Copyright 2005-2010 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2011 Mike Frysinger - <vapier@gentoo.org>
@@ -11,15 +11,16 @@
#define QCHECK_FLAGS "aes:uABHTp" COMMON_FLAGS
static struct option const qcheck_long_opts[] = {
- {"all", no_argument, NULL, 'a'},
- {"exact", no_argument, NULL, 'e'},
- {"skip", a_argument, NULL, 's'},
- {"update", no_argument, NULL, 'u'},
- {"noafk", no_argument, NULL, 'A'},
- {"badonly", no_argument, NULL, 'B'},
- {"nohash", no_argument, NULL, 'H'},
- {"nomtime", no_argument, NULL, 'T'},
- {"prelink", no_argument, NULL, 'p'},
+ {"all", no_argument, NULL, 'a'},
+ {"exact", no_argument, NULL, 'e'},
+ {"skip", a_argument, NULL, 's'},
+ {"update", no_argument, NULL, 'u'},
+ {"noafk", no_argument, NULL, 'A'},
+ {"badonly", no_argument, NULL, 'B'},
+ {"nohash", no_argument, NULL, 'H'},
+ {"nomtime", no_argument, NULL, 'T'},
+ {"skip-protected", no_argument, NULL, 128},
+ {"prelink", no_argument, NULL, 'p'},
COMMON_LONG_OPTS
};
static const char * const qcheck_opts_help[] = {
@@ -31,10 +32,11 @@ static const char * const qcheck_opts_help[] = {
"Only print pkgs containing bad files",
"Ignore differing/unknown file chksums",
"Ignore differing file mtimes",
+ "Ignore files in CONFIG_PROTECT-ed paths",
"Undo prelink when calculating checksums",
COMMON_OPTS_HELP
};
-static const char qcheck_rcsid[] = "$Id: qcheck.c,v 1.55 2011/12/19 04:23:18 vapier Exp $";
+static const char qcheck_rcsid[] = "$Id: qcheck.c,v 1.56 2012/10/28 04:52:56 vapier Exp $";
#define qcheck_usage(ret) usage(ret, QCHECK_FLAGS, qcheck_long_opts, qcheck_opts_help, lookup_applet_idx("qcheck"))
#define qcprintf(fmt, args...) if (!state->bad_only) printf(_(fmt), ## args)
@@ -49,6 +51,7 @@ struct qcheck_opt_state {
bool chk_afk;
bool chk_hash;
bool chk_mtime;
+ bool chk_config_protect;
bool undo_prelink;
bool exact;
};
@@ -63,6 +66,8 @@ static int qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_sta
char *buffer, *line;
size_t linelen;
struct stat st, cst;
+ int cp_argc, cpm_argc;
+ char **cp_argv, **cpm_argv;
fpx = NULL;
@@ -91,6 +96,11 @@ static int qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_sta
}
}
+ if (!state->chk_config_protect) {
+ makeargv(config_protect, &cp_argc, &cp_argv);
+ makeargv(config_protect_mask, &cpm_argc, &cpm_argv);
+ }
+
buffer = line = NULL;
while (getline(&line, &linelen, fp) != -1) {
contents_entry *e;
@@ -127,6 +137,21 @@ static int qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_sta
continue;
}
if (e->digest && S_ISREG(st.st_mode)) {
+ if (!state->chk_config_protect) {
+ /* handle CONFIG_PROTECT-ed files */
+ int i;
+ /* if it's in CONFIG_PROTECT_MASK, check it like normal */
+ for (i = 1; i < cpm_argc; ++i)
+ if (strncmp(cpm_argv[i], e->name, strlen(cpm_argv[i])) == 0)
+ break;
+ if (i == cpm_argc) {
+ /* not explicitly masked, so if it's protected */
+ for (i = 1; i < cp_argc; ++i)
+ if (strncmp(cp_argv[i], e->name, strlen(cp_argv[i])) == 0)
+ goto cfg_protected;
+ }
+ }
+
/* validate digest (handles MD5 / SHA1) */
uint8_t hash_algo;
char *hashed_file;
@@ -225,12 +250,18 @@ static int qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_sta
if (state->qc_update)
fputs(buffer, fpx);
}
+ cfg_protected:
++num_files_ok;
}
free(line);
free(buffer);
fclose(fp);
+ if (!state->chk_config_protect) {
+ freeargv(cp_argc, cp_argv);
+ freeargv(cpm_argc, cpm_argv);
+ }
+
if (state->qc_update) {
if (fchown(fd, cst.st_uid, cst.st_gid)) {
/* meh */;
@@ -338,6 +369,7 @@ int qcheck_main(int argc, char **argv)
.chk_afk = true,
.chk_hash = true,
.chk_mtime = true,
+ .chk_config_protect = true,
.undo_prelink = false,
.exact = false,
};
@@ -361,6 +393,7 @@ int qcheck_main(int argc, char **argv)
case 'B': state.bad_only = true; break;
case 'H': state.chk_hash = false; break;
case 'T': state.chk_mtime = false; break;
+ case 128: state.chk_config_protect = false; break;
case 'p': state.undo_prelink = prelink_available(); break;
}
}