| 1 | /* |
| 2 | ** Copyright 2000 Double Precision, Inc. See COPYING for |
| 3 | ** distribution information. |
| 4 | */ |
| 5 | |
| 6 | #include "courier_auth_config.h" |
| 7 | #include <sys/types.h> |
| 8 | #include <sys/stat.h> |
| 9 | #include <sys/socket.h> |
| 10 | #include <sys/un.h> |
| 11 | #include <sys/time.h> |
| 12 | #include <sys/wait.h> |
| 13 | #include <unistd.h> |
| 14 | #include <stdlib.h> |
| 15 | #include <stdio.h> |
| 16 | #include <string.h> |
| 17 | |
| 18 | static const char rcsid[]="$Id: authmksock.c,v 1.3 2004/10/21 00:10:49 mrsam Exp $"; |
| 19 | |
| 20 | #ifndef SOMAXCONN |
| 21 | #define SOMAXCONN 5 |
| 22 | #endif |
| 23 | |
| 24 | int main(int argc, char *argv[]) |
| 25 | { |
| 26 | int fd=socket(PF_UNIX, SOCK_STREAM, 0); |
| 27 | struct sockaddr_un skun; |
| 28 | |
| 29 | if (argc < 2) exit(1); |
| 30 | if (fd < 0) exit(1); |
| 31 | skun.sun_family=AF_UNIX; |
| 32 | strcpy(skun.sun_path, argv[1]); |
| 33 | unlink(skun.sun_path); |
| 34 | if (bind(fd, (const struct sockaddr *)&skun, sizeof(skun)) || |
| 35 | listen(fd, SOMAXCONN)) |
| 36 | exit(1); |
| 37 | exit (0); |
| 38 | return (0); |
| 39 | } |