Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nxcomp/src/Loop.cpp: Support NXTransDialog caption / title being pref… #1079

Open
wants to merge 1 commit into
base: 3.6.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion nxcomp/src/Loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14731,7 +14731,19 @@ static void handleAlertInLoop()
{
char caption[DEFAULT_STRING_LENGTH];

strcpy(caption, ALERT_CAPTION_PREFIX);
const char* caption_prefix = getenv("NX_DIALOG_CAPTIONPREFIX");

if (!caption_prefix) {
// Use the hard-coded 'NX -' as default.
strncpy(caption, ALERT_CAPTION_PREFIX, DEFAULT_STRING_LENGTH);
caption[DEFAULT_STRING_LENGTH-1] = '\0';
}
else
{
// Use what gets provided via NX_DIALOG_CAPTIONPREFIX (used in X2Go)
strncpy(caption, caption_prefix, DEFAULT_STRING_LENGTH-1);
Copy link
Member

@uli42 uli42 Jun 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this strncpy is different from the one above regarding the number of characters to be copied. While both are technically correct they should at least be unified.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you suggest a clean solution? (You are the C dev... ;-) ).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str(n)cpy is always tricky. I would do the getenv only once. Then strdup either the result or the default. And free the dupped string at shutdown.

caption[DEFAULT_STRING_LENGTH-1] = '\0';
}

int length = strlen(sessionId);

Expand Down
8 changes: 8 additions & 0 deletions nxproxy/man/nxproxy.1
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,14 @@ where <nxclient> is located in a different directory compared to the
other programs, to make easier for the user to execute the program from
the shell.

.TP 8
.B NX_DIALOG_CAPTIONPREFIX
This variable can be used to override the default caption prefix for
agent calls to nxdialog. By default (if NX_DIALOG_CAPTIONPREFIX is
unset), the caption prefix gets set to 'NX - '. This variable is only
used if the proxy is running in server mode or if nxcomp code is run
as part of nxagent.

.TP 8
.B NX_SLAVE_CMD
The full path to the slave channel handler. When the slave channel is
Expand Down
Loading