Add an autologin mode to xenodm.
This commit is contained in:
parent
7cd788e5d9
commit
33973f7a55
@ -356,3 +356,28 @@ greet_user_rtn GreetUser(
|
||||
}
|
||||
return Greet_Success;
|
||||
}
|
||||
|
||||
_X_EXPORT
|
||||
greet_user_rtn AutoLogin(
|
||||
struct display *d,
|
||||
struct verify_info *verify,
|
||||
struct greet_info *greet)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!autoLoginEnv(d, verify, greet)) {
|
||||
LogError("Autologin %s failed\n", d->autoLogin);
|
||||
SessionExit(d, UNMANAGE_DISPLAY, TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Run system-wide initialization file
|
||||
*/
|
||||
if (source (verify->systemEnviron, d->startup) != 0)
|
||||
{
|
||||
Debug ("Startup program %s exited with non-zero status\n",
|
||||
d->startup);
|
||||
SessionExit (d, OBEYSESS_DISPLAY, FALSE);
|
||||
}
|
||||
return Greet_Success;
|
||||
}
|
||||
|
@ -203,3 +203,41 @@ Verify (struct display *d, struct greet_info *greet, struct verify_info *verify)
|
||||
Debug ("end of environments\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
_X_INTERNAL
|
||||
int
|
||||
autoLoginEnv(struct display *d, struct verify_info *verify,
|
||||
struct greet_info *greet)
|
||||
{
|
||||
struct passwd *p;
|
||||
char *shell, *home, **argv;
|
||||
|
||||
Debug("Autologin %s\n", d->autoLogin);
|
||||
p = getpwnam (d->autoLogin);
|
||||
endpwent();
|
||||
if (p == NULL)
|
||||
return 0;
|
||||
|
||||
greet->name = strdup(d->autoLogin);
|
||||
verify->uid = p->pw_uid;
|
||||
verify->gid = p->pw_gid;
|
||||
home = p->pw_dir;
|
||||
shell = p->pw_shell;
|
||||
argv = NULL;
|
||||
if (d->session)
|
||||
argv = parseArgs (argv, d->session);
|
||||
if (greet->string)
|
||||
argv = parseArgs (argv, greet->string);
|
||||
if (!argv)
|
||||
argv = parseArgs (argv, "xsession");
|
||||
verify->argv = argv;
|
||||
verify->userEnviron = userEnv (d, p->pw_uid == 0,
|
||||
greet->name, home, shell);
|
||||
Debug ("user environment:\n");
|
||||
printEnv (verify->userEnviron);
|
||||
verify->systemEnviron = systemEnv (d, greet->name, home);
|
||||
Debug ("system environment:\n");
|
||||
printEnv (verify->systemEnviron);
|
||||
Debug ("end of environments\n");
|
||||
return 1;
|
||||
}
|
||||
|
@ -141,6 +141,9 @@ struct display {
|
||||
|
||||
Display *dpy; /* Display */
|
||||
char *windowPath; /* path to server "window" */
|
||||
|
||||
/* autologin */
|
||||
char *autoLogin; /* user to auto-login */
|
||||
};
|
||||
|
||||
|
||||
@ -302,6 +305,7 @@ extern void printEnv (char **e);
|
||||
|
||||
/* in verify.c */
|
||||
extern int Verify (struct display *d, struct greet_info *greet, struct verify_info *verify);
|
||||
extern int autoLoginEnv(struct display *d, struct verify_info *verify, struct greet_info *greet);
|
||||
|
||||
/* in dm.c */
|
||||
extern void StopDisplay (struct display *d);
|
||||
|
@ -65,3 +65,5 @@ typedef enum {
|
||||
extern greet_user_rtn GreetUser(struct display *, Display **,
|
||||
struct verify_info *, struct greet_info *);
|
||||
|
||||
extern greet_user_rtn AutoLogin(struct display *,
|
||||
struct verify_info *, struct greet_info *);
|
||||
|
@ -106,7 +106,8 @@ to assist in setting up the screen the user sees along with the
|
||||
\fIxlogin\fP widget.
|
||||
.PP
|
||||
The \fIxlogin\fP widget, which \fIxenodm\fP presents,
|
||||
offers the familiar login and password prompts.
|
||||
offers the familiar login and password prompts, unless
|
||||
\fIautoLogin\fP is set.
|
||||
.PP
|
||||
After the user logs in, \fIxenodm\fP runs the \fIXstartup\fP script as
|
||||
root.
|
||||
@ -260,6 +261,9 @@ A list of additional environment variables, separated by white space,
|
||||
to pass on to the \fIXsetup\fP,
|
||||
\fIXstartup\fP, \fIXsession\fP, and \fIXreset\fP programs.
|
||||
.\"
|
||||
.IP "\fBDisplayManager.\fP\fIDISPLAY\fP\fB.autoLogin\fP"
|
||||
This resource specifes the name of an user that will be logged in
|
||||
automatically, without displaying the xlogin widget.
|
||||
.IP "\fBDisplayManager.\fP\fIDISPLAY\fP\fB.resources\fP"
|
||||
This resource specifies the name of the file to be loaded by \fIxrdb\fP
|
||||
as the resource database onto the root window of screen 0 of the display.
|
||||
|
@ -176,6 +176,8 @@ struct displayResource serverResources[] = {
|
||||
DEF_AUTH_NAME },
|
||||
{ "authFile", "AuthFile", DM_STRING, boffset(clientAuthFile),
|
||||
"" },
|
||||
{ "autoLogin", "AutoLogin", DM_STRING, boffset(autoLogin),
|
||||
"" },
|
||||
};
|
||||
|
||||
#define NUM_SERVER_RESOURCES (sizeof serverResources/\
|
||||
|
@ -155,12 +155,13 @@ ManageSession (struct display *d)
|
||||
(void)XSetErrorHandler(ErrorHandler);
|
||||
setproctitle("%s", d->name);
|
||||
|
||||
/*
|
||||
* Load system default Resources
|
||||
*/
|
||||
LoadXloginResources (d);
|
||||
|
||||
greet_stat = GreetUser(d, &dpy, &verify, &greet);
|
||||
if (d->autoLogin == NULL || d->autoLogin[0] == '\0') {
|
||||
/* Load system default Resources */
|
||||
LoadXloginResources (d);
|
||||
greet_stat = GreetUser(d, &dpy, &verify, &greet);
|
||||
} else
|
||||
greet_stat = AutoLogin(d, &verify, &greet);
|
||||
|
||||
if (greet_stat == Greet_Success) {
|
||||
clientPid = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user