Skip to content

Commit 759a16b

Browse files
committed
dbus: Hardcode EXTERNAL auth using the uid to avoid dynamic linking
The default mode of dbusConn.Auth(nil) is to use EXTERNAL and DBUS_COOKIE_SHA1. This code calls user.Current() which gives this warning when linking docker: /var/tmp/go-link-mIsVGq/000005.o: In function `mygetpwuid_r': /usr/local/go/src/pkg/os/user/lookup_unix.go:72: warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /var/tmp/go-link-mIsVGq/000005.o: In function `_cgo_bc43c179ae62_Cfunc_mygetpwuid_r': /usr/local/go/src/pkg/os/user/lookup_unix.go:27: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking Created binary: /go/src/github.com/dotcloud/docker/bundles/0.9.0-dev/binary/docker-0.9.0-dev For the systemd we use EXTERNAL anyway, which only needs the uid, not the username. So we set our own list of methods to avoid running this code.
1 parent d712533 commit 759a16b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

dbus/dbus.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ limitations under the License.
1818
package dbus
1919

2020
import (
21+
"os"
22+
"strconv"
2123
"strings"
2224
"sync"
2325

@@ -73,7 +75,12 @@ func (c *Conn) initConnection() error {
7375
return err
7476
}
7577

76-
err = c.sysconn.Auth(nil)
78+
// Only use EXTERNAL method, and hardcode the uid (not username)
79+
// to avoid a username lookup (which requires a dynamically linked
80+
// libc)
81+
methods := []dbus.Auth{dbus.AuthExternal(strconv.Itoa(os.Getuid()))}
82+
83+
err = c.sysconn.Auth(methods)
7784
if err != nil {
7885
c.sysconn.Close()
7986
return err

0 commit comments

Comments
 (0)