[LEDE-DEV] [PATCH ubox] getrandom: Define SYS_getrandom if no definition exists
John Crispin
john at phrozen.org
Sun Sep 18 05:03:20 PDT 2016
On 18/09/2016 02:13, Florian Fainelli wrote:
> Le 17/09/2016 à 16:49, Etienne Champetier a écrit :
>> Hi Florian,
>>
>> What is your use case?
>
> Pre-built toolchain which ships with kernel headers 3.8 at the moment.
>
>> If you run it on kernel less than 3.17 this will then fail at run time ...
>
> I run a kernel newer than 3.17, but that's a good point.
>
>> I would prefer to not compile it instead of having an unusable binary
>
> Ok, so something more like that:
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 6cf0c934aac6..1d04c1d77662 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -16,10 +16,15 @@ IF(DEBUG)
> ADD_DEFINITIONS(-DDEBUG -g3)
> ENDIF()
>
> -ADD_EXECUTABLE(getrandom getrandom.c)
> -INSTALL(TARGETS getrandom
> +INCLUDE (CheckSymbolExists)
> +CHECK_SYMBOL_EXISTS(SYS_getrandom sycall.h getrandom)
> +
> +IF(getrandom)
> + ADD_EXECUTABLE(getrandom getrandom.c)
> + INSTALL(TARGETS getrandom
> RUNTIME DESTINATION bin
> -)
> + )
> +ENDIF()
>
> ADD_EXECUTABLE(kmodloader kmodloader.c)
> TARGET_LINK_LIBRARIES(kmodloader ubox)
>
> diff --git a/package/system/ubox/Makefile b/package/system/ubox/Makefile
> index 9f0c4dc10250..48371e168fd3 100644
> --- a/package/system/ubox/Makefile
> +++ b/package/system/ubox/Makefile
> @@ -32,7 +32,7 @@ define Package/ubox/install
> $(INSTALL_DIR) $(1)/sbin $(1)/usr/sbin $(1)/lib $(1)/usr/bin
> $(1)/etc/init.d
>
> $(INSTALL_BIN)
> $(PKG_INSTALL_DIR)/usr/sbin/{kmodloader,validate_data} $(1)/sbin/
> - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/getrandom $(1)/usr/bin/
> + -$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/getrandom $(1)/usr/bin/
> $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libvalidate.so $(1)/lib
>
> $(LN) ../../sbin/kmodloader $(1)/usr/sbin/rmmod
>
>
looks better. i think that the code invoking getrandom would also need
to be changed to fallback to urandom if the helper does not exist.
John
More information about the Lede-dev
mailing list