dtlaunch: the clipboard history is opt-in and leaves passwords out (t0080 2')
What was copied is shown on the screen the moment the launcher opens, so a password from a password manager sat there in clear. - Dtlaunch*clipboardHistory, default False. Off: nothing is asked of the clipboard's owner (no XFixes watch, no poll) and the hint line drops "the clipboard". System Settings > Keyboard & Mouse > Shortcuts has the toggle "The launcher keeps a history of what was copied"; it writes the resource like the hot key does and restarts the launcher. - On: a text that is new is kept only if its owner does not offer the target x-kde-passwordManagerHint with the value "secret" (what KeePassXC, KDE Wallet and others set; docs/reference/clipboard-password-hint.txt has the two sources and what they do not say). An unchanged clipboard costs no second request. The copy of the text is overwritten after use. Measured (Xvfb, a small X program as the password manager, logging requests): on: owners "ordinary-text-123" (no hint target), "hunter2-PASSWORD" (hint "secret"), "second-ordinary-456": each got UTF8_STRING then the hint request; the list shows the two ordinary texts, not the password. Off (no resource): 0 requests in total, empty list. The toggle in the real dtsystemsettings gives the resource True, False, True; the indicator changes; the note fits. Cross compile (build's flags): dtlaunch.c and input.c without a warning; make check of dtlaunch passes. Not verified: a real password manager (the assumption that its MIME type is an X11 target of that name is written in the reference file), a launcher restart on a real session. The default is the task's; one word in dtlaunch.c's resource table turns it back. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b20fca5845
commit
e9d38270a3
3 files changed
+92
-8
No files matched your search
@@ -363,7 +363,12 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt
|
||||
connects, `privates.h: dixGetPrivateAddr: Assertion key->initialized`, also
|
||||
for an unmodified dtpad, so it cannot serve for this). Both paths still
|
||||
catch a copy (`xclip` while the launcher idles, then `dtlaunch -show`: the
|
||||
history shows it). The recipe has `x11/libXfixes/buildlink3.mk` for it --
|
||||
history shows it). **The history is opt-in** (`Dtlaunch*clipboardHistory`,
|
||||
default False; System Settings > Keyboard & Mouse > Shortcuts writes it and
|
||||
restarts the launcher): off, nothing is asked of the clipboard's owner (0
|
||||
requests measured) and the hint line drops "the clipboard". On, a new text
|
||||
is kept only if its owner does not offer `x-kde-passwordManagerHint` as
|
||||
"secret" (`docs/reference/clipboard-password-hint.txt`). The recipe has `x11/libXfixes/buildlink3.mk` for it --
|
||||
not yet through a real cross build. **Not done yet:** the two-column list
|
||||
grouped by category, documents/mail/PDF/web results, and the magnifier button
|
||||
in dtbar with `-at X,Y`.
|
||||
|
||||
@@ -83,7 +83,8 @@ static struct {
|
||||
Display *dpy;
|
||||
Window root;
|
||||
Atom a_clipboard, a_utf8, a_targets, a_text, a_self, a_quit,
|
||||
a_show;
|
||||
a_show, a_secret;
|
||||
Boolean keep_history; /* Dtlaunch*clipboardHistory */
|
||||
KeyCode hot_code;
|
||||
unsigned int hot_mods;
|
||||
char **programs;
|
||||
@@ -105,11 +106,16 @@ static struct {
|
||||
|
||||
typedef struct {
|
||||
String hotkey;
|
||||
Boolean history;
|
||||
} Resources;
|
||||
|
||||
static XtResource resources[] = {
|
||||
{ "hotkey", "Hotkey", XtRString, sizeof(String),
|
||||
XtOffsetOf(Resources, hotkey), XtRString, "Cmd+space" },
|
||||
/* off unless asked for (System Settings > Keyboard > Shortcuts): what
|
||||
* was copied is shown on the screen the moment the launcher opens */
|
||||
{ "clipboardHistory", "ClipboardHistory", XtRBoolean, sizeof(Boolean),
|
||||
XtOffsetOf(Resources, history), XtRImmediate, (XtPointer) False },
|
||||
};
|
||||
|
||||
static XrmOptionDescRec options[] = {
|
||||
@@ -350,18 +356,47 @@ remember(const char *text)
|
||||
L.nhistory++;
|
||||
}
|
||||
|
||||
/* Password managers (KeePassXC, KDE Wallet ...) offer the target
|
||||
* x-kde-passwordManagerHint with the value "secret" beside the text they put
|
||||
* on the clipboard, and clipboard managers are meant to leave such a text
|
||||
* out (docs/reference/clipboard-password-hint.txt). An owner that does not
|
||||
* know the target fails the conversion: then the text is an ordinary one. */
|
||||
static void
|
||||
got_hint(Widget w, XtPointer client, Atom *selection, Atom *type,
|
||||
XtPointer value, unsigned long *length, int *format)
|
||||
{
|
||||
char *text = (char *)client;
|
||||
int secret;
|
||||
|
||||
(void)w; (void)selection; (void)type;
|
||||
secret = value != NULL && *format == 8 && *length >= 6 &&
|
||||
memcmp(value, "secret", 6) == 0;
|
||||
if (!secret)
|
||||
remember(text);
|
||||
memset(text, 0, strlen(text)); /* it may have been a password */
|
||||
free(text);
|
||||
XtFree((char *)value);
|
||||
}
|
||||
|
||||
static void
|
||||
got_clipboard(Widget w, XtPointer client, Atom *selection, Atom *type,
|
||||
XtPointer value, unsigned long *length, int *format)
|
||||
{
|
||||
(void)w; (void)client; (void)selection;
|
||||
(void)w; (void)client;
|
||||
if (value != NULL && *format == 8 &&
|
||||
(*type == L.a_utf8 || *type == XA_STRING)) {
|
||||
char *s = XtMalloc((Cardinal)(*length + 1));
|
||||
|
||||
memcpy(s, value, *length);
|
||||
s[*length] = '\0';
|
||||
remember(s);
|
||||
/* only a text that is new asks the owner for the hint: the
|
||||
* same text again (the poll) costs no second request */
|
||||
if (s[0] != '\0' && !(L.nhistory > 0 &&
|
||||
strcmp(L.history[0], s) == 0)) {
|
||||
XtGetSelectionValue(L.top, *selection, L.a_secret,
|
||||
got_hint, xstrdup(s), CurrentTime);
|
||||
}
|
||||
memset(s, 0, *length);
|
||||
XtFree(s);
|
||||
}
|
||||
XtFree((char *)value);
|
||||
@@ -906,11 +941,13 @@ main(int argc, char **argv)
|
||||
L.a_utf8 = XInternAtom(L.dpy, "UTF8_STRING", False);
|
||||
L.a_targets = XInternAtom(L.dpy, "TARGETS", False);
|
||||
L.a_text = XInternAtom(L.dpy, "TEXT", False);
|
||||
L.a_secret = XInternAtom(L.dpy, "x-kde-passwordManagerHint", False);
|
||||
L.a_self = XInternAtom(L.dpy, "_MCDE_DTLAUNCH", False);
|
||||
L.a_show = XInternAtom(L.dpy, "_MCDE_DTLAUNCH_SHOW", False);
|
||||
L.a_quit = XInternAtom(L.dpy, "_MCDE_DTLAUNCH_QUIT", False);
|
||||
XtGetApplicationResources(L.top, &res, resources, XtNumber(resources),
|
||||
NULL, 0);
|
||||
L.keep_history = res.history;
|
||||
s = NULL;
|
||||
show_now = XrmGetResource(XtDatabase(L.dpy), "dtlaunch.show",
|
||||
"Dtlaunch.Show", &s, &(XrmValue){ 0, NULL }) ? True : False;
|
||||
@@ -969,8 +1006,16 @@ main(int argc, char **argv)
|
||||
fprintf(stderr, "dtlaunch: hot key \"%s\" not understood\n",
|
||||
res.hotkey);
|
||||
}
|
||||
if (!watch_clipboard())
|
||||
/* no history, no watching: nothing is asked of the clipboard's owner */
|
||||
if (L.keep_history && !watch_clipboard())
|
||||
(void)XtAppAddTimeOut(L.app, POLL_MS, poll_clipboard, NULL);
|
||||
if (!L.keep_history) {
|
||||
XmString none = XmStringCreateLocalized((char *)"Type to find a "
|
||||
"program, a setting, a snippet, or =1+2");
|
||||
|
||||
XtVaSetValues(L.hint, XmNlabelString, none, NULL);
|
||||
XmStringFree(none);
|
||||
}
|
||||
if (show_now)
|
||||
show();
|
||||
|
||||
|
||||
@@ -738,7 +738,8 @@ static struct {
|
||||
};
|
||||
#define NSHORTCUTS ((int) (sizeof shortcuts / sizeof shortcuts[0]))
|
||||
|
||||
static Widget scList, scField, scChange, scNote;
|
||||
static Widget scList, scField, scChange, scNote, scHistory;
|
||||
static Boolean scHistoryState;
|
||||
static int scSel = -1;
|
||||
|
||||
/* ~/.dt/shortcuts: "Name=key", one a line */
|
||||
@@ -983,6 +984,29 @@ ShortcutRestore(Widget w, XtPointer data, XtPointer call)
|
||||
XmTextFieldSetString(scField, "Cmd+space");
|
||||
}
|
||||
|
||||
/* "The launcher keeps a history of what was copied": Dtlaunch*clipboardHistory,
|
||||
* off unless asked for (the launcher shows it the moment it opens; t0080).
|
||||
* Written as the key is, and the launcher started again to read it. */
|
||||
static void
|
||||
LaunchHistoryChanged(Widget w, XtPointer data, XtPointer call)
|
||||
{
|
||||
char res[80];
|
||||
|
||||
(void) w;
|
||||
(void) data;
|
||||
(void) call;
|
||||
if (inputSyncing)
|
||||
return;
|
||||
scHistoryState = XmToggleButtonGetState(scHistory);
|
||||
(void)snprintf(res, sizeof res, "Dtlaunch*clipboardHistory: %s\n",
|
||||
scHistoryState ? "True" : "False");
|
||||
_DtAddToResource(XtDisplay(scList), res);
|
||||
RestartDtlaunch();
|
||||
SetText(scNote, scHistoryState ?
|
||||
"Kept in memory only; a password manager's passwords are left out." :
|
||||
"The launcher keeps no history of what you copy.");
|
||||
}
|
||||
|
||||
static Widget
|
||||
MakeShortcutsPage(Widget parent)
|
||||
{
|
||||
@@ -1007,6 +1031,14 @@ MakeShortcutsPage(Widget parent)
|
||||
scChange = Button(row, "Change", ShortcutChange, NULL);
|
||||
XtSetSensitive(scChange, False);
|
||||
(void) Button(row, "Restore Defaults", ShortcutRestore, NULL);
|
||||
scHistory = XtVaCreateManagedWidget("The launcher keeps a history of what "
|
||||
"was copied", xmToggleButtonWidgetClass, box, NULL);
|
||||
scHistoryState = DtwmResource(XtDisplay(parent),
|
||||
"dtlaunch.clipboardHistory", "Dtlaunch.ClipboardHistory", "true",
|
||||
False);
|
||||
XmToggleButtonSetState(scHistory, scHistoryState, False);
|
||||
XtAddCallback(scHistory, XmNvalueChangedCallback,
|
||||
LaunchHistoryChanged, NULL);
|
||||
scNote = Text(box, "shortNote", "");
|
||||
ShortcutRead();
|
||||
ShortcutFill();
|
||||
@@ -1023,8 +1055,8 @@ static Widget inputPage[3];
|
||||
static void
|
||||
InputSyncToggles(void)
|
||||
{
|
||||
Widget toggles[10];
|
||||
Boolean state[10];
|
||||
Widget toggles[11];
|
||||
Boolean state[11];
|
||||
int i, n = 0;
|
||||
|
||||
toggles[n] = kbRepeat; n++;
|
||||
@@ -1037,6 +1069,7 @@ InputSyncToggles(void)
|
||||
toggles[n] = msScrollNatural; n++;
|
||||
toggles[n] = wfPointer; n++;
|
||||
toggles[n] = wfRaise; n++;
|
||||
toggles[n] = scHistory; n++;
|
||||
state[0] = kbRepeatState;
|
||||
state[1] = kbKindState == 0;
|
||||
state[2] = kbKindState == 1;
|
||||
@@ -1047,6 +1080,7 @@ InputSyncToggles(void)
|
||||
state[7] = msWheelNaturalState;
|
||||
state[8] = wfPointerState;
|
||||
state[9] = wfRaiseState;
|
||||
state[10] = scHistoryState;
|
||||
/* off then on, with the notifications: the indicator redraws, and
|
||||
* the pane's own callbacks stand aside (inputSyncing) */
|
||||
inputSyncing = True;
|
||||
|
||||
Reference in new issue
Block a user