linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vitaly Chikunov <vt@altlinux.org>
To: Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
	linux-integrity@vger.kernel.org
Subject: [PATCH] ima-evm-utils: Namespace some too generic function names
Date: Wed, 24 Jul 2019 23:42:04 +0300	[thread overview]
Message-ID: <20190724204204.25383-1-vt@altlinux.org> (raw)

Prefix `dump', `do_dump', and `params' with `ima_' to avoid colliding
with other global symbols.

`params' is prefixed with a #define trick to avoid change in half
hundred places.

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
---

I think all other exported functions (good example is verify_hash) should be
prefixed too.

 src/evmctl.c    | 6 +++---
 src/imaevm.h    | 9 ++++++---
 src/libimaevm.c | 6 +++---
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/evmctl.c b/src/evmctl.c
index 3289061..b2e5af5 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -565,7 +565,7 @@ static int sign_evm(const char *file, const char *key)
 		sig[1] = 3; /* immutable signature version */
 
 	if (sigdump || params.verbose >= LOG_INFO)
-		dump(sig, len);
+		ima_dump(sig, len);
 
 	if (xattr) {
 		err = lsetxattr(file, xattr_evm, sig, len, 0);
@@ -604,7 +604,7 @@ static int hash_ima(const char *file)
 		log_info("hash: ");
 
 	if (sigdump || params.verbose >= LOG_INFO)
-		dump(hash, len);
+		ima_dump(hash, len);
 
 	if (xattr) {
 		err = lsetxattr(file, xattr_ima, hash, len, 0);
@@ -638,7 +638,7 @@ static int sign_ima(const char *file, const char *key)
 	sig[0] = EVM_IMA_XATTR_DIGSIG;
 
 	if (sigdump || params.verbose >= LOG_INFO)
-		dump(sig, len);
+		ima_dump(sig, len);
 
 	if (sigfile)
 		bin2file(file, "sig", sig, len);
diff --git a/src/imaevm.h b/src/imaevm.h
index 0414433..d00922c 100644
--- a/src/imaevm.h
+++ b/src/imaevm.h
@@ -49,9 +49,12 @@
 
 #include <openssl/rsa.h>
 
+/* Namespace some internal symbols */
+#define params		ima_params
+
 #ifdef USE_FPRINTF
 #define do_log(level, fmt, args...)	({ if (level <= params.verbose) fprintf(stderr, fmt, ##args); })
-#define do_log_dump(level, p, len, cr)	({ if (level <= params.verbose) do_dump(stderr, p, len, cr); })
+#define do_log_dump(level, p, len, cr)	({ if (level <= params.verbose) ima_do_dump(stderr, p, len, cr); })
 #else
 #define do_log(level, fmt, args...)	syslog(level, fmt, ##args)
 #define do_log_dump(level, p, len, cr)
@@ -206,8 +209,8 @@ struct RSA_ASN1_template {
 
 extern struct libevm_params params;
 
-void do_dump(FILE *fp, const void *ptr, int len, bool cr);
-void dump(const void *ptr, int len);
+void ima_do_dump(FILE *fp, const void *ptr, int len, bool cr);
+void ima_dump(const void *ptr, int len);
 int ima_calc_hash(const char *file, uint8_t *hash);
 int get_hash_algo(const char *algo);
 RSA *read_pub_key(const char *keyfile, int x509);
diff --git a/src/libimaevm.c b/src/libimaevm.c
index 2d99570..afa978f 100644
--- a/src/libimaevm.c
+++ b/src/libimaevm.c
@@ -89,7 +89,7 @@ struct libevm_params params = {
 
 static void __attribute__ ((constructor)) libinit(void);
 
-void do_dump(FILE *fp, const void *ptr, int len, bool cr)
+void ima_do_dump(FILE *fp, const void *ptr, int len, bool cr)
 {
 	int i;
 	uint8_t *data = (uint8_t *) ptr;
@@ -100,9 +100,9 @@ void do_dump(FILE *fp, const void *ptr, int len, bool cr)
 		fprintf(fp, "\n");
 }
 
-void dump(const void *ptr, int len)
+void ima_dump(const void *ptr, int len)
 {
-	do_dump(stdout, ptr, len, true);
+	ima_do_dump(stdout, ptr, len, true);
 }
 
 const char *get_hash_algo_by_id(int algo)
-- 
2.11.0


             reply	other threads:[~2019-07-24 20:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-24 20:42 Vitaly Chikunov [this message]
2019-07-24 21:46 ` [PATCH] ima-evm-utils: Namespace some too generic function names Bruno E. O. Meneguele
2019-07-24 23:24 ` Mimi Zohar
2019-07-25  1:53   ` Vitaly Chikunov
2019-07-25 11:48     ` Mimi Zohar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190724204204.25383-1-vt@altlinux.org \
    --to=vt@altlinux.org \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=zohar@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).