mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
feat(native): guests see the session hostname from uname and gethostname
This commit is contained in:
1 parent
bde8c9fbed
commit
0c5219b225
6 files changed
+43
-2
No files matched your search
@@ -92,6 +92,7 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe) {
|
||||
// are compared (this was 13 strncmp() calls for each of the 30 or so variables)
|
||||
int has_nt = 0;
|
||||
int has_binds = 0;
|
||||
int has_hostname = 0;
|
||||
int has_preload_list = 0;
|
||||
const char *preload_value = NULL;
|
||||
while (envp && envp[count]) {
|
||||
@@ -119,6 +120,7 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe) {
|
||||
else if (strncmp(e, "DDNATV_NT=", 10) == 0) has_nt = 1;
|
||||
else if (strncmp(e, "DDNATV_BINDS=", 13) == 0) has_binds = 1;
|
||||
else if (strncmp(e, "DDNATV_PRELOAD=", 15) == 0) has_preload_list = 1;
|
||||
else if (strncmp(e, "DDNATV_HOSTNAME=", 16) == 0) has_hostname = 1;
|
||||
else if (strncmp(e, "DPKG_DEB_THREADS_MAX=", 21) == 0) has_threads_max = 1;
|
||||
else if (strncmp(e, "DEBIAN_FRONTEND=", 16) == 0) has_frontend = 1;
|
||||
else if (strncmp(e, "DEBCONF_FRONTEND=", 17) == 0) has_debconf_frontend = 1;
|
||||
@@ -130,7 +132,7 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe) {
|
||||
count++;
|
||||
}
|
||||
|
||||
char **new_env = calloc(count + 22, sizeof(char *));
|
||||
char **new_env = calloc(count + 23, sizeof(char *));
|
||||
int dst = 0;
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (has_preload && envp[i][0] == 'L' && strncmp(envp[i], "LD_PRELOAD=", 11) == 0) {
|
||||
@@ -215,6 +217,13 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe) {
|
||||
new_env[dst++] = str;
|
||||
}
|
||||
}
|
||||
if (!has_hostname && g_hostname[0]) {
|
||||
char *str = malloc(16 + sizeof(g_hostname));
|
||||
if (str) {
|
||||
snprintf(str, 16 + sizeof(g_hostname), "DDNATV_HOSTNAME=%s", g_hostname);
|
||||
new_env[dst++] = str;
|
||||
}
|
||||
}
|
||||
if (!has_binds && g_binds_raw) {
|
||||
size_t len = strlen(g_binds_raw);
|
||||
char *str = malloc(13 + len + 1);
|
||||
|
||||
Reference in new issue
Block a user