static int proxy_socket(const char *path, uid_t uid, gid_t gid)

{

    int sock, client;

    struct sockaddr_un proxy, qemu;

    socklen_t size;



    /* requested socket already exists, refuse to start */

    if (!access(path, F_OK)) {

        do_log(LOG_CRIT, "socket already exists\n");

        return -1;

    }




    sock = socket(AF_UNIX, SOCK_STREAM, 0);

    if (sock < 0) {

        do_perror("socket");

        return -1;

    }



    /* mask other part of mode bits */

    umask(7);



    proxy.sun_family = AF_UNIX;

    strcpy(proxy.sun_path, path);

    if (bind(sock, (struct sockaddr *)&proxy,

            sizeof(struct sockaddr_un)) < 0) {

        do_perror("bind");

        goto error;

    }

    if (chown(proxy.sun_path, uid, gid) < 0) {

        do_perror("chown");

        goto error;

    }

    if (listen(sock, 1) < 0) {

        do_perror("listen");

        goto error;

    }



    size = sizeof(qemu);

    client = accept(sock, (struct sockaddr *)&qemu, &size);

    if (client < 0) {

        do_perror("accept");

        goto error;

    }

    close(sock);

    return client;



error:

    close(sock);

    return -1;

}
static int proxy_socket(const char *path, uid_t uid, gid_t gid)

{

    int sock, client;

    struct sockaddr_un proxy, qemu;

    socklen_t size;



    

    if (!access(path, F_OK)) {

        do_log(LOG_CRIT, "socket already exists\n");

        return -1;

    }




    sock = socket(AF_UNIX, SOCK_STREAM, 0);

    if (sock < 0) {

        do_perror("socket");

        return -1;

    }



    

    umask(7);



    proxy.sun_family = AF_UNIX;

    strcpy(proxy.sun_path, path);

    if (bind(sock, (struct sockaddr *)&proxy,

            sizeof(struct sockaddr_un)) < 0) {

        do_perror("bind");

        goto error;

    }

    if (chown(proxy.sun_path, uid, gid) < 0) {

        do_perror("chown");

        goto error;

    }

    if (listen(sock, 1) < 0) {

        do_perror("listen");

        goto error;

    }



    size = sizeof(qemu);

    client = accept(sock, (struct sockaddr *)&qemu, &size);

    if (client < 0) {

        do_perror("accept");

        goto error;

    }

    close(sock);

    return client;



error:

    close(sock);

    return -1;

}
static int FUNC_0(const char *VAR_0, uid_t VAR_1, gid_t VAR_2)

{

    int VAR_3, VAR_4;

    struct sockaddr_un VAR_5, VAR_6;

    socklen_t size;



    

    if (!access(VAR_0, F_OK)) {

        do_log(LOG_CRIT, "socket already exists\n");

        return -1;

    }




    VAR_3 = socket(AF_UNIX, SOCK_STREAM, 0);

    if (VAR_3 < 0) {

        do_perror("socket");

        return -1;

    }



    

    umask(7);



    VAR_5.sun_family = AF_UNIX;

    strcpy(VAR_5.sun_path, VAR_0);

    if (bind(VAR_3, (struct sockaddr *)&VAR_5,

            sizeof(struct sockaddr_un)) < 0) {

        do_perror("bind");

        goto error;

    }

    if (chown(VAR_5.sun_path, VAR_1, VAR_2) < 0) {

        do_perror("chown");

        goto error;

    }

    if (listen(VAR_3, 1) < 0) {

        do_perror("listen");

        goto error;

    }



    size = sizeof(VAR_6);

    VAR_4 = accept(VAR_3, (struct sockaddr *)&VAR_6, &size);

    if (VAR_4 < 0) {

        do_perror("accept");

        goto error;

    }

    close(VAR_3);

    return VAR_4;



error:

    close(VAR_3);

    return -1;

}
static int FUNC_0(const char *VAR_0, uid_t VAR_1, gid_t VAR_2)
{ int VAR_3, VAR_4; struct sockaddr_un VAR_5, VAR_6; socklen_t size; if (!access(VAR_0, F_OK)) { do_log(LOG_CRIT, "socket already exists\n"); return -1; } VAR_3 = socket(AF_UNIX, SOCK_STREAM, 0); if (VAR_3 < 0) { do_perror("socket"); return -1; } umask(7); VAR_5.sun_family = AF_UNIX; strcpy(VAR_5.sun_path, VAR_0); if (bind(VAR_3, (struct sockaddr *)&VAR_5,
sizeof(struct sockaddr_un)) < 0) { do_perror("bind"); goto error; } if (chown(VAR_5.sun_path, VAR_1, VAR_2) < 0) { do_perror("chown"); goto error; } if (listen(VAR_3, 1) < 0) { do_perror("listen"); goto error; } size = sizeof(VAR_6); VAR_4 = accept(VAR_3, (struct sockaddr *)&VAR_6, &size); if (VAR_4 < 0) { do_perror("accept"); goto error; } close(VAR_3); return VAR_4; error:
close(VAR_3); return -1; }