[PATCH skeleton 2/2] bmc_update: allow whitelist to be files in a directory

Patrick Williams patrick at stwcx.xyz
Thu Jun 30 06:33:23 AEST 2016


On Wed, Jun 22, 2016 at 07:41:00PM -0500, OpenBMC Patches wrote:
> From: Milton Miller <miltonm at us.ibm.com>
> 
> The whitelist is moveing from a file to a set of files in a directory.

s/moveing/moving/

> Use try when deleting whitelist entries.
> 
> It would be better to call update without saving the files in the
> first place but this will suffice for now.
> 
> Signed-off-by: Milton Miller <miltonm at us.ibm.com>
> ---
>  pyflashbmc/bmc_update.py | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/pyflashbmc/bmc_update.py b/pyflashbmc/bmc_update.py
> index cd2f3c1..50042c1 100644
> --- a/pyflashbmc/bmc_update.py
> +++ b/pyflashbmc/bmc_update.py
> @@ -111,7 +111,27 @@ class BmcFlashControl(DbusProperties,DbusObjectManager):
>  
>  			if (self.Get(DBUS_NAME,"clear_persistent_files") == True):
>  				print "Removing persistent files"
> -				os.unlink(UPDATE_PATH+"/whitelist")
> +				try:
> +					os.unlink(UPDATE_PATH+"/whitelist")
> +				except OSError as e:
> +					if (e.errno == errno.EISDIR):
> +						pass
> +					elif (e.errno == errno.ENOENT):
> +						pass
> +					else:
> +						raise
> +
> +				try:
> +					wldir = UPDATE_PATH + "/whitelist.d"
> +
> +					for file in os.listdir(wldir):
> +						os.unlink(os.path.join(wldir,file))
> +				except OSError as e:
> +					if (e.errno == errno.EISDIR):
> +						pass
> +					else:
> +						raise
> +

Is there a reason we aren't doing the python-equivalent of an 'rm -rf
.../whitelist.d'?  It seems like simply unlinking the files leaves us
open to accidentally leaving files in place and using up flash space
never to be reclaimed.

>  			if (self.Get(DBUS_NAME,"preserve_network_settings") == True):
>  				print "Preserving network settings"
>  				shutil.copy2("/run/fw_env",UPDATE_PATH+"/image-u-boot-env")
> -- 
> 2.9.0
> 
> 
> _______________________________________________
> openbmc mailing list
> openbmc at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc

-- 
Patrick Williams
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20160629/2f54c5ab/attachment.sig>


More information about the openbmc mailing list