Linux-Wireless Archive on lore.kernel.org
 help / color / Atom feed
From: jtojnar@gmail.com
To: ahmed.taahir@gmail.com, linux-wireless@vger.kernel.org
Subject: Re: [PATCH 1/2] Support python 3 in utils/key2pub.py.
Date: Wed, 25 Dec 2019 17:19:01 +0100
Message-ID: <24df021f5e30c51e2d9fff8533ff5591d37d2d2d.camel@gmail.com> (raw)
In-Reply-To: <1437542484-23409-2-git-send-email-ahmed.taahir@gmail.com> (sfid-20150722_072142_438085_5E3B829E)

On Wed, 2015-07-22 at 00:21 -0500, ahmed.taahir@gmail.com wrote:
> From: Taahir Ahmed <ahmed.taahir@gmail.com>
> 
> utils/key2pub.py can now be run under either python 2.7 or python
> 3.x.
> This required some minor syntactical changes as well as switching
> from
> M2Crypto to pycrypto, since M2Crypto doesn't support python 3.x.
[...]
>  CFLAGS += -O2 -fpic
>  CFLAGS += -std=gnu99 -Wall -Werror -pedantic
>  CFLAGS += -Wall -g
> @@ -42,13 +46,13 @@ ifeq ($(USE_OPENSSL),1)
>  CFLAGS += -DUSE_OPENSSL -DPUBKEY_DIR=\"$(RUNTIME_PUBKEY_DIR)\" `pkg-
> config --cflags openssl`
>  LDLIBS += `pkg-config --libs openssl`
>  
> -$(LIBREG): keys-ssl.c
> +$(LIBREG): keys-ssl.h
>  
>  else
>  CFLAGS += -DUSE_GCRYPT
>  LDLIBS += -lgcrypt
>  
> -$(LIBREG): keys-gcrypt.c
> +$(LIBREG): keys-gcrypt.h

Changing the file names to headers appears to install them. We probably
do not want to do that either.

[...]
> -    modes[mode][0](output, 'e_%d' % idx, key.e[4:])
> -    modes[mode][0](output, 'n_%d' % idx, key.n[4:])
> +    key_contents = io.open(f, 'rb').read()
> +    key = RSA.importKey(key_contents)

It is a good practice to close opened files. It would be even better to
use context manager (i.e. `with io.open(f, 'rb') as key_file:`) since
it will close the file automatically.

Other than this the patches look good, crda builds with both Python 2
and Python 3 with the patch and produce the same keys-gcrypt.h files.
Comparing to the keys-gcrypt.c, apart from the trivial formatting
changes, the ul suffixes for numbers are the only difference.

I was not able to build crda with USE_OPENSSL=1 with or without this
patch due to a large number of compilation errors. However, the
differences between keys-ssl.c and keys-ssl.h are equivalent to the
grypt ones. Also the addition of ul suffixes fixed the overflow errors, so definitely an improvement in this case as well.


  reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22  5:21 Support Python 3 in the crda build system (Take 2) ahmed.taahir
2015-07-22  5:21 ` [PATCH 1/2] Support python 3 in utils/key2pub.py ahmed.taahir
2019-12-25 16:19   ` jtojnar [this message]
2015-07-22  5:21 ` [PATCH 2/2] Small build system improvements ahmed.taahir
  -- strict thread matches above, loose matches on Subject: below --
2015-07-22  0:37 Support Python3 in the crda buildsystem ahmed.taahir
2015-07-22  0:37 ` [PATCH 1/2] Support python 3 in utils/key2pub.py ahmed.taahir
2015-07-22  2:50   ` Stefan Lippers-Hollmann
2015-07-22  2:59     ` Taahir Ahmed
2015-07-22  4:01       ` Stefan Lippers-Hollmann

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=24df021f5e30c51e2d9fff8533ff5591d37d2d2d.camel@gmail.com \
    --to=jtojnar@gmail.com \
    --cc=ahmed.taahir@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    /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

Linux-Wireless Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-wireless/0 linux-wireless/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-wireless linux-wireless/ https://lore.kernel.org/linux-wireless \
		linux-wireless@vger.kernel.org
	public-inbox-index linux-wireless

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-wireless


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git