Skip to content

Commit

Permalink
master: Removed unused process_exec(extra_args) parameter
Browse files Browse the repository at this point in the history
Removes unnecessarily complicated code marked with @unsafe.
  • Loading branch information
sirainen committed Dec 16, 2016
1 parent fa780a1 commit e8df5cf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/master/common.h
Expand Up @@ -13,8 +13,7 @@ extern int global_master_dead_pipe_fd[2];
extern struct service_list *services;
extern bool startup_finished;

void process_exec(const char *cmd, const char *extra_args[])
ATTR_NORETURN ATTR_NULL(2);
void process_exec(const char *cmd) ATTR_NORETURN;

int get_uidgid(const char *user, uid_t *uid_r, gid_t *gid_r,
const char **error_r);
Expand Down
16 changes: 1 addition & 15 deletions src/master/main.c
Expand Up @@ -58,27 +58,13 @@ static const struct setting_parser_info *set_roots[] = {
NULL
};

void process_exec(const char *cmd, const char *extra_args[])
void process_exec(const char *cmd)
{
const char *executable, *p, **argv;

argv = t_strsplit(cmd, " ");
executable = argv[0];

if (extra_args != NULL) {
unsigned int count1, count2;
const char **new_argv;

/* @UNSAFE */
count1 = str_array_length(argv);
count2 = str_array_length(extra_args);
new_argv = t_new(const char *, count1 + count2 + 1);
memcpy(new_argv, argv, sizeof(const char *) * count1);
memcpy(new_argv + count1, extra_args,
sizeof(const char *) * count2);
argv = new_argv;
}

/* hide the path, it's ugly */
p = strrchr(argv[0], '/');
if (p != NULL) argv[0] = p+1;
Expand Down
2 changes: 1 addition & 1 deletion src/master/service-process.c
Expand Up @@ -323,7 +323,7 @@ struct service_process *service_process_create(struct service *service)
service_reopen_inet_listeners(service);
service_dup_fds(service);
drop_privileges(service);
process_exec(service->executable, NULL);
process_exec(service->executable);
}
i_assert(hash_table_lookup(service_pids, POINTER_CAST(pid)) == NULL);

Expand Down

0 comments on commit e8df5cf

Please sign in to comment.