[mythtv-users] FW: mythDVD playback problem
Michael T. Dean
mtdean at thirdcontact.com
Wed Jul 28 20:21:08 EDT 2004
Sperlongano Brian M NPRI wrote:
>1.) Power up the box. "X" and "mythfrontend" are started via a respawn
>entry in my /etc/inittab
>
>
Which means that you're not logging in to the myth box (i.e.
/etc/profile, ~/.bash_profile, ~/.bash_login, and ~/.profile are not
executed or whichever file(s) your shell uses). Therefore, your
environment is not properly configured (you get a PATH of
/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin and no DISPLAY, etc.). As
a matter of fact you're probably not even running a shell (although it
would be possible to have inittab start a shell that starts X, etc.).
>2.) Choose "Play DVD" command in mythtTV. xine starts up, switches to
>full-screen black, X cursor appears for a second, then immediately
>returns to mythTV DVD menu.
>
>
Probably giving the error "Cannot open display" or "command not found."
You can find out by logging xine's output. Use something like the
following for your MythDVD playback command:
xine --no-splash -fg --auto-play --auto-scan dvd > /tmp/xine.log 2>&1
>3.) Press Alt+F1. Login. Type: export DISPLAY="localhost:0.0". Run
>xine command (same as specified in DVD setup in mythTV). Press Alt+F7
>(to go back to X). DVD (audio AND video) are playing perfectly.
>
>
Here you've logged in, so the environment is properly configured, and
you have a proper shell running beneath xine.
So, to fix the problem, just make sure you log someone in (i.e. a user
mythtv), who then automatically starts X which then automatically starts
mythfrontend. You can do this using GDM (as described in Jarod's guide
http://www.wilsonet.com/mythtv/fcmyth.php#auto ) or KDM.
Or, if--like me--you don't want GNOME or KDE (and their multitudes of
libraries) installed on your Myth box (which seems to be the case since
you were trying to auto-start using inittab), write your own auto-login
facility. You can do so using the instructions at
http://www.linuxgazette.com/issue72/chung.html .
I wanted a bit more control over the process (and error logging and
fallback to (non-auto) login if an error occurs (instead of spawning
millions of runaway autologin instances until init disabled the
respawn)), so I modified the 1-line program Adrian Chung used (see
attached). The program can be compiled with:
gcc -o autologin autologin.c
There are several places where my autologin could be improved, so if
you add to it, please let me know. :) Also, there are several security
weaknesses (and possibly some security holes), but, then again,
autologin itself is a security weakness...
Mike
Using my program, the relevant line from /etc/inittab is (notice that,
unlike with Adrian Chung's program, the username is not specified here):
1:2345:respawn:/sbin/agetty -n -l /bin/autologin tty1 9600
In my /etc/autologin, I put a single line with the username of the user
who should automatically log in. (Make sure this line is
readable/writable only by root (i.e. chmod 600 /etc/autologin):
mythtv
In my mythtv user's ~/.bash_profile:
# If logging in on /dev/tty1, start X
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
startx
fi
In my mythtv user's ~/.xinitrc (after taking care of other
housekeeping--i.e. X resources, keyboard mappings, mouse acceleration
and threshold, etc.):
# Start the window manager (change WM name as appropriate)
fluxbox & wmpid=$!
mythfrontend > /home/mythtv/logs/mythfrontend.log 2>&1
# Wait for the window manager to exit
# Comment out if you want X to exit when mythfrontend exits
#wait $wmpid
-------------- next part --------------
/*
* $Header$
* $Revision$
* $Date$
*
* autologin
*
* Copyright 2004, Michael T. Dean
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
/* Location of commands/files used by autologin. */
const char* AUTOLOGIN="autologin";
const char* LOGIN_CMD="login";
const char* LOGIN_PREAUTH_ARG="-f";
const char* LOGGER_CMD="logger";
const char* AUTOLOGIN_FILE="/etc/autologin";
void login();
void autologin(const char* username);
void log_message(const char* message, int len);
int main() {
FILE *file;
char file_data[100];
char username[100];
/*
* Check to see if autologin is enabled.
* The existence of the file AUTOLOGIN_FILE indicates that we should
* proceed with autologin.
*/
if(access(AUTOLOGIN_FILE, F_OK) == -1) {
/*
* Autologin is disabled. Call login without arguments.
*/
login();
} else {
/*
* Proceed with autologin.
* Read the first line from the AUTOLOGIN_FILE and parse the first
* token (up to 99 characters) for use as the username.
*/
if ((file = fopen(AUTOLOGIN_FILE, "r")) == NULL) {
/* File could not be opened. Fall back to login. */
login();
} else {
if (fgets(file_data, 99, file) == NULL) {
/* File could not be read or contained no data. Fall back to login. */
fclose(file);
login();
} else {
fclose(file);
/*
* Limit the allowable characters in the username to alphanumerics
* to try to prevent hijacking the execlp. Any disallowed characters
* are truncated.
*/
sscanf(file_data, "%[A-Za-z0-9]%*", username);
autologin(username);
}
}
}
}
void login() {
execlp(LOGIN_CMD, LOGIN_CMD, NULL);
/* If execlp returns, an error has occurred.*/
char message[500];
sprintf((char *)message, "autologin: \'%s\' failed.\n", LOGIN_CMD);
log_message((char *)message, 500);
sprintf((char *)message, "autologin: %s\n", strerror(errno));
log_message((char *)message, 500);
}
void autologin(const char *username) {
if (strnlen(username,99)) {
execlp(LOGIN_CMD, LOGIN_CMD, LOGIN_PREAUTH_ARG, username, NULL);
/* If execlp returns, an error has occurred.*/
char message[500];
sprintf((char *)message, "autologin: \'%s %s %s\' failed.\n",
LOGIN_CMD, LOGIN_PREAUTH_ARG, username);
log_message((char *)message, 500);
sprintf((char *)message, "autologin: %s\n", strerror(errno));
log_message((char *)message, 500);
}
/*
* No username specified or execlp for autologin returned.
* Fall back to login.
*/
login();
}
void log_message(const char *message, int len) {
char logcmd[300 + strnlen(message, len)];
sprintf((char *)logcmd, "%s \"%s\"", LOGGER_CMD, message);
system(logcmd);
}
More information about the mythtv-users
mailing list