version 1.1, 2013/07/22 00:51:38
|
version 1.1.1.2, 2013/10/14 07:56:35
|
Line 73 build_timestamp(struct passwd *pw)
|
Line 73 build_timestamp(struct passwd *pw)
|
debug_decl(build_timestamp, SUDO_DEBUG_AUTH) |
debug_decl(build_timestamp, SUDO_DEBUG_AUTH) |
|
|
/* Stash the tty's device, session ID and ctime for ticket comparison. */ |
/* Stash the tty's device, session ID and ctime for ticket comparison. */ |
if (def_tty_tickets && user_ttypath && stat(user_ttypath, &sb) == 0) { | if (def_tty_tickets) { |
tty_info.dev = sb.st_dev; | if (user_ttypath && stat(user_ttypath, &sb) == 0) { |
tty_info.ino = sb.st_ino; | tty_info.dev = sb.st_dev; |
tty_info.rdev = sb.st_rdev; | tty_info.ino = sb.st_ino; |
tty_info.uid = sb.st_uid; | tty_info.rdev = sb.st_rdev; |
tty_info.gid = sb.st_gid; | tty_info.uid = sb.st_uid; |
| tty_info.gid = sb.st_gid; |
| } |
tty_info.sid = user_sid; |
tty_info.sid = user_sid; |
} |
} |
|
|
Line 94 build_timestamp(struct passwd *pw)
|
Line 96 build_timestamp(struct passwd *pw)
|
* the directory as the timestamp. |
* the directory as the timestamp. |
*/ |
*/ |
if (def_tty_tickets) { |
if (def_tty_tickets) { |
|
char pidbuf[sizeof("pid") + (((sizeof(pid_t) * 8) + 2) / 3)]; |
char *p; |
char *p; |
|
|
if ((p = strrchr(user_tty, '/'))) | if (user_ttypath == NULL) { |
| /* No tty, use parent pid. */ |
| len = snprintf(pidbuf, sizeof(pidbuf), "pid%u", |
| (unsigned int)getppid()); |
| if (len <= 0 || len >= sizeof(pidbuf)) |
| goto bad; |
| p = pidbuf; |
| } else if ((p = strrchr(user_tty, '/'))) { |
p++; |
p++; |
else | } else { |
p = user_tty; |
p = user_tty; |
if (def_targetpw) | } |
| if (def_targetpw) { |
len = snprintf(timestampfile, sizeof(timestampfile), "%s/%s/%s:%s", |
len = snprintf(timestampfile, sizeof(timestampfile), "%s/%s/%s:%s", |
dirparent, user_name, p, runas_pw->pw_name); |
dirparent, user_name, p, runas_pw->pw_name); |
else | } else { |
len = snprintf(timestampfile, sizeof(timestampfile), "%s/%s/%s", |
len = snprintf(timestampfile, sizeof(timestampfile), "%s/%s/%s", |
dirparent, user_name, p); |
dirparent, user_name, p); |
|
} |
if (len <= 0 || len >= sizeof(timestampfile)) |
if (len <= 0 || len >= sizeof(timestampfile)) |
goto bad; |
goto bad; |
} else if (def_targetpw) { |
} else if (def_targetpw) { |
Line 132 update_timestamp(struct passwd *pw)
|
Line 144 update_timestamp(struct passwd *pw)
|
{ |
{ |
debug_decl(update_timestamp, SUDO_DEBUG_AUTH) |
debug_decl(update_timestamp, SUDO_DEBUG_AUTH) |
|
|
/* If using tty timestamps but we have no tty there is nothing to do. */ |
|
if (def_tty_tickets && !user_ttypath) |
|
debug_return_bool(false); |
|
|
|
if (timestamp_uid != 0) |
if (timestamp_uid != 0) |
set_perms(PERM_TIMESTAMP); |
set_perms(PERM_TIMESTAMP); |
if (*timestampfile) { |
if (*timestampfile) { |
Line 270 timestamp_status_internal(bool removing)
|
Line 278 timestamp_status_internal(bool removing)
|
if (*timestampfile && status != TS_ERROR) { |
if (*timestampfile && status != TS_ERROR) { |
if (status != TS_MISSING) |
if (status != TS_MISSING) |
status = TS_NOFILE; /* dir there, file missing */ |
status = TS_NOFILE; /* dir there, file missing */ |
if (def_tty_tickets && !user_ttypath) |
|
goto done; /* no tty, always prompt */ |
|
if (lstat(timestampfile, &sb) == 0) { |
if (lstat(timestampfile, &sb) == 0) { |
if (!S_ISREG(sb.st_mode)) { |
if (!S_ISREG(sb.st_mode)) { |
status = TS_ERROR; |
status = TS_ERROR; |
Line 396 remove_timestamp(bool remove)
|
Line 402 remove_timestamp(bool remove)
|
status = rmdir(timestampdir); |
status = rmdir(timestampdir); |
if (status == -1 && errno != ENOENT) { |
if (status == -1 && errno != ENOENT) { |
log_warning(0, |
log_warning(0, |
N_("unable to remove %s, will reset to the epoch"), path); | N_("unable to remove %s, will reset to the Unix epoch"), |
| path); |
remove = false; |
remove = false; |
} |
} |
} |
} |
if (!remove) { |
if (!remove) { |
timevalclear(&tv); |
timevalclear(&tv); |
if (touch(-1, path, &tv) == -1 && errno != ENOENT) |
if (touch(-1, path, &tv) == -1 && errno != ENOENT) |
fatal(_("unable to reset %s to the epoch"), path); | fatal(_("unable to reset %s to the Unix epoch"), path); |
} |
} |
} |
} |
|
|