File: DBUS_SESSION_BUS_ADDRESS_parsing.patch

package info (click to toggle)
golang-github-containers-common 0.33.4%2Bds1-1%2Bdeb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,268 kB
  • sloc: makefile: 118; sh: 25
file content (37 lines) | stat: -rw-r--r-- 1,147 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
commit 47ea9a8cbcc35d1e758b01ae40f37fec8a2e310b
Author: Giuseppe Scrivano <gscrivan@redhat.com>
Date:   Mon Jul 26 15:00:25 2021 +0200

    config: split arguments in DBUS_SESSION_BUS_ADDRESS
    
    split the DBUS_SESSION_BUS_ADDRESS value so that something like:
    
    unix:path=/run/user/1000/bus,guid=817e9ffcfb383869ad17ea8360e7428a
    
    will ignore ",guid=817e9ffcfb383869ad17ea8360e7428a" when checking
    that the path exists.
    
    Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1984531
    
    Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -538,9 +538,14 @@
 
 	session := os.Getenv("DBUS_SESSION_BUS_ADDRESS")
 	hasSession := session != ""
-	if hasSession && strings.HasPrefix(session, "unix:path=") {
-		_, err := os.Stat(strings.TrimPrefix(session, "unix:path="))
-		hasSession = err == nil
+	if hasSession {
+		for _, part := range strings.Split(session, ",") {
+			if strings.HasPrefix(part, "unix:path=") {
+				_, err := os.Stat(strings.TrimPrefix(part, "unix:path="))
+				hasSession = err == nil
+				break
+			}
+		}
 	}
 
 	if !hasSession {