- char *name;
- int retval = 0;
-
- if(sock_path) {
- if (asprintf(&name, "%s", sock_path) < 0) {
- ERR("ustcomm_init_ustd : asprintf failed (sock_path %s)",
- sock_path);
- return -1;
- }
- }
- else {
- int result;
-
- /* Only check if socket dir exists if we are using the default directory */
- result = ensure_dir_exists(SOCK_DIR);
- if(result == -1) {
- ERR("Unable to create socket directory %s", SOCK_DIR);
- return -1;
- }
-
- if (asprintf(&name, "%s/%s", SOCK_DIR, "ustd") < 0) {
- ERR("ustcomm_init_ustd : asprintf failed (%s/ustd)",
- SOCK_DIR);
- return -1;
- }
- }
-
- handle->server.listen_fd = init_named_socket(name, &handle->server.socketpath);
- if(handle->server.listen_fd < 0) {
- ERR("error initializing named socket at %s", name);
- retval = -1;
- goto free_name;