fix(ibus): make the X11 frontend fail truthfully

This commit is contained in:
2026-08-14 22:10:40 +09:00
parent 77c6dd66ca
commit f2fb71cd89
3 changed files with 121 additions and 22 deletions

View File

@@ -20,7 +20,7 @@
enum
{
Maxconnections = 16,
Maxconnections = 64,
Calltimeout = 4000,
Starttimeout = 8000,
Stoptimeout = 3000,
@@ -312,7 +312,8 @@ startdaemon(Daemon *d, char *program, char *mapdir)
setenv("XDG_CONFIG_HOME", d->config, 1) < 0 ||
setenv("HOME", d->home, 1) < 0 || unsetenv("DISPLAY") < 0 ||
unsetenv("DBUS_SESSION_BUS_ADDRESS") < 0 ||
unsetenv("IBUS_ADDRESS") < 0){
unsetenv("IBUS_ADDRESS") < 0 ||
unsetenv("IBUS_ADDRESS_FILE") < 0){
dprintf(STDERR_FILENO, "set daemon environment: %s\n",
strerror(errno));
_exit(126);
@@ -1346,6 +1347,9 @@ runlifecycle(Daemon *d)
goto out;
if(!createcontext(c1, a, sizeof a) || !createcontext(c2, b, sizeof b))
goto out;
if(!unknowncall(c1, a, "ProcessKeyEvent", DBUS_ERROR_INVALID_ARGS) ||
!unknowncall(c1, a, "SetEngine", DBUS_ERROR_INVALID_ARGS))
goto out;
if(!unknowncall(c1, "/org/freedesktop/IBus/InputContext_missing",
"FocusIn", DBUS_ERROR_UNKNOWN_OBJECT))
goto out;
@@ -1477,6 +1481,22 @@ runpolicy(Daemon *d)
if(!expectkey(c1, &s1, a, 'n', Ctrlmask, 1, NULL,
"zero-capability language") ||
!expectkey(c1, &s1, a, 'k', 0, 1, NULL, "zero-capability key") ||
!emptycall(c1, &s1, a, "Reset") ||
!nosignal(&s1, "zero-capability Reset") ||
!expectkey(c1, &s1, a, 'k', 0, 1, NULL,
"zero-capability before PASSWORD") ||
!contentcall(c1, &s1, a, Purposepassword, 0) ||
!nosignal(&s1, "zero-capability PASSWORD") ||
!contentcall(c1, &s1, a, Purposefree, 0) ||
!nosignal(&s1, "zero-capability leave PASSWORD") ||
!expectkey(c1, &s1, a, 'k', 0, 1, NULL,
"zero-capability before FocusOut") ||
!emptycall(c1, &s1, a, "FocusOut") ||
!nosignal(&s1, "zero-capability FocusOut") ||
!emptycall(c1, &s1, a, "FocusIn") ||
!nosignal(&s1, "zero-capability refocus") ||
!expectkey(c1, &s1, a, 'k', 0, 1, NULL,
"zero-capability after refocus") ||
!capcall(c1, &s1, a, 1<<1) || !nosignal(&s1, "non-preedit cap") ||
!capcall(c1, &s1, a, Cappreedit|(1<<1)) ||
!preedit(&s1, a, "k", 1, 1, "enable inline") ||

View File

@@ -30,8 +30,8 @@ void
ibus_machine_id_fallback(struct ct *t)
{
char root[] = "/tmp/strans-machine-id.XXXXXX";
char primary[128], fallback[128], got[64];
char *path[2];
char primary[128], fallback[128], override[128], got[512];
char *path[2], *old, *saved;
FILE *fp;
int madeprimary, madefallback;
@@ -61,6 +61,24 @@ ibus_machine_id_fallback(struct ct *t)
path[1] = fallback;
machineidfiles(got, sizeof got, path, nelem(path));
CT_EQ_STR(t, "fallback-machine-id", got);
old = getenv("IBUS_ADDRESS_FILE");
saved = old == nil ? nil : strdup(old);
if(old == nil || CT_CHECK(t, saved != nil)){
if(CT_CHECK(t, snprintf(override, sizeof override, "%s/address", root)
< (int)sizeof override) &&
CT_CHECK(t, setenv("IBUS_ADDRESS_FILE", override, 1) == 0)){
CT_EQ_INT(t, 0, buildaddrpath(got, sizeof got));
CT_EQ_STR(t, override, got);
CT_CHECK(t, setenv("IBUS_ADDRESS_FILE", "", 1) == 0);
CT_EQ_INT(t, -1, buildaddrpath(got, sizeof got));
}
if(saved != nil){
setenv("IBUS_ADDRESS_FILE", saved, 1);
free(saved);
}else
unsetenv("IBUS_ADDRESS_FILE");
}
cleanup:
if(madefallback)
CT_CHECK(t, unlink(fallback) == 0);