From e66460b8942afc349793d018627b403bbd4eaad0 Mon Sep 17 00:00:00 2001 From: cperciva Date: Wed, 22 Mar 2006 16:00:42 +0000 Subject: Add missing code needed for the detection of IPSec packet replays. [1] Correctly identify the user running opiepasswd(1) when the login name differs from the account name. [2] Security: FreeBSD-SA-06:11.ipsec [1] Security: FreeBSD-SA-06:12.opie [2] --- contrib/opie/opiepasswd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'contrib/opie') diff --git a/contrib/opie/opiepasswd.c b/contrib/opie/opiepasswd.c index 2e2358a..cd4ff01 100644 --- a/contrib/opie/opiepasswd.c +++ b/contrib/opie/opiepasswd.c @@ -118,11 +118,18 @@ int main FUNCTION((argc, argv), int argc AND char *argv[]) struct opie opie; int rval, n = 499, i, mode = MODE_DEFAULT, force = 0; char seed[OPIE_SEED_MAX+1]; + char *username; + uid_t ruid; struct passwd *pp; memset(seed, 0, sizeof(seed)); - if (!(pp = getpwnam(getlogin()))) { + ruid = getuid(); + username = getlogin(); + pp = getpwnam(username); + if (username == NULL || pp == NULL || pp->pw_uid != ruid) + pp = getpwuid(ruid); + if (pp == NULL) { fprintf(stderr, "Who are you?"); return 1; } -- cgit v1.1