mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
created create_pipe_socket() function.
(This used to be commit a3af3b4312144943413894b18b5845b56474ebb5)
This commit is contained in:
parent
ddda7722a6
commit
854f35e20f
@ -138,12 +138,6 @@ BOOL allow_access(char *deny_list,char *allow_list,
|
||||
char *cname,char *caddr);
|
||||
BOOL check_access(int sock, char *allow_list, char *deny_list);
|
||||
|
||||
/*The following definitions come from lib/agent.c */
|
||||
|
||||
void init_sock_redir(struct vagent_ops*va);
|
||||
void free_sock_redir(struct vagent_ops*va);
|
||||
void start_agent(struct vagent_ops *va);
|
||||
|
||||
/*The following definitions come from lib/bitmap.c */
|
||||
|
||||
struct bitmap *bitmap_allocate(int n);
|
||||
@ -620,6 +614,8 @@ void reset_globals_after_fork(void);
|
||||
char *client_name(int fd);
|
||||
char *client_addr(int fd);
|
||||
int open_pipe_sock(char *path);
|
||||
int create_pipe_socket(char *dir, int dir_perms,
|
||||
char *path, int path_perms);
|
||||
|
||||
/*The following definitions come from lib/util_status.c */
|
||||
|
||||
@ -681,6 +677,12 @@ BOOL copy_unistr2(UNISTR2 *str, const UNISTR2 *from);
|
||||
UNISTR2 *unistr2_dup(const UNISTR2 *name);
|
||||
void unistr2_free(UNISTR2 *name);
|
||||
|
||||
/*The following definitions come from lib/vagent.c */
|
||||
|
||||
void init_sock_redir(struct vagent_ops*va);
|
||||
void free_sock_redir(struct vagent_ops*va);
|
||||
void start_agent(struct vagent_ops *va);
|
||||
|
||||
/*The following definitions come from libsmb/clientgen.c */
|
||||
|
||||
void copy_user_creds(struct user_credentials *to,
|
||||
|
@ -36,14 +36,14 @@ struct sock_redir
|
||||
struct vagent_ops
|
||||
{
|
||||
void (*free_sock)(void* sock);
|
||||
int (*get_agent_sock)(void* id);
|
||||
int (*get_agent_sock)(char* id);
|
||||
|
||||
BOOL (*process_cli_sock)(struct sock_redir **socks, uint32 num_socks,
|
||||
struct sock_redir *sock);
|
||||
BOOL (*process_srv_sock)(struct sock_redir **socks, uint32 num_socks,
|
||||
int fd);
|
||||
|
||||
void* id;
|
||||
char* id;
|
||||
struct sock_redir **socks;
|
||||
uint32 num_socks;
|
||||
};
|
||||
|
@ -894,3 +894,65 @@ int open_pipe_sock(char *path)
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
int create_pipe_socket(char *dir, int dir_perms,
|
||||
char *path, int path_perms)
|
||||
{
|
||||
int s;
|
||||
struct sockaddr_un sa;
|
||||
|
||||
mkdir(dir, dir_perms);
|
||||
|
||||
if (chmod(dir, dir_perms) < 0)
|
||||
{
|
||||
DEBUG(0, ("chmod on %s failed\n", dir));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!remove(path))
|
||||
{
|
||||
DEBUG(0, ("remove on %s failed\n", path));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* start listening on unix socket */
|
||||
s = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
|
||||
if (s < 0)
|
||||
{
|
||||
DEBUG(0, ("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)
|
||||
{
|
||||
DEBUG(0, ("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;
|
||||
}
|
||||
|
||||
if (path_perms != 0)
|
||||
{
|
||||
chmod(path, path_perms);
|
||||
}
|
||||
|
||||
if (listen(s, 5) == -1)
|
||||
{
|
||||
DEBUG(0,("listen failed\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user