1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: rxvtd.C |
2 | * File: rxvtd.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
… | |
… | |
69 | }; |
69 | }; |
70 | |
70 | |
71 | unix_listener::unix_listener (const char *sockname) |
71 | unix_listener::unix_listener (const char *sockname) |
72 | : accept_ev (this, &unix_listener::accept_cb) |
72 | : accept_ev (this, &unix_listener::accept_cb) |
73 | { |
73 | { |
|
|
74 | sockaddr_un sa; |
|
|
75 | |
|
|
76 | if (strlen(sockname) >= sizeof(sa.sun_path)) |
|
|
77 | rxvt_fatal ("socket name too long, aborting.\n"); |
|
|
78 | |
74 | if ((fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) |
79 | if ((fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) |
75 | { |
80 | { |
76 | perror ("unable to create listening socket"); |
81 | perror ("unable to create listening socket"); |
77 | exit (EXIT_FAILURE); |
82 | exit (EXIT_FAILURE); |
78 | } |
83 | } |
79 | |
84 | |
80 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
85 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
81 | |
|
|
82 | sockaddr_un sa; |
|
|
83 | |
86 | |
84 | sa.sun_family = AF_UNIX; |
87 | sa.sun_family = AF_UNIX; |
85 | strcpy (sa.sun_path, sockname); |
88 | strcpy (sa.sun_path, sockname); |
86 | |
89 | |
87 | unlink (rxvt_connection::unix_sockname ()); |
90 | unlink (rxvt_connection::unix_sockname ()); |