X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fudev%2Fudev-ctrl.c;h=39d777ec7384b9eeee88e089d14c364ea108c290;hp=4bb0ceafe710094398ab77faf7fc99ea5a0ad603;hb=eff05270986a13e7de93ae16311f654d3f7c166f;hpb=96415cad2fdd8d280ae94b02651b5f826a2f7f3d diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c index 4bb0ceafe..39d777ec7 100644 --- a/src/udev/udev-ctrl.c +++ b/src/udev/udev-ctrl.c @@ -181,10 +181,10 @@ struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) { struct udev_ctrl_connection *conn; struct ucred ucred; - socklen_t slen; const int on = 1; + int r; - conn = calloc(1, sizeof(struct udev_ctrl_connection)); + conn = new(struct udev_ctrl_connection, 1); if (conn == NULL) return NULL; conn->refcount = 1; @@ -198,9 +198,9 @@ struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) } /* check peer credential of connection */ - slen = sizeof(ucred); - if (getsockopt(conn->sock, SOL_SOCKET, SO_PEERCRED, &ucred, &slen) < 0) { - log_error("unable to receive credentials of ctrl connection: %m\n"); + r = getpeercred(conn->sock, &ucred); + if (r < 0) { + log_error("unable to receive credentials of ctrl connection: %s", strerror(-r)); goto err; } if (ucred.uid > 0) {