libcamera: utils: call secure_getenv() if it exists or workaround with issetugid()

When secure_getenv() is not available, need to have a workaround.

Check if secure_getenv() is present, otherwise call issetugid() on its
place.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[Kieran: include stdlib.h]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Giulio Benetti 2019-04-26 10:42:20 +02:00 committed by Kieran Bingham
parent 46bfc32157
commit ab0188fc8b

View file

@ -7,8 +7,9 @@
#include "utils.h"
#include <stdlib.h>
#include <string.h>
#include <sys/auxv.h>
#include <unistd.h>
/**
* \file utils.h
@ -57,10 +58,14 @@ const char *basename(const char *path)
*/
char *secure_getenv(const char *name)
{
if (getauxval(AT_SECURE))
#if HAVE_SECURE_GETENV
return ::secure_getenv(name);
#else
if (issetugid())
return NULL;
return getenv(name);
#endif
}
/**