@@ -63,6 +63,7 @@ static struct
63
63
{
64
64
const char * name ;
65
65
const char * assname ; /* Name used by Assuan or NULL. */
66
+ unsigned int disabled ;/* The entry is not valid */
66
67
} stdenvnames [] = {
67
68
{ "GPG_TTY" , "ttyname" }, /* GnuPG specific envvar. */
68
69
{ "TERM" , "ttytype" }, /* Used to set ttytype. */
@@ -97,11 +98,41 @@ static struct
97
98
allocation. Note that this is not reentrant if used with a
98
99
preemptive thread model. */
99
100
static size_t lastallocatedarraysize ;
100
- #define INITIAL_ARRAYSIZE 8 /* Let's use the number of stdenvnames. */
101
- #define CHUNK_ARRAYSIZE 10
101
+ #define INITIAL_ARRAYSIZE 14 /* Let's use the number of stdenvnames. */
102
+ #define CHUNK_ARRAYSIZE 16
102
103
#define MAXDEFAULT_ARRAYSIZE (INITIAL_ARRAYSIZE + CHUNK_ARRAYSIZE * 5)
103
104
104
105
106
+ /* Modify the list of environment names which are known to gpg-agent.
107
+ * This function must be called before the session names are used and
108
+ * should not be changed later. The syntax for NAME is:
109
+ *
110
+ * -FOO := Remove the environment variable FOO from the list
111
+ * [+]FOO := Add the environment variable FOO to the list
112
+ * [+]FOO:bar := Ditto, but also add "bar" as Assuan alias.
113
+ *
114
+ * Note that adding environment variables is not yet supported and
115
+ * silently ignored.
116
+ */
117
+ void
118
+ session_env_mod_stdenvnames (const char * name )
119
+ {
120
+ int idx ;
121
+
122
+ if (* name != '-' )
123
+ return ;
124
+ name ++ ;
125
+ if (!* name )
126
+ return ;
127
+
128
+ for (idx = 0 ; idx < DIM (stdenvnames ); idx ++ )
129
+ {
130
+ if (!strcmp (stdenvnames [idx ].name , name ))
131
+ stdenvnames [idx ].disabled = 1 ;
132
+ }
133
+ }
134
+
135
+
105
136
/* Return the names of standard environment variables one after the
106
137
other. The caller needs to set the value at the address of
107
138
ITERATOR initially to 0 and then call this function until it
@@ -133,6 +164,8 @@ session_env_list_stdenvnames (int *iterator, const char **r_assname)
133
164
p = commastring ;
134
165
for (idx = 0 ; idx < DIM (stdenvnames ); idx ++ )
135
166
{
167
+ if (stdenvnames [idx ].disabled )
168
+ continue ;
136
169
if (idx )
137
170
* p ++ = ',' ;
138
171
p = stpcpy (p , stdenvnames [idx ].name );
@@ -142,10 +175,14 @@ session_env_list_stdenvnames (int *iterator, const char **r_assname)
142
175
return commastring ;
143
176
}
144
177
145
- idx = * iterator ;
146
- if (idx < 0 || idx >= DIM (stdenvnames ))
147
- return NULL ;
148
- * iterator = idx + 1 ;
178
+ do
179
+ {
180
+ idx = * iterator ;
181
+ if (idx < 0 || idx >= DIM (stdenvnames ))
182
+ return NULL ;
183
+ * iterator = idx + 1 ;
184
+ }
185
+ while (stdenvnames [idx ].disabled );
149
186
if (r_assname )
150
187
* r_assname = stdenvnames [idx ].assname ;
151
188
return stdenvnames [idx ].name ;
0 commit comments