return -1;
}
}
- ret = smbrun(add_script,NULL);
+ ret = smbrun(add_script, NULL, NULL);
flush_pwnam_cache();
DEBUG(ret ? 0 : 3,
("smb_create_user: Running the command `%s' gave %d\n",
}
DEBUG(8, ("running command: [%s]\n", command));
- if (smbrun(command, NULL) != 0) {
+ if (smbrun(command, NULL, NULL) != 0) {
DEBUG(0, ("Could not log NT token\n"));
TALLOC_FREE(frame);
return NT_STATUS_ACCESS_DENIED;
}
DEBUG(10,("Running [%s]\n", command));
- ret = smbrun(command, &fd);
+ ret = smbrun(command, &fd, NULL);
DEBUGADD(10,("returned [%d]\n", ret));
TALLOC_FREE(command);
return -1;
}
- ret = smbrun(add_script, &fd);
+ ret = smbrun(add_script, &fd, NULL);
DEBUG(ret ? 0 : 3,("smb_create_group: Running the command `%s' gave %d\n",add_script,ret));
if (ret == 0) {
smb_nscd_flush_group_cache();
if (!del_script) {
return -1;
}
- ret = smbrun(del_script,NULL);
+ ret = smbrun(del_script, NULL, NULL);
DEBUG(ret ? 0 : 3,("smb_delete_group: Running the command `%s' gave %d\n",del_script,ret));
if (ret == 0) {
smb_nscd_flush_group_cache();
if (!add_script) {
return -1;
}
- ret = smbrun(add_script,NULL);
+ ret = smbrun(add_script, NULL, NULL);
flush_pwnam_cache();
DEBUG(ret ? 0 : 3,("smb_set_primary_group: "
"Running the command `%s' gave %d\n",add_script,ret));
if (!add_script) {
return -1;
}
- ret = smbrun(add_script,NULL);
+ ret = smbrun(add_script, NULL, NULL);
DEBUG(ret ? 0 : 3,("smb_add_user_group: Running the command `%s' gave %d\n",add_script,ret));
if (ret == 0) {
smb_nscd_flush_group_cache();
if (!del_script) {
return -1;
}
- ret = smbrun(del_script,NULL);
+ ret = smbrun(del_script, NULL, NULL);
DEBUG(ret ? 0 : 3,("smb_delete_user_group: Running the command `%s' gave %d\n",del_script,ret));
if (ret == 0) {
smb_nscd_flush_group_cache();
/* The following definitions come from lib/smbrun.c */
-int smbrun_no_sanitize(const char *cmd, int *outfd);
-int smbrun(const char *cmd, int *outfd);
+int smbrun_no_sanitize(const char *cmd, int *outfd, char * const *env);
+int smbrun(const char *cmd, int *outfd, char * const *env);
int smbrunsecret(const char *cmd, const char *secret);
/* The following definitions come from lib/sock_exec.c */
outfd (or discard it if outfd is NULL).
****************************************************************************/
-static int smbrun_internal(const char *cmd, int *outfd, bool sanitize)
+static int smbrun_internal(const char *cmd, int *outfd, bool sanitize,
+ char * const *env)
{
pid_t pid;
uid_t uid = current_user.ut.uid;
exit(82);
}
- execl("/bin/sh","sh","-c",
- newcmd ? (const char *)newcmd : cmd, NULL);
+ if (env != NULL) {
+ execle("/bin/sh","sh","-c",
+ newcmd ? (const char *)newcmd : cmd, NULL,
+ env);
+ } else {
+ execl("/bin/sh","sh","-c",
+ newcmd ? (const char *)newcmd : cmd, NULL);
+ }
SAFE_FREE(newcmd);
}
Use only in known safe shell calls (printing).
****************************************************************************/
-int smbrun_no_sanitize(const char *cmd, int *outfd)
+int smbrun_no_sanitize(const char *cmd, int *outfd, char * const *env)
{
- return smbrun_internal(cmd, outfd, False);
+ return smbrun_internal(cmd, outfd, false, env);
}
/****************************************************************************
By default this now sanitizes shell expansion.
****************************************************************************/
-int smbrun(const char *cmd, int *outfd)
+int smbrun(const char *cmd, int *outfd, char * const *env)
{
- return smbrun_internal(cmd, outfd, True);
+ return smbrun_internal(cmd, outfd, true, env);
}
/****************************************************************************
if (!add_script) {
return NT_STATUS_NO_MEMORY;
}
- add_ret = smbrun(add_script, NULL);
+ add_ret = smbrun(add_script, NULL, NULL);
DEBUG(add_ret ? 0 : 1,("fetch_account: Running the command `%s' "
"gave %d\n", add_script, add_ret));
if (add_ret == 0) {
if (!add_script) {
return NT_STATUS_NO_MEMORY;
}
- add_ret = smbrun(add_script, NULL);
+ add_ret = smbrun(add_script, NULL, NULL);
DEBUG(add_ret ? 0 : 1,("fetch_account: Running the command `%s' "
"gave %d\n", add_script, add_ret));
if (add_ret == 0) {
goto err_tmp_free;
}
- ret = smbrun(cmd_run, NULL);
+ ret = smbrun(cmd_run, NULL, NULL);
if (ret != 0) {
DEBUG(0, ("%s failed with %d\n", cmd_run, ret));
status = NT_STATUS_NOT_SUPPORTED;
goto err_tmp_free;
}
- ret = smbrun(cmd_run, &fd);
+ ret = smbrun(cmd_run, &fd, NULL);
talloc_free(cmd_run);
if (ret != 0) {
if (fd != -1) {
return NT_STATUS_NO_MEMORY;
}
- ret = smbrun(cmd_run, NULL);
+ ret = smbrun(cmd_run, NULL, NULL);
talloc_free(cmd_run);
if (ret != 0) {
return NT_STATUS_UNSUCCESSFUL;
return NT_STATUS_NO_MEMORY;
}
DEBUG(10, ("tsmsm_set_offline: Running [%s]\n", command));
- if((result = smbrun(command, NULL)) != 0) {
+ result = smbrun(command, NULL, NULL)
+ if(result != 0) {
DEBUG(1,("tsmsm_set_offline: Running [%s] returned %d\n", command, result));
TALLOC_FREE(command);
return NT_STATUS_INTERNAL_ERROR;
}
DEBUG(3,("calling wins hook for %s\n", nmb_namestr(&namerec->name)));
- smbrun(command, NULL);
+ smbrun(command, NULL, NULL);
TALLOC_FREE(command);
}
if (!add_script) {
return NT_STATUS_NO_MEMORY;
}
- add_ret = smbrun(add_script,NULL);
+ add_ret = smbrun(add_script, NULL, NULL);
DEBUG(add_ret ? 0 : 3, ("_samr_create_user: Running the command `%s' gave %d\n",
add_script, add_ret));
if (add_ret == 0) {
if (!del_script) {
return -1;
}
- ret = smbrun(del_script,NULL);
+ ret = smbrun(del_script, NULL, NULL);
flush_pwnam_cache();
if (ret == 0) {
smb_nscd_flush_user_cache();
oldname_lower,
true,
true);
- rc = smbrun(rename_script, NULL);
+ rc = smbrun(rename_script, NULL, NULL);
DEBUG(rc ? 0 : 3,("Running the command `%s' gave %d\n",
rename_script, rc));
goto done;
}
- rename_ret = smbrun(rename_script, NULL);
+ rename_ret = smbrun(rename_script, NULL, NULL);
DEBUG(rename_ret ? 0 : 3,("Running the command `%s' gave %d\n", rename_script, rename_ret));
if (!rename_script) {
goto cancel;
}
- rename_ret = smbrun(rename_script, NULL);
+ rename_ret = smbrun(rename_script, NULL, NULL);
DEBUG(rename_ret ? 0 : 3,("Running the command `%s' gave %d\n",
rename_script, rename_ret));
}
}
- ret = smbrun_no_sanitize(syscmd,outfd);
+ ret = smbrun_no_sanitize(syscmd, outfd, NULL);
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
if ( is_print_op )
become_root();
- if ( (ret = smbrun(command, NULL)) == 0 ) {
+ ret = smbrun(command, NULL, NULL);
+ if (ret == 0) {
/* Tell everyone we updated smb.conf. */
message_send_all(msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0, NULL);
}
if ( is_print_op )
become_root();
- ret = smbrun(command, NULL);
+ ret = smbrun(command, NULL, NULL);
if ( is_print_op )
unbecome_root();
if ( is_print_op )
become_root();
- if ( (ret = smbrun(command, &fd)) == 0 ) {
+ ret = smbrun(command, &fd, NULL);
+ if (ret == 0) {
/* Tell everyone we updated smb.conf. */
message_send_all(msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0, NULL);
}
}
DEBUG(10,("Running [%s]\n", command));
- ret = smbrun(command, &fd);
+ ret = smbrun(command, &fd, NULL);
DEBUG(10,("Returned [%d]\n", ret));
TALLOC_FREE(command);
if (ret != 0) {
if (is_disk_op)
become_root();
- if ( (ret = smbrun(command, NULL)) == 0 ) {
+ ret = smbrun(command, NULL, NULL);
+ if (ret == 0) {
/* Tell everyone we updated smb.conf. */
message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED,
NULL, 0, NULL);
/* FIXME: use libnetconf here - gd */
- if ( (ret = smbrun(command, NULL)) == 0 ) {
+ ret = smbrun(command, NULL, NULL);
+ if (ret == 0) {
/* Tell everyone we updated smb.conf. */
message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0,
NULL);
if ( is_disk_op )
become_root();
- if ( (ret = smbrun(command, NULL)) == 0 ) {
+ ret = smbrun(command, NULL, NULL);
+ if (ret == 0) {
/* Tell everyone we updated smb.conf. */
message_send_all(p->msg_ctx, MSG_SMB_CONF_UPDATED, NULL, 0,
NULL);
if ( can_shutdown )
become_root();
- ret = smbrun( shutdown_script, NULL );
+ ret = smbrun(shutdown_script, NULL, NULL);
if ( can_shutdown )
unbecome_root();
if ( can_shutdown )
become_root();
- ret = smbrun( abort_shutdown_script, NULL );
+ ret = smbrun(abort_shutdown_script, NULL, NULL);
if ( can_shutdown )
unbecome_root();
/* we've already performed the access check when the service was opened */
become_root();
- ret = smbrun( command , &fd );
+ ret = smbrun(command, &fd, NULL);
unbecome_root();
DEBUGADD(5, ("rcinit_start: [%s] returned [%d]\n", command, ret));
/* we've already performed the access check when the service was opened */
become_root();
- ret = smbrun( command , &fd );
+ ret = smbrun(command, &fd, NULL);
unbecome_root();
DEBUGADD(5, ("rcinit_start: [%s] returned [%d]\n", command, ret));
is STOPPED */
become_root();
- ret = smbrun( command , &fd );
+ ret = smbrun(command, &fd, NULL);
unbecome_root();
DEBUGADD(5, ("rcinit_start: [%s] returned [%d]\n", command, ret));
status = map_nt_error_from_unix(errno);
goto out;
}
- ret = smbrun(p,&tmp_fd);
+ ret = smbrun(p, &tmp_fd, NULL);
DEBUG(3,("Invoking magic command %s gave %d\n",
p,ret));
if (s == NULL) {
goto done;
}
- smbrun(s,NULL);
+ smbrun(s, NULL, NULL);
done:
TALLOC_FREE(frame);
conn->session_info->info->domain_name,
lp_root_preexec(talloc_tos(), snum));
DEBUG(5,("cmd=%s\n",cmd));
- ret = smbrun(cmd,NULL);
+ ret = smbrun(cmd, NULL, NULL);
TALLOC_FREE(cmd);
if (ret != 0 && lp_root_preexec_close(snum)) {
DEBUG(1,("root preexec gave %d - failing "
conn->session_info->unix_info->sanitized_username,
conn->session_info->info->domain_name,
lp_preexec(talloc_tos(), snum));
- ret = smbrun(cmd,NULL);
+ ret = smbrun(cmd, NULL, NULL);
TALLOC_FREE(cmd);
if (ret != 0 && lp_preexec_close(snum)) {
DEBUG(1,("preexec gave %d - failing connection\n",
conn->session_info->unix_info->sanitized_username,
conn->session_info->info->domain_name,
lp_postexec(talloc_tos(), SNUM(conn)));
- smbrun(cmd,NULL);
+ smbrun(cmd, NULL, NULL);
TALLOC_FREE(cmd);
change_to_root_user();
}
conn->session_info->unix_info->sanitized_username,
conn->session_info->info->domain_name,
lp_root_postexec(talloc_tos(), SNUM(conn)));
- smbrun(cmd,NULL);
+ smbrun(cmd, NULL, NULL);
TALLOC_FREE(cmd);
}