2
0
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:
Todd C. Miller
2010-12-31 09:55:40 -05:00
parent 755e3ef0ab
commit 1bb3518b33
3 changed files with 11 additions and 6 deletions

View File

@@ -145,7 +145,8 @@ fill_command(char *str, size_t strsize)
} }
char * 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; size_t plen = 0, psize = 1024;
char *path, *dst; char *path, *dst;
@@ -170,9 +171,11 @@ expand_iolog_path(const char *prefix, const char *dir, const char *file)
src = dir; src = dir;
break; break;
case 1: case 1:
/* Only add path separator if dir doesn't end in a slash. */ /* Trim trailing slashes from dir component. */
if (dst > path && dst[-1] == '/') while (dst > path && dst[-1] == '/')
continue; dst--;
if (slashp)
*slashp = dst;
src = "/"; src = "/";
break; break;
case 2: case 2:

View File

@@ -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 (def_iolog_file && def_iolog_dir) {
if (strstr(def_iolog_file, "%{seq}") != NULL) /* XXX - inline? */ if (strstr(def_iolog_file, "%{seq}") != NULL) /* XXX - inline? */
io_nextid(def_iolog_dir, sudo_user.sessid); 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) { if (def_log_input) {
command_info[info_len++] = estrdup("iolog_stdin=true"); command_info[info_len++] = estrdup("iolog_stdin=true");

View File

@@ -286,7 +286,8 @@ int get_boottime(struct timeval *);
void io_nextid(char *iolog_dir, char sessid[7]); void io_nextid(char *iolog_dir, char sessid[7]);
/* iolog_path.c */ /* 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 */ /* env.c */
char **env_get(void); char **env_get(void);