mirror of
https://github.com/samba-team/samba.git
synced 2025-01-19 10:03:58 +03:00
Fix a file descriptor leak in add_port_hook
This was probably cut&paste from add_printer_hook which further down has the unconditional close(fd). In add_port_hook() we're not interested in the output of 'addport command', so don't create the out fd.
This commit is contained in:
parent
7a853d265b
commit
0c5ca2127a
@ -6155,7 +6155,6 @@ WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname
|
|||||||
char *cmd = lp_addport_cmd();
|
char *cmd = lp_addport_cmd();
|
||||||
char *command = NULL;
|
char *command = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
int fd;
|
|
||||||
SE_PRIV se_printop = SE_PRINT_OPERATOR;
|
SE_PRIV se_printop = SE_PRINT_OPERATOR;
|
||||||
bool is_print_op = False;
|
bool is_print_op = False;
|
||||||
|
|
||||||
@ -6179,7 +6178,7 @@ WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname
|
|||||||
if ( is_print_op )
|
if ( is_print_op )
|
||||||
become_root();
|
become_root();
|
||||||
|
|
||||||
ret = smbrun(command, &fd);
|
ret = smbrun(command, NULL);
|
||||||
|
|
||||||
if ( is_print_op )
|
if ( is_print_op )
|
||||||
unbecome_root();
|
unbecome_root();
|
||||||
@ -6191,8 +6190,6 @@ WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname
|
|||||||
TALLOC_FREE(command);
|
TALLOC_FREE(command);
|
||||||
|
|
||||||
if ( ret != 0 ) {
|
if ( ret != 0 ) {
|
||||||
if (fd != -1)
|
|
||||||
close(fd);
|
|
||||||
return WERR_ACCESS_DENIED;
|
return WERR_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user