}
/*
- * Read the on-disk sequence number, set sudo_user.sessid to the next
+ * Read the on-disk sequence number, set sessid to the next
* number, and update the on-disk copy.
* Uses file locking to avoid sequence number collisions.
*/
{
int len;
+ /* XXX - sessid should be static to fill_seq */
+ if (sudo_user.sessid[0] == '\0')
+ io_nextid(def_iolog_dir, sudo_user.sessid);
+
/* Path is of the form /var/log/sudo-io/00/00/01. */
len = snprintf(str, strsize, "%c%c/%c%c/%c%c", sudo_user.sessid[0],
sudo_user.sessid[1], sudo_user.sessid[2], sudo_user.sessid[3],
new_logline(const char *message, int serrno)
{
size_t len = 0;
- char *evstr = NULL;
char *errstr = NULL;
- char *line;
+ char *evstr = NULL;
+ char *line, *tsid;
+
+ /* A TSID may be a sudoers-style session ID or a free-form string. */
+ tsid =
+ sudo_user.sessid[0] != '\0' ? sudo_user.sessid : sudo_user.iolog_file;
/*
* Compute line length
len += sizeof(LL_USER_STR) + 2 + strlen(runas_pw->pw_name);
if (runas_gr != NULL)
len += sizeof(LL_GROUP_STR) + 2 + strlen(runas_gr->gr_name);
- if (sudo_user.sessid[0] != '\0')
- len += sizeof(LL_TSID_STR) + 2 + strlen(sudo_user.sessid);
+ if (tsid != NULL)
+ len += sizeof(LL_TSID_STR) + 2 + strlen(tsid);
if (sudo_user.env_vars != NULL) {
size_t evlen = 0;
char * const *ep;
strlcat(line, " ; ", len) >= len)
goto toobig;
}
- if (sudo_user.sessid[0] != '\0') {
+ if (tsid != NULL) {
if (strlcat(line, LL_TSID_STR, len) >= len ||
- strlcat(line, sudo_user.sessid, len) >= len ||
+ strlcat(line, tsid, len) >= len ||
strlcat(line, " ; ", len) >= len)
goto toobig;
}
if (ISSET(sudo_mode, (MODE_RUN | MODE_EDIT)) && (def_log_input || def_log_output)) {
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, NULL);
+ def_iolog_dir, def_iolog_file, &sudo_user.iolog_file);
+ sudo_user.iolog_file++;
}
if (def_log_input) {
command_info[info_len++] = estrdup("iolog_stdin=true");
char *type;
#endif
char *cwd;
+ char *iolog_file;
char sessid[7];
#ifdef HAVE_MBR_CHECK_MEMBERSHIP
uuid_t uuid;