@@ -196,8 +196,7 @@ _public_ int sd_bus_new(sd_bus **ret) {
196196 r -> inotify_fd = -1 ;
197197 r -> message_version = 1 ;
198198 r -> creds_mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES |SD_BUS_CREDS_UNIQUE_NAME ;
199- r -> hello_flags |= KDBUS_HELLO_ACCEPT_FD ;
200- r -> attach_flags |= KDBUS_ATTACH_NAMES ;
199+ r -> accept_fd = true;
201200 r -> original_pid = getpid_cached ();
202201 r -> n_groups = (size_t ) -1 ;
203202
@@ -286,7 +285,7 @@ _public_ int sd_bus_set_monitor(sd_bus *bus, int b) {
286285 assert_return (bus -> state == BUS_UNSET , - EPERM );
287286 assert_return (!bus_pid_changed (bus ), - ECHILD );
288287
289- SET_FLAG ( bus -> hello_flags , KDBUS_HELLO_MONITOR , b ) ;
288+ bus -> is_monitor = b ;
290289 return 0 ;
291290}
292291
@@ -295,30 +294,23 @@ _public_ int sd_bus_negotiate_fds(sd_bus *bus, int b) {
295294 assert_return (bus -> state == BUS_UNSET , - EPERM );
296295 assert_return (!bus_pid_changed (bus ), - ECHILD );
297296
298- SET_FLAG ( bus -> hello_flags , KDBUS_HELLO_ACCEPT_FD , b ) ;
297+ bus -> accept_fd = b ;
299298 return 0 ;
300299}
301300
302301_public_ int sd_bus_negotiate_timestamp (sd_bus * bus , int b ) {
303- uint64_t new_flags ;
304302 assert_return (bus , - EINVAL );
305303 assert_return (!IN_SET (bus -> state , BUS_CLOSING , BUS_CLOSED ), - EPERM );
306304 assert_return (!bus_pid_changed (bus ), - ECHILD );
307305
308- new_flags = bus -> attach_flags ;
309- SET_FLAG (new_flags , KDBUS_ATTACH_TIMESTAMP , b );
310-
311- if (bus -> attach_flags == new_flags )
312- return 0 ;
313-
314- bus -> attach_flags = new_flags ;
306+ /* This is not actually supported by any of our transports these days, but we do honour it for synthetic
307+ * replies, and maybe one day classic D-Bus learns this too */
308+ bus -> attach_timestamp = b ;
315309
316310 return 0 ;
317311}
318312
319313_public_ int sd_bus_negotiate_creds (sd_bus * bus , int b , uint64_t mask ) {
320- uint64_t new_flags ;
321-
322314 assert_return (bus , - EINVAL );
323315 assert_return (mask <= _SD_BUS_CREDS_ALL , - EINVAL );
324316 assert_return (!IN_SET (bus -> state , BUS_CLOSING , BUS_CLOSED ), - EPERM );
@@ -329,13 +321,6 @@ _public_ int sd_bus_negotiate_creds(sd_bus *bus, int b, uint64_t mask) {
329321 /* The well knowns we need unconditionally, so that matches can work */
330322 bus -> creds_mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES |SD_BUS_CREDS_UNIQUE_NAME ;
331323
332- /* Make sure we don't lose the timestamp flag */
333- new_flags = (bus -> attach_flags & KDBUS_ATTACH_TIMESTAMP ) | attach_flags_to_kdbus (bus -> creds_mask );
334- if (bus -> attach_flags == new_flags )
335- return 0 ;
336-
337- bus -> attach_flags = new_flags ;
338-
339324 return 0 ;
340325}
341326
@@ -1094,7 +1079,6 @@ _public_ int sd_bus_open(sd_bus **ret) {
10941079 * be safe, and authenticate everything */
10951080 b -> trusted = false;
10961081 b -> is_local = false;
1097- b -> attach_flags |= KDBUS_ATTACH_CAPS | KDBUS_ATTACH_CREDS ;
10981082 b -> creds_mask |= SD_BUS_CREDS_UID | SD_BUS_CREDS_EUID | SD_BUS_CREDS_EFFECTIVE_CAPS ;
10991083
11001084 r = sd_bus_start (b );
@@ -1140,7 +1124,6 @@ _public_ int sd_bus_open_system(sd_bus **ret) {
11401124 /* Let's do per-method access control on the system bus. We
11411125 * need the caller's UID and capability set for that. */
11421126 b -> trusted = false;
1143- b -> attach_flags |= KDBUS_ATTACH_CAPS | KDBUS_ATTACH_CREDS ;
11441127 b -> creds_mask |= SD_BUS_CREDS_UID | SD_BUS_CREDS_EUID | SD_BUS_CREDS_EFFECTIVE_CAPS ;
11451128 b -> is_local = true;
11461129
@@ -1419,11 +1402,11 @@ _public_ int sd_bus_can_send(sd_bus *bus, char type) {
14191402 assert_return (bus -> state != BUS_UNSET , - ENOTCONN );
14201403 assert_return (!bus_pid_changed (bus ), - ECHILD );
14211404
1422- if (bus -> hello_flags & KDBUS_HELLO_MONITOR )
1405+ if (bus -> is_monitor )
14231406 return 0 ;
14241407
14251408 if (type == SD_BUS_TYPE_UNIX_FD ) {
1426- if (!( bus -> hello_flags & KDBUS_HELLO_ACCEPT_FD ) )
1409+ if (!bus -> accept_fd )
14271410 return 0 ;
14281411
14291412 r = bus_ensure_running (bus );
@@ -1491,7 +1474,7 @@ int bus_seal_synthetic_message(sd_bus *b, sd_bus_message *m) {
14911474
14921475 /* Fake some timestamps, if they were requested, and not
14931476 * already initialized */
1494- if (b -> attach_flags & KDBUS_ATTACH_TIMESTAMP ) {
1477+ if (b -> attach_timestamp ) {
14951478 if (m -> realtime <= 0 )
14961479 m -> realtime = now (CLOCK_REALTIME );
14971480
@@ -1936,7 +1919,7 @@ _public_ int sd_bus_call(
19361919
19371920 if (incoming -> header -> type == SD_BUS_MESSAGE_METHOD_RETURN ) {
19381921
1939- if (incoming -> n_fds <= 0 || ( bus -> hello_flags & KDBUS_HELLO_ACCEPT_FD ) ) {
1922+ if (incoming -> n_fds <= 0 || bus -> accept_fd ) {
19401923 if (reply )
19411924 * reply = incoming ;
19421925 else
@@ -2262,7 +2245,7 @@ static int process_reply(sd_bus *bus, sd_bus_message *m) {
22622245
22632246 slot = container_of (c , sd_bus_slot , reply_callback );
22642247
2265- if (m -> n_fds > 0 && !( bus -> hello_flags & KDBUS_HELLO_ACCEPT_FD ) ) {
2248+ if (m -> n_fds > 0 && !bus -> accept_fd ) {
22662249
22672250 /* If the reply contained a file descriptor which we
22682251 * didn't want we pass an error instead. */
@@ -2394,7 +2377,7 @@ static int process_builtin(sd_bus *bus, sd_bus_message *m) {
23942377 assert (bus );
23952378 assert (m );
23962379
2397- if (bus -> hello_flags & KDBUS_HELLO_MONITOR )
2380+ if (bus -> is_monitor )
23982381 return 0 ;
23992382
24002383 if (bus -> manual_peer_interface )
@@ -2452,13 +2435,13 @@ static int process_fd_check(sd_bus *bus, sd_bus_message *m) {
24522435 * delivered to us later even though we ourselves did not
24532436 * negotiate it. */
24542437
2455- if (bus -> hello_flags & KDBUS_HELLO_MONITOR )
2438+ if (bus -> is_monitor )
24562439 return 0 ;
24572440
24582441 if (m -> n_fds <= 0 )
24592442 return 0 ;
24602443
2461- if (bus -> hello_flags & KDBUS_HELLO_ACCEPT_FD )
2444+ if (bus -> accept_fd )
24622445 return 0 ;
24632446
24642447 if (m -> header -> type != SD_BUS_MESSAGE_METHOD_CALL )
@@ -3769,7 +3752,7 @@ _public_ int sd_bus_is_monitor(sd_bus *bus) {
37693752 assert_return (bus , - EINVAL );
37703753 assert_return (!bus_pid_changed (bus ), - ECHILD );
37713754
3772- return !!( bus -> hello_flags & KDBUS_HELLO_MONITOR ) ;
3755+ return bus -> is_monitor ;
37733756}
37743757
37753758static void flush_close (sd_bus * bus ) {
0 commit comments