mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 22:35:10 +00:00
Add extra out parameter to expand_iolog_path() to allow the caller
to split the path into dir and file components if needed.
This commit is contained in:
@@ -145,7 +145,8 @@ fill_command(char *str, size_t strsize)
|
||||
}
|
||||
|
||||
char *
|
||||
expand_iolog_path(const char *prefix, const char *dir, const char *file)
|
||||
expand_iolog_path(const char *prefix, const char *dir, const char *file,
|
||||
char **slashp)
|
||||
{
|
||||
size_t plen = 0, psize = 1024;
|
||||
char *path, *dst;
|
||||
@@ -170,9 +171,11 @@ expand_iolog_path(const char *prefix, const char *dir, const char *file)
|
||||
src = dir;
|
||||
break;
|
||||
case 1:
|
||||
/* Only add path separator if dir doesn't end in a slash. */
|
||||
if (dst > path && dst[-1] == '/')
|
||||
continue;
|
||||
/* Trim trailing slashes from dir component. */
|
||||
while (dst > path && dst[-1] == '/')
|
||||
dst--;
|
||||
if (slashp)
|
||||
*slashp = dst;
|
||||
src = "/";
|
||||
break;
|
||||
case 2:
|
||||
|
@@ -513,7 +513,8 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
|
||||
if (def_iolog_file && def_iolog_dir) {
|
||||
if (strstr(def_iolog_file, "%{seq}") != NULL) /* XXX - inline? */
|
||||
io_nextid(def_iolog_dir, sudo_user.sessid);
|
||||
command_info[info_len++] = expand_iolog_path("iolog_path=", def_iolog_dir, def_iolog_file);
|
||||
command_info[info_len++] = expand_iolog_path("iolog_path=",
|
||||
def_iolog_dir, def_iolog_file, NULL);
|
||||
}
|
||||
if (def_log_input) {
|
||||
command_info[info_len++] = estrdup("iolog_stdin=true");
|
||||
|
@@ -286,7 +286,8 @@ int get_boottime(struct timeval *);
|
||||
void io_nextid(char *iolog_dir, char sessid[7]);
|
||||
|
||||
/* iolog_path.c */
|
||||
char *expand_iolog_path(const char *prefix, const char *dir, const char *file);
|
||||
char *expand_iolog_path(const char *prefix, const char *dir, const char *file,
|
||||
char **slashp);
|
||||
|
||||
/* env.c */
|
||||
char **env_get(void);
|
||||
|
Reference in New Issue
Block a user