1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

dtsession: fix screen saver/locking on linux

The POSIX __linux__ commit broke the special detection on linux used
to determine whether a secure system was in use or not.

This commit reworks the logic a little bit to avoid special casing
linux in main().

It also reworks the logic in CanReAuthenticate() to fix up some issues
"fixed" to correct converity warnings.  The logic in this case was
mostly ok, but still didn't account for the proper usage of this
function.  Error detection improved somewhat as a result.
This commit is contained in:
Jon Trulson 2018-05-29 12:28:21 -06:00
parent ad219d40c3
commit 20cad57cd4
2 changed files with 25 additions and 33 deletions

View file

@ -153,14 +153,20 @@ static void BlinkCaret( XtPointer, XtIntervalId *) ;
static Boolean CanReAuthenticate(char *name, uid_t uid, char *passwd,
struct passwd **pwent, struct spwd **spent)
{
Boolean fail = False;
if (!pwent)
return False;
if (pwent)
*pwent = (name == NULL) ? getpwuid(uid) : getpwnam(name);
if (!*pwent)
return False;
*spent = getspnam((*pwent)->pw_name);
#ifdef JET_AUTHDEBUG
fprintf(stderr, "CanReAuthenticate(): %s %s %s\n",
fprintf(stderr, "CanReAuthenticate(): uid: %d name: '%s' errno %d %s %s %s\n",
uid,
(name) ? name : "NULL",
errno,
(*pwent) ? "PWENT" : "NULL",
(*spent) ? "SPENT" : "NULL",
(name) ? name : "NULL");

View file

@ -95,7 +95,7 @@ static int RegisterX11ScreenSaver(Display *display, int *ssEventType);
#ifdef _AIX
#define SECURE_SYS_PATH "/etc/security/passwd"
#endif
#ifdef SVR4
#if defined(SVR4) || defined(__linux__)
#define SECURE_SYS_PATH "/etc/shadow"
#endif
#ifdef CSRG_BASED
@ -183,17 +183,6 @@ main (int argc, char **argv)
*/
smGD.runningUID = getuid();
#ifdef linux /* linux always needs to be setup as secure */
/*
* Save the root privilege to be restored when trying to unlock
*/
smGD.unLockUID = geteuid();
smGD.secureSystem = True;
SM_SETEUID(smGD.runningUID);
#else
# ifdef SECURE_SYS_PATH
status = stat(SECURE_SYS_PATH, &buf);
# else
@ -219,8 +208,6 @@ main (int argc, char **argv)
SM_SETEUID(smGD.runningUID);
}
#endif /* linux */
/*
* Initialize LANG if it isn't defined.
*/
@ -677,4 +664,3 @@ RegisterX11ScreenSaver(
return(result);
}
#endif /* USE_X11SSEXT */