File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -54,16 +54,29 @@ const (
54
54
// (false, err) - notification supported, but failure happened (e.g. error connecting to NOTIFY_SOCKET or while sending data)
55
55
// (true, nil) - notification supported, data has been sent
56
56
func SdNotify (unsetEnvironment bool , state string ) (bool , error ) {
57
- socketAddr := & net.UnixAddr {
58
- Name : os .Getenv ("NOTIFY_SOCKET" ),
59
- Net : "unixgram" ,
60
- }
57
+ notifySocket := os .Getenv ("NOTIFY_SOCKET" )
61
58
62
59
// NOTIFY_SOCKET not set
63
- if socketAddr .Name == "" {
60
+ if notifySocket == "" {
61
+ return false , nil
62
+ }
63
+
64
+ // socket type not supported. We only support unix domain sockets
65
+ // but NOTIFY_SOCKET can also use vsock
66
+ if notifySocket [0 ] != '@' || notifySocket [0 ] != '/' {
64
67
return false , nil
65
68
}
66
69
70
+ // abstract unix socket. Start with a 0-byte
71
+ if notifySocket [0 ] == '@' {
72
+ notifySocket = "\x00 " + notifySocket [1 :]
73
+ }
74
+
75
+ socketAddr := & net.UnixAddr {
76
+ Name : notifySocket ,
77
+ Net : "unixgram" ,
78
+ }
79
+
67
80
if unsetEnvironment {
68
81
if err := os .Unsetenv ("NOTIFY_SOCKET" ); err != nil {
69
82
return false , err
You can’t perform that action at this time.
0 commit comments