mirror of
https://github.com/clearlinux/linux-steam-integration.git
synced 2026-08-22 15:56:46 +00:00
redirect: Add new override on getpwuid
This is required for some Aspyr ports which will form their own fixed paths to directories based on getpwuid() as opposed to using the environment `HOME` variable. With this we force the home directory to be consistent under snapd and alleviate any issues with denials based on home directory lookups. Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This commit is contained in:
@@ -19,6 +19,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/* Expose getpwuid override in snapd */
|
||||
#ifdef HAVE_SNAPD_SUPPORT
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "../common/files.h"
|
||||
#include "../common/log.h"
|
||||
@@ -82,6 +89,9 @@ static LsiRedirectProfile *lsi_profile = NULL;
|
||||
static LsiSymbolBinding lsi_libc_bindings[] = {
|
||||
SYMBOL_BINDING(libc, open),
|
||||
SYMBOL_BINDING(libc, fopen64),
|
||||
#ifdef HAVE_SNAPD_SUPPORT
|
||||
SYMBOL_BINDING(libc, getpwuid),
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -335,6 +345,32 @@ fallback_open:
|
||||
return lsi_table.fopen64(p, modes);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SNAPD_SUPPORT
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
_nica_public_ struct passwd *getpwuid(uid_t uid)
|
||||
{
|
||||
/* Must ensure we're **really** initialised, as we might see open happen
|
||||
* before the constructor..
|
||||
*/
|
||||
lsi_redirect_init_tables();
|
||||
|
||||
struct passwd *ret = NULL;
|
||||
const char *snap_root = getenv("SNAP_USER_COMMON");
|
||||
|
||||
/* If they're requesting our uid and SNAP_USER_COMMON is set, then
|
||||
* let us override the home directory to be correct.
|
||||
*/
|
||||
ret = lsi_table.getpwuid(uid);
|
||||
if (uid == getuid() && snap_root && *snap_root) {
|
||||
ret->pw_dir = (char *)snap_root;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
|
||||
@@ -14,6 +14,12 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_SNAPD_SUPPORT
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle definitions
|
||||
*/
|
||||
@@ -21,6 +27,10 @@ typedef int (*lsi_open_file)(const char *p, int flags, mode_t mode);
|
||||
|
||||
typedef FILE *(*lsi_fopen64_file)(const char *p, const char *modes);
|
||||
|
||||
#ifdef HAVE_SNAPD_SUPPORT
|
||||
typedef struct passwd *(*lsi_getpwuid)(uid_t uid);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Global storage of handles for nicer organisation.
|
||||
*/
|
||||
@@ -28,6 +38,10 @@ typedef struct LsiRedirectTable {
|
||||
lsi_open_file open;
|
||||
lsi_fopen64_file fopen64;
|
||||
|
||||
#ifdef HAVE_SNAPD_SUPPORT
|
||||
lsi_getpwuid getpwuid;
|
||||
#endif
|
||||
|
||||
/* Allow future handle opens.. */
|
||||
struct {
|
||||
void *libc;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
global:
|
||||
fopen64;
|
||||
getpwuid;
|
||||
open;
|
||||
local:
|
||||
*;
|
||||
|
||||
Reference in New Issue
Block a user