Skip to content

Commit 26bfd07

Browse files
committed
Annotate dbus.append calls with {.gcsafe.}
1 parent 72c566f commit 26bfd07

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Annotate dbus.append calls with {.gcsafe.}

src/keyring/linux.nim

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ proc openSession(bus:Bus): ObjectPath =
7070
SERVICE_INTERFACE,
7171
"OpenSession",
7272
)
73-
msg.append("plain")
74-
msg.append(newVariant[string](""))
73+
{.gcsafe.}:
74+
msg.append("plain")
75+
{.gcsafe.}:
76+
msg.append(newVariant[string](""))
7577
let open_result = bus.call(msg)
7678
result = open_result[^1].objectPathValueOrFail("in openSession")
7779
doAssert $result != ""
@@ -83,7 +85,8 @@ proc unlock(bus:Bus, thing:ObjectPath) =
8385
SERVICE_INTERFACE,
8486
"Unlock",
8587
)
86-
unlock_msg.append(@[thing])
88+
{.gcsafe.}:
89+
unlock_msg.append(@[thing])
8790
let unlock_result = bus.call(unlock_msg)
8891
doAssert $(unlock_result[0].arrayValue[0].objectPathValueOrFail("in unlock")) == $thing
8992
doAssert $(unlock_result[1].objectPathValueOrFail("in unlock")) == "/" # special value indicating no prompt needed
@@ -146,18 +149,21 @@ proc setPassword*(service: string, username: string, password: string) {.gcsafe,
146149
(SS_PREFIX & "Item.Attributes").asDbusValue(),
147150
newVariant(inner).asDbusValue()
148151
)
149-
create_msg.append(outer)
152+
{.gcsafe.}:
153+
create_msg.append(outer)
150154
# TODO: this is where in-transit encryption would happen
151-
create_msg.append(
152-
DbusValue(kind: dtStruct, structValues: @[
153-
session_object_path.asDbusValue(),
154-
"".toByteArray().asDbusValue(),
155-
password.toByteArray().asDbusValue(),
156-
"text/plain".asDbusValue(),
157-
])
158-
)
155+
{.gcsafe.}:
156+
create_msg.append(
157+
DbusValue(kind: dtStruct, structValues: @[
158+
session_object_path.asDbusValue(),
159+
"".toByteArray().asDbusValue(),
160+
password.toByteArray().asDbusValue(),
161+
"text/plain".asDbusValue(),
162+
])
163+
)
159164
# create_msg.append(password)
160-
create_msg.append(true)
165+
{.gcsafe.}:
166+
create_msg.append(true)
161167
discard bus.call(create_msg)
162168

163169
proc getPassword*(service: string, username: string): Option[string] {.gcsafe, raises: [KeyringError, DbusException, ValueError, Exception].} =
@@ -177,7 +183,8 @@ proc getPassword*(service: string, username: string): Option[string] {.gcsafe, r
177183
"service": service,
178184
"username": username,
179185
}.toTable()
180-
search_msg.append(attrs)
186+
{.gcsafe.}:
187+
search_msg.append(attrs)
181188
var found_item_path:ObjectPath
182189
try:
183190
let search_result = bus.call(search_msg)
@@ -195,7 +202,8 @@ proc getPassword*(service: string, username: string): Option[string] {.gcsafe, r
195202
ITEM_INTERFACE,
196203
"GetSecret",
197204
)
198-
get_msg.append(session_object_path)
205+
{.gcsafe.}:
206+
get_msg.append(session_object_path)
199207
try:
200208
let get_result = bus.call(get_msg)
201209
let secret = get_result[0]
@@ -221,7 +229,8 @@ proc deletePassword*(service: string, username: string) {.gcsafe, raises: [Keyri
221229
"service": service,
222230
"username": username,
223231
}.toTable()
224-
search_msg.append(attrs)
232+
{.gcsafe.}:
233+
search_msg.append(attrs)
225234
var found_item_path:ObjectPath
226235
let search_result = bus.call(search_msg)
227236
doAssert search_result[0].kind == dtArray

0 commit comments

Comments
 (0)