version 1.17, 2008/11/25 17:02:27 |
version 1.18, 2009/04/11 11:48:06 |
|
|
#include "sudo.h" |
#include "sudo.h" |
|
|
#ifndef lint |
#ifndef lint |
__unused static const char rcsid[] = "$Sudo: check.c,v 1.245 2008/11/25 17:01:34 millert Exp $"; |
__unused static const char rcsid[] = "$Sudo: check.c,v 1.246 2009/02/24 13:04:39 millert Exp $"; |
#endif /* lint */ |
#endif /* lint */ |
|
|
/* Status codes for timestamp_status() */ |
/* Status codes for timestamp_status() */ |
|
|
* verify who he/she is. |
* verify who he/she is. |
*/ |
*/ |
void |
void |
check_user(validated, interactive) |
check_user(validated, mode) |
int validated; |
int validated; |
int interactive; |
int mode; |
{ |
{ |
char *timestampdir = NULL; |
char *timestampdir = NULL; |
char *timestampfile = NULL; |
char *timestampfile = NULL; |
char *prompt; |
char *prompt; |
int status; |
int status; |
|
|
if (user_uid == 0 || user_uid == runas_pw->pw_uid || user_is_exempt()) |
if (mode & MODE_INVALIDATE) { |
return; |
/* do not check or update timestamp */ |
|
status = TS_ERROR; |
|
} else { |
|
if (user_uid == 0 || user_uid == runas_pw->pw_uid || user_is_exempt()) |
|
return; |
|
|
build_timestamp(×tampdir, ×tampfile); |
build_timestamp(×tampdir, ×tampfile); |
status = timestamp_status(timestampdir, timestampfile, user_name, |
status = timestamp_status(timestampdir, timestampfile, user_name, |
TS_MAKE_DIRS); |
TS_MAKE_DIRS); |
|
} |
if (status != TS_CURRENT || ISSET(validated, FLAG_CHECK_USER)) { |
if (status != TS_CURRENT || ISSET(validated, FLAG_CHECK_USER)) { |
/* Bail out if we are non-interactive and a password is required */ |
/* Bail out if we are non-interactive and a password is required */ |
if (!interactive) |
if (ISSET(mode, MODE_NONINTERACTIVE)) |
errorx(1, "sorry, a password is required to run %s", getprogname()); |
errorx(1, "sorry, a password is required to run %s", getprogname()); |
|
|
/* If user specified -A, make sure we have an askpass helper. */ |
/* If user specified -A, make sure we have an askpass helper. */ |
|
|
|
|
/* |
/* |
* Standard sudo lecture. |
* Standard sudo lecture. |
* TODO: allow the user to specify a file name instead. |
|
*/ |
*/ |
static void |
static void |
lecture(status) |
lecture(status) |