File: authmksock.c

package info (click to toggle)
courier-authlib 0.72.6-3
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 17,844 kB
  • sloc: ansic: 25,772; cpp: 12,475; sh: 5,588; makefile: 938; perl: 761
file content (38 lines) | stat: -rw-r--r-- 742 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
** Copyright 2000 Double Precision, Inc.  See COPYING for
** distribution information.
*/

#include	"courier_auth_config.h"
#include	<sys/types.h>
#include	<sys/stat.h>
#include	<sys/socket.h>
#include	<sys/un.h>
#include	<sys/time.h>
#include	<sys/wait.h>
#include	<unistd.h>
#include	<stdlib.h>
#include	<stdio.h>
#include	<string.h>


#ifndef	SOMAXCONN
#define	SOMAXCONN	5
#endif

int main(int argc, char *argv[])
{
int	fd=socket(PF_UNIX, SOCK_STREAM, 0);
struct	sockaddr_un skun;

	if (argc < 2)	exit(1);
	if (fd < 0)	exit(1);
	skun.sun_family=AF_UNIX;
	strcpy(skun.sun_path, argv[1]);
	unlink(skun.sun_path);
	if (bind(fd, (const struct sockaddr *)&skun, sizeof(skun)) ||
		listen(fd, SOMAXCONN))
		exit(1);
	exit (0);
	return (0);
}