From ff78d6cea19ba392d6c389ad3a16f10e3f245fb5 Mon Sep 17 00:00:00 2001 From: David Nugent Date: Tue, 7 Jan 1997 13:29:21 +0000 Subject: [PATCH] Fix for login_getclass(NULL) case. --- libutil/login_cap.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libutil/login_cap.c b/libutil/login_cap.c index 21ff02f..8f3c56d 100644 --- a/libutil/login_cap.c +++ b/libutil/login_cap.c @@ -21,7 +21,7 @@ * * Low-level routines relating to the user capabilities database * - * $Id$ + * $Id: login_cap.c,v 1.1 1997/01/04 16:50:02 davidn Exp $ */ #include @@ -214,9 +214,11 @@ login_getclassbyname(char const * name, char const * dir) login_cap_t * login_getclass(const struct passwd *pwd) { - const char * class = (pwd == NULL) ? NULL : pwd->pw_class; - if (pwd->pw_class == NULL || *pwd->pw_class == '\0') - class = (pwd->pw_uid == 0) ? "root" : NULL; /* Kludge for 'root' user(s) */ + const char * class = NULL; + if (pwd == NULL) { + if ((class = pwd->pw_class) == NULL) || *class == '\0') + class = (pwd->pw_uid == 0) ? "root" : NULL; + } return login_getclassbyname(class, 0); } -- 2.47.1