summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-12-05 00:13:17 +0000
committerLuke Leighton <lkcl@samba.org>1999-12-05 00:13:17 +0000
commit854f35e20fa4748312e4b0fbae6bb38342ab0389 (patch)
treef3fd0a7de90630a4442e54f6214966dd923a3003 /source3/utils
parentddda7722a673cefc89a55133f99c07dd153b1f19 (diff)
downloadsamba-854f35e20fa4748312e4b0fbae6bb38342ab0389.tar.gz
samba-854f35e20fa4748312e4b0fbae6bb38342ab0389.tar.bz2
samba-854f35e20fa4748312e4b0fbae6bb38342ab0389.zip
created create_pipe_socket() function.
(This used to be commit a3af3b4312144943413894b18b5845b56474ebb5)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/nmb-agent.c54
-rw-r--r--source3/utils/smb-agent.c45
2 files changed, 5 insertions, 94 deletions
diff --git a/source3/utils/nmb-agent.c b/source3/utils/nmb-agent.c
index ad9c958350..f49983db79 100644
--- a/source3/utils/nmb-agent.c
+++ b/source3/utils/nmb-agent.c
@@ -167,63 +167,15 @@ static BOOL process_srv_sock(struct sock_redir **socks,
return True;
}
-static int get_agent_sock(void*id)
+static int get_agent_sock(char *id)
{
- int s;
- struct sockaddr_un sa;
- fstring path;
fstring dir;
-
- CatchChild();
+ fstring path;
slprintf(dir, sizeof(dir)-1, "/tmp/.nmb");
- mkdir(dir, 0777);
-
slprintf(path, sizeof(path)-1, "%s/agent", dir);
- if (chmod(dir, 0777) < 0)
- {
- fprintf(stderr, "chmod on %s failed\n", sa.sun_path);
- return -1;
- }
-
-
- /* start listening on unix socket */
- s = socket(AF_UNIX, SOCK_STREAM, 0);
-
- if (s < 0)
- {
- fprintf(stderr, "socket open failed\n");
- return -1;
- }
-
- ZERO_STRUCT(sa);
- sa.sun_family = AF_UNIX;
- safe_strcpy(sa.sun_path, path, sizeof(sa.sun_path)-1);
-
- if (bind(s, (struct sockaddr*) &sa, sizeof(sa)) < 0)
- {
- fprintf(stderr, "socket bind to %s failed\n", sa.sun_path);
- close(s);
- remove(path);
- return -1;
- }
-
- if (s == -1)
- {
- DEBUG(0,("bind failed\n"));
- remove(path);
- return -1;
- }
-
- chmod(path, 0777);
-
- if (listen(s, 5) == -1)
- {
- DEBUG(0,("listen failed\n"));
- return -1;
- }
- return s;
+ return create_pipe_socket(dir, 0777, path, 0777);
}
static void start_nmb_agent(void)
diff --git a/source3/utils/smb-agent.c b/source3/utils/smb-agent.c
index 5d1aa4db04..96c43cadaf 100644
--- a/source3/utils/smb-agent.c
+++ b/source3/utils/smb-agent.c
@@ -303,7 +303,7 @@ static BOOL process_srv_sock(struct sock_redir **socks, uint32 num_socks,
return False;
}
-static int get_agent_sock(void *id)
+static int get_agent_sock(char *id)
{
int s;
struct sockaddr_un sa;
@@ -311,50 +311,9 @@ static int get_agent_sock(void *id)
fstring dir;
slprintf(dir, sizeof(dir)-1, "/tmp/.smb.%d", getuid());
- mkdir(dir, S_IRUSR|S_IWUSR|S_IXUSR);
-
slprintf(path, sizeof(path)-1, "%s/agent", dir);
- if (chmod(dir, S_IRUSR|S_IWUSR|S_IXUSR) < 0)
- {
- fprintf(stderr, "chmod on %s failed\n", sa.sun_path);
- exit(1);
- }
-
-
- /* start listening on unix socket */
- s = socket(AF_UNIX, SOCK_STREAM, 0);
-
- if (s < 0)
- {
- fprintf(stderr, "socket open failed\n");
- exit(1);
- }
-
- ZERO_STRUCT(sa);
- sa.sun_family = AF_UNIX;
- safe_strcpy(sa.sun_path, path, sizeof(sa.sun_path)-1);
- if (bind(s, (struct sockaddr*) &sa, sizeof(sa)) < 0)
- {
- fprintf(stderr, "socket bind to %s failed\n", sa.sun_path);
- close(s);
- remove(path);
- exit(1);
- }
-
- if (s == -1)
- {
- DEBUG(0,("bind failed\n"));
- remove(path);
- exit(1);
- }
-
- if (listen(s, 5) == -1)
- {
- DEBUG(0,("listen failed\n"));
- remove(path);
- }
- return s;
+ return create_pipe_socket(dir, S_IRUSR|S_IWUSR|S_IXUSR, path, 0);
}
static void start_smb_agent(void)