lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 20 Jul 2023 13:49:20 +0200
From: Petr Machata <me@...chata.org>
To: Gioele Barabucci <gioele@...rio.it>
Cc: netdev@...r.kernel.org, Stephen Hemminger <stephen@...workplumber.org>
Subject: Re: [iproute2 05/22] tc/m_ematch: Read ematch from /etc and /usr


Gioele Barabucci <gioele@...rio.it> writes:

> Signed-off-by: Gioele Barabucci <gioele@...rio.it>
> ---
>  tc/m_ematch.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/tc/m_ematch.c b/tc/m_ematch.c
> index e30ee205..1d0a208f 100644
> --- a/tc/m_ematch.c
> +++ b/tc/m_ematch.c
> @@ -21,7 +21,8 @@
>  #include "tc_util.h"
>  #include "m_ematch.h"
>  
> -#define EMATCH_MAP "/etc/iproute2/ematch_map"
> +#define EMATCH_MAP_USR	"/usr/lib/iproute2/ematch_map"
> +#define EMATCH_MAP_ETC	"/etc/iproute2/ematch_map"
>  
>  static struct ematch_util *ematch_list;
>  
> @@ -39,11 +40,11 @@ static void bstr_print(FILE *fd, const struct bstr *b, int ascii);
>  static inline void map_warning(int num, char *kind)
>  {
>  	fprintf(stderr,
> -	    "Error: Unable to find ematch \"%s\" in %s\n" \
> +	    "Error: Unable to find ematch \"%s\" in %s or %s\n" \
>  	    "Please assign a unique ID to the ematch kind the suggested " \
>  	    "entry is:\n" \
>  	    "\t%d\t%s\n",
> -	    kind, EMATCH_MAP, num, kind);
> +	    kind, EMATCH_MAP_ETC, EMATCH_MAP_USR, num, kind);
>  }
>  
>  static int lookup_map(__u16 num, char *dst, int len, const char *file)
> @@ -160,8 +161,12 @@ static struct ematch_util *get_ematch_kind(char *kind)
>  static struct ematch_util *get_ematch_kind_num(__u16 kind)
>  {
>  	char name[513];
> +	int ret;
>  
> -	if (lookup_map(kind, name, sizeof(name), EMATCH_MAP) < 0)
> +	ret = lookup_map(kind, name, sizeof(name), EMATCH_MAP_ETC);
> +	if (ret == -ENOENT)

OK, so this retains other errors, so e.g. -EACCES would be treated the
same as before, as a failure. I guess that makes sense.

> +		ret = lookup_map(kind, name, sizeof(name), EMATCH_MAP_USR);
> +	if (ret < 0)
>  		return NULL;
>  
>  	return get_ematch_kind(name);
> @@ -227,7 +232,9 @@ static int parse_tree(struct nlmsghdr *n, struct ematch *tree)
>  				return -1;
>  			}
>  
> -			err = lookup_map_id(buf, &num, EMATCH_MAP);
> +			err = lookup_map_id(buf, &num, EMATCH_MAP_ETC);
> +			if (err == -ENOENT)
> +				err = lookup_map_id(buf, &num, EMATCH_MAP_USR);
>  			if (err < 0) {
>  				if (err == -ENOENT)
>  					map_warning(e->kind_num, buf);

Reviewed-by: Petr Machata <me@...chata.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ