aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2019-05-08 23:21:30 +0200
committerUlrich Sibiller <uli42@gmx.de>2019-05-10 09:59:08 +0200
commit3c9ee1ff7bc78d91b28eb52f8d15b4f3bf514be1 (patch)
treece04707b8bbb9b58150bd2ccc5e6c65c448c3183 /nx-X11/programs/Xserver/hw/nxagent
parent4ce890758035078bb1ca133cc4584ca02db8ad6d (diff)
downloadnx-libs-3c9ee1ff7bc78d91b28eb52f8d15b4f3bf514be1.tar.gz
nx-libs-3c9ee1ff7bc78d91b28eb52f8d15b4f3bf514be1.tar.bz2
nx-libs-3c9ee1ff7bc78d91b28eb52f8d15b4f3bf514be1.zip
nxagent: Determine nxagentProgName only once
also add TEST prints, init nxagentProgName with NULL and add const where it was missing. Fixes ArcticaProject/nx-libs#803
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Args.c28
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Init.c7
2 files changed, 27 insertions, 8 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c
index 949892f25..607dab9bf 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Args.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c
@@ -126,7 +126,7 @@ extern int _XGetBitsPerPixel(Display *dpy, int depth);
extern char dispatchExceptionAtReset;
-char *nxagentProgName;
+const char *nxagentProgName = NULL;
char nxagentDisplayName[NXAGENTDISPLAYNAMELENGTH];
Bool nxagentSynchronize = False;
@@ -186,17 +186,31 @@ char *nxagentKeystrokeFile = NULL;
int ddxProcessArgument(int argc, char *argv[], int i)
{
/*
- * Ensure that the options are set to their defaults.
+ * The flavour can never change, so only set it once.
+ *
+ * FIXME: ddxProcessArgument() is called once for every command line
+ * argument, with argv[0] being the argument and not the program
+ * name! We should move this check somewhere else.
*/
+ if (nxagentProgName == NULL)
+ {
+ char *basec = strdup(argv[0]);
+ nxagentProgName = strdup(basename(basec));
+ free(basec);
- char *basec = strdup(argv[0]);
- nxagentProgName = strdup(basename(basec));
- free(basec);
+ /*
+ * Check if we are running as X2Go Agent
+ */
+ checkX2goAgent();
+ }
+
+ #ifdef TEST
+ fprintf(stderr, "%s: argv[0] [%s] nxagentProgName [%s]\n", __func__, argv[0], nxagentProgName);
+ #endif
/*
- * Check if we running as X2Go Agent
+ * Ensure that the options are set to their defaults.
*/
- checkX2goAgent();
static Bool resetOptions = True;
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c
index d95c4b70f..d02af3f8d 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Init.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c
@@ -194,7 +194,12 @@ int nxagentX2go;
void checkX2goAgent(void)
{
- extern char *nxagentProgName;
+ extern const char *nxagentProgName;
+
+ #ifdef TEST
+ fprintf(stderr, "%s: nxagentProgName [%s]\n", __func__, nxagentProgName);
+ #endif
+
if( strcasecmp(nxagentProgName,"x2goagent") == 0)
{
fprintf(stderr, "\nrunning as X2Go Agent\n");